Allow the SHAMap visitLeaves functions to sanely handle a missing map node.

This commit is contained in:
JoelKatz
2013-11-13 11:04:17 -08:00
parent 1daf1b9932
commit 9322233b37
3 changed files with 25 additions and 5 deletions

View File

@@ -1241,8 +1241,17 @@ static void visitHelper (FUNCTION_TYPE<void (SLE::ref)>& function, SHAMapItem::r
void Ledger::visitStateItems (FUNCTION_TYPE<void (SLE::ref)> function)
{
if (mAccountStateMap)
mAccountStateMap->visitLeaves(BIND_TYPE(&visitHelper, beast::ref(function), P_1));
try
{
if (mAccountStateMap)
mAccountStateMap->visitLeaves(BIND_TYPE(&visitHelper, beast::ref(function), P_1));
}
catch (SHAMapMissingNode& sn)
{
if (mHash.isNonZero ())
getApp().getInboundLedgers().findCreate(mHash, mLedgerSeq, false);
throw;
}
}
/*

View File

@@ -105,8 +105,19 @@ void OrderBookDB::update (Ledger::pointer ledger)
// walk through the entire ledger looking for orderbook entries
int books = 0;
ledger->visitStateItems(BIND_TYPE(&updateHelper, P_1, boost::ref(seen), boost::ref(destMap),
boost::ref(sourceMap), boost::ref(XRPBooks), boost::ref(books)));
try
{
ledger->visitStateItems(BIND_TYPE(&updateHelper, P_1, boost::ref(seen), boost::ref(destMap),
boost::ref(sourceMap), boost::ref(XRPBooks), boost::ref(books)));
}
catch (const SHAMapMissingNode&)
{
WriteLog (lsINFO, OrderBookDB) << "OrderBookDB::update encountered a missing node";
ScopedLockType sl (mLock, __FILE__, __LINE__);
mSeq = 0;
return;
}
WriteLog (lsDEBUG, OrderBookDB) << "OrderBookDB::update< " << books << " books found";
{

View File

@@ -53,7 +53,7 @@ void SHAMap::visitLeaves (FUNCTION_TYPE<void (SHAMapItem::ref item)> function)
++pos;
else
{
SHAMapTreeNode* child = getNodePointerNT (node->getChildNodeID (pos), node->getChildHash (pos));
SHAMapTreeNode* child = getNodePointer (node->getChildNodeID (pos), node->getChildHash (pos));
if (child->isLeaf ())
{
function (child->peekItem ());