Error() when an error occurs on the MultiConn execute a callback. Optionally pass a reputation delta to slash the peer
(err error, reputationDelta ...int32)
| 319 | |
| 320 | // Error() when an error occurs on the MultiConn execute a callback. Optionally pass a reputation delta to slash the peer |
| 321 | func (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 |
no test coverage detected