p2p: print message code alongside decoding errors

This commit is contained in:
Felix Lange 2015-01-04 22:55:50 +01:00
parent 51d7ab7924
commit 68335e8aac

View file

@ -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 {