From 15d68649d58b88f15d6ab9812c82e32f0e8fa4dc Mon Sep 17 00:00:00 2001 From: Miguel Portilla Date: Tue, 21 Apr 2015 15:52:56 -0400 Subject: [PATCH] Fix check for current ledger ID in RPC --- src/ripple/rpc/impl/RPCHandler.cpp | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/ripple/rpc/impl/RPCHandler.cpp b/src/ripple/rpc/impl/RPCHandler.cpp index 6577c8788..24c4b26b4 100644 --- a/src/ripple/rpc/impl/RPCHandler.cpp +++ b/src/ripple/rpc/impl/RPCHandler.cpp @@ -146,14 +146,24 @@ error_code_i fillHandler (Context& context, return rpcNO_NETWORK; } - if (!getConfig ().RUN_STANDALONE - && (handler->condition_ & NEEDS_CURRENT_LEDGER) - && (getApp().getLedgerMaster().getValidatedLedgerAge() > - Tuning::maxValidatedLedgerAge - || context.netOps.getCurrentLedgerID() <= - context.netOps.getValidatedLedger ()->getLedgerSeq ())) + if (! getConfig ().RUN_STANDALONE && + handler->condition_ & NEEDS_CURRENT_LEDGER) { - return rpcNO_CURRENT; + if (getApp ().getLedgerMaster ().getValidatedLedgerAge () > + Tuning::maxValidatedLedgerAge) + { + 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) &&