tendermint/merkle/types.go

51 lines
899 B
Go
Raw Normal View History

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