1 // Copyright (c) 2016 The btcsuite developers
2 // Use of this source code is governed by an ISC
3 // license that can be found in the LICENSE file.
12 // MsgSendHeaders implements the Message interface and represents a bitcoin
13 // sendheaders message. It is used to request the peer send block headers
14 // rather than inventory vectors.
16 // This message has no payload and was not added until protocol versions
17 // starting with SendHeadersVersion.
18 type MsgSendHeaders struct{}
20 // BtcDecode decodes r using the bitcoin protocol encoding into the receiver.
21 // This is part of the Message interface implementation.
22 func (msg *MsgSendHeaders) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error {
23 if pver < SendHeadersVersion {
24 str := fmt.Sprintf("sendheaders message invalid for protocol "+
26 return messageError("MsgSendHeaders.BtcDecode", str)
32 // BtcEncode encodes the receiver to w using the bitcoin protocol encoding.
33 // This is part of the Message interface implementation.
34 func (msg *MsgSendHeaders) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error {
35 if pver < SendHeadersVersion {
36 str := fmt.Sprintf("sendheaders message invalid for protocol "+
38 return messageError("MsgSendHeaders.BtcEncode", str)
44 // Command returns the protocol command string for the message. This is part
45 // of the Message interface implementation.
46 func (msg *MsgSendHeaders) Command() string {
50 // MaxPayloadLength returns the maximum length the payload can be for the
51 // receiver. This is part of the Message interface implementation.
52 func (msg *MsgSendHeaders) MaxPayloadLength(pver uint32) uint32 {
56 // NewMsgSendHeaders returns a new bitcoin sendheaders message that conforms to
57 // the Message interface. See MsgSendHeaders for details.
58 func NewMsgSendHeaders() *MsgSendHeaders {
59 return &MsgSendHeaders{}