p2p: define DiscReason as uint8 (#164)

p2p: define DiscReason as uint8 (#24507)

All other implementations store disconnect reasons as a single byte,
so go-ethereum should do it too.

Co-authored-by: Felix Lange <fjl@twurst.com>
This commit is contained in:
iczc 2022-10-12 20:05:56 +08:00 committed by GitHub
parent 4ee7885525
commit b3a7c9b691
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View file

@ -324,11 +324,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()

View file

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