Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove peer's count of first responses when peer becomes unavailable #757

Merged
merged 2 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions bitswap/client/internal/session/peerresponsetracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,7 @@ func (prt *peerResponseTracker) getPeerCount(p peer.ID) int {
// will be chosen
return prt.firstResponder[p] + 1
}

func (prt *peerResponseTracker) remove(p peer.ID) {
delete(prt.firstResponder, p)
}
5 changes: 3 additions & 2 deletions bitswap/client/internal/session/sessionwantsender.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,14 +321,15 @@ func (sws *sessionWantSender) processAvailability(availability map[peer.ID]bool)
if wasAvailable {
stateChange = true
newlyUnavailable = append(newlyUnavailable, p)
// Remove count of first responses from peer.
sws.peerRspTrkr.remove(p)
}
}

// If the state has changed
if stateChange {
sws.updateWantsPeerAvailability(p, isNowAvailable)
// Reset the count of consecutive DONT_HAVEs received from the
// peer
// Reset count of consecutive DONT_HAVEs received from the peer.
delete(sws.peerConsecutiveDontHaves, p)
}
}
Expand Down
Loading