MCPcopy Create free account
hub / github.com/ethstorage/es-node / RemovePeer

Method RemovePeer

ethstorage/p2p/protocol/syncclient.go:544–561  ·  view source on GitHub ↗
(id peer.ID)

Source from the content-addressed store, hash-verified

542}
543
544func (s *SyncClient) RemovePeer(id peer.ID) bool {
545 s.lock.Lock()
546 defer s.lock.Unlock()
547 pr, ok := s.peers[id]
548 if !ok {
549 s.lg.Debug("Cannot remove peer from sync duties, peer was not registered", "peer", id)
550 return false
551 }
552 pr.resCancel() // once loop exits
553 delete(s.peers, id)
554 s.removePeerFromTask(pr.shards)
555 s.metrics.DecPeerCount()
556 delete(s.idlerPeers, id)
557 for _, t := range s.tasks {
558 delete(t.statelessPeers, id)
559 }
560 return true
561}
562
563// Close will shut down the sync client and all attached work, and block until shutdown is complete.
564// This will block if the Start() has not created the main background loop.

Callers 2

initMethod · 0.80

Calls 2

removePeerFromTaskMethod · 0.95
DecPeerCountMethod · 0.65

Tested by 1