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:
JoelKatz
2013-01-23 10:14:20 -08:00
parent 122593d0c1
commit e25863207a
2 changed files with 8 additions and 2 deletions

View File

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