Skip to content

Commit

Permalink
chore(shwap/bitswap): prevent not found error logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Wondertan committed Sep 19, 2024
1 parent 89e8781 commit e07728f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions share/shwap/p2p/bitswap/block_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ package bitswap

import (
"context"
"errors"
"fmt"

blocks "github.com/ipfs/go-block-format"
"github.com/ipfs/go-cid"
ipld "github.com/ipfs/go-ipld-format"

"github.com/celestiaorg/celestia-node/share/eds"
"github.com/celestiaorg/celestia-node/store"
)

// AccessorGetter abstracts storage system that indexes and manages multiple eds.AccessorGetter by
Expand All @@ -29,17 +32,20 @@ func (b *Blockstore) getBlock(ctx context.Context, cid cid.Cid) (blocks.Block, e
return nil, err
}

eds, err := b.Getter.GetByHeight(ctx, blk.Height())
acc, err := b.Getter.GetByHeight(ctx, blk.Height())
if errors.Is(err, store.ErrNotFound) {
return nil, ipld.ErrNotFound{Cid: cid}
}
if err != nil {
return nil, fmt.Errorf("getting EDS Accessor for height %v: %w", blk.Height(), err)
}
defer func() {
if err := eds.Close(); err != nil {
if err := acc.Close(); err != nil {
log.Warnf("failed to close EDS accessor for height %v: %s", blk.Height(), err)
}
}()

if err = blk.Populate(ctx, eds); err != nil {
if err = blk.Populate(ctx, acc); err != nil {
return nil, fmt.Errorf("failed to populate Shwap Block on height %v: %w", blk.Height(), err)
}

Expand Down

0 comments on commit e07728f

Please sign in to comment.