Commit 75a367fc authored by Matthew Slipper's avatar Matthew Slipper Committed by GitHub

op-node: Noop RemovePeer when closing (#13091)

Sometimes, disconnection events happen after the sync client is closed. This can (among other things) lead to panics in tests due to logs occurring after the test has exited. This PR makes RemovePeer a noop when `s.closingPeers == true`, which is the same functionality as `AddPeer`.
parent 77d35a51
...@@ -346,6 +346,9 @@ func (s *SyncClient) AddPeer(id peer.ID) { ...@@ -346,6 +346,9 @@ func (s *SyncClient) AddPeer(id peer.ID) {
func (s *SyncClient) RemovePeer(id peer.ID) { func (s *SyncClient) RemovePeer(id peer.ID) {
s.peersLock.Lock() s.peersLock.Lock()
defer s.peersLock.Unlock() defer s.peersLock.Unlock()
if s.closingPeers {
return
}
cancel, ok := s.peers[id] cancel, ok := s.peers[id]
if !ok { if !ok {
s.log.Warn("cannot remove peer from sync duties, peer was not registered", "peer", id) s.log.Warn("cannot remove peer from sync duties, peer was not registered", "peer", id)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment