We didn't correctly store root nodes we acquired from the network.

This commit is contained in:
JoelKatz
2012-10-25 02:22:23 -07:00
parent aa83827f79
commit 98130b524d
4 changed files with 38 additions and 14 deletions

View File

@@ -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");