Convert MsgVersion errors to MessageError type.

This commit is contained in:
Dave Collins 2013-05-11 02:23:45 -05:00
parent f6cdbd430e
commit cbcbe5eb43

View file

@ -95,8 +95,9 @@ func (msg *MsgVersion) BtcDecode(r io.Reader, pver uint32) error {
return err return err
} }
if len(userAgent) > MaxUserAgentLen { if len(userAgent) > MaxUserAgentLen {
str := "MsgVersion.BtcDecode: user agent too long [max %v]" str := fmt.Sprintf("user agent too long [len %v, max %v]",
return fmt.Errorf(str, MaxUserAgentLen) len(userAgent), MaxUserAgentLen)
return messageError("MsgVersion.BtcDecode", str)
} }
msg.UserAgent = userAgent msg.UserAgent = userAgent
@ -112,8 +113,9 @@ func (msg *MsgVersion) BtcDecode(r io.Reader, pver uint32) error {
// This is part of the Message interface implementation. // This is part of the Message interface implementation.
func (msg *MsgVersion) BtcEncode(w io.Writer, pver uint32) error { func (msg *MsgVersion) BtcEncode(w io.Writer, pver uint32) error {
if len(msg.UserAgent) > MaxUserAgentLen { if len(msg.UserAgent) > MaxUserAgentLen {
str := "MsgVersion.BtcEncode: user agent too long [max %v]" str := fmt.Sprintf("user agent too long [len %v, max %v]",
return fmt.Errorf(str, MaxUserAgentLen) len(msg.UserAgent), MaxUserAgentLen)
return messageError("MsgVersion.BtcEncode", str)
} }
err := writeElements(w, msg.ProtocolVersion, msg.Services, err := writeElements(w, msg.ProtocolVersion, msg.Services,