erigon-pulse/core/rawdb/state_version.go
hexoscott 636586c1b5
cache state check (#5844)
draft for now to get some early feedback on approach
2022-11-07 13:04:31 +00:00

23 lines
435 B
Go

package rawdb
import (
"encoding/binary"
"github.com/ledgerwatch/erigon-lib/kv"
)
func GetStateVersion(tx kv.Tx) (uint64, error) {
val, err := tx.GetOne(kv.Sequence, kv.PlainStateVersion)
if err != nil {
return 0, err
}
if len(val) == 0 {
return 0, nil
}
return binary.BigEndian.Uint64(val), nil
}
func IncrementStateVersion(tx kv.RwTx) (uint64, error) {
return tx.IncrementSequence(string(kv.PlainStateVersion), 1)
}