mpt: allow to remove non-existent keys in batch

This bug was here before batch were intoduced.
`Delete` is allowed to be called on missing keys with
HALT result, MPT needs to take this into account.
This commit is contained in:
Evgeniy Stratonikov 2021-02-17 12:26:32 +03:00
parent 4d0681d898
commit 0cb6ec7345
6 changed files with 37 additions and 15 deletions

View file

@ -207,10 +207,8 @@ func (t *Trie) newSubTrieMany(prefix []byte, kv []keyValue, value []byte) (Node,
if len(kv[0].key) == 0 {
if len(kv[0].value) == 0 {
if len(kv) == 1 {
if len(value) != 0 {
return new(HashNode), 1, nil
}
return new(HashNode), 0, ErrNotFound
return new(HashNode), 1, nil
}
node, n, err := t.newSubTrieMany(prefix, kv[1:], nil)
return node, n + 1, err