Skip to content

Commit b3a7c9b

Browse files
iczcfjl
andauthored
p2p: define DiscReason as uint8 (#164)
p2p: define DiscReason as uint8 (ethereum#24507) All other implementations store disconnect reasons as a single byte, so go-ethereum should do it too. Co-authored-by: Felix Lange <[email protected]>
1 parent 4ee7885 commit b3a7c9b

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
@@ -324,11 +324,11 @@ func (p *Peer) handle(msg Msg) error {
324324
msg.Discard()
325325
go SendItems(p.rw, pongMsg)
326326
case msg.Code == discMsg:
327-
var reason [1]DiscReason
328327
// This is the last message. We don't need to discard or
329328
// check errors because, the connection will be closed after it.
330-
rlp.Decode(msg.Payload, &reason)
331-
return reason[0]
329+
var m struct{ R DiscReason }
330+
rlp.Decode(msg.Payload, &m)
331+
return m.R
332332
case msg.Code < baseProtocolLength:
333333
// ignore other base protocol messages
334334
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)