cosmos-sdk/store/v2/internal/encoding/prefix.go
cool-developer 6d4097bfb7
feat(store/v2): implement the feature to upgrade the store keys (#20453)
Co-authored-by: Matt Kocubinski <mkocubinski@gmail.com>
2024-08-05 12:34:36 +00:00

17 lines
461 B
Go

package encoding
import "encoding/binary"
const separator = '/'
// BuildPrefixWithVersion returns a byte slice with the given prefix and BigEndian encoded version.
// It is mainly used to represent the removed store key at the metadata store.
func BuildPrefixWithVersion(prefix string, version uint64) []byte {
n := len(prefix)
buf := make([]byte, n+8+1)
copy(buf, prefix)
binary.BigEndian.PutUint64(buf[n:], version)
buf[n+8] = separator
return buf
}