mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
We didn't correctly store root nodes we acquired from the network.
This commit is contained in:
@@ -131,7 +131,7 @@ bool SHAMap::getRootNode(Serializer& s, SHANodeFormat format)
|
||||
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);
|
||||
|
||||
@@ -154,16 +154,23 @@ bool SHAMap::addRootNode(const std::vector<unsigned char>& rootNode, SHANodeForm
|
||||
|
||||
root = node;
|
||||
mTNByID[*root] = root;
|
||||
if (!root->getNodeHash())
|
||||
if (root->getNodeHash().isZero())
|
||||
{
|
||||
root->setFullBelow();
|
||||
clearSynching();
|
||||
}
|
||||
else if (filter)
|
||||
{
|
||||
Serializer s;
|
||||
root->addRaw(s, snfPREFIX);
|
||||
filter->gotNode(*root, root->getNodeHash(), s.peekData(), root->getType());
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
@@ -184,11 +191,17 @@ bool SHAMap::addRootNode(const uint256& hash, const std::vector<unsigned char>&
|
||||
returnNode(root, true);
|
||||
root = node;
|
||||
mTNByID[*root] = root;
|
||||
if (!root->getNodeHash())
|
||||
if (root->getNodeHash().isZero())
|
||||
{
|
||||
root->setFullBelow();
|
||||
clearSynching();
|
||||
}
|
||||
else if (filter)
|
||||
{
|
||||
Serializer s;
|
||||
root->addRaw(s, snfPREFIX);
|
||||
filter->gotNode(*root, root->getNodeHash(), s.peekData(), root->getType());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -458,7 +471,7 @@ BOOST_AUTO_TEST_CASE( SHAMapSync_test )
|
||||
cLog(lsFATAL) << "Didn't get root node " << gotNodes.size();
|
||||
BOOST_FAIL("NodeSize");
|
||||
}
|
||||
if (!destination.addRootNode(*gotNodes.begin(), snfWIRE))
|
||||
if (!destination.addRootNode(*gotNodes.begin(), snfWIRE, NULL))
|
||||
{
|
||||
cLog(lsFATAL) << "AddRootNode fails";
|
||||
BOOST_FAIL("AddRootNode");
|
||||
|
||||
Reference in New Issue
Block a user