diff --git a/common.go b/common.go index 1cacfdd8..dd6b61bd 100644 --- a/common.go +++ b/common.go @@ -83,7 +83,7 @@ func readElement(r io.Reader, element interface{}) error { return nil // Message header command. - case *[commandSize]uint8: + case *[CommandSize]uint8: _, err := io.ReadFull(r, e[:]) if err != nil { return err @@ -233,7 +233,7 @@ func writeElement(w io.Writer, element interface{}) error { return nil // Message header command. - case [commandSize]uint8: + case [CommandSize]uint8: _, err := w.Write(e[:]) if err != nil { return err diff --git a/internal_test.go b/internal_test.go index 6f332712..5663e05f 100644 --- a/internal_test.go +++ b/internal_test.go @@ -31,10 +31,6 @@ const ( // MaxCountSetSubVer makes the internal maxCountSetSubVer constant // available to the test package. MaxCountSetSubVer = maxCountSetSubVer - - // CommandSize makes the internal commandSize constant available to the - // test package. - CommandSize = commandSize ) // TstRandomUint64 makes the internal randomUint64 function available to the diff --git a/message.go b/message.go index d5b51ea0..7d4da72f 100644 --- a/message.go +++ b/message.go @@ -16,9 +16,9 @@ import ( // checksum 4 bytes. const MessageHeaderSize = 24 -// commandSize is the fixed size of all commands in the common bitcoin message +// CommandSize is the fixed size of all commands in the common bitcoin message // header. Shorter commands must be zero padded. -const commandSize = 12 +const CommandSize = 12 // MaxMessagePayload is the maximum bytes a message can be regardless of other // individual limits imposed by messages themselves. @@ -157,7 +157,7 @@ func readMessageHeader(r io.Reader) (int, *messageHeader, error) { // Create and populate a messageHeader struct from the raw header bytes. hdr := messageHeader{} - var command [commandSize]byte + var command [CommandSize]byte readElements(hr, &hdr.magic, &command, &hdr.length, &hdr.checksum) // Strip trailing zeros from command string. @@ -193,11 +193,11 @@ func WriteMessageN(w io.Writer, msg Message, pver uint32, btcnet BitcoinNet) (in totalBytes := 0 // Enforce max command size. - var command [commandSize]byte + var command [CommandSize]byte cmd := msg.Command() - if len(cmd) > commandSize { + if len(cmd) > CommandSize { str := fmt.Sprintf("command [%s] is too long [max %v]", - cmd, commandSize) + cmd, CommandSize) return totalBytes, messageError("WriteMessage", str) } copy(command[:], []byte(cmd))