You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
711 B

10 years ago
11 years ago
10 years ago
11 years ago
10 years ago
11 years ago
10 years ago
11 years ago
10 years ago
10 years ago
11 years ago
10 years ago
  1. package merkle
  2. import (
  3. "fmt"
  4. . "github.com/tendermint/tendermint/binary"
  5. )
  6. type Value interface {
  7. Binary
  8. }
  9. type Key interface {
  10. Binary
  11. Equals(Binary) bool
  12. Less(b Binary) bool
  13. }
  14. type Db interface {
  15. Get([]byte) []byte
  16. Put([]byte, []byte)
  17. }
  18. type Node interface {
  19. Binary
  20. Key() Key
  21. Value() Value
  22. Size() uint64
  23. Height() uint8
  24. Hash() (ByteSlice, uint64)
  25. Save(Db)
  26. }
  27. type Tree interface {
  28. Root() Node
  29. Size() uint64
  30. Height() uint8
  31. Has(key Key) bool
  32. Get(key Key) Value
  33. Hash() (ByteSlice, uint64)
  34. Save()
  35. Put(Key, Value) bool
  36. Remove(Key) (Value, error)
  37. Copy() Tree
  38. Traverse(func(Node) bool)
  39. Values() <-chan Value
  40. }
  41. func NotFound(key Key) error {
  42. return fmt.Errorf("Key was not found.")
  43. }