make server_info more friendly.

This commit is contained in:
JoelKatz
2013-01-15 02:01:24 -08:00
parent 88437c9cab
commit 343d9edb51

View File

@@ -1102,42 +1102,49 @@ Json::Value NetworkOPs::getServerInfo()
switch (mMode) switch (mMode)
{ {
case omDISCONNECTED: info["serverState"] = "disconnected"; break; case omDISCONNECTED: info["server_state"] = "disconnected"; break;
case omCONNECTED: info["serverState"] = "connected"; break; case omCONNECTED: info["server_state"] = "connected"; break;
case omTRACKING: info["serverState"] = "tracking"; break; case omTRACKING: info["server_state"] = "tracking"; break;
case omFULL: info["serverState"] = "validating"; break; case omFULL: info["server_state"] = "validating"; break;
default: info["serverState"] = "unknown"; default: info["server_state"] = "unknown";
} }
if (!theConfig.VALIDATION_PUB.isValid())
info["serverState"] = "none";
else
info["validationPKey"] = theConfig.VALIDATION_PUB.humanNodePublic();
if (mNeedNetworkLedger) if (mNeedNetworkLedger)
info["networkLedger"] = "waiting"; info["network_ledger"] = "waiting";
info["completeLedgers"] = theApp->getLedgerMaster().getCompleteLedgers(); if (theConfig.VALIDATION_PUB.isValid())
info["pubkey_validator"] = theConfig.VALIDATION_PUB.humanNodePublic();
info["pubkey_node"] = theApp->getWallet().getNodePublic().humanNodePublic();
info["complete_ledgers"] = theApp->getLedgerMaster().getCompleteLedgers();
info["peers"] = theApp->getConnectionPool().getPeerCount(); info["peers"] = theApp->getConnectionPool().getPeerCount();
Json::Value lastClose = Json::objectValue; Json::Value lastClose = Json::objectValue;
lastClose["proposers"] = theApp->getOPs().getPreviousProposers(); lastClose["proposers"] = theApp->getOPs().getPreviousProposers();
lastClose["convergeTime"] = theApp->getOPs().getPreviousConvergeTime(); lastClose["converge_time"] = static_cast<double>(theApp->getOPs().getPreviousConvergeTime()) / 1000.0;
info["lastClose"] = lastClose; info["last_close"] = lastClose;
if (mConsensus) // if (mConsensus)
info["consensus"] = mConsensus->getJson(); // info["consensus"] = mConsensus->getJson();
info["load"] = theApp->getJobQueue().getJson(); info["load"] = theApp->getJobQueue().getJson();
info["load_base"] = theApp->getFeeTrack().getLoadBase(); info["load_factor"] =
info["load_fee"] = theApp->getFeeTrack().getLoadFactor(); static_cast<double>(theApp->getFeeTrack().getLoadBase()) / theApp->getFeeTrack().getLoadFactor();
Ledger::pointer lpClosed = getClosedLedger(); Ledger::pointer lpClosed = getClosedLedger();
if (lpClosed) if (lpClosed)
{ {
info["reserve_base"] = Json::UInt(lpClosed->getReserve(0)); uint64 baseFee = lpClosed->getBaseFee();
info["reserve_inc"] = Json::UInt(lpClosed->getReserveInc()); uint64 baseRef = lpClosed->getReferenceFeeUnits();
Json::Value l(Json::objectValue);
l["seq"] = Json::UInt(lpClosed->getLedgerSeq());
l["hash"] = lpClosed->getHash().GetHex();
l["base_fee"] = static_cast<double>(Json::UInt(baseFee)) / SYSTEM_CURRENCY_PARTS;
l["reserve_base"] =
static_cast<double>(Json::UInt(lpClosed->getReserve(0) * baseFee / baseRef)) / SYSTEM_CURRENCY_PARTS;
l["reserve_inc"] =
static_cast<double>(Json::UInt(lpClosed->getReserveInc() * baseFee / baseRef)) / SYSTEM_CURRENCY_PARTS;
info["closed_ledger"] = l;
} }
return info; return info;