Cleanups.

This commit is contained in:
JoelKatz
2012-05-26 15:11:10 -07:00
parent 2866cec281
commit d442534c70
3 changed files with 8 additions and 8 deletions

View File

@@ -124,8 +124,9 @@ SHAMapTreeNode* SHAMap::walkToPointer(const uint256& id)
while (!inNode->isLeaf())
{
int branch = inNode->selectBranch(id);
if (inNode->isEmptyBranch(branch)) return NULL;
inNode = getNodePointer(inNode->getChildNodeID(branch), inNode->getChildHash(branch));
const uint256& nextHash = inNode->getChildHash(branch);
if (!nextHash) return NULL;
inNode = getNodePointer(inNode->getChildNodeID(branch), nextHash);
if (!inNode) throw SHAMapException(MissingNode);
}
return (inNode->getTag() == id) ? inNode : NULL;

View File

@@ -179,10 +179,14 @@ public:
// inner node functions
bool isInnerNode() const { return !mItem; }
bool setChildHash(int m, const uint256& hash);
const uint256& getChildHash(int m) const;
bool isEmptyBranch(int m) const { return !mHashes[m]; }
int getBranchCount() const;
void makeInner();
const uint256& getChildHash(int m) const
{
assert((m >= 0) && (m < 16) && (mType == tnINNER));
return mHashes[m];
}
// item node function
bool hasItem() const { return !!mItem; }

View File

@@ -370,9 +370,4 @@ bool SHAMapTreeNode::setChildHash(int m, const uint256 &hash)
return updateHash();
}
const uint256& SHAMapTreeNode::getChildHash(int m) const
{
assert((m >= 0) && (m < 16) && (mType == tnINNER));
return mHashes[m];
}
// vim:ts=4