Merge pull request #2 from fjl/debug-decode

p2p: print message code alongside decoding errors
This commit is contained in:
Viktor Trón 2015-01-04 22:09:01 +00:00
commit 0bd94fcbed

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 {