mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-05 16:57:56 +00:00
We didn't correctly store root nodes we acquired from the network.
This commit is contained in:
@@ -400,7 +400,7 @@ bool LedgerAcquire::takeTxNode(const std::list<SHAMapNode>& nodeIDs,
|
|||||||
{
|
{
|
||||||
if (nodeIDit->isRoot())
|
if (nodeIDit->isRoot())
|
||||||
{
|
{
|
||||||
if (!mLedger->peekTransactionMap()->addRootNode(mLedger->getTransHash(), *nodeDatait, snfWIRE))
|
if (!mLedger->peekTransactionMap()->addRootNode(mLedger->getTransHash(), *nodeDatait, snfWIRE, &tFilter))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (!mLedger->peekTransactionMap()->addKnownNode(*nodeIDit, *nodeDatait, &tFilter))
|
else if (!mLedger->peekTransactionMap()->addKnownNode(*nodeIDit, *nodeDatait, &tFilter))
|
||||||
@@ -435,7 +435,8 @@ bool LedgerAcquire::takeAsNode(const std::list<SHAMapNode>& nodeIDs,
|
|||||||
{
|
{
|
||||||
if (nodeIDit->isRoot())
|
if (nodeIDit->isRoot())
|
||||||
{
|
{
|
||||||
if (!mLedger->peekAccountStateMap()->addRootNode(mLedger->getAccountHash(), *nodeDatait, snfWIRE))
|
if (!mLedger->peekAccountStateMap()->addRootNode(mLedger->getAccountHash(),
|
||||||
|
*nodeDatait, snfWIRE, &tFilter))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (!mLedger->peekAccountStateMap()->addKnownNode(*nodeIDit, *nodeDatait, &tFilter))
|
else if (!mLedger->peekAccountStateMap()->addKnownNode(*nodeIDit, *nodeDatait, &tFilter))
|
||||||
@@ -458,14 +459,22 @@ bool LedgerAcquire::takeAsNode(const std::list<SHAMapNode>& nodeIDs,
|
|||||||
|
|
||||||
bool LedgerAcquire::takeAsRootNode(const std::vector<unsigned char>& data)
|
bool LedgerAcquire::takeAsRootNode(const std::vector<unsigned char>& data)
|
||||||
{
|
{
|
||||||
if (!mHaveBase) return false;
|
if (!mHaveBase)
|
||||||
return mLedger->peekAccountStateMap()->addRootNode(mLedger->getAccountHash(), data, snfWIRE);
|
return false;
|
||||||
|
AccountStateSF tFilter(mLedger->getHash(), mLedger->getLedgerSeq());
|
||||||
|
if (!mLedger->peekAccountStateMap()->addRootNode(mLedger->getAccountHash(), data, snfWIRE, &tFilter))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LedgerAcquire::takeTxRootNode(const std::vector<unsigned char>& data)
|
bool LedgerAcquire::takeTxRootNode(const std::vector<unsigned char>& data)
|
||||||
{
|
{
|
||||||
if (!mHaveBase) return false;
|
if (!mHaveBase)
|
||||||
return mLedger->peekTransactionMap()->addRootNode(mLedger->getTransHash(), data, snfWIRE);
|
return false;
|
||||||
|
TransactionStateSF tFilter(mLedger->getHash(), mLedger->getLedgerSeq());
|
||||||
|
if (!mLedger->peekTransactionMap()->addRootNode(mLedger->getTransHash(), data, snfWIRE, &tFilter))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
LedgerAcquire::pointer LedgerAcquireMaster::findCreate(const uint256& hash)
|
LedgerAcquire::pointer LedgerAcquireMaster::findCreate(const uint256& hash)
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ bool TransactionAcquire::takeNodes(const std::list<SHAMapNode>& nodeIDs,
|
|||||||
cLog(lsWARNING) << "Got root TXS node, already have it";
|
cLog(lsWARNING) << "Got root TXS node, already have it";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!mMap->addRootNode(getHash(), *nodeDatait, snfWIRE))
|
if (!mMap->addRootNode(getHash(), *nodeDatait, snfWIRE, NULL))
|
||||||
return false;
|
return false;
|
||||||
else
|
else
|
||||||
mHaveRoot = true;
|
mHaveRoot = true;
|
||||||
|
|||||||
@@ -368,8 +368,10 @@ public:
|
|||||||
bool getNodeFat(const SHAMapNode& node, std::vector<SHAMapNode>& nodeIDs,
|
bool getNodeFat(const SHAMapNode& node, std::vector<SHAMapNode>& nodeIDs,
|
||||||
std::list<std::vector<unsigned char> >& rawNode, bool fatRoot, bool fatLeaves);
|
std::list<std::vector<unsigned char> >& rawNode, bool fatRoot, bool fatLeaves);
|
||||||
bool getRootNode(Serializer& s, SHANodeFormat format);
|
bool getRootNode(Serializer& s, SHANodeFormat format);
|
||||||
bool addRootNode(const uint256& hash, const std::vector<unsigned char>& rootNode, 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);
|
SHAMapSyncFilter* filter);
|
||||||
|
bool addRootNode(const std::vector<unsigned char>& rootNode, SHANodeFormat format,
|
||||||
|
SHAMapSyncFilter* filter);
|
||||||
bool addKnownNode(const SHAMapNode& nodeID, const std::vector<unsigned char>& rawNode,
|
bool addKnownNode(const SHAMapNode& nodeID, const std::vector<unsigned char>& rawNode,
|
||||||
SHAMapSyncFilter* filter);
|
SHAMapSyncFilter* filter);
|
||||||
|
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ bool SHAMap::getRootNode(Serializer& s, SHANodeFormat format)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SHAMap::addRootNode(const std::vector<unsigned char>& rootNode, SHANodeFormat format)
|
bool SHAMap::addRootNode(const std::vector<unsigned char>& rootNode, SHANodeFormat format, SHAMapSyncFilter* filter)
|
||||||
{
|
{
|
||||||
boost::recursive_mutex::scoped_lock sl(mLock);
|
boost::recursive_mutex::scoped_lock sl(mLock);
|
||||||
|
|
||||||
@@ -154,16 +154,23 @@ bool SHAMap::addRootNode(const std::vector<unsigned char>& rootNode, SHANodeForm
|
|||||||
|
|
||||||
root = node;
|
root = node;
|
||||||
mTNByID[*root] = root;
|
mTNByID[*root] = root;
|
||||||
if (!root->getNodeHash())
|
if (root->getNodeHash().isZero())
|
||||||
{
|
{
|
||||||
root->setFullBelow();
|
root->setFullBelow();
|
||||||
clearSynching();
|
clearSynching();
|
||||||
}
|
}
|
||||||
|
else if (filter)
|
||||||
|
{
|
||||||
|
Serializer s;
|
||||||
|
root->addRaw(s, snfPREFIX);
|
||||||
|
filter->gotNode(*root, root->getNodeHash(), s.peekData(), root->getType());
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SHAMap::addRootNode(const uint256& hash, const std::vector<unsigned char>& rootNode, SHANodeFormat format)
|
bool SHAMap::addRootNode(const uint256& hash, const std::vector<unsigned char>& rootNode, SHANodeFormat format,
|
||||||
|
SHAMapSyncFilter* filter)
|
||||||
{
|
{
|
||||||
boost::recursive_mutex::scoped_lock sl(mLock);
|
boost::recursive_mutex::scoped_lock sl(mLock);
|
||||||
|
|
||||||
@@ -184,11 +191,17 @@ bool SHAMap::addRootNode(const uint256& hash, const std::vector<unsigned char>&
|
|||||||
returnNode(root, true);
|
returnNode(root, true);
|
||||||
root = node;
|
root = node;
|
||||||
mTNByID[*root] = root;
|
mTNByID[*root] = root;
|
||||||
if (!root->getNodeHash())
|
if (root->getNodeHash().isZero())
|
||||||
{
|
{
|
||||||
root->setFullBelow();
|
root->setFullBelow();
|
||||||
clearSynching();
|
clearSynching();
|
||||||
}
|
}
|
||||||
|
else if (filter)
|
||||||
|
{
|
||||||
|
Serializer s;
|
||||||
|
root->addRaw(s, snfPREFIX);
|
||||||
|
filter->gotNode(*root, root->getNodeHash(), s.peekData(), root->getType());
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -458,7 +471,7 @@ BOOST_AUTO_TEST_CASE( SHAMapSync_test )
|
|||||||
cLog(lsFATAL) << "Didn't get root node " << gotNodes.size();
|
cLog(lsFATAL) << "Didn't get root node " << gotNodes.size();
|
||||||
BOOST_FAIL("NodeSize");
|
BOOST_FAIL("NodeSize");
|
||||||
}
|
}
|
||||||
if (!destination.addRootNode(*gotNodes.begin(), snfWIRE))
|
if (!destination.addRootNode(*gotNodes.begin(), snfWIRE, NULL))
|
||||||
{
|
{
|
||||||
cLog(lsFATAL) << "AddRootNode fails";
|
cLog(lsFATAL) << "AddRootNode fails";
|
||||||
BOOST_FAIL("AddRootNode");
|
BOOST_FAIL("AddRootNode");
|
||||||
|
|||||||
Reference in New Issue
Block a user