Cleanup some todos

This commit is contained in:
Ethan Frey
2017-08-03 17:37:15 +02:00
parent cdaee322bc
commit 0b9be1069f
5 changed files with 29 additions and 6 deletions
+11 -2
View File
@@ -11,8 +11,8 @@ type nonce int64
// Bonsai is a deformed tree forced to fit in a small pot
type Bonsai struct {
id nonce
merkle.Tree
id nonce
Tree merkle.Tree
}
var _ SimpleDB = &Bonsai{}
@@ -31,6 +31,11 @@ func (b *Bonsai) Get(key []byte) []byte {
return value
}
// Get matches the signature of KVStore
func (b *Bonsai) Has(key []byte) bool {
return b.Tree.Has(key)
}
// Set matches the signature of KVStore
func (b *Bonsai) Set(key, value []byte) {
b.Tree.Set(key, value)
@@ -41,6 +46,10 @@ func (b *Bonsai) Remove(key []byte) (value []byte) {
return
}
func (b *Bonsai) Proof(key []byte) (value []byte, proof []byte, exists bool) {
return b.Tree.Proof(key)
}
func (b *Bonsai) List(start, end []byte, limit int) []Model {
res := []Model{}
stopAtCount := func(key []byte, value []byte) (stop bool) {
+6 -1
View File
@@ -117,7 +117,12 @@ func (c *MemKVCache) Commit(sub SimpleDB) error {
if !ok {
return ErrNotASubTransaction()
}
// TODO: see if it points to us
// see if it points to us
ref, ok := cache.store.(*MemKVCache)
if !ok || ref != c {
return ErrNotASubTransaction()
}
// apply the cached data to us
cache.applyCache()
+6 -1
View File
@@ -149,7 +149,12 @@ func (m *MemKVStore) Commit(sub SimpleDB) error {
if !ok {
return ErrNotASubTransaction()
}
// TODO: see if it points to us
// see if it points to us
ref, ok := cache.store.(*MemKVStore)
if !ok || ref != m {
return ErrNotASubTransaction()
}
// apply the cached data to us
cache.applyCache()
+4
View File
@@ -24,6 +24,10 @@ func NewState(tree merkle.Tree, persistent bool) State {
}
}
func (s State) Size() int {
return s.committed.Tree.Size()
}
func (s State) Committed() *Bonsai {
return s.committed
}