Skip to content
This repository has been archived by the owner on Feb 1, 2023. It is now read-only.

Commit

Permalink
remove unused haves parameter on Engine.ReceiveFrom
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed May 12, 2021
1 parent 6ea1681 commit a016d39
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
12 changes: 6 additions & 6 deletions bitswap.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import (

deciface "github.com/ipfs/go-bitswap/decision"
bsbpm "github.com/ipfs/go-bitswap/internal/blockpresencemanager"
decision "github.com/ipfs/go-bitswap/internal/decision"
"github.com/ipfs/go-bitswap/internal/decision"
bsgetter "github.com/ipfs/go-bitswap/internal/getter"
bsmq "github.com/ipfs/go-bitswap/internal/messagequeue"
notifications "github.com/ipfs/go-bitswap/internal/notifications"
"github.com/ipfs/go-bitswap/internal/notifications"
bspm "github.com/ipfs/go-bitswap/internal/peermanager"
bspqm "github.com/ipfs/go-bitswap/internal/providerquerymanager"
bssession "github.com/ipfs/go-bitswap/internal/session"
Expand All @@ -27,14 +27,14 @@ import (
bsmsg "github.com/ipfs/go-bitswap/message"
bsnet "github.com/ipfs/go-bitswap/network"
blocks "github.com/ipfs/go-block-format"
cid "github.com/ipfs/go-cid"
"github.com/ipfs/go-cid"
blockstore "github.com/ipfs/go-ipfs-blockstore"
exchange "github.com/ipfs/go-ipfs-exchange-interface"
logging "github.com/ipfs/go-log"
metrics "github.com/ipfs/go-metrics-interface"
"github.com/ipfs/go-metrics-interface"
process "github.com/jbenet/goprocess"
procctx "github.com/jbenet/goprocess/context"
peer "github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-libp2p-core/peer"
)

var log = logging.Logger("bitswap")
Expand Down Expand Up @@ -402,7 +402,7 @@ func (bs *Bitswap) receiveBlocksFrom(ctx context.Context, from peer.ID, blks []b
bs.sm.ReceiveFrom(ctx, from, allKs, haves, dontHaves)

// Send wanted blocks to decision engine
bs.engine.ReceiveFrom(from, wanted, haves)
bs.engine.ReceiveFrom(from, wanted)

// Publish the block to any Bitswap clients that had requested blocks.
// (the sessions use this pubsub mechanism to inform clients of incoming
Expand Down
6 changes: 3 additions & 3 deletions internal/decision/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ import (
pb "github.com/ipfs/go-bitswap/message/pb"
wl "github.com/ipfs/go-bitswap/wantlist"
blocks "github.com/ipfs/go-block-format"
cid "github.com/ipfs/go-cid"
"github.com/ipfs/go-cid"
bstore "github.com/ipfs/go-ipfs-blockstore"
logging "github.com/ipfs/go-log"
"github.com/ipfs/go-peertaskqueue"
"github.com/ipfs/go-peertaskqueue/peertask"
process "github.com/jbenet/goprocess"
peer "github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-libp2p-core/peer"
)

// TODO consider taking responsibility for other types of requests. For
Expand Down Expand Up @@ -563,7 +563,7 @@ func (e *Engine) splitWantsCancels(es []bsmsg.Entry) ([]bsmsg.Entry, []bsmsg.Ent
// the blocks to them.
//
// This function also updates the receive side of the ledger.
func (e *Engine) ReceiveFrom(from peer.ID, blks []blocks.Block, haves []cid.Cid) {
func (e *Engine) ReceiveFrom(from peer.ID, blks []blocks.Block) {
if len(blks) == 0 {
return
}
Expand Down
7 changes: 3 additions & 4 deletions internal/decision/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
pb "github.com/ipfs/go-bitswap/message/pb"

blocks "github.com/ipfs/go-block-format"
cid "github.com/ipfs/go-cid"
ds "github.com/ipfs/go-datastore"
dssync "github.com/ipfs/go-datastore/sync"
blockstore "github.com/ipfs/go-ipfs-blockstore"
Expand Down Expand Up @@ -123,7 +122,7 @@ func TestConsistentAccounting(t *testing.T) {

sender.Engine.MessageSent(receiver.Peer, m)
receiver.Engine.MessageReceived(ctx, sender.Peer, m)
receiver.Engine.ReceiveFrom(sender.Peer, m.Blocks(), nil)
receiver.Engine.ReceiveFrom(sender.Peer, m.Blocks())
}

// Ensure sender records the change
Expand Down Expand Up @@ -899,7 +898,7 @@ func TestSendReceivedBlocksToPeersThatWantThem(t *testing.T) {
if err := bs.PutMany([]blocks.Block{blks[0], blks[2]}); err != nil {
t.Fatal(err)
}
e.ReceiveFrom(otherPeer, []blocks.Block{blks[0], blks[2]}, []cid.Cid{})
e.ReceiveFrom(otherPeer, []blocks.Block{blks[0], blks[2]})
_, env = getNextEnvelope(e, next, 5*time.Millisecond)
if env == nil {
t.Fatal("expected envelope")
Expand Down Expand Up @@ -962,7 +961,7 @@ func TestSendDontHave(t *testing.T) {
if err := bs.PutMany(blks); err != nil {
t.Fatal(err)
}
e.ReceiveFrom(otherPeer, blks, []cid.Cid{})
e.ReceiveFrom(otherPeer, blks)

// Envelope should contain 2 HAVEs / 2 blocks
_, env = getNextEnvelope(e, next, 10*time.Millisecond)
Expand Down

0 comments on commit a016d39

Please sign in to comment.