mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Add 'walkMap' function.
This commit is contained in:
@@ -400,6 +400,8 @@ public:
|
||||
static std::vector<unsigned char> checkTrustedPath(const uint256& ledgerHash, const uint256& leafIndex,
|
||||
const std::list<std::vector<unsigned char> >& path);
|
||||
|
||||
void walkMap(std::vector<SHAMapMissingNode>& missingNodes, int maxMissing);
|
||||
|
||||
bool deepCompare(SHAMap& other);
|
||||
virtual void dump(bool withHashes = false);
|
||||
};
|
||||
|
||||
@@ -186,3 +186,38 @@ bool SHAMap::compare(SHAMap::ref otherMap, SHAMapDiff& differences, int maxCount
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SHAMap::walkMap(std::vector<SHAMapMissingNode>& missingNodes, int maxMissing)
|
||||
{
|
||||
std::stack<SHAMapTreeNode::pointer> nodeStack;
|
||||
|
||||
boost::recursive_mutex::scoped_lock sl(mLock);
|
||||
|
||||
if (!root->isInner()) // root is only node, and we have it
|
||||
return;
|
||||
|
||||
nodeStack.push(root);
|
||||
|
||||
while (!nodeStack.empty())
|
||||
{
|
||||
SHAMapTreeNode::pointer node = nodeStack.top();
|
||||
nodeStack.pop();
|
||||
|
||||
for (int i = 0; i < 16; ++i)
|
||||
if (!node->isEmptyBranch(i))
|
||||
{
|
||||
try
|
||||
{
|
||||
SHAMapTreeNode::pointer d = getNode(node->getChildNodeID(i), node->getChildHash(i), false);
|
||||
if (d->isInner())
|
||||
nodeStack.push(d);
|
||||
}
|
||||
catch (SHAMapMissingNode& n)
|
||||
{
|
||||
missingNodes.push_back(n);
|
||||
if (--maxMissing <= 0)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user