Skip to content

Commit bb55b0f

Browse files
nonsensezelig
authored andcommitted
swarm/storage: add comparison towards leveldb.ErrNotFound (#19243)
* swarm/storage: add comparison towards leveldb.ErrNotFound * swarm/storage: wrap leveldb ErrNotFound
1 parent 2cfe0be commit bb55b0f

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

‎swarm/storage/ldbstore.go‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1005,7 +1005,10 @@ func (s *LDBStore) get(addr Address) (chunk Chunk, err error) {
10051005
if err != nil {
10061006
log.Trace("ldbstore.get chunk found but could not be accessed", "key", addr, "err", err)
10071007
s.deleteNow(index, getIndexKey(addr), s.po(addr))
1008-
return
1008+
if err == leveldb.ErrNotFound {
1009+
return nil, ErrChunkNotFound
1010+
}
1011+
return nil, err
10091012
}
10101013
}
10111014

‎swarm/storage/netstore.go‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
"github.com/ethereum/go-ethereum/swarm/spancontext"
3030
"github.com/opentracing/opentracing-go"
3131
olog "github.com/opentracing/opentracing-go/log"
32+
"github.com/syndtr/goleveldb/leveldb"
3233

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

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

0 commit comments

Comments
 (0)