core: implement MPT Billet structure for MPT restore

MPT restore process is much simpler then regular MPT maintaining: trie
has a fixed structure, we don't need to remove or rebuild MPT nodes. The
only thing we should do is to replace Hash nodes to their unhashed
counterparts and increment refcount. It's better not to touch the
regular MPT code and create a separate structure for this.
This commit is contained in:
Anna Shaleva 2021-07-29 18:00:07 +03:00
parent c9e62769a6
commit a22b1caa3e
3 changed files with 290 additions and 0 deletions

View file

@ -40,3 +40,12 @@ func toNibbles(path []byte) []byte {
}
return result
}
// fromNibbles performs operation opposite to toNibbles and does no path validity checks.
func fromNibbles(path []byte) []byte {
result := make([]byte, len(path)/2)
for i := range result {
result[i] = path[2*i]<<4 + path[2*i+1]
}
return result
}