1 package wire
2 3 import (
4 "fmt"
5 "io"
6 )
7 8 // MsgMemPool implements the Message interface and represents a bitcoin mempool message. It is used to request a list of
9 // transactions still in the active memory pool of a relay. This message has no payload and was not added until protocol
10 // versions starting with BIP0035Version.
11 type MsgMemPool 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 *MsgMemPool) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) (e error) {
16 if pver < BIP0035Version {
17 str := fmt.Sprintf("mempool message invalid for protocol "+
18 "version %d", pver,
19 )
20 return messageError("MsgMemPool.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 *MsgMemPool) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) (e error) {
28 if pver < BIP0035Version {
29 str := fmt.Sprintf("mempool message invalid for protocol "+
30 "version %d", pver,
31 )
32 return messageError("MsgMemPool.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 *MsgMemPool) Command() string {
39 return CmdMemPool
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 *MsgMemPool) MaxPayloadLength(pver uint32) uint32 {
45 return 0
46 }
47 48 // NewMsgMemPool returns a new bitcoin pong message that conforms to the Message interface. See MsgPong for details.
49 func NewMsgMemPool() *MsgMemPool {
50 return &MsgMemPool{}
51 }
52