Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
hsanjuan committed Dec 9, 2024
1 parent 949b1ba commit f530462
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 392 deletions.
2 changes: 1 addition & 1 deletion bitswap/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func New(parent context.Context, network bsnet.BitSwapNetwork, providerFinder Pr
}
}
peerQueueFactory := func(ctx context.Context, p peer.ID) bspm.PeerQueue {
return bsmq.New(ctx, network.Self(), p, network, onDontHaveTimeout)
return bsmq.New(ctx, p, network, onDontHaveTimeout)
}

sim := bssim.New()
Expand Down
10 changes: 4 additions & 6 deletions bitswap/client/internal/messagequeue/messagequeue.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ type MessageNetwork interface {
NewMessageSender(context.Context, peer.ID, *bsnet.MessageSenderOpts) (bsnet.MessageSender, error)
Latency(peer.ID) time.Duration
Ping(context.Context, peer.ID) ping.Result
Self() peer.ID
}

// MessageQueue implements queue of want messages to send to peers.
type MessageQueue struct {
ctx context.Context
shutdown func()
p peer.ID
self peer.ID
network MessageNetwork
dhTimeoutMgr DontHaveTimeoutManager

Expand Down Expand Up @@ -231,14 +231,14 @@ type DontHaveTimeoutManager interface {
}

// New creates a new MessageQueue.
func New(ctx context.Context, self, p peer.ID, network MessageNetwork, onDontHaveTimeout OnDontHaveTimeout) *MessageQueue {
func New(ctx context.Context, p peer.ID, network MessageNetwork, onDontHaveTimeout OnDontHaveTimeout) *MessageQueue {
onTimeout := func(ks []cid.Cid) {
log.Infow("Bitswap: timeout waiting for blocks", "cids", ks, "peer", p)
onDontHaveTimeout(p, ks)
}
clock := clock.New()
dhTimeoutMgr := newDontHaveTimeoutMgr(newPeerConnection(p, network), onTimeout, clock)
return newMessageQueue(ctx, self, p, network, maxMessageSize, sendErrorBackoff, maxValidLatency, dhTimeoutMgr, clock, nil)
return newMessageQueue(ctx, p, network, maxMessageSize, sendErrorBackoff, maxValidLatency, dhTimeoutMgr, clock, nil)
}

type messageEvent int
Expand All @@ -252,7 +252,6 @@ const (
// This constructor is used by the tests
func newMessageQueue(
ctx context.Context,
self peer.ID,
p peer.ID,
network MessageNetwork,
maxMsgSize int,
Expand All @@ -266,7 +265,6 @@ func newMessageQueue(
return &MessageQueue{
ctx: ctx,
shutdown: cancel,
self: self,
p: p,
network: network,
dhTimeoutMgr: dhTimeoutMgr,
Expand Down Expand Up @@ -649,7 +647,7 @@ func (mq *MessageQueue) logOutgoingMessage(wantlist []bsmsg.Entry) {
return
}

self := mq.self
self := mq.network.Self()
for _, e := range wantlist {
if e.Cancel {
if e.WantType == pb.Message_Wantlist_Have {
Expand Down
217 changes: 0 additions & 217 deletions bitswap/network/httpnet/connecteventmanager.go

This file was deleted.

Loading

0 comments on commit f530462

Please sign in to comment.