From 036f14ff4971831ef4d8dc76e1685408dc3551f6 Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Fri, 10 May 2013 10:12:45 -0500 Subject: [PATCH] Convert MsgInv errors to new MessageError type. --- msginv.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/msginv.go b/msginv.go index 9cbb5bf1..8ec0c246 100644 --- a/msginv.go +++ b/msginv.go @@ -25,8 +25,9 @@ type MsgInv struct { // AddInvVect adds an inventory vector to the message. func (msg *MsgInv) AddInvVect(iv *InvVect) error { if len(msg.InvList)+1 > MaxInvPerMsg { - str := "MsgInv.AddAddress: too many invvect in message [max %v]" - return fmt.Errorf(str, MaxInvPerMsg) + str := fmt.Sprintf("too many invvect in message [max %v]", + MaxInvPerMsg) + return messageError("MsgInv.AddAddress", str) } msg.InvList = append(msg.InvList, iv) @@ -43,8 +44,8 @@ func (msg *MsgInv) BtcDecode(r io.Reader, pver uint32) error { // Limit to max inventory vectors per message. if count > MaxInvPerMsg { - str := "MsgInv.BtcDecode: too many invvect in message [%v]" - return fmt.Errorf(str, count) + str := fmt.Sprintf("too many invvect in message [%v]", count) + return messageError("MsgInv.BtcDecode", str) } for i := uint64(0); i < count; i++ { @@ -65,8 +66,8 @@ func (msg *MsgInv) BtcEncode(w io.Writer, pver uint32) error { // Limit to max inventory vectors per message. count := len(msg.InvList) if count > MaxInvPerMsg { - str := "MsgInv.BtcEncode: too many invvect in message [%v]" - return fmt.Errorf(str, count) + str := fmt.Sprintf("too many invvect in message [%v]", count) + return messageError("MsgInv.BtcDecode", str) } err := writeVarInt(w, pver, uint64(count))