tendermint/merkle/types.go

51 lines
711 B
Go
Raw Normal View History

package merkle
import (
2014-07-01 14:50:24 -07:00
"fmt"
. "github.com/tendermint/tendermint/binary"
)
2014-05-21 16:24:50 -07:00
type Value interface {
2014-07-01 14:50:24 -07:00
Binary
2014-05-21 16:24:50 -07:00
}
type Key interface {
2014-07-01 14:50:24 -07:00
Binary
Equals(Binary) bool
Less(b Binary) bool
}
2014-05-23 17:49:28 -07:00
type Db interface {
2014-07-01 14:50:24 -07:00
Get([]byte) []byte
Put([]byte, []byte)
2014-05-23 17:49:28 -07:00
}
2014-05-23 23:11:22 -07:00
type Node interface {
2014-07-01 14:50:24 -07:00
Binary
Key() Key
Value() Value
Size() uint64
Height() uint8
Hash() (ByteSlice, uint64)
Save(Db)
}
2014-05-23 23:11:22 -07:00
type Tree interface {
2014-07-01 14:50:24 -07:00
Root() Node
Size() uint64
Height() uint8
Has(key Key) bool
Get(key Key) Value
Hash() (ByteSlice, uint64)
Save()
Put(Key, Value) bool
Remove(Key) (Value, error)
Copy() Tree
Traverse(func(Node) bool)
Values() <-chan Value
2014-05-23 23:11:22 -07:00
}
2014-05-21 16:24:50 -07:00
func NotFound(key Key) error {
2014-07-01 14:50:24 -07:00
return fmt.Errorf("Key was not found.")
}