From f77f0e4825e17fdda5984ce556a1102e32e7af72 Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Mon, 17 Jul 2017 15:43:12 -0700 Subject: [PATCH 1/3] Add warnings field to getblockchaininfo --- src/rpc/blockchain.cpp | 2 ++ test/functional/blockchain.py | 1 + 2 files changed, 3 insertions(+) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 46f4f16321..099e4825d4 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1162,6 +1162,7 @@ UniValue getblockchaininfo(const JSONRPCRequest& request) " }\n" " }\n" " }\n" + " \"warnings\" : \"...\", (string) any network and blockchain errors.\n" "}\n" "\nExamples:\n" + HelpExampleCli("getblockchaininfo", "") @@ -1201,6 +1202,7 @@ UniValue getblockchaininfo(const JSONRPCRequest& request) obj.push_back(Pair("pruneheight", block->nHeight)); } + obj.push_back(Pair("warnings", GetWarnings("statusbar"))); return obj; } diff --git a/test/functional/blockchain.py b/test/functional/blockchain.py index 63c56d0e9b..c5967aa10b 100755 --- a/test/functional/blockchain.py +++ b/test/functional/blockchain.py @@ -60,6 +60,7 @@ class BlockchainTest(BitcoinTestFramework): 'pruned', 'softforks', 'verificationprogress', + 'warnings', ] res = self.nodes[0].getblockchaininfo() # result should have pruneheight and default keys if pruning is enabled From 8502b2085288bcf5b5ff96b77236a3b04c65f082 Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Mon, 17 Jul 2017 15:55:14 -0700 Subject: [PATCH 2/3] Unify help text for GetWarnings output in get*info RPCs --- src/rpc/blockchain.cpp | 3 ++- src/rpc/mining.cpp | 4 ++-- src/rpc/net.cpp | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 099e4825d4..8c0268e264 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -24,6 +24,7 @@ #include "util.h" #include "utilstrencodings.h" #include "hash.h" +#include "warnings.h" #include @@ -1162,7 +1163,7 @@ UniValue getblockchaininfo(const JSONRPCRequest& request) " }\n" " }\n" " }\n" - " \"warnings\" : \"...\", (string) any network and blockchain errors.\n" + " \"warnings\" : \"...\", (string) any network and blockchain warnings.\n" "}\n" "\nExamples:\n" + HelpExampleCli("getblockchaininfo", "") diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 5ac32dc974..85cc906b7b 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -199,10 +199,10 @@ UniValue getmininginfo(const JSONRPCRequest& request) " \"currentblockweight\": nnn, (numeric) The last block weight\n" " \"currentblocktx\": nnn, (numeric) The last block transaction\n" " \"difficulty\": xxx.xxxxx (numeric) The current difficulty\n" - " \"errors\": \"...\" (string) Current errors\n" " \"networkhashps\": nnn, (numeric) The network hashes per second\n" " \"pooledtx\": n (numeric) The size of the mempool\n" " \"chain\": \"xxxx\", (string) current network name as defined in BIP70 (main, test, regtest)\n" + " \"errors\": \"...\" (string) (string) any network and blockchain warnings\n" "}\n" "\nExamples:\n" + HelpExampleCli("getmininginfo", "") @@ -217,10 +217,10 @@ UniValue getmininginfo(const JSONRPCRequest& request) obj.push_back(Pair("currentblockweight", (uint64_t)nLastBlockWeight)); obj.push_back(Pair("currentblocktx", (uint64_t)nLastBlockTx)); obj.push_back(Pair("difficulty", (double)GetDifficulty())); - obj.push_back(Pair("errors", GetWarnings("statusbar"))); obj.push_back(Pair("networkhashps", getnetworkhashps(request))); obj.push_back(Pair("pooledtx", (uint64_t)mempool.size())); obj.push_back(Pair("chain", Params().NetworkIDString())); + obj.push_back(Pair("errors", GetWarnings("statusbar"))); return obj; } diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp index 7faf216047..0184448213 100644 --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -447,7 +447,7 @@ UniValue getnetworkinfo(const JSONRPCRequest& request) " }\n" " ,...\n" " ]\n" - " \"warnings\": \"...\" (string) any network warnings\n" + " \"warnings\": \"...\" (string) any network and blockchain warnings\n" "}\n" "\nExamples:\n" + HelpExampleCli("getnetworkinfo", "") From 395cef7601479b97f5794b0c98067c859f00fc7f Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Tue, 26 Sep 2017 12:03:34 -0400 Subject: [PATCH 3/3] Change getmininginfo errors field to warnings Changes the errors field to warnings. To maintain compatibility, the errors field is deprecated and enabled by starting bitcoind with -deprecatedrpc=getmininginfo --- src/rpc/mining.cpp | 9 +++++++-- test/functional/p2p-versionbits-warning.py | 6 +++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 85cc906b7b..f79439f038 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -202,7 +202,8 @@ UniValue getmininginfo(const JSONRPCRequest& request) " \"networkhashps\": nnn, (numeric) The network hashes per second\n" " \"pooledtx\": n (numeric) The size of the mempool\n" " \"chain\": \"xxxx\", (string) current network name as defined in BIP70 (main, test, regtest)\n" - " \"errors\": \"...\" (string) (string) any network and blockchain warnings\n" + " \"warnings\": \"...\" (string) any network and blockchain warnings\n" + " \"errors\": \"...\" (string) DEPRECATED. Same as warnings. Only shown when bitcoind is started with -deprecatedrpc=getmininginfo\n" "}\n" "\nExamples:\n" + HelpExampleCli("getmininginfo", "") @@ -220,7 +221,11 @@ UniValue getmininginfo(const JSONRPCRequest& request) obj.push_back(Pair("networkhashps", getnetworkhashps(request))); obj.push_back(Pair("pooledtx", (uint64_t)mempool.size())); obj.push_back(Pair("chain", Params().NetworkIDString())); - obj.push_back(Pair("errors", GetWarnings("statusbar"))); + if (IsDeprecatedRPCEnabled("getmininginfo")) { + obj.push_back(Pair("errors", GetWarnings("statusbar"))); + } else { + obj.push_back(Pair("warnings", GetWarnings("statusbar"))); + } return obj; } diff --git a/test/functional/p2p-versionbits-warning.py b/test/functional/p2p-versionbits-warning.py index 0848fcde64..f9bef2580a 100755 --- a/test/functional/p2p-versionbits-warning.py +++ b/test/functional/p2p-versionbits-warning.py @@ -87,7 +87,7 @@ class VersionBitsWarningTest(BitcoinTestFramework): self.nodes[0].generate(VB_PERIOD - VB_THRESHOLD + 1) # Check that we're not getting any versionbit-related errors in # get*info() - assert(not VB_PATTERN.match(self.nodes[0].getmininginfo()["errors"])) + assert(not VB_PATTERN.match(self.nodes[0].getmininginfo()["warnings"])) assert(not VB_PATTERN.match(self.nodes[0].getnetworkinfo()["warnings"])) # 3. Now build one period of blocks with >= VB_THRESHOLD blocks signaling @@ -98,7 +98,7 @@ class VersionBitsWarningTest(BitcoinTestFramework): # have gotten a different alert due to more than 51/100 blocks # being of unexpected version. # Check that get*info() shows some kind of error. - assert(WARN_UNKNOWN_RULES_MINED in self.nodes[0].getmininginfo()["errors"]) + assert(WARN_UNKNOWN_RULES_MINED in self.nodes[0].getmininginfo()["warnings"]) assert(WARN_UNKNOWN_RULES_MINED in self.nodes[0].getnetworkinfo()["warnings"]) # Mine a period worth of expected blocks so the generic block-version warning @@ -113,7 +113,7 @@ class VersionBitsWarningTest(BitcoinTestFramework): # Connecting one block should be enough to generate an error. self.nodes[0].generate(1) - assert(WARN_UNKNOWN_RULES_ACTIVE in self.nodes[0].getmininginfo()["errors"]) + assert(WARN_UNKNOWN_RULES_ACTIVE in self.nodes[0].getmininginfo()["warnings"]) assert(WARN_UNKNOWN_RULES_ACTIVE in self.nodes[0].getnetworkinfo()["warnings"]) self.stop_nodes() self.test_versionbits_in_alert_file()