2014-05-19 20:46:41 -07:00
|
|
|
package merkle
|
|
|
|
|
|
|
|
import (
|
2014-07-01 14:50:24 -07:00
|
|
|
"fmt"
|
2014-05-19 20:46:41 -07:00
|
|
|
)
|
|
|
|
|
2014-10-05 21:21:34 -07:00
|
|
|
type DB interface {
|
2014-07-01 14:50:24 -07:00
|
|
|
Get([]byte) []byte
|
2014-07-19 15:19:07 -07:00
|
|
|
Set([]byte, []byte)
|
2014-05-23 17:49:28 -07:00
|
|
|
}
|
|
|
|
|
2014-05-23 23:11:22 -07:00
|
|
|
type Tree interface {
|
2014-07-01 14:50:24 -07:00
|
|
|
Size() uint64
|
|
|
|
Height() uint8
|
2014-09-03 19:21:19 -07:00
|
|
|
Has(key []byte) bool
|
|
|
|
Get(key []byte) []byte
|
|
|
|
HashWithCount() ([]byte, uint64)
|
|
|
|
Hash() []byte
|
2014-07-01 14:50:24 -07:00
|
|
|
Save()
|
2014-08-10 16:35:08 -07:00
|
|
|
SaveKey(string)
|
2014-09-03 19:21:19 -07:00
|
|
|
Set(key []byte, vlaue []byte) bool
|
|
|
|
Remove(key []byte) ([]byte, error)
|
2014-07-01 14:50:24 -07:00
|
|
|
Copy() Tree
|
2014-05-23 23:11:22 -07:00
|
|
|
}
|
2014-05-19 20:46:41 -07:00
|
|
|
|
2014-09-03 19:21:19 -07:00
|
|
|
func NotFound(key []byte) error {
|
2014-07-01 14:50:24 -07:00
|
|
|
return fmt.Errorf("Key was not found.")
|
2014-05-19 20:46:41 -07:00
|
|
|
}
|
2014-09-14 15:37:32 -07:00
|
|
|
|
|
|
|
type Hashable interface {
|
|
|
|
Hash() []byte
|
|
|
|
}
|