From eed66894db918b8367dbcb6546f6747939aa9fb0 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Sun, 11 May 2014 21:31:41 -0700 Subject: [PATCH] SHAMap::canonicalize must return a node with the correct ID --- src/ripple_app/shamap/SHAMap.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/ripple_app/shamap/SHAMap.cpp b/src/ripple_app/shamap/SHAMap.cpp index af215439f..87f9a0ae4 100644 --- a/src/ripple_app/shamap/SHAMap.cpp +++ b/src/ripple_app/shamap/SHAMap.cpp @@ -1307,7 +1307,21 @@ SHAMapTreeNode::pointer SHAMap::getCache (uint256 const& hash, SHAMapNode const& void SHAMap::canonicalize (uint256 const& hash, SHAMapTreeNode::pointer& node) { assert (node->getSeq() == 0); + + SHAMapNode id = *node; + treeNodeCache.canonicalize (hash, node); + + if (id != *node) + { + // The cache has the node with a different ID + node = boost::make_shared (*node, 0); + node->set (id); + + // Future fetches are likely to use the newer ID + treeNodeCache.canonicalize (hash, node, true); + assert (id == *node); + } } //------------------------------------------------------------------------------