mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Allow the SHAMap visitLeaves functions to sanely handle a missing map node.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -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";
|
||||
{
|
||||
|
||||
@@ -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 ());
|
||||
|
||||
Reference in New Issue
Block a user