20 #include <ripple/basics/contract.h>
21 #include <ripple/shamap/SHAMap.h>
35 bool isFirstMap,
Delta& differences,
int& maxCount)
const
39 nodeStack.
push (node);
41 bool emptyBranch = !otherMapItem;
43 while (!nodeStack.
empty ())
45 node = nodeStack.
top ();
52 for (
int i = 0; i < 16; ++i)
53 if (!inner->isEmptyBranch (i))
61 if (emptyBranch || (item->key() != otherMapItem->key()))
74 else if (item->peekData () != otherMapItem->peekData ())
117 Delta& differences,
int maxCount)
const
124 assert (isValid () && otherMap.
isValid ());
126 if (getHash () == otherMap.
getHash ())
132 nodeStack.
push ({root_.get(), otherMap.
root_.get()});
133 while (!nodeStack.
empty ())
135 auto [ourNode, otherNode] = nodeStack.
top();
138 if (!ourNode || !otherNode)
141 Throw<SHAMapMissingNode> (type_,
uint256 ());
144 if (ourNode->isLeaf () && otherNode->isLeaf ())
149 if (ours->peekItem()->key() == other->peekItem()->key())
151 if (ours->peekItem()->peekData () != other->peekItem()->peekData ())
155 other->peekItem ())));
174 else if (ourNode->isInner () && otherNode->isLeaf ())
178 if (!walkBranch (ours, other->peekItem (),
179 true, differences, maxCount))
182 else if (ourNode->isLeaf () && otherNode->isInner ())
186 if (!otherMap.
walkBranch (other, ours->peekItem (),
187 false, differences, maxCount))
190 else if (ourNode->isInner () && otherNode->isInner ())
194 for (
int i = 0; i < 16; ++i)
195 if (ours->getChildHash (i) != other->getChildHash (i))
197 if (other->isEmptyBranch (i))
201 if (!walkBranch (iNode,
203 differences, maxCount))
206 else if (ours->isEmptyBranch (i))
213 false, differences, maxCount))
217 nodeStack.
push ({descendThrow (ours, i),
230 if (!root_->isInner ())
236 nodeStack.
push (std::static_pointer_cast<SHAMapInnerNode>(root_));
238 while (!nodeStack.
empty ())
243 for (
int i = 0; i < 16; ++i)
245 if (!node->isEmptyBranch (i))
251 if (nextNode->isInner ())
253 std::static_pointer_cast<SHAMapInnerNode>(nextNode));
257 missingNodes.
emplace_back (type_, node->getChildHash (i));
258 if (--maxMissing <= 0)