mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Add new 'isEmpty' function to find empty inner nodes.
This commit is contained in:
@@ -364,7 +364,7 @@ void SHAMapTreeNode::addRaw(Serializer& s, SHANodeFormat format)
|
||||
|
||||
if (mType == tnINNER)
|
||||
{
|
||||
assert(getBranchCount() != 0);
|
||||
assert(!isEmpty());
|
||||
if (format == snfPREFIX)
|
||||
{
|
||||
s.add32(sHP_InnerNode);
|
||||
@@ -453,6 +453,14 @@ SHAMapItem::pointer SHAMapTreeNode::getItem() const
|
||||
return boost::make_shared<SHAMapItem>(*mItem);
|
||||
}
|
||||
|
||||
bool SHAMapTreeNode::isEmpty() const
|
||||
{
|
||||
assert(isInner());
|
||||
for (int i = 0; i < 16; ++i)
|
||||
if (mHashes[i].isNonZero()) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
int SHAMapTreeNode::getBranchCount() const
|
||||
{
|
||||
assert(isInner());
|
||||
|
||||
Reference in New Issue
Block a user