mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
An assert in NetworkOPs.cpp line 850 was reported. This suggests a mutable
ledger came from the ledger master's "ledger by hash" table. This fixes an obvious way that this can happen (that seems incredibly rare and requires a transaction / ledger acquire race with a very narrow window) and adds some extra asserts to try to catch this earlier.
This commit is contained in:
@@ -24,6 +24,7 @@ LedgerHistory::LedgerHistory() : mLedgersByHash("LedgerCache", CACHED_LEDGER_NUM
|
||||
|
||||
void LedgerHistory::addLedger(Ledger::pointer ledger)
|
||||
{
|
||||
assert(ledger->isImmutable());
|
||||
mLedgersByHash.canonicalize(ledger->getHash(), ledger, true);
|
||||
}
|
||||
|
||||
@@ -78,13 +79,17 @@ Ledger::pointer LedgerHistory::getLedgerByHash(const uint256& hash)
|
||||
{
|
||||
Ledger::pointer ret = mLedgersByHash.fetch(hash);
|
||||
if (ret)
|
||||
{
|
||||
assert(ret->getHash() == hash);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = Ledger::loadByHash(hash);
|
||||
if (!ret)
|
||||
return ret;
|
||||
assert(ret->getHash() == hash);
|
||||
mLedgersByHash.canonicalize(ret->getHash(), ret);
|
||||
assert(ret->getHash() == hash);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user