From a016d3900ac99799d9508ac118806450653f2905 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Tue, 11 May 2021 17:36:34 -0700 Subject: [PATCH] remove unused haves parameter on Engine.ReceiveFrom --- bitswap.go | 12 ++++++------ internal/decision/engine.go | 6 +++--- internal/decision/engine_test.go | 7 +++---- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/bitswap.go b/bitswap.go index 0297c098..90ad9002 100644 --- a/bitswap.go +++ b/bitswap.go @@ -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" @@ -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") @@ -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 diff --git a/internal/decision/engine.go b/internal/decision/engine.go index 6e69ca65..cb7b2be3 100644 --- a/internal/decision/engine.go +++ b/internal/decision/engine.go @@ -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 @@ -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 } diff --git a/internal/decision/engine_test.go b/internal/decision/engine_test.go index 2cf9e773..7528cd15 100644 --- a/internal/decision/engine_test.go +++ b/internal/decision/engine_test.go @@ -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" @@ -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 @@ -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") @@ -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)