diff --git a/p2p/peer.go b/p2p/peer.go index 99d2bc28053..93222940e26 100644 --- a/p2p/peer.go +++ b/p2p/peer.go @@ -320,11 +320,11 @@ func (p *Peer) handle(msg Msg) error { msg.Discard() go SendItems(p.rw, pongMsg) case msg.Code == discMsg: - var reason [1]DiscReason // This is the last message. We don't need to discard or // check errors because, the connection will be closed after it. - _ = rlp.Decode(msg.Payload, &reason) - return fmt.Errorf("peer has: %w", reason[0]) + var m struct{ R DiscReason } + rlp.Decode(msg.Payload, &m) + return m.R case msg.Code < baseProtocolLength: // ignore other base protocol messages msg.Discard() diff --git a/p2p/peer_error.go b/p2p/peer_error.go index 393cc86b097..aad1a65c7ac 100644 --- a/p2p/peer_error.go +++ b/p2p/peer_error.go @@ -54,7 +54,7 @@ func (pe *peerError) Error() string { var errProtocolReturned = errors.New("protocol returned") -type DiscReason uint +type DiscReason uint8 const ( DiscRequested DiscReason = iota