Skip to content

Commit

Permalink
Merge pull request #4811 from filecoin-project/raulk/badger-ctx-tests
Browse files Browse the repository at this point in the history
badger blockstore: minor improvements
  • Loading branch information
Jakub Sztandera authored Nov 12, 2020
2 parents f4df58e + 72547f9 commit a389622
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/blockstore/badger/blockstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,11 @@ func (b *Blockstore) AllKeysChan(ctx context.Context) (<-chan cid.Cid, error) {
buf = make([]byte, reqlen)
}
if n, err := base32.RawStdEncoding.Decode(buf, k); err == nil {
ch <- cid.NewCidV1(cid.Raw, buf[:n])
select {
case ch <- cid.NewCidV1(cid.Raw, buf[:n]):
case <-ctx.Done():
return
}
} else {
log.Warnf("failed to decode key %s in badger AllKeysChan; err: %s", k, err)
}
Expand Down
3 changes: 3 additions & 0 deletions lib/blockstore/badger/blockstore_test_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ func (s *Suite) TestReopenPutGet(t *testing.T) {
fetched, err := bs.Get(orig.Cid())
require.NoError(t, err)
require.Equal(t, orig.RawData(), fetched.RawData())

err = bs.(io.Closer).Close()
require.NoError(t, err)
}

func (s *Suite) TestPutMany(t *testing.T) {
Expand Down

0 comments on commit a389622

Please sign in to comment.