p2p: Stop peers gracefully when stopping switch#3729
p2p: Stop peers gracefully when stopping switch#3729melekes merged 2 commits intotendermint:developfrom
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #3729 +/- ##
===========================================
+ Coverage 63.93% 63.98% +0.05%
===========================================
Files 241 241
Lines 19856 19985 +129
===========================================
+ Hits 12694 12787 +93
- Misses 6125 6156 +31
- Partials 1037 1042 +5
|
melekes
left a comment
There was a problem hiding this comment.
👍
Although I am not sure this PR actually changes anything except removing duplicated code. I think we already do "gracefully disconnect from peers", so the TODO can be removed.
p2p/switch.go
Outdated
| sw.metrics.Peers.Add(float64(-1)) | ||
| } | ||
| sw.StopPeerGracefully(p) | ||
| sw.metrics.Peers.Add(float64(-1)) |
There was a problem hiding this comment.
StopPeerGracefully already decrements this counter
p2p/switch.go
Outdated
| if sw.peers.Remove(p) { | ||
| sw.metrics.Peers.Add(float64(-1)) | ||
| } | ||
| sw.StopPeerGracefully(p) |
There was a problem hiding this comment.
I think it's better to call sw.stopAndRemovePeer(peer, nil) to avoid excessive logging
Yeah, it seems that the original code works. |
This PR fixed
TODO: gracefully disconnect from peers.inp2p/switch.go.