Avoid some unnecessary work.

This commit is contained in:
JoelKatz
2013-03-27 11:09:00 -07:00
parent a72e4555bd
commit edf019c0dd
4 changed files with 20 additions and 10 deletions

View File

@@ -177,7 +177,7 @@ SHAMapTreeNode::SHAMapTreeNode(const SHAMapNode& node, SHAMapItem::ref item, TNT
}
SHAMapTreeNode::SHAMapTreeNode(const SHAMapNode& id, const std::vector<unsigned char>& rawNode, uint32 seq,
SHANodeFormat format, const uint256& hash) :
SHANodeFormat format, const uint256& hash, bool hashValid) :
SHAMapNode(id), mSeq(seq), mType(tnERROR), mIsBranch(0), mFullBelow(false)
{
if (format == snfWIRE)
@@ -317,9 +317,7 @@ SHAMapTreeNode::SHAMapTreeNode(const SHAMapNode& id, const std::vector<unsigned
throw std::runtime_error("Unknown format");
}
if (hash.isZero())
updateHash();
else
if (hashValid)
{
mHash = hash;
#ifdef PARANOID
@@ -327,6 +325,8 @@ SHAMapTreeNode::SHAMapTreeNode(const SHAMapNode& id, const std::vector<unsigned
assert(mHash == hash);
#endif
}
else
updateHash();
}
bool SHAMapTreeNode::updateHash()