Install SHAMapInnerNodeV2

* Inner node optimization.
This commit is contained in:
Howard Hinnant
2016-01-27 18:45:29 -05:00
parent e499e908d2
commit 1c3ee48146
19 changed files with 1286 additions and 191 deletions

View File

@@ -102,7 +102,7 @@ std::string SHAMapNodeID::getRawString () const
SHAMapNodeID SHAMapNodeID::getChildNodeID (int m) const
{
assert ((m >= 0) && (m < 16));
assert (mDepth <= 64);
assert (mDepth < 64);
uint256 child (mNodeID);
child.begin ()[mDepth / 2] |= (mDepth & 1) ? m : (m << 4);
@@ -143,6 +143,25 @@ int SHAMapNodeID::selectBranch (uint256 const& hash) const
return branch;
}
bool
SHAMapNodeID::has_common_prefix(SHAMapNodeID const& other) const
{
assert(mDepth <= other.mDepth);
auto x = mNodeID.begin();
auto y = other.mNodeID.begin();
for (unsigned i = 0; i < mDepth/2; ++i, ++x, ++y)
{
if (*x != *y)
return false;
}
if (mDepth & 1)
{
auto i = mDepth/2;
return (*(mNodeID.begin() + i) & 0xF0) == (*(other.mNodeID.begin() + i) & 0xF0);
}
return true;
}
void SHAMapNodeID::dump (beast::Journal journal) const
{
JLOG(journal.debug()) <<