Skip to content

Commit

Permalink
swarm/storage: add comparison towards leveldb.ErrNotFound (ethereum#1…
Browse files Browse the repository at this point in the history
…9243)

* swarm/storage: add comparison towards leveldb.ErrNotFound

* swarm/storage: wrap leveldb ErrNotFound
  • Loading branch information
nonsense authored and zelig committed Mar 8, 2019
1 parent 2cfe0be commit bb55b0f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion swarm/storage/ldbstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,10 @@ func (s *LDBStore) get(addr Address) (chunk Chunk, err error) {
if err != nil {
log.Trace("ldbstore.get chunk found but could not be accessed", "key", addr, "err", err)
s.deleteNow(index, getIndexKey(addr), s.po(addr))
return
if err == leveldb.ErrNotFound {
return nil, ErrChunkNotFound
}
return nil, err
}
}

Expand Down
4 changes: 3 additions & 1 deletion swarm/storage/netstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/ethereum/go-ethereum/swarm/spancontext"
"github.com/opentracing/opentracing-go"
olog "github.com/opentracing/opentracing-go/log"
"github.com/syndtr/goleveldb/leveldb"

lru "github.com/hashicorp/golang-lru"
)
Expand Down Expand Up @@ -167,7 +168,8 @@ func (n *NetStore) get(ctx context.Context, ref Address) (Chunk, func(context.Co

chunk, err := n.store.Get(ctx, ref)
if err != nil {
if err != ErrChunkNotFound {
// TODO: Fix comparison - we should be comparing against leveldb.ErrNotFound, this error should be wrapped.
if err != ErrChunkNotFound && err != leveldb.ErrNotFound {
log.Debug("Received error from LocalStore other than ErrNotFound", "err", err)
}
// The chunk is not available in the LocalStore, let's get the fetcher for it, or create a new one
Expand Down

0 comments on commit bb55b0f

Please sign in to comment.