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

refactor(share/bitswap): remove feature flag for bitswap fix #3703

Merged
merged 3 commits into from
Aug 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 5 additions & 29 deletions share/eds/blockstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"errors"
"fmt"
"os"

bstore "github.com/ipfs/boxo/blockstore"
"github.com/ipfs/boxo/datastore/dshelp"
Expand All @@ -17,8 +16,6 @@ import (
share_ipld "github.com/celestiaorg/celestia-node/share/ipld"
)

var enableFixedDataSize = os.Getenv("CELESTIA_CONST_DATA_SIZE") == "1"

var _ bstore.Blockstore = (*blockstore)(nil)

var (
Expand Down Expand Up @@ -84,32 +81,11 @@ func (bs *blockstore) Get(ctx context.Context, cid cid.Cid) (blocks.Block, error
return nil, err
}

func (bs *blockstore) GetSize(ctx context.Context, cid cid.Cid) (int, error) {
if enableFixedDataSize {
// For now we return a fixed result, which is a max of possible values (see above).
// Motivation behind such behavior is described here:
// https://github.com/celestiaorg/celestia-node/issues/3630
return share_ipld.LeafNodeSize, nil
}

blockstr, err := bs.getReadOnlyBlockstore(ctx, cid)
if err == nil {
defer closeAndLog("blockstore", blockstr)
return blockstr.GetSize(ctx, cid)
}

if errors.Is(err, ErrNotFound) || errors.Is(err, ErrNotFoundInIndex) {
k := dshelp.MultihashToDsKey(cid.Hash())
size, err := bs.ds.GetSize(ctx, k)
if err == nil {
return size, nil
}
// nmt's GetSize expects an ipld.ErrNotFound when a cid is not found.
return 0, ipld.ErrNotFound{Cid: cid}
}

log.Debugf("failed to get size for cid %s: %s", cid, err)
return 0, err
func (bs *blockstore) GetSize(context.Context, cid.Cid) (int, error) {
// For now we return a fixed result, which is a max of possible values (see above).
// Motivation behind such behavior is described here:
// https://github.com/celestiaorg/celestia-node/issues/3630
return share_ipld.LeafNodeSize, nil
}

func (bs *blockstore) DeleteBlock(ctx context.Context, cid cid.Cid) error {
Expand Down
Loading