From 7a5db15041dc909b173b59906e407ccf9a64f10c Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Mon, 6 Aug 2012 03:51:44 -0700 Subject: [PATCH] Add more consensus information to the "server_info" RPC call. --- src/LedgerConsensus.cpp | 19 +++++++++++++++++++ src/LedgerProposal.h | 3 +++ 2 files changed, 22 insertions(+) diff --git a/src/LedgerConsensus.cpp b/src/LedgerConsensus.cpp index 93229b5e42..e07bd8a817 100644 --- a/src/LedgerConsensus.cpp +++ b/src/LedgerConsensus.cpp @@ -960,6 +960,25 @@ void LedgerConsensus::endConsensus() Json::Value LedgerConsensus::getJson() { Json::Value ret(Json::objectValue); + ret["proposing"] = mProposing ? "yes" : "no"; + ret["validating"] = mValidating ? "yes" : "no"; + ret["synched"] = mHaveCorrectLCL ? "yes" : "no"; + ret["proposers"] = static_cast(mPeerPositions.size()); + + switch (mState) + { + case lcsPRE_CLOSE: ret["state"] = "open"; break; + case lcsESTABLISH: ret["state"] = "consensus"; break; + case lcsFINISHED: ret["state"] = "finished"; break; + case lcsACCEPTED: ret["state"] = "accepted"; break; + } + + int v = mDisputes.size(); + if (v != 0) + ret["disputes"] = v; + + if (mOurPosition) + ret["our_position"] = mOurPosition->getJson(); return ret; } diff --git a/src/LedgerProposal.h b/src/LedgerProposal.h index 1490e9d5ee..790b61fb4d 100644 --- a/src/LedgerProposal.h +++ b/src/LedgerProposal.h @@ -5,6 +5,8 @@ #include +#include "../json/value.h" + #include "NewcoinAddress.h" #include "Serializer.h" @@ -48,6 +50,7 @@ public: std::vector sign(); void changePosition(const uint256& newPosition, uint32 newCloseTime); + Json::Value getJson() const; }; #endif