mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 18:02:24 +00:00
trie: combine validation loops in VerifyRangeProof
This commit is contained in:
parent
8c1a36dad3
commit
e1026e2edd
1 changed files with 3 additions and 5 deletions
|
|
@ -486,13 +486,11 @@ func VerifyRangeProof(rootHash common.Hash, firstKey []byte, keys [][]byte, valu
|
||||||
return false, fmt.Errorf("inconsistent proof data, keys: %d, values: %d", len(keys), len(values))
|
return false, fmt.Errorf("inconsistent proof data, keys: %d, values: %d", len(keys), len(values))
|
||||||
}
|
}
|
||||||
// Ensure the received batch is monotonic increasing and contains no deletions
|
// Ensure the received batch is monotonic increasing and contains no deletions
|
||||||
for i := 0; i < len(keys)-1; i++ {
|
for i := 0; i < len(keys); i++ {
|
||||||
if bytes.Compare(keys[i], keys[i+1]) >= 0 {
|
if i < len(keys)-1 && bytes.Compare(keys[i], keys[i+1]) >= 0 {
|
||||||
return false, errors.New("range is not monotonically increasing")
|
return false, errors.New("range is not monotonically increasing")
|
||||||
}
|
}
|
||||||
}
|
if len(values[i]) == 0 {
|
||||||
for _, value := range values {
|
|
||||||
if len(value) == 0 {
|
|
||||||
return false, errors.New("range contains deletion")
|
return false, errors.New("range contains deletion")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue