Skip to content

Commit

Permalink
p2p: define DiscReason as uint8 (#4090)
Browse files Browse the repository at this point in the history
Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
  • Loading branch information
AlexeyAkhunov and Alexey Sharp authored May 6, 2022
1 parent ba987cf commit 6468403
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions p2p/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,11 +320,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 fmt.Errorf("peer has: %w", reason[0])
var m struct{ R DiscReason }
rlp.Decode(msg.Payload, &m)
return m.R
case msg.Code < baseProtocolLength:
// ignore other base protocol messages
msg.Discard()
Expand Down
2 changes: 1 addition & 1 deletion p2p/peer_error.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6468403

Please sign in to comment.