NetworkOPs function to test if we have in our database a specified range of ledger numbers.

This commit is contained in:
JoelKatz
2012-11-29 11:46:22 -08:00
parent e05a24d055
commit 0fe9f178ef
4 changed files with 16 additions and 0 deletions

View File

@@ -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);

View File

@@ -93,6 +93,8 @@ public:
void addHeldTransaction(const Transaction::pointer& trans);
bool haveLedgerRange(uint32 from, uint32 to);
void sweep(void) { mLedgerHistory.sweep(); }
};

View File

@@ -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;

View File

@@ -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; }