msgsendheaders.go raw

   1  package wire
   2  
   3  import (
   4  	"fmt"
   5  	"io"
   6  )
   7  
   8  // MsgSendHeaders implements the Message interface and represents a bitcoin sendheaders message. It is used to request
   9  // the peer send block headers rather than inventory vectors. This message has no payload and was not added until
  10  // protocol versions starting with SendHeadersVersion.
  11  type MsgSendHeaders struct{}
  12  
  13  // BtcDecode decodes r using the bitcoin protocol encoding into the receiver. This is part of the Message interface
  14  // implementation.
  15  func (msg *MsgSendHeaders) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) (e error) {
  16  	if pver < SendHeadersVersion {
  17  		str := fmt.Sprintf("sendheaders message invalid for protocol "+
  18  			"version %d", pver,
  19  		)
  20  		return messageError("MsgSendHeaders.BtcDecode", str)
  21  	}
  22  	return nil
  23  }
  24  
  25  // BtcEncode encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface
  26  // implementation.
  27  func (msg *MsgSendHeaders) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) (e error) {
  28  	if pver < SendHeadersVersion {
  29  		str := fmt.Sprintf("sendheaders message invalid for protocol "+
  30  			"version %d", pver,
  31  		)
  32  		return messageError("MsgSendHeaders.BtcEncode", str)
  33  	}
  34  	return nil
  35  }
  36  
  37  // Command returns the protocol command string for the message. This is part of the Message interface implementation.
  38  func (msg *MsgSendHeaders) Command() string {
  39  	return CmdSendHeaders
  40  }
  41  
  42  // MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message
  43  // interface implementation.
  44  func (msg *MsgSendHeaders) MaxPayloadLength(pver uint32) uint32 {
  45  	return 0
  46  }
  47  
  48  // NewMsgSendHeaders returns a new bitcoin sendheaders message that conforms to the Message interface. See
  49  // MsgSendHeaders for details.
  50  func NewMsgSendHeaders() *MsgSendHeaders {
  51  	return &MsgSendHeaders{}
  52  }
  53