mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Use fat root semantics when acquire transaction sets. This might save a pass.
This commit is contained in:
@@ -928,7 +928,7 @@ void Peer::recvGetLedger(newcoin::TMGetLedger& packet)
|
||||
{
|
||||
SHAMap::pointer map;
|
||||
newcoin::TMLedgerData reply;
|
||||
bool fatLeaves = true;
|
||||
bool fatLeaves = true, fatRoot = false;
|
||||
|
||||
if (packet.itype() == newcoin::liTS_CANDIDATE)
|
||||
{ // Request is for a transaction candidate set
|
||||
@@ -952,6 +952,7 @@ void Peer::recvGetLedger(newcoin::TMGetLedger& packet)
|
||||
reply.set_ledgerhash(txHash.begin(), txHash.size());
|
||||
reply.set_type(newcoin::liTS_CANDIDATE);
|
||||
fatLeaves = false; // We'll already have most transactions
|
||||
fatRoot = true; // Save a pass
|
||||
}
|
||||
else
|
||||
{ // Figure out what ledger they want
|
||||
@@ -1057,7 +1058,7 @@ void Peer::recvGetLedger(newcoin::TMGetLedger& packet)
|
||||
}
|
||||
std::vector<SHAMapNode> nodeIDs;
|
||||
std::list< std::vector<unsigned char> > rawNodes;
|
||||
if(map->getNodeFat(mn, nodeIDs, rawNodes, fatLeaves))
|
||||
if(map->getNodeFat(mn, nodeIDs, rawNodes, fatRoot, fatLeaves))
|
||||
{
|
||||
std::vector<SHAMapNode>::iterator nodeIDIterator;
|
||||
std::list< std::vector<unsigned char> >::iterator rawNodeIterator;
|
||||
@@ -1074,7 +1075,8 @@ void Peer::recvGetLedger(newcoin::TMGetLedger& packet)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (packet.has_requestcookie()) reply.set_requestcookie(packet.requestcookie());
|
||||
if (packet.has_requestcookie())
|
||||
reply.set_requestcookie(packet.requestcookie());
|
||||
PackedMessage::pointer oPacket = boost::make_shared<PackedMessage>(reply, newcoin::mtLEDGER_DATA);
|
||||
sendPacket(oPacket);
|
||||
}
|
||||
|
||||
@@ -327,7 +327,7 @@ public:
|
||||
void getMissingNodes(std::vector<SHAMapNode>& nodeIDs, std::vector<uint256>& hashes, int max,
|
||||
SHAMapSyncFilter* filter);
|
||||
bool getNodeFat(const SHAMapNode& node, std::vector<SHAMapNode>& nodeIDs,
|
||||
std::list<std::vector<unsigned char> >& rawNode, bool fatLeaves);
|
||||
std::list<std::vector<unsigned char> >& rawNode, bool fatRoot, bool fatLeaves);
|
||||
bool getRootNode(Serializer& s, SHANodeFormat format);
|
||||
bool addRootNode(const uint256& hash, const std::vector<unsigned char>& rootNode, SHANodeFormat format);
|
||||
bool addRootNode(const std::vector<unsigned char>& rootNode, SHANodeFormat format);
|
||||
|
||||
@@ -86,7 +86,7 @@ void SHAMap::getMissingNodes(std::vector<SHAMapNode>& nodeIDs, std::vector<uint2
|
||||
}
|
||||
|
||||
bool SHAMap::getNodeFat(const SHAMapNode& wanted, std::vector<SHAMapNode>& nodeIDs,
|
||||
std::list<std::vector<unsigned char> >& rawNodes, bool fatLeaves)
|
||||
std::list<std::vector<unsigned char> >& rawNodes, bool fatRoot, bool fatLeaves)
|
||||
{ // Gets a node and some of its children
|
||||
boost::recursive_mutex::scoped_lock sl(mLock);
|
||||
|
||||
@@ -102,7 +102,7 @@ bool SHAMap::getNodeFat(const SHAMapNode& wanted, std::vector<SHAMapNode>& nodeI
|
||||
node->addRaw(s, snfWIRE);
|
||||
rawNodes.push_back(s.peekData());
|
||||
|
||||
if (node->isRoot() || node->isLeaf()) // don't get a fat root, can't get a fat leaf
|
||||
if ((!fatRoot && node->isRoot()) || node->isLeaf()) // don't get a fat root, can't get a fat leaf
|
||||
return true;
|
||||
|
||||
for (int i = 0; i < 16; ++i)
|
||||
@@ -141,7 +141,8 @@ bool SHAMap::addRootNode(const std::vector<unsigned char>& rootNode, SHANodeForm
|
||||
}
|
||||
|
||||
SHAMapTreeNode::pointer node = boost::make_shared<SHAMapTreeNode>(SHAMapNode(), rootNode, 0, format);
|
||||
if (!node) return false;
|
||||
if (!node)
|
||||
return false;
|
||||
|
||||
#ifdef DEBUG
|
||||
node->dump();
|
||||
@@ -444,7 +445,7 @@ BOOST_AUTO_TEST_CASE( SHAMapSync_test )
|
||||
|
||||
destination.setSynching();
|
||||
|
||||
if (!source.getNodeFat(SHAMapNode(), nodeIDs, gotNodes, (rand() % 2) == 0))
|
||||
if (!source.getNodeFat(SHAMapNode(), nodeIDs, gotNodes, (rand() % 2) == 0, (rand() % 2) == 0))
|
||||
{
|
||||
Log(lsFATAL) << "GetNodeFat(root) fails";
|
||||
BOOST_FAIL("GetNodeFat");
|
||||
@@ -481,7 +482,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, (rand() % 2) == 0))
|
||||
if (!source.getNodeFat(*nodeIDIterator, gotNodeIDs, gotNodes, (rand() % 2) == 0, (rand() % 2) == 0))
|
||||
{
|
||||
Log(lsFATAL) << "GetNodeFat fails";
|
||||
BOOST_FAIL("GetNodeFat");
|
||||
|
||||
Reference in New Issue
Block a user