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.

23 lines
751 B

  1. package merkle
  2. type Tree interface {
  3. Size() (size int)
  4. Height() (height int8)
  5. Has(key []byte) (has bool)
  6. Proof(key []byte) (value []byte, proof []byte, exists bool) // TODO make it return an index
  7. Get(key []byte) (index int, value []byte, exists bool)
  8. GetByIndex(index int) (key []byte, value []byte)
  9. Set(key []byte, value []byte) (updated bool)
  10. Remove(key []byte) (value []byte, removed bool)
  11. HashWithCount() (hash []byte, count int)
  12. Hash() (hash []byte)
  13. Save() (hash []byte)
  14. Load(hash []byte)
  15. Copy() Tree
  16. Iterate(func(key []byte, value []byte) (stop bool)) (stopped bool)
  17. IterateRange(start []byte, end []byte, ascending bool, fx func(key []byte, value []byte) (stop bool)) (stopped bool)
  18. }
  19. type Hasher interface {
  20. Hash() []byte
  21. }