Ledger loading cleanups:

* Fix close time settings for ledger load
* More info in ledger_request and inbound ledger JSON replies
This commit is contained in:
David Schwartz
2014-06-23 11:03:59 -07:00
committed by Nik Bougalis
parent 9dc32cb791
commit adce6ae851
3 changed files with 19 additions and 4 deletions

View File

@@ -1241,6 +1241,9 @@ Json::Value InboundLedger::getJson (int)
{
ret["have_state"] = mHaveState;
ret["have_transactions"] = mHaveTransactions;
if (!mHaveState)
ret["state_nodes"] = static_cast<Json::Value::UInt>
(mLedger->peekAccountStateMap()->size());
}
if (mAborted)

View File

@@ -1135,6 +1135,8 @@ bool ApplicationImp::loadOldLedger (
std::uint32_t seq = 1;
std::uint32_t closeTime = getApp().getOPs().getCloseTimeNC ();
std::uint32_t closeTimeResolution = 30;
bool closeTimeEstimated = false;
std::uint64_t totalCoins = 0;
if (ledger.get().isMember ("accountState"))
@@ -1147,6 +1149,16 @@ bool ApplicationImp::loadOldLedger (
{
closeTime = ledger.get()["close_time"].asUInt();
}
if (ledger.get().isMember ("close_time_resolution"))
{
closeTimeResolution =
ledger.get()["close_time_resolution"].asUInt();
}
if (ledger.get().isMember ("close_time_estimated"))
{
closeTimeEstimated =
ledger.get()["close_time_estimated"].asBool();
}
if (ledger.get().isMember ("total_coins"))
{
totalCoins =
@@ -1188,7 +1200,8 @@ bool ApplicationImp::loadOldLedger (
}
}
loadLedger->setAccepted();
loadLedger->setAccepted (closeTime,
closeTimeResolution, ! closeTimeEstimated);
}
}
}

View File

@@ -75,10 +75,9 @@ Json::Value doLedgerRequest (RPC::Context& context)
{
// We don't have the ledger we need to figure out which ledger
// they want. Try to get it.
getApp().getInboundLedgers().findCreate (
refHash, refIndex, InboundLedger::fcGENERIC);
Json::Value jvResult = getApp().getInboundLedgers().findCreate (
refHash, refIndex, InboundLedger::fcGENERIC)->getJson (0);
Json::Value jvResult;
jvResult[jss::error] = "ledgerNotFound";
return jvResult;
}