mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
getNodePointer function for when you only know the node ID.
This commit is contained in:
@@ -985,6 +985,34 @@ SHAMapTreeNode::pointer SHAMap::getNode (const SHAMapNode& nodeID)
|
||||
return node;
|
||||
}
|
||||
|
||||
// This function returns NULL if no node with that ID exists in the map
|
||||
// It throws if the map is incomplete
|
||||
SHAMapTreeNode* SHAMap::getNodePointer (const SHAMapNode& nodeID)
|
||||
{
|
||||
boost::unordered_map<SHAMapNode, SHAMapTreeNode::pointer>::iterator it = mTNByID.find (nodeID);
|
||||
if (it != mTNByID.end())
|
||||
{
|
||||
it->second->touch(mSeq);
|
||||
return it->second.get();
|
||||
}
|
||||
|
||||
SHAMapTreeNode* node = root.get();
|
||||
|
||||
while (nodeID != *node)
|
||||
{
|
||||
int branch = node->selectBranch (nodeID.getNodeID ());
|
||||
assert (branch >= 0);
|
||||
|
||||
if ((branch < 0) || node->isEmptyBranch (branch))
|
||||
return NULL;
|
||||
|
||||
node = getNodePointer (node->getChildNodeID (branch), node->getChildHash (branch));
|
||||
assert (node);
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
bool SHAMap::getPath (uint256 const& index, std::vector< Blob >& nodes, SHANodeFormat format)
|
||||
{
|
||||
// Return the path of nodes to the specified index in the specified format
|
||||
|
||||
@@ -202,6 +202,7 @@ private:
|
||||
|
||||
SHAMapTreeNode::pointer getNode (const SHAMapNode & id);
|
||||
SHAMapTreeNode::pointer getNode (const SHAMapNode & id, uint256 const & hash, bool modify);
|
||||
SHAMapTreeNode* getNodePointer (const SHAMapNode & id);
|
||||
SHAMapTreeNode* getNodePointer (const SHAMapNode & id, uint256 const & hash);
|
||||
SHAMapTreeNode* getNodePointerNT (const SHAMapNode & id, uint256 const & hash);
|
||||
SHAMapTreeNode* getNodePointer (const SHAMapNode & id, uint256 const & hash, SHAMapSyncFilter * filter);
|
||||
|
||||
Reference in New Issue
Block a user