Helper functions.

This commit is contained in:
JoelKatz
2013-01-11 14:21:31 -08:00
parent 7d7d2bc46b
commit d14d8cbf76
4 changed files with 24 additions and 0 deletions

View File

@@ -1053,6 +1053,22 @@ uint256 Ledger::getLedgerHash(uint32 ledgerIndex)
return uint256();
}
std::vector< std::pair<uint32, uint256> > Ledger::getLedgerHashes()
{
std::vector< std::pair<uint32, uint256> > ret;
SLE::pointer hashIndex = getSLE(getLedgerHashIndex());
if (hashIndex)
{
STVector256 vec = hashIndex->getFieldV256(sfHashes);
int size = vec.size();
ret.reserve(size);
uint32 seq = hashIndex->getFieldU32(sfLastLedgerSequence) - size;
for (int i = 0; i < size; ++i)
ret.push_back(std::make_pair(++seq, vec.at(i)));
}
return ret;
}
uint256 Ledger::getBookBase(const uint160& uTakerPaysCurrency, const uint160& uTakerPaysIssuerID,
const uint160& uTakerGetsCurrency, const uint160& uTakerGetsIssuerID)
{

View File

@@ -200,6 +200,7 @@ public:
static int getLedgerHashOffset(uint32 desiredLedgerIndex);
static int getLedgerHashOffset(uint32 desiredLedgerIndex, uint32 currentLedgerIndex);
uint256 getLedgerHash(uint32 ledgerIndex);
std::vector< std::pair<uint32, uint256> > getLedgerHashes();
static uint256 getLedgerFeatureIndex();
static uint256 getLedgerFeeIndex();

View File

@@ -798,4 +798,10 @@ void LedgerAcquireMaster::sweep()
}
}
int LedgerAcquire::getFetchCount()
{
boost::mutex::scoped_lock sl(mLock);
return mLedgers.size();
}
// vim:ts=4

View File

@@ -146,6 +146,7 @@ public:
void dropLedger(const uint256& ledgerHash);
SMAddNode gotLedgerData(ripple::TMLedgerData& packet, Peer::ref);
int getFetchCount();
void logFailure(const uint256& h) { mRecentFailures.add(h); }
bool isFailure(const uint256& h) { return mRecentFailures.isPresent(h, false); }