MCPcopy
hub / github.com/canopy-network/canopy / Error

Method Error

p2p/conn.go:321–336  ·  view source on GitHub ↗

Error() when an error occurs on the MultiConn execute a callback. Optionally pass a reputation delta to slash the peer

(err error, reputationDelta ...int32)

Source from the content-addressed store, hash-verified

319
320// Error() when an error occurs on the MultiConn execute a callback. Optionally pass a reputation delta to slash the peer
321func (c *MultiConn) Error(err error, reputationDelta ...int32) {
322 if len(reputationDelta) == 1 {
323 c.p2p.ChangeReputation(c.Address.PublicKey, reputationDelta[0])
324 }
325 // call onError() for the peer
326 c.error.Do(func() {
327 // mark the connection as failed under lock, but avoid holding the lock during teardown
328 unlock := lockWithTrace("p2p", &c.p2p.mux, c.p2p.log)
329 c.hasError.Store(true)
330 // run the callback after releasing the lock to prevent blocking other readers
331 c.onError(err, c.Address.PublicKey, c.conn.RemoteAddr().String(), c.uuid)
332 unlock()
333 // stop the multi-conn
334 c.Stop()
335 })
336}
337
338// waitForAndHandleWireBytes() a rate limited handler of inbound bytes from the wire.
339// Blocks until bytes are received converts bytes into a proto.Message using an Envelope

Callers 3

startReceiveServiceMethod · 0.95
startHeartbeatMethod · 0.95
sendWireBytesMethod · 0.95

Calls 6

StopMethod · 0.95
lockWithTraceFunction · 0.85
ChangeReputationMethod · 0.80
StoreMethod · 0.80
RemoteAddrMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected