Skip to content

Commit

Permalink
Merge pull request ipfs/go-bitswap#275 from ipfs/refactor/session-peers
Browse files Browse the repository at this point in the history
Refactor: simplify session peer management

This commit was moved from ipfs/go-bitswap@981dfb1
  • Loading branch information
Stebalien authored Mar 6, 2020
2 parents e8cd6cc + 09ec5df commit 7a62158
Show file tree
Hide file tree
Showing 14 changed files with 606 additions and 1,258 deletions.
4 changes: 2 additions & 2 deletions bitswap/bitswap.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,10 @@ func New(parent context.Context, network bsnet.BitSwapNetwork,
provSearchDelay time.Duration,
rebroadcastDelay delay.D,
self peer.ID) bssm.Session {
return bssession.New(ctx, id, wm, spm, sim, pm, bpm, notif, provSearchDelay, rebroadcastDelay, self)
return bssession.New(ctx, id, wm, spm, pqm, sim, pm, bpm, notif, provSearchDelay, rebroadcastDelay, self)
}
sessionPeerManagerFactory := func(ctx context.Context, id uint64) bssession.SessionPeerManager {
return bsspm.New(ctx, id, network.ConnectionManager(), pqm)
return bsspm.New(id, network.ConnectionManager())
}
notif := notifications.New()
sm := bssm.New(ctx, sessionFactory, sim, sessionPeerManagerFactory, bpm, pm, notif, network.Self())
Expand Down
12 changes: 6 additions & 6 deletions bitswap/internal/messagequeue/messagequeue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,9 @@ func TestWantlistRebroadcast(t *testing.T) {
t.Fatal("wrong number of wants")
}

// Tell message queue to rebroadcast after 5ms, then wait 8ms
messageQueue.SetRebroadcastInterval(5 * time.Millisecond)
messages = collectMessages(ctx, t, messagesSent, 8*time.Millisecond)
// Tell message queue to rebroadcast after 10ms, then wait 15ms
messageQueue.SetRebroadcastInterval(10 * time.Millisecond)
messages = collectMessages(ctx, t, messagesSent, 15*time.Millisecond)
firstMessage = messages[0]

// Both original and new wants should have been rebroadcast
Expand Down Expand Up @@ -425,9 +425,9 @@ func TestWantlistRebroadcast(t *testing.T) {
}
}

// Tell message queue to rebroadcast after 5ms, then wait 8ms
messageQueue.SetRebroadcastInterval(5 * time.Millisecond)
messages = collectMessages(ctx, t, messagesSent, 8*time.Millisecond)
// Tell message queue to rebroadcast after 10ms, then wait 15ms
messageQueue.SetRebroadcastInterval(10 * time.Millisecond)
messages = collectMessages(ctx, t, messagesSent, 15*time.Millisecond)
firstMessage = messages[0]
if len(firstMessage.Wantlist()) != totalWants-len(cancels) {
t.Fatal("did not rebroadcast all wants")
Expand Down
57 changes: 0 additions & 57 deletions bitswap/internal/session/peeravailabilitymanager.go

This file was deleted.

74 changes: 0 additions & 74 deletions bitswap/internal/session/peeravailabilitymanager_test.go

This file was deleted.

Loading

0 comments on commit 7a62158

Please sign in to comment.