github.com/dashpay/godash@v0.0.0-20160726055534-e038a21e0e3d/wire/msgsendheaders.go (about) 1 // Copyright (c) 2016 The btcsuite developers 2 // Copyright (c) 2016 The Dash developers 3 // Use of this source code is governed by an ISC 4 // license that can be found in the LICENSE file. 5 6 package wire 7 8 import ( 9 "fmt" 10 "io" 11 ) 12 13 // MsgSendHeaders implements the Message interface and represents a bitcoin 14 // sendheaders message. It is used to request the peer send block headers 15 // rather than inventory vectors. 16 // 17 // This message has no payload and was not added until protocol versions 18 // starting with SendHeadersVersion. 19 type MsgSendHeaders struct{} 20 21 // BtcDecode decodes r using the bitcoin protocol encoding into the receiver. 22 // This is part of the Message interface implementation. 23 func (msg *MsgSendHeaders) BtcDecode(r io.Reader, pver uint32) error { 24 if pver < SendHeadersVersion { 25 str := fmt.Sprintf("sendheaders message invalid for protocol "+ 26 "version %d", pver) 27 return messageError("MsgSendHeaders.BtcDecode", str) 28 } 29 30 return nil 31 } 32 33 // BtcEncode encodes the receiver to w using the bitcoin protocol encoding. 34 // This is part of the Message interface implementation. 35 func (msg *MsgSendHeaders) BtcEncode(w io.Writer, pver uint32) error { 36 if pver < SendHeadersVersion { 37 str := fmt.Sprintf("sendheaders message invalid for protocol "+ 38 "version %d", pver) 39 return messageError("MsgSendHeaders.BtcEncode", str) 40 } 41 42 return nil 43 } 44 45 // Command returns the protocol command string for the message. This is part 46 // of the Message interface implementation. 47 func (msg *MsgSendHeaders) Command() string { 48 return CmdSendHeaders 49 } 50 51 // MaxPayloadLength returns the maximum length the payload can be for the 52 // receiver. This is part of the Message interface implementation. 53 func (msg *MsgSendHeaders) MaxPayloadLength(pver uint32) uint32 { 54 return 0 55 } 56 57 // NewMsgSendHeaders returns a new bitcoin sendheaders message that conforms to 58 // the Message interface. See MsgSendHeaders for details. 59 func NewMsgSendHeaders() *MsgSendHeaders { 60 return &MsgSendHeaders{} 61 }