From 7dcb10b178915996aa5ead20c4136104633cfe88 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Mon, 4 Jun 2012 06:01:33 -0700 Subject: [PATCH] Make an option whether fat node gets should include leaves. This will save bandwidth and improve performance in ledger consensus. (Well, it will once the rest of the code is tied in.) --- src/SHAMapSync.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/SHAMapSync.cpp b/src/SHAMapSync.cpp index edc59f15c5..aca6891d54 100644 --- a/src/SHAMapSync.cpp +++ b/src/SHAMapSync.cpp @@ -58,7 +58,7 @@ void SHAMap::getMissingNodes(std::vector& nodeIDs, std::vector& nodeIDs, - std::list >& rawNodes) + std::list >& rawNodes, bool fatLeaves) { // Gets a node and some of its children boost::recursive_mutex::scoped_lock sl(mLock); @@ -82,7 +82,7 @@ bool SHAMap::getNodeFat(const SHAMapNode& wanted, std::vector& nodeI { SHAMapTreeNode::pointer nextNode = getNode(node->getChildNodeID(i), node->getChildHash(i), false); assert(nextNode); - if(nextNode) + if (nextNode && (fatLeaves || !nextNode->isLeaf())) { nodeIDs.push_back(*nextNode); Serializer s; @@ -387,7 +387,7 @@ BOOST_AUTO_TEST_CASE( SHAMapSync_test ) destination.setSynching(); - if (!source.getNodeFat(SHAMapNode(), nodeIDs, gotNodes)) + if (!source.getNodeFat(SHAMapNode(), nodeIDs, gotNodes, (rand() % 2) == 0)) { Log(lsFATAL) << "GetNodeFat(root) fails"; BOOST_FAIL("GetNodeFat"); @@ -423,7 +423,7 @@ BOOST_AUTO_TEST_CASE( SHAMapSync_test ) // get as many nodes as possible based on this information for (nodeIDIterator = nodeIDs.begin(); nodeIDIterator != nodeIDs.end(); ++nodeIDIterator) - if (!source.getNodeFat(*nodeIDIterator, gotNodeIDs, gotNodes)) + if (!source.getNodeFat(*nodeIDIterator, gotNodeIDs, gotNodes, (rand() % 2) == 0)) { Log(lsFATAL) << "GetNodeFat fails"; BOOST_FAIL("GetNodeFat");