github.com/devwanda/aphelion-staking@v0.33.9/crypto/merkle/types.go (about) 1 package merkle 2 3 import ( 4 "io" 5 6 amino "github.com/evdatsion/go-amino" 7 ) 8 9 // Tree is a Merkle tree interface. 10 type Tree interface { 11 Size() (size int) 12 Height() (height int8) 13 Has(key []byte) (has bool) 14 Proof(key []byte) (value []byte, proof []byte, exists bool) // TODO make it return an index 15 Get(key []byte) (index int, value []byte, exists bool) 16 GetByIndex(index int) (key []byte, value []byte) 17 Set(key []byte, value []byte) (updated bool) 18 Remove(key []byte) (value []byte, removed bool) 19 HashWithCount() (hash []byte, count int) 20 Hash() (hash []byte) 21 Save() (hash []byte) 22 Load(hash []byte) 23 Copy() Tree 24 Iterate(func(key []byte, value []byte) (stop bool)) (stopped bool) 25 IterateRange(start []byte, end []byte, ascending bool, fx func(key []byte, value []byte) (stop bool)) (stopped bool) 26 } 27 28 //----------------------------------------------------------------------- 29 30 // Uvarint length prefixed byteslice 31 func encodeByteSlice(w io.Writer, bz []byte) (err error) { 32 return amino.EncodeByteSlice(w, bz) 33 }