mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 04:36:42 +00:00
Merge pull request #2 from fjl/debug-decode
p2p: print message code alongside decoding errors
This commit is contained in:
commit
0bd94fcbed
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