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