Range of validated ledgers.

This commit is contained in:
JoelKatz
2013-03-27 14:46:31 -07:00
parent ff1742a068
commit 3ec1865ce5
3 changed files with 18 additions and 0 deletions

View File

@@ -141,6 +141,22 @@ bool LedgerMaster::haveLedger(uint32 seq)
return mCompleteLedgers.hasValue(seq); return mCompleteLedgers.hasValue(seq);
} }
bool LedgerMaster::getValidatedRange(uint32& minVal, uint32& maxVal)
{
boost::recursive_mutex::scoped_lock sl(mLock);
if (!mValidLedger)
return false;
maxVal = mValidLedger->getLedgerSeq();
if (maxVal == 0)
return false;
minVal = mCompleteLedgers.prevMissing(maxVal);
if (minVal == RangeSet::RangeSetAbsent)
minVal = 0;
else
++minVal;
return true;
}
void LedgerMaster::asyncAccept(Ledger::pointer ledger) void LedgerMaster::asyncAccept(Ledger::pointer ledger)
{ {
uint32 seq = ledger->getLedgerSeq(); uint32 seq = ledger->getLedgerSeq();

View File

@@ -143,6 +143,7 @@ public:
bool haveLedgerRange(uint32 from, uint32 to); bool haveLedgerRange(uint32 from, uint32 to);
bool haveLedger(uint32 seq); bool haveLedger(uint32 seq);
bool getValidatedRange(uint32& minVal, uint32& maxVal);
void resumeAcquiring(); void resumeAcquiring();

View File

@@ -175,6 +175,7 @@ public:
bool isValidated(uint32 seq); bool isValidated(uint32 seq);
bool isValidated(uint32 seq, const uint256& hash); bool isValidated(uint32 seq, const uint256& hash);
bool isValidated(Ledger::ref l) { return isValidated(l->getLedgerSeq(), l->getHash()); } bool isValidated(Ledger::ref l) { return isValidated(l->getLedgerSeq(), l->getHash()); }
bool getValidatedRange(uint32& minVal, uint32& maxVal) { return mLedgerMaster->getValidatedRange(minVal, maxVal); }
SerializedValidation::ref getLastValidation() { return mLastValidation; } SerializedValidation::ref getLastValidation() { return mLastValidation; }
void setLastValidation(SerializedValidation::ref v) { mLastValidation = v; } void setLastValidation(SerializedValidation::ref v) { mLastValidation = v; }