diff --git a/src/cpp/ripple/LedgerMaster.cpp b/src/cpp/ripple/LedgerMaster.cpp index 52468b743e..0a130f90a3 100644 --- a/src/cpp/ripple/LedgerMaster.cpp +++ b/src/cpp/ripple/LedgerMaster.cpp @@ -117,6 +117,12 @@ TER LedgerMaster::doTransaction(const SerializedTransaction& txn, TransactionEng return result; } +bool LedgerMaster::haveLedgerRange(uint32 from, uint32 to) +{ + uint32 prevMissing = mCompleteLedgers.prevMissing(to + 1); + return (prevMissing == RangeSet::RangeSetAbsent) || (prevMissing < from); +} + void LedgerMaster::acquireMissingLedger(const uint256& ledgerHash, uint32 ledgerSeq) { mMissingLedger = theApp->getMasterLedgerAcquire().findCreate(ledgerHash); diff --git a/src/cpp/ripple/LedgerMaster.h b/src/cpp/ripple/LedgerMaster.h index 152952b50b..801e2f8d74 100644 --- a/src/cpp/ripple/LedgerMaster.h +++ b/src/cpp/ripple/LedgerMaster.h @@ -93,6 +93,8 @@ public: void addHeldTransaction(const Transaction::pointer& trans); + bool haveLedgerRange(uint32 from, uint32 to); + void sweep(void) { mLedgerHistory.sweep(); } }; diff --git a/src/cpp/ripple/NetworkOPs.cpp b/src/cpp/ripple/NetworkOPs.cpp index 9e7bb541e5..ae2d11087d 100644 --- a/src/cpp/ripple/NetworkOPs.cpp +++ b/src/cpp/ripple/NetworkOPs.cpp @@ -81,6 +81,11 @@ uint32 NetworkOPs::getCurrentLedgerID() return mLedgerMaster->getCurrentLedger()->getLedgerSeq(); } +bool NetworkOPs::haveLedgerRange(uint32 from, uint32 to) +{ + return mLedgerMaster->haveLedgerRange(from, to); +} + void NetworkOPs::submitTransaction(Job&, SerializedTransaction::pointer iTrans, stCallback callback) { // this is an asynchronous interface Serializer s; diff --git a/src/cpp/ripple/NetworkOPs.h b/src/cpp/ripple/NetworkOPs.h index 78d6aaabe7..8e5730df55 100644 --- a/src/cpp/ripple/NetworkOPs.h +++ b/src/cpp/ripple/NetworkOPs.h @@ -134,6 +134,9 @@ public: uint256 getClosedLedgerHash() { return mLedgerMaster->getClosedLedger()->getHash(); } + // Do we have this inclusive range of ledgers in our database + bool haveLedgerRange(uint32 from, uint32 to); + SerializedValidation::ref getLastValidation() { return mLastValidation; } void setLastValidation(SerializedValidation::ref v) { mLastValidation = v; }