mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-25 06:42:16 +00:00
* crypto/merkle: Remove byter in favor of plain byte slices This PR is fully backwards compatible in terms of function output! (The Go API differs though) The only test case changes was to refactor it to be table driven. * Update godocs per review comments
34 lines
1015 B
Go
34 lines
1015 B
Go
package merkle
|
|
|
|
import (
|
|
"io"
|
|
|
|
amino "github.com/tendermint/go-amino"
|
|
)
|
|
|
|
// Tree is a Merkle tree interface.
|
|
type Tree interface {
|
|
Size() (size int)
|
|
Height() (height int8)
|
|
Has(key []byte) (has bool)
|
|
Proof(key []byte) (value []byte, proof []byte, exists bool) // TODO make it return an index
|
|
Get(key []byte) (index int, value []byte, exists bool)
|
|
GetByIndex(index int) (key []byte, value []byte)
|
|
Set(key []byte, value []byte) (updated bool)
|
|
Remove(key []byte) (value []byte, removed bool)
|
|
HashWithCount() (hash []byte, count int)
|
|
Hash() (hash []byte)
|
|
Save() (hash []byte)
|
|
Load(hash []byte)
|
|
Copy() Tree
|
|
Iterate(func(key []byte, value []byte) (stop bool)) (stopped bool)
|
|
IterateRange(start []byte, end []byte, ascending bool, fx func(key []byte, value []byte) (stop bool)) (stopped bool)
|
|
}
|
|
|
|
//-----------------------------------------------------------------------
|
|
|
|
// Uvarint length prefixed byteslice
|
|
func encodeByteSlice(w io.Writer, bz []byte) (err error) {
|
|
return amino.EncodeByteSlice(w, bz)
|
|
}
|