Skip to content

Commit 224686a

Browse files
fjlJacek Glen
authored andcommitted
p2p: define DiscReason as uint8 (ethereum#24507)
All other implementations store disconnect reasons as a single byte, so go-ethereum should do it too.
1 parent 113fa1a commit 224686a

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

p2p/peer.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -332,11 +332,11 @@ func (p *Peer) handle(msg Msg) error {
332332
msg.Discard()
333333
go SendItems(p.rw, pongMsg)
334334
case msg.Code == discMsg:
335-
var reason [1]DiscReason
336335
// This is the last message. We don't need to discard or
337336
// check errors because, the connection will be closed after it.
338-
rlp.Decode(msg.Payload, &reason)
339-
return reason[0]
337+
var m struct{ R DiscReason }
338+
rlp.Decode(msg.Payload, &m)
339+
return m.R
340340
case msg.Code < baseProtocolLength:
341341
// ignore other base protocol messages
342342
return msg.Discard()

p2p/peer_error.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func (pe *peerError) Error() string {
5454

5555
var errProtocolReturned = errors.New("protocol returned")
5656

57-
type DiscReason uint
57+
type DiscReason uint8
5858

5959
const (
6060
DiscRequested DiscReason = iota

0 commit comments

Comments
 (0)