138 isValid() && otherMap.
isValid(),
"xrpl::SHAMap::compare : valid state and valid input");
147 while (!nodeStack.
empty())
149 auto [ourNode, otherNode] = nodeStack.
top();
152 if ((ourNode ==
nullptr) || (otherNode ==
nullptr))
155 UNREACHABLE(
"xrpl::SHAMap::compare : missing a node");
160 if (ourNode->isLeaf() && otherNode->isLeaf())
165 if (ours->peekItem()->key() == other->peekItem()->key())
167 if (ours->peekItem()->slice() != other->peekItem()->slice())
171 ours->peekItem()->key(),
172 DeltaRef(ours->peekItem(), other->peekItem())));
190 else if (ourNode->isInner() && otherNode->isLeaf())
194 if (!
walkBranch(ours, other->peekItem(),
true, differences, maxCount))
197 else if (ourNode->isLeaf() && otherNode->isInner())
201 if (!otherMap.
walkBranch(other, ours->peekItem(),
false, differences, maxCount))
204 else if (ourNode->isInner() && otherNode->isInner())
208 for (
int i = 0; i < 16; ++i)
210 if (ours->getChildHash(i) != other->getChildHash(i))
212 if (other->isEmptyBranch(i))
216 if (!
walkBranch(iNode,
nullptr,
true, differences, maxCount))
219 else if (ours->isEmptyBranch(i))
223 if (!otherMap.
walkBranch(iNode,
nullptr,
false, differences, maxCount))
236 UNREACHABLE(
"xrpl::SHAMap::compare : invalid node");
285 if (!
root_->isInner())
292 for (
int i = 0; i < 16; ++i)
294 if (!innerRoot->isEmptyBranch(i))
309 for (
int rootChildIndex = 0; rootChildIndex < 16; ++rootChildIndex)
311 auto const& child = topChildren[rootChildIndex];
312 if (!child || !child->isInner())
317 JLOG(
journal_.debug()) <<
"starting worker " << rootChildIndex;
319 [&m, &missingNodes, &maxMissing, &exceptions,
this](
323 while (!nodeStack.empty())
326 std::move(nodeStack.top());
327 XRPL_ASSERT(node,
"xrpl::SHAMap::walkMapParallel : non-null node");
330 for (
int i = 0; i < 16; ++i)
332 if (node->isEmptyBranch(i))
338 if (nextNode->isInner())
348 if (--maxMissing <= 0)
360 std::move(nodeStacks[rootChildIndex]));
367 if (exceptions.
empty())
370 ss <<
"Exception(s) in ledger load: ";
371 for (
auto const& e : exceptions)
372 ss << e.what() <<
", ";
bool walkBranch(SHAMapTreeNode *node, boost::intrusive_ptr< SHAMapItem const > const &otherMapItem, bool isFirstMap, Delta &differences, int &maxCount) const