Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

memdb: use btree for storage #53

Merged
merged 9 commits into from
Mar 9, 2020
Prev Previous commit
Next Next commit
Minor tweaks
  • Loading branch information
erikgrinaker committed Mar 3, 2020
commit 5fe3042ffd0176cacda03faca306d9085a6c8567
5 changes: 2 additions & 3 deletions mem_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ var _ Iterator = (*memDBIterator)(nil)

func newMemDBIterator(bt *btree.BTree, start []byte, end []byte, reverse bool) *memDBIterator {
ctx, cancel := context.WithCancel(context.Background())
ch := make(chan *item)
ch := make(chan *item, 64)
erikgrinaker marked this conversation as resolved.
Show resolved Hide resolved
iter := &memDBIterator{
ch: ch,
cancel: cancel,
Expand Down Expand Up @@ -268,8 +268,6 @@ func newMemDBIterator(bt *btree.BTree, start []byte, end []byte, reverse bool) *
// prime the iterator with the first value, if any
if item, ok := <-ch; ok {
iter.item = item
} else {
iter.item = nil
}

return iter
Expand All @@ -280,6 +278,7 @@ func (i *memDBIterator) Close() {
i.cancel()
for range i.ch { // drain channel
}
i.item = nil
}

// Domain implements Iterator.
Expand Down