tendermint/merkle/types.go

64 lines
1.0 KiB
Go
Raw Normal View History

package merkle
import (
"fmt"
)
2014-05-22 18:08:49 -07:00
type Binary interface {
ByteSize() int
SaveTo([]byte) int
}
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-05-21 21:48:41 -07:00
Equals(b Key) bool
Less(b Key) bool
}
type Tree interface {
2014-05-21 21:48:41 -07:00
Root() Node
2014-05-21 21:48:41 -07:00
Size() uint64
Height() uint8
Has(key Key) bool
2014-05-22 18:08:49 -07:00
Get(key Key) Value
Hash() (ByteSlice, uint64)
2014-05-22 18:08:49 -07:00
Put(Key, Value)
2014-05-21 21:48:41 -07:00
Remove(Key) (Value, error)
}
2014-05-22 02:34:07 -07:00
type Db interface {
2014-05-22 18:08:49 -07:00
Get([]byte) []byte
Put([]byte, []byte)
2014-05-22 02:34:07 -07:00
}
type Node interface {
2014-05-22 18:08:49 -07:00
Binary
2014-05-21 21:48:41 -07:00
Key() Key
Value() Value
2014-05-22 02:34:07 -07:00
Left(Db) Node
Right(Db) Node
2014-05-21 21:48:41 -07:00
Size() uint64
Height() uint8
2014-05-22 02:34:07 -07:00
Has(Db, Key) bool
2014-05-22 18:08:49 -07:00
Get(Db, Key) Value
Hash() (ByteSlice, uint64)
2014-05-21 21:48:41 -07:00
2014-05-22 02:34:07 -07:00
Put(Db, Key, Value) (*IAVLNode, bool)
Remove(Db, Key) (*IAVLNode, Value, error)
}
2014-05-21 21:48:41 -07:00
type NodeIterator func() Node
2014-05-21 16:24:50 -07:00
func NotFound(key Key) error {
return fmt.Errorf("Key was not found.")
}