diff --git a/src/SHAMap.cpp b/src/SHAMap.cpp index 04fee377f8..f234581afd 100644 --- a/src/SHAMap.cpp +++ b/src/SHAMap.cpp @@ -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; diff --git a/src/SHAMap.h b/src/SHAMap.h index 992f346470..031ea1609b 100644 --- a/src/SHAMap.h +++ b/src/SHAMap.h @@ -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; } diff --git a/src/SHAMapNodes.cpp b/src/SHAMapNodes.cpp index e791e28e83..17d6206045 100644 --- a/src/SHAMapNodes.cpp +++ b/src/SHAMapNodes.cpp @@ -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