Fix check for current ledger ID in RPC

This commit is contained in:
Miguel Portilla
2015-04-21 15:52:56 -04:00
committed by Vinnie Falco
parent 29d644e9d3
commit 568e4cebda

View File

@@ -146,16 +146,26 @@ error_code_i fillHandler (Context& context,
return rpcNO_NETWORK; return rpcNO_NETWORK;
} }
if (!getConfig ().RUN_STANDALONE if (! getConfig ().RUN_STANDALONE &&
&& (handler->condition_ & NEEDS_CURRENT_LEDGER) handler->condition_ & NEEDS_CURRENT_LEDGER)
&& (getApp().getLedgerMaster().getValidatedLedgerAge() > {
Tuning::maxValidatedLedgerAge if (getApp ().getLedgerMaster ().getValidatedLedgerAge () >
|| context.netOps.getCurrentLedgerID() <= Tuning::maxValidatedLedgerAge)
context.netOps.getValidatedLedger ()->getLedgerSeq ()))
{ {
return rpcNO_CURRENT; return rpcNO_CURRENT;
} }
auto const cID = context.netOps.getCurrentLedgerID ();
auto const vID = context.netOps.getValidatedSeq ();
if (cID + 10 < vID)
{
WriteLog (lsDEBUG, RPCHandler) << "Current ledger ID(" << cID <<
") is less than validated ledger ID(" << vID << ")";
return rpcNO_CURRENT;
}
}
if ((handler->condition_ & NEEDS_CLOSED_LEDGER) && if ((handler->condition_ & NEEDS_CLOSED_LEDGER) &&
!context.netOps.getClosedLedger ()) !context.netOps.getClosedLedger ())
{ {