Skip to content

Commit

Permalink
refactor: noNotifyExchange
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias committed Apr 26, 2024
1 parent b2d4cd2 commit a1a3e54
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ import (
bsserver "github.com/ipfs/boxo/bitswap/server"
"github.com/ipfs/boxo/blockservice"
"github.com/ipfs/boxo/blockstore"
"github.com/ipfs/boxo/exchange"
bsfetcher "github.com/ipfs/boxo/fetcher/impl/blockservice"
"github.com/ipfs/boxo/gateway"
"github.com/ipfs/boxo/namesys"
"github.com/ipfs/boxo/path/resolver"
"github.com/ipfs/boxo/peering"
blocks "github.com/ipfs/go-block-format"
"github.com/ipfs/go-cid"
"github.com/ipfs/go-datastore"
badger4 "github.com/ipfs/go-ds-badger4"
Expand Down Expand Up @@ -231,7 +233,7 @@ func Setup(ctx context.Context, cfg Config, key crypto.PrivKey, dnsCache *cached
return nil, err
}

bsrv := blockservice.New(blkst, bswap,
bsrv := blockservice.New(blkst, &noNotifyExchange{bswap},
// if we are doing things right, our bitswap wantlists should
// not have blocks that we already have (see
// https://github.com/ipfs/boxo/blob/e0d4b3e9b91e9904066a10278e366c9a6d9645c7/blockservice/blockservice.go#L272). Thus
Expand Down Expand Up @@ -474,3 +476,12 @@ func (*noopPeerLedger) WantlistForPeer(p peer.ID) []wl.Entry {
func (*noopPeerLedger) ClearPeerWantlist(p peer.ID) {}

Check warning on line 476 in setup.go

View check run for this annotation

Codecov / codecov/patch

setup.go#L476

Added line #L476 was not covered by tests

func (*noopPeerLedger) PeerDisconnected(p peer.ID) {}

Check warning on line 478 in setup.go

View check run for this annotation

Codecov / codecov/patch

setup.go#L478

Added line #L478 was not covered by tests

type noNotifyExchange struct {
exchange.Interface
}

func (e *noNotifyExchange) NotifyNewBlocks(ctx context.Context, blocks ...blocks.Block) error {
// Rainbow does not notify when we get new blocks in our Blockservice.
return nil
}

0 comments on commit a1a3e54

Please sign in to comment.