aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2016-03-03 21:00:03 +0100
committerBtcDrak <btcdrak@gmail.com>2016-03-18 09:14:52 +0000
commit0bdaacd7913fd626691daa2946590547071dcf3b (patch)
tree09af110e8aef6dc532a3bb1df5f0903409417d65 /src
parent5f90d4e29470a8a8fa9f9580b195a0d5c23430b7 (diff)
downloadbitcoin-0bdaacd7913fd626691daa2946590547071dcf3b.tar.xz
Softfork status report in RPC
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp6
-rw-r--r--src/main.h4
-rw-r--r--src/rpcblockchain.cpp22
3 files changed, 31 insertions, 1 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 542f37876a..89ca99bc90 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -5930,7 +5930,11 @@ bool SendMessages(CNode* pto)
return strprintf("CBlockFileInfo(blocks=%u, size=%u, heights=%u...%u, time=%s...%s)", nBlocks, nSize, nHeightFirst, nHeightLast, DateTimeStrFormat("%Y-%m-%d", nTimeFirst), DateTimeStrFormat("%Y-%m-%d", nTimeLast));
}
-
+ThresholdState VersionBitsTipState(const Consensus::Params& params, Consensus::DeploymentPos pos)
+{
+ LOCK(cs_main);
+ return VersionBitsState(chainActive.Tip(), params, pos, versionbitscache);
+}
class CMainCleanup
{
diff --git a/src/main.h b/src/main.h
index 8c6a51cacd..05ae9ea450 100644
--- a/src/main.h
+++ b/src/main.h
@@ -16,6 +16,7 @@
#include "net.h"
#include "script/script_error.h"
#include "sync.h"
+#include "versionbits.h"
#include <algorithm>
#include <exception>
@@ -275,6 +276,9 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
/** Convert CValidationState to a human-readable message for logging */
std::string FormatStateMessage(const CValidationState &state);
+/** Get the BIP9 state for a given deployment at the current tip. */
+ThresholdState VersionBitsTipState(const Consensus::Params& params, Consensus::DeploymentPos pos);
+
struct CNodeStateStats {
int nMisbehavior;
int nSyncHeight;
diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp
index f5b16bc7c4..4fd2e6d05c 100644
--- a/src/rpcblockchain.cpp
+++ b/src/rpcblockchain.cpp
@@ -604,6 +604,20 @@ static UniValue SoftForkDesc(const std::string &name, int version, CBlockIndex*
return rv;
}
+static UniValue BIP9SoftForkDesc(const std::string& name, const Consensus::Params& consensusParams, Consensus::DeploymentPos id)
+{
+ UniValue rv(UniValue::VOBJ);
+ rv.push_back(Pair("id", name));
+ switch (VersionBitsTipState(consensusParams, id)) {
+ case THRESHOLD_DEFINED: rv.push_back(Pair("status", "defined")); break;
+ case THRESHOLD_STARTED: rv.push_back(Pair("status", "started")); break;
+ case THRESHOLD_LOCKED_IN: rv.push_back(Pair("status", "locked_in")); break;
+ case THRESHOLD_ACTIVE: rv.push_back(Pair("status", "active")); break;
+ case THRESHOLD_FAILED: rv.push_back(Pair("status", "failed")); break;
+ }
+ return rv;
+}
+
UniValue getblockchaininfo(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 0)
@@ -634,6 +648,12 @@ UniValue getblockchaininfo(const UniValue& params, bool fHelp)
" },\n"
" \"reject\": { ... } (object) progress toward rejecting pre-softfork blocks (same fields as \"enforce\")\n"
" }, ...\n"
+ " ],\n"
+ " \"bip9_softforks\": [ (array) status of BIP9 softforks in progress\n"
+ " {\n"
+ " \"id\": \"xxxx\", (string) name of the softfork\n"
+ " \"status\": \"xxxx\", (string) one of \"defined\", \"started\", \"lockedin\", \"active\", \"failed\"\n"
+ " }\n"
" ]\n"
"}\n"
"\nExamples:\n"
@@ -657,10 +677,12 @@ UniValue getblockchaininfo(const UniValue& params, bool fHelp)
const Consensus::Params& consensusParams = Params().GetConsensus();
CBlockIndex* tip = chainActive.Tip();
UniValue softforks(UniValue::VARR);
+ UniValue bip9_softforks(UniValue::VARR);
softforks.push_back(SoftForkDesc("bip34", 2, tip, consensusParams));
softforks.push_back(SoftForkDesc("bip66", 3, tip, consensusParams));
softforks.push_back(SoftForkDesc("bip65", 4, tip, consensusParams));
obj.push_back(Pair("softforks", softforks));
+ obj.push_back(Pair("bip9_softforks", bip9_softforks));
if (fPruneMode)
{