More work on peer to peer ledger sync.

This commit is contained in:
JoelKatz
2012-02-13 10:48:59 -08:00
parent b8b78b2c27
commit db8763ef19
6 changed files with 184 additions and 47 deletions

View File

@@ -95,6 +95,22 @@ SHAMapNode::SHAMapNode(int depth, const uint256 &hash) : mDepth(depth)
mNodeID = getNodeID(depth, hash);
}
SHAMapNode::SHAMapNode(const void *ptr, int len)
{
if(len<33) mDepth=-1;
else
{
memcpy(&mNodeID, ptr, 32);
mDepth=*(reinterpret_cast<const unsigned char *>(ptr) + 32);
}
}
void SHAMapNode::addIDRaw(Serializer &s) const
{
s.add256(mNodeID);
s.add1(mDepth);
}
SHAMapNode SHAMapNode::getChildNodeID(int m) const
{ // This can be optimized to avoid the << if needed
assert((m>=0) && (m<16));