mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-02 00:45:58 +00:00
Clean up JSON reporting of booleans and network state.
This commit is contained in:
@@ -195,17 +195,17 @@ Json::Value FeatureTable::getJson(int)
|
||||
{
|
||||
Json::Value v(Json::objectValue);
|
||||
|
||||
v["supported"] = it.second.mSupported ? "true" : "false";
|
||||
v["supported"] = it.second.mSupported;
|
||||
|
||||
if (it.second.mEnabled)
|
||||
v["enabled"] = "true";
|
||||
v["enabled"] = true;
|
||||
else
|
||||
{
|
||||
v["enabled"] = "false";
|
||||
v["enabled"] = false;
|
||||
if (mLastReport != 0)
|
||||
{
|
||||
if (it.second.mLastMajority == 0)
|
||||
v["majority"] = "no";
|
||||
v["majority"] = false;
|
||||
else
|
||||
{
|
||||
if (it.second.mFirstMajority != 0)
|
||||
@@ -227,7 +227,7 @@ Json::Value FeatureTable::getJson(int)
|
||||
}
|
||||
|
||||
if (it.second.mVetoed)
|
||||
v["veto"] = "true";
|
||||
v["veto"] = true;
|
||||
|
||||
ret[it.first.GetHex()] = v;
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ Json::Value JobQueue::getJson(int)
|
||||
{
|
||||
Json::Value pri(Json::objectValue);
|
||||
if (isOver)
|
||||
pri["over_target"] = "true";
|
||||
pri["over_target"] = true;
|
||||
pri["job_type"] = Job::toString(static_cast<JobType>(i));
|
||||
if (jobCount != 0)
|
||||
pri["waiting"] = static_cast<int>(jobCount);
|
||||
|
||||
@@ -294,6 +294,7 @@ LedgerConsensus::LedgerConsensus(const uint256& prevLCLHash, Ledger::ref previou
|
||||
mHaveCorrectLCL = (mPreviousLedger->getHash() == mPrevLedgerHash);
|
||||
if (!mHaveCorrectLCL)
|
||||
{
|
||||
theApp->getOPs().setProposing(false, false);
|
||||
handleLCL(mPrevLedgerHash);
|
||||
if (!mHaveCorrectLCL)
|
||||
{
|
||||
@@ -302,6 +303,8 @@ LedgerConsensus::LedgerConsensus(const uint256& prevLCLHash, Ledger::ref previou
|
||||
cLog(lsINFO) << "Correct LCL is: " << prevLCLHash;
|
||||
}
|
||||
}
|
||||
else
|
||||
theApp->getOPs().setProposing(mProposing, mValidating);
|
||||
}
|
||||
|
||||
void LedgerConsensus::checkOurValidation()
|
||||
@@ -1343,18 +1346,18 @@ void LedgerConsensus::simulate()
|
||||
Json::Value LedgerConsensus::getJson()
|
||||
{
|
||||
Json::Value ret(Json::objectValue);
|
||||
ret["proposing"] = mProposing ? "yes" : "no";
|
||||
ret["validating"] = mValidating ? "yes" : "no";
|
||||
ret["proposing"] = mProposing;
|
||||
ret["validating"] = mValidating;
|
||||
ret["proposers"] = static_cast<int>(mPeerPositions.size());
|
||||
|
||||
if (mHaveCorrectLCL)
|
||||
{
|
||||
ret["synched"] = "yes";
|
||||
ret["synched"] = true;
|
||||
ret["ledger_seq"] = mPreviousLedger->getLedgerSeq() + 1;
|
||||
ret["close_granularity"] = mCloseResolution;
|
||||
}
|
||||
else
|
||||
ret["synched"] = "no";
|
||||
ret["synched"] = false;
|
||||
|
||||
switch (mState)
|
||||
{
|
||||
|
||||
@@ -33,9 +33,9 @@ void InfoSub::onSendEmpty()
|
||||
}
|
||||
|
||||
NetworkOPs::NetworkOPs(boost::asio::io_service& io_service, LedgerMaster* pLedgerMaster) :
|
||||
mMode(omDISCONNECTED), mNeedNetworkLedger(false), mNetTimer(io_service), mLedgerMaster(pLedgerMaster),
|
||||
mCloseTimeOffset(0), mLastCloseProposers(0), mLastCloseConvergeTime(1000 * LEDGER_IDLE_INTERVAL),
|
||||
mLastValidationTime(0)
|
||||
mMode(omDISCONNECTED), mNeedNetworkLedger(false), mProposing(false), mValidating(false),
|
||||
mNetTimer(io_service), mLedgerMaster(pLedgerMaster), mCloseTimeOffset(0), mLastCloseProposers(0),
|
||||
mLastCloseConvergeTime(1000 * LEDGER_IDLE_INTERVAL), mLastValidationTime(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -48,6 +48,14 @@ std::string NetworkOPs::strOperatingMode()
|
||||
"full"
|
||||
};
|
||||
|
||||
if (mMode == omFULL)
|
||||
{
|
||||
if (mProposing)
|
||||
return "proposing";
|
||||
if (mValidating)
|
||||
return "validating";
|
||||
}
|
||||
|
||||
return paStatusToken[mMode];
|
||||
}
|
||||
|
||||
@@ -1100,14 +1108,8 @@ Json::Value NetworkOPs::getServerInfo(bool human, bool admin)
|
||||
if (theConfig.TESTNET)
|
||||
info["testnet"] = theConfig.TESTNET;
|
||||
|
||||
switch (mMode)
|
||||
{
|
||||
case omDISCONNECTED: info["server_state"] = "disconnected"; break;
|
||||
case omCONNECTED: info["server_state"] = "connected"; break;
|
||||
case omTRACKING: info["server_state"] = "tracking"; break;
|
||||
case omFULL: info["server_state"] = "validating"; break;
|
||||
default: info["server_state"] = "unknown";
|
||||
}
|
||||
info["server_state"] = strOperatingMode();
|
||||
|
||||
if (mNeedNetworkLedger)
|
||||
info["network_ledger"] = "waiting";
|
||||
|
||||
|
||||
@@ -76,6 +76,7 @@ protected:
|
||||
|
||||
OperatingMode mMode;
|
||||
bool mNeedNetworkLedger;
|
||||
bool mProposing, mValidating;
|
||||
boost::posix_time::ptime mConnectTime;
|
||||
boost::asio::deadline_timer mNetTimer;
|
||||
boost::shared_ptr<LedgerConsensus> mConsensus;
|
||||
@@ -238,6 +239,9 @@ public:
|
||||
void needNetworkLedger() { mNeedNetworkLedger = true; }
|
||||
void clearNeedNetworkLedger() { mNeedNetworkLedger = false; }
|
||||
bool isNeedNetworkLedger() { return mNeedNetworkLedger; }
|
||||
void setProposing(bool p, bool v) { mProposing = p; mValidating = v; }
|
||||
bool isProposing() { return mProposing; }
|
||||
bool isValidating() { return mValidating; }
|
||||
void consensusViewChange();
|
||||
int getPreviousProposers() { return mLastCloseProposers; }
|
||||
int getPreviousConvergeTime() { return mLastCloseConvergeTime; }
|
||||
|
||||
Reference in New Issue
Block a user