Unverified Commit 870b4505 authored by Felix Lange's avatar Felix Lange Committed by GitHub

p2p: define DiscReason as uint8 (#24507)

All other implementations store disconnect reasons as a single byte,
so go-ethereum should do it too.
parent a79afd9a
...@@ -332,11 +332,11 @@ func (p *Peer) handle(msg Msg) error { ...@@ -332,11 +332,11 @@ func (p *Peer) handle(msg Msg) error {
msg.Discard() msg.Discard()
go SendItems(p.rw, pongMsg) go SendItems(p.rw, pongMsg)
case msg.Code == discMsg: case msg.Code == discMsg:
var reason [1]DiscReason
// This is the last message. We don't need to discard or // This is the last message. We don't need to discard or
// check errors because, the connection will be closed after it. // check errors because, the connection will be closed after it.
rlp.Decode(msg.Payload, &reason) var m struct{ R DiscReason }
return reason[0] rlp.Decode(msg.Payload, &m)
return m.R
case msg.Code < baseProtocolLength: case msg.Code < baseProtocolLength:
// ignore other base protocol messages // ignore other base protocol messages
return msg.Discard() return msg.Discard()
......
...@@ -54,7 +54,7 @@ func (pe *peerError) Error() string { ...@@ -54,7 +54,7 @@ func (pe *peerError) Error() string {
var errProtocolReturned = errors.New("protocol returned") var errProtocolReturned = errors.New("protocol returned")
type DiscReason uint type DiscReason uint8
const ( const (
DiscRequested DiscReason = iota DiscRequested DiscReason = iota
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment