MCPcopy Create free account
hub / github.com/CPChain/chain / removePeer

Method removePeer

protocols/cpc/handler.go:160–176  ·  view source on GitHub ↗
(id string)

Source from the content-addressed store, hash-verified

158}
159
160func (pm *ProtocolManager) removePeer(id string) {
161 // Short circuit if the peer was already removed
162 peer := pm.peers.Peer(id)
163 if peer == nil {
164 return
165 }
166 log.Debug("Removing cpchain peer", "peer", id)
167
168 if err := pm.peers.Unregister(id); err != nil {
169 log.Error("Peer removal failed", "peer", id, "err", err)
170 }
171 // Hard disconnect at the networking layer
172 if peer != nil {
173 peer.Peer.Disconnect(p2p.DiscUselessPeer)
174 }
175 pm.syncer.RemovePeer(peer.IDString())
176}
177
178// Start starts all the blockchain synchronization mechanisms
179func (pm *ProtocolManager) Start(maxPeers int) {

Callers 1

handlePeerMethod · 0.95

Calls 6

PeerMethod · 0.80
DebugMethod · 0.80
ErrorMethod · 0.65
RemovePeerMethod · 0.65
IDStringMethod · 0.65
UnregisterMethod · 0.45

Tested by

no test coverage detected