p2p: define DiscReason as uint8 (#24507)

All other implementations store disconnect reasons as a single byte,
so go-ethereum should do it too.
pull/24515/head
Felix Lange 3 years ago committed by GitHub
parent a79afd9ac3
commit 870b4505a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      p2p/peer.go
  2. 2
      p2p/peer_error.go

@ -332,11 +332,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 reason[0]
var m struct{ R DiscReason }
rlp.Decode(msg.Payload, &m)
return m.R
case msg.Code < baseProtocolLength:
// ignore other base protocol messages
return msg.Discard()

@ -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

Loading…
Cancel
Save