mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 12:46:44 +00:00
p2p: print message code alongside decoding errors
This commit is contained in:
parent
51d7ab7924
commit
68335e8aac
1 changed files with 4 additions and 1 deletions
|
|
@ -50,7 +50,10 @@ func encodePayload(params ...interface{}) []byte {
|
||||||
// For the decoding rules, please see package rlp.
|
// For the decoding rules, please see package rlp.
|
||||||
func (msg Msg) Decode(val interface{}) error {
|
func (msg Msg) Decode(val interface{}) error {
|
||||||
s := rlp.NewListStream(msg.Payload, uint64(msg.Size))
|
s := rlp.NewListStream(msg.Payload, uint64(msg.Size))
|
||||||
return s.Decode(val)
|
if err := s.Decode(val); err != nil {
|
||||||
|
return newPeerError(errInvalidMsg, "(code %#x) (size %d) %v", msg.Code, msg.Size, err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (msg Msg) String() string {
|
func (msg Msg) String() string {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue