erigon-pulse/erigon-lib/kv/dbutils/helper.go
a 436493350e
Sentinel refactor (#8296)
1. changes sentinel to use an http-like interface

2. moves hexutil, crypto/blake2b, metrics packages to erigon-lib
2023-10-22 01:17:18 +02:00

19 lines
403 B
Go

package dbutils
// NextNibblesSubtree does []byte++. Returns false if overflow.
func NextNibblesSubtree(in []byte, out *[]byte) bool {
r := (*out)[:len(in)]
copy(r, in)
for i := len(r) - 1; i >= 0; i-- {
if r[i] != 15 { // max value of nibbles
r[i]++
*out = r
return true
}
r = r[:i] // make it shorter, because in tries after 11ff goes 12, but not 1200
}
*out = r
return false
}