Skip to content

Commit 9a8e916

Browse files
committed
Merge #10858: [RPC] Add "errors" field to getblockchaininfo and unify "errors" field in get*info RPCs
395cef7 Change getmininginfo errors field to warnings (Andrew Chow) 8502b20 Unify help text for GetWarnings output in get*info RPCs (Andrew Chow) f77f0e4 Add warnings field to getblockchaininfo (Andrew Chow) Pull request description: The `getblockchaininfo` output does not contain the `errors` field which the `getinfo`, `getmininginfo`, and `getnetworkinfo` RPCs have. It should have it as the errors pertain to the blockchain. This PR adds that field. This PR also unifies the help text for the `errors` field and its output position so that all of the `get*info` commands are consistent. `getnetworkinfo`'s `errors` field is named `warnings`. I did not change this even though it is inconsistent since this naming has been in use for a long time. Tree-SHA512: 385ab6acfee67fc8816f4d51ab2bd7a623264c7973906dfbab0a171f199e9db16fde19093a5bc3dfbdd4ff5f19d2186b646eb6b3bae0a4d7c9add43650a4a9d9
2 parents 4202273 + 395cef7 commit 9a8e916

File tree

5 files changed

+15
-6
lines changed

5 files changed

+15
-6
lines changed

src/rpc/blockchain.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "util.h"
2525
#include "utilstrencodings.h"
2626
#include "hash.h"
27+
#include "warnings.h"
2728

2829
#include <stdint.h>
2930

@@ -1162,6 +1163,7 @@ UniValue getblockchaininfo(const JSONRPCRequest& request)
11621163
" }\n"
11631164
" }\n"
11641165
" }\n"
1166+
" \"warnings\" : \"...\", (string) any network and blockchain warnings.\n"
11651167
"}\n"
11661168
"\nExamples:\n"
11671169
+ HelpExampleCli("getblockchaininfo", "")
@@ -1201,6 +1203,7 @@ UniValue getblockchaininfo(const JSONRPCRequest& request)
12011203

12021204
obj.push_back(Pair("pruneheight", block->nHeight));
12031205
}
1206+
obj.push_back(Pair("warnings", GetWarnings("statusbar")));
12041207
return obj;
12051208
}
12061209

src/rpc/mining.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,11 @@ UniValue getmininginfo(const JSONRPCRequest& request)
199199
" \"currentblockweight\": nnn, (numeric) The last block weight\n"
200200
" \"currentblocktx\": nnn, (numeric) The last block transaction\n"
201201
" \"difficulty\": xxx.xxxxx (numeric) The current difficulty\n"
202-
" \"errors\": \"...\" (string) Current errors\n"
203202
" \"networkhashps\": nnn, (numeric) The network hashes per second\n"
204203
" \"pooledtx\": n (numeric) The size of the mempool\n"
205204
" \"chain\": \"xxxx\", (string) current network name as defined in BIP70 (main, test, regtest)\n"
205+
" \"warnings\": \"...\" (string) any network and blockchain warnings\n"
206+
" \"errors\": \"...\" (string) DEPRECATED. Same as warnings. Only shown when bitcoind is started with -deprecatedrpc=getmininginfo\n"
206207
"}\n"
207208
"\nExamples:\n"
208209
+ HelpExampleCli("getmininginfo", "")
@@ -217,10 +218,14 @@ UniValue getmininginfo(const JSONRPCRequest& request)
217218
obj.push_back(Pair("currentblockweight", (uint64_t)nLastBlockWeight));
218219
obj.push_back(Pair("currentblocktx", (uint64_t)nLastBlockTx));
219220
obj.push_back(Pair("difficulty", (double)GetDifficulty()));
220-
obj.push_back(Pair("errors", GetWarnings("statusbar")));
221221
obj.push_back(Pair("networkhashps", getnetworkhashps(request)));
222222
obj.push_back(Pair("pooledtx", (uint64_t)mempool.size()));
223223
obj.push_back(Pair("chain", Params().NetworkIDString()));
224+
if (IsDeprecatedRPCEnabled("getmininginfo")) {
225+
obj.push_back(Pair("errors", GetWarnings("statusbar")));
226+
} else {
227+
obj.push_back(Pair("warnings", GetWarnings("statusbar")));
228+
}
224229
return obj;
225230
}
226231

src/rpc/net.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ UniValue getnetworkinfo(const JSONRPCRequest& request)
447447
" }\n"
448448
" ,...\n"
449449
" ]\n"
450-
" \"warnings\": \"...\" (string) any network warnings\n"
450+
" \"warnings\": \"...\" (string) any network and blockchain warnings\n"
451451
"}\n"
452452
"\nExamples:\n"
453453
+ HelpExampleCli("getnetworkinfo", "")

test/functional/blockchain.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ def _test_getblockchaininfo(self):
6060
'pruned',
6161
'softforks',
6262
'verificationprogress',
63+
'warnings',
6364
]
6465
res = self.nodes[0].getblockchaininfo()
6566
# result should have pruneheight and default keys if pruning is enabled

test/functional/p2p-versionbits-warning.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def run_test(self):
8787
self.nodes[0].generate(VB_PERIOD - VB_THRESHOLD + 1)
8888
# Check that we're not getting any versionbit-related errors in
8989
# get*info()
90-
assert(not VB_PATTERN.match(self.nodes[0].getmininginfo()["errors"]))
90+
assert(not VB_PATTERN.match(self.nodes[0].getmininginfo()["warnings"]))
9191
assert(not VB_PATTERN.match(self.nodes[0].getnetworkinfo()["warnings"]))
9292

9393
# 3. Now build one period of blocks with >= VB_THRESHOLD blocks signaling
@@ -98,7 +98,7 @@ def run_test(self):
9898
# have gotten a different alert due to more than 51/100 blocks
9999
# being of unexpected version.
100100
# Check that get*info() shows some kind of error.
101-
assert(WARN_UNKNOWN_RULES_MINED in self.nodes[0].getmininginfo()["errors"])
101+
assert(WARN_UNKNOWN_RULES_MINED in self.nodes[0].getmininginfo()["warnings"])
102102
assert(WARN_UNKNOWN_RULES_MINED in self.nodes[0].getnetworkinfo()["warnings"])
103103

104104
# Mine a period worth of expected blocks so the generic block-version warning
@@ -113,7 +113,7 @@ def run_test(self):
113113

114114
# Connecting one block should be enough to generate an error.
115115
self.nodes[0].generate(1)
116-
assert(WARN_UNKNOWN_RULES_ACTIVE in self.nodes[0].getmininginfo()["errors"])
116+
assert(WARN_UNKNOWN_RULES_ACTIVE in self.nodes[0].getmininginfo()["warnings"])
117117
assert(WARN_UNKNOWN_RULES_ACTIVE in self.nodes[0].getnetworkinfo()["warnings"])
118118
self.stop_nodes()
119119
self.test_versionbits_in_alert_file()

0 commit comments

Comments
 (0)