mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Major updates to the ledger tracking system.
This commit is contained in:
@@ -45,7 +45,8 @@ Ledger::pointer LedgerHistory::getLedgerBySeq(uint32 index)
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock sl(mLedgersByHash.peekMutex());
|
||||
std::map<uint32, Ledger::pointer>::iterator it(mLedgersByIndex.find(index));
|
||||
if (it != mLedgersByIndex.end()) return it->second;
|
||||
if (it != mLedgersByIndex.end())
|
||||
return it->second;
|
||||
sl.unlock();
|
||||
|
||||
Ledger::pointer ret(Ledger::loadByIndex(index));
|
||||
@@ -61,25 +62,14 @@ Ledger::pointer LedgerHistory::getLedgerBySeq(uint32 index)
|
||||
Ledger::pointer LedgerHistory::getLedgerByHash(const uint256& hash)
|
||||
{
|
||||
Ledger::pointer ret = mLedgersByHash.fetch(hash);
|
||||
if (ret) return ret;
|
||||
|
||||
#if 0
|
||||
// FIXME: A ledger without SHA maps isn't very useful
|
||||
// This code will need to build them
|
||||
|
||||
// The fix is to audit all callers to this function and replace them with
|
||||
// higher-level functions that ask more-specific questions that we can
|
||||
// test against our database
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = Ledger::loadByHash(hash);
|
||||
if (!ret) return ret;
|
||||
if (!ret)
|
||||
return ret;
|
||||
assert(ret->getHash() == hash);
|
||||
|
||||
boost::recursive_mutex::scoped_lock sl(mLedgersByHash.peekMutex());
|
||||
mLedgersByHash.canonicalize(hash, ret);
|
||||
if (ret->isAccepted()) mLedgersByIndex[ret->getLedgerSeq()] = ret;
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user