diff --git a/message.go b/message.go index 7d4da72f..1e2b7d3d 100644 --- a/message.go +++ b/message.go @@ -26,27 +26,27 @@ const MaxMessagePayload = (1024 * 1024 * 32) // 32MB // Commands used in bitcoin message headers which describe the type of message. const ( - cmdVersion = "version" - cmdVerAck = "verack" - cmdGetAddr = "getaddr" - cmdAddr = "addr" - cmdGetBlocks = "getblocks" - cmdInv = "inv" - cmdGetData = "getdata" - cmdNotFound = "notfound" - cmdBlock = "block" - cmdTx = "tx" - cmdGetHeaders = "getheaders" - cmdHeaders = "headers" - cmdPing = "ping" - cmdPong = "pong" - cmdAlert = "alert" - cmdMemPool = "mempool" - cmdFilterAdd = "filteradd" - cmdFilterClear = "filterclear" - cmdFilterLoad = "filterload" - cmdMerkleBlock = "merkleblock" - cmdReject = "reject" + CmdVersion = "version" + CmdVerAck = "verack" + CmdGetAddr = "getaddr" + CmdAddr = "addr" + CmdGetBlocks = "getblocks" + CmdInv = "inv" + CmdGetData = "getdata" + CmdNotFound = "notfound" + CmdBlock = "block" + CmdTx = "tx" + CmdGetHeaders = "getheaders" + CmdHeaders = "headers" + CmdPing = "ping" + CmdPong = "pong" + CmdAlert = "alert" + CmdMemPool = "mempool" + CmdFilterAdd = "filteradd" + CmdFilterClear = "filterclear" + CmdFilterLoad = "filterload" + CmdMerkleBlock = "merkleblock" + CmdReject = "reject" ) // Message is an interface that describes a bitcoin message. A type that @@ -65,67 +65,67 @@ type Message interface { func makeEmptyMessage(command string) (Message, error) { var msg Message switch command { - case cmdVersion: + case CmdVersion: msg = &MsgVersion{} - case cmdVerAck: + case CmdVerAck: msg = &MsgVerAck{} - case cmdGetAddr: + case CmdGetAddr: msg = &MsgGetAddr{} - case cmdAddr: + case CmdAddr: msg = &MsgAddr{} - case cmdGetBlocks: + case CmdGetBlocks: msg = &MsgGetBlocks{} - case cmdBlock: + case CmdBlock: msg = &MsgBlock{} - case cmdInv: + case CmdInv: msg = &MsgInv{} - case cmdGetData: + case CmdGetData: msg = &MsgGetData{} - case cmdNotFound: + case CmdNotFound: msg = &MsgNotFound{} - case cmdTx: + case CmdTx: msg = &MsgTx{} - case cmdPing: + case CmdPing: msg = &MsgPing{} - case cmdPong: + case CmdPong: msg = &MsgPong{} - case cmdGetHeaders: + case CmdGetHeaders: msg = &MsgGetHeaders{} - case cmdHeaders: + case CmdHeaders: msg = &MsgHeaders{} - case cmdAlert: + case CmdAlert: msg = &MsgAlert{} - case cmdMemPool: + case CmdMemPool: msg = &MsgMemPool{} - case cmdFilterAdd: + case CmdFilterAdd: msg = &MsgFilterAdd{} - case cmdFilterClear: + case CmdFilterClear: msg = &MsgFilterClear{} - case cmdFilterLoad: + case CmdFilterLoad: msg = &MsgFilterLoad{} - case cmdMerkleBlock: + case CmdMerkleBlock: msg = &MsgMerkleBlock{} - case cmdReject: + case CmdReject: msg = &MsgReject{} default: diff --git a/msgaddr.go b/msgaddr.go index 678de22d..b1767620 100644 --- a/msgaddr.go +++ b/msgaddr.go @@ -118,7 +118,7 @@ func (msg *MsgAddr) BtcEncode(w io.Writer, pver uint32) error { // Command returns the protocol command string for the message. This is part // of the Message interface implementation. func (msg *MsgAddr) Command() string { - return cmdAddr + return CmdAddr } // MaxPayloadLength returns the maximum length the payload can be for the diff --git a/msgalert.go b/msgalert.go index 6b95fb49..4aa186a8 100644 --- a/msgalert.go +++ b/msgalert.go @@ -400,7 +400,7 @@ func (msg *MsgAlert) BtcEncode(w io.Writer, pver uint32) error { // Command returns the protocol command string for the message. This is part // of the Message interface implementation. func (msg *MsgAlert) Command() string { - return cmdAlert + return CmdAlert } // MaxPayloadLength returns the maximum length the payload can be for the diff --git a/msgblock.go b/msgblock.go index 60f46eb1..7d058923 100644 --- a/msgblock.go +++ b/msgblock.go @@ -211,7 +211,7 @@ func (msg *MsgBlock) SerializeSize() int { // Command returns the protocol command string for the message. This is part // of the Message interface implementation. func (msg *MsgBlock) Command() string { - return cmdBlock + return CmdBlock } // MaxPayloadLength returns the maximum length the payload can be for the diff --git a/msgfilteradd.go b/msgfilteradd.go index 4b19a62e..a04bdcc4 100644 --- a/msgfilteradd.go +++ b/msgfilteradd.go @@ -71,7 +71,7 @@ func (msg *MsgFilterAdd) BtcEncode(w io.Writer, pver uint32) error { // Command returns the protocol command string for the message. This is part // of the Message interface implementation. func (msg *MsgFilterAdd) Command() string { - return cmdFilterAdd + return CmdFilterAdd } // MaxPayloadLength returns the maximum length the payload can be for the diff --git a/msgfilterclear.go b/msgfilterclear.go index 5d736b6e..45580786 100644 --- a/msgfilterclear.go +++ b/msgfilterclear.go @@ -43,7 +43,7 @@ func (msg *MsgFilterClear) BtcEncode(w io.Writer, pver uint32) error { // Command returns the protocol command string for the message. This is part // of the Message interface implementation. func (msg *MsgFilterClear) Command() string { - return cmdFilterClear + return CmdFilterClear } // MaxPayloadLength returns the maximum length the payload can be for the diff --git a/msgfilterload.go b/msgfilterload.go index 35725f19..f0bdbe66 100644 --- a/msgfilterload.go +++ b/msgfilterload.go @@ -117,7 +117,7 @@ func (msg *MsgFilterLoad) BtcEncode(w io.Writer, pver uint32) error { // Command returns the protocol command string for the message. This is part // of the Message interface implementation. func (msg *MsgFilterLoad) Command() string { - return cmdFilterLoad + return CmdFilterLoad } // MaxPayloadLength returns the maximum length the payload can be for the diff --git a/msggetaddr.go b/msggetaddr.go index 78716806..6ccf767e 100644 --- a/msggetaddr.go +++ b/msggetaddr.go @@ -31,7 +31,7 @@ func (msg *MsgGetAddr) BtcEncode(w io.Writer, pver uint32) error { // Command returns the protocol command string for the message. This is part // of the Message interface implementation. func (msg *MsgGetAddr) Command() string { - return cmdGetAddr + return CmdGetAddr } // MaxPayloadLength returns the maximum length the payload can be for the diff --git a/msggetblocks.go b/msggetblocks.go index 45ec0d47..e8e5dcfe 100644 --- a/msggetblocks.go +++ b/msggetblocks.go @@ -121,7 +121,7 @@ func (msg *MsgGetBlocks) BtcEncode(w io.Writer, pver uint32) error { // Command returns the protocol command string for the message. This is part // of the Message interface implementation. func (msg *MsgGetBlocks) Command() string { - return cmdGetBlocks + return CmdGetBlocks } // MaxPayloadLength returns the maximum length the payload can be for the diff --git a/msggetdata.go b/msggetdata.go index 3add4782..63392eee 100644 --- a/msggetdata.go +++ b/msggetdata.go @@ -90,7 +90,7 @@ func (msg *MsgGetData) BtcEncode(w io.Writer, pver uint32) error { // Command returns the protocol command string for the message. This is part // of the Message interface implementation. func (msg *MsgGetData) Command() string { - return cmdGetData + return CmdGetData } // MaxPayloadLength returns the maximum length the payload can be for the diff --git a/msggetheaders.go b/msggetheaders.go index 607fba49..e407f4d9 100644 --- a/msggetheaders.go +++ b/msggetheaders.go @@ -119,7 +119,7 @@ func (msg *MsgGetHeaders) BtcEncode(w io.Writer, pver uint32) error { // Command returns the protocol command string for the message. This is part // of the Message interface implementation. func (msg *MsgGetHeaders) Command() string { - return cmdGetHeaders + return CmdGetHeaders } // MaxPayloadLength returns the maximum length the payload can be for the diff --git a/msgheaders.go b/msgheaders.go index b4a44426..c895b6a4 100644 --- a/msgheaders.go +++ b/msgheaders.go @@ -113,7 +113,7 @@ func (msg *MsgHeaders) BtcEncode(w io.Writer, pver uint32) error { // Command returns the protocol command string for the message. This is part // of the Message interface implementation. func (msg *MsgHeaders) Command() string { - return cmdHeaders + return CmdHeaders } // MaxPayloadLength returns the maximum length the payload can be for the diff --git a/msginv.go b/msginv.go index 55ca11ca..1cf9a261 100644 --- a/msginv.go +++ b/msginv.go @@ -98,7 +98,7 @@ func (msg *MsgInv) BtcEncode(w io.Writer, pver uint32) error { // Command returns the protocol command string for the message. This is part // of the Message interface implementation. func (msg *MsgInv) Command() string { - return cmdInv + return CmdInv } // MaxPayloadLength returns the maximum length the payload can be for the diff --git a/msgmempool.go b/msgmempool.go index cb4f5b75..376b8786 100644 --- a/msgmempool.go +++ b/msgmempool.go @@ -44,7 +44,7 @@ func (msg *MsgMemPool) BtcEncode(w io.Writer, pver uint32) error { // Command returns the protocol command string for the message. This is part // of the Message interface implementation. func (msg *MsgMemPool) Command() string { - return cmdMemPool + return CmdMemPool } // MaxPayloadLength returns the maximum length the payload can be for the diff --git a/msgmerkleblock.go b/msgmerkleblock.go index 18b579fb..b5f2ae36 100644 --- a/msgmerkleblock.go +++ b/msgmerkleblock.go @@ -146,7 +146,7 @@ func (msg *MsgMerkleBlock) BtcEncode(w io.Writer, pver uint32) error { // Command returns the protocol command string for the message. This is part // of the Message interface implementation. func (msg *MsgMerkleBlock) Command() string { - return cmdMerkleBlock + return CmdMerkleBlock } // MaxPayloadLength returns the maximum length the payload can be for the diff --git a/msgnotfound.go b/msgnotfound.go index fa439f55..3c18b77d 100644 --- a/msgnotfound.go +++ b/msgnotfound.go @@ -87,7 +87,7 @@ func (msg *MsgNotFound) BtcEncode(w io.Writer, pver uint32) error { // Command returns the protocol command string for the message. This is part // of the Message interface implementation. func (msg *MsgNotFound) Command() string { - return cmdNotFound + return CmdNotFound } // MaxPayloadLength returns the maximum length the payload can be for the diff --git a/msgping.go b/msgping.go index 7a7937aa..58e54f63 100644 --- a/msgping.go +++ b/msgping.go @@ -60,7 +60,7 @@ func (msg *MsgPing) BtcEncode(w io.Writer, pver uint32) error { // Command returns the protocol command string for the message. This is part // of the Message interface implementation. func (msg *MsgPing) Command() string { - return cmdPing + return CmdPing } // MaxPayloadLength returns the maximum length the payload can be for the diff --git a/msgpong.go b/msgpong.go index d8958031..9bd0431a 100644 --- a/msgpong.go +++ b/msgpong.go @@ -61,7 +61,7 @@ func (msg *MsgPong) BtcEncode(w io.Writer, pver uint32) error { // Command returns the protocol command string for the message. This is part // of the Message interface implementation. func (msg *MsgPong) Command() string { - return cmdPong + return CmdPong } // MaxPayloadLength returns the maximum length the payload can be for the diff --git a/msgreject.go b/msgreject.go index c8d33fff..84f21f95 100644 --- a/msgreject.go +++ b/msgreject.go @@ -52,7 +52,7 @@ func (code RejectCode) String() string { // This message was not added until protocol version RejectVersion. type MsgReject struct { // Cmd is the command for the message which was rejected such as - // as cmdBlock or cmdTx. This can be obtained from the Command function + // as CmdBlock or CmdTx. This can be obtained from the Command function // of a Message. Cmd string @@ -99,9 +99,9 @@ func (msg *MsgReject) BtcDecode(r io.Reader, pver uint32) error { } msg.Reason = reason - // cmdBlock and cmdTx messages have an additional hash field that + // CmdBlock and CmdTx messages have an additional hash field that // identifies the specific block or transaction. - if msg.Cmd == cmdBlock || msg.Cmd == cmdTx { + if msg.Cmd == CmdBlock || msg.Cmd == CmdTx { err := readElement(r, &msg.Hash) if err != nil { return err @@ -139,9 +139,9 @@ func (msg *MsgReject) BtcEncode(w io.Writer, pver uint32) error { return err } - // cmdBlock and cmdTx messages have an additional hash field that + // CmdBlock and CmdTx messages have an additional hash field that // identifies the specific block or transaction. - if msg.Cmd == cmdBlock || msg.Cmd == cmdTx { + if msg.Cmd == CmdBlock || msg.Cmd == CmdTx { err := writeElement(w, &msg.Hash) if err != nil { return err @@ -154,7 +154,7 @@ func (msg *MsgReject) BtcEncode(w io.Writer, pver uint32) error { // Command returns the protocol command string for the message. This is part // of the Message interface implementation. func (msg *MsgReject) Command() string { - return cmdReject + return CmdReject } // MaxPayloadLength returns the maximum length the payload can be for the diff --git a/msgtx.go b/msgtx.go index df2426c7..273bc8d1 100644 --- a/msgtx.go +++ b/msgtx.go @@ -405,7 +405,7 @@ func (msg *MsgTx) SerializeSize() int { // Command returns the protocol command string for the message. This is part // of the Message interface implementation. func (msg *MsgTx) Command() string { - return cmdTx + return CmdTx } // MaxPayloadLength returns the maximum length the payload can be for the diff --git a/msgverack.go b/msgverack.go index 94a27249..a6ccfa67 100644 --- a/msgverack.go +++ b/msgverack.go @@ -30,7 +30,7 @@ func (msg *MsgVerAck) BtcEncode(w io.Writer, pver uint32) error { // Command returns the protocol command string for the message. This is part // of the Message interface implementation. func (msg *MsgVerAck) Command() string { - return cmdVerAck + return CmdVerAck } // MaxPayloadLength returns the maximum length the payload can be for the diff --git a/msgversion.go b/msgversion.go index f4ca826a..daf6da9d 100644 --- a/msgversion.go +++ b/msgversion.go @@ -206,7 +206,7 @@ func (msg *MsgVersion) BtcEncode(w io.Writer, pver uint32) error { // Command returns the protocol command string for the message. This is part // of the Message interface implementation. func (msg *MsgVersion) Command() string { - return cmdVersion + return CmdVersion } // MaxPayloadLength returns the maximum length the payload can be for the