core: clone MPT node while restoring it multiple times

We need this to avoid collapse collisions. Example of such collapse
described in
https://github.com/nspcc-dev/neo-go/pull/2019#discussion_r689629704.
This commit is contained in:
Anna Shaleva 2021-08-27 16:58:27 +03:00
parent 5cd78c31af
commit 36808b8904
8 changed files with 138 additions and 1 deletions

View file

@ -89,6 +89,12 @@ func (b *BranchNode) UnmarshalJSON(data []byte) error {
return errors.New("expected branch node")
}
// Clone implements Node interface.
func (b *BranchNode) Clone() Node {
res := *b
return &res
}
// splitPath splits path for a branch node.
func splitPath(path []byte) (byte, []byte) {
if len(path) != 0 {