-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmsg_ext_msg.go
More file actions
66 lines (56 loc) · 2.21 KB
/
Copy pathmsg_ext_msg.go
File metadata and controls
66 lines (56 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright (c) 2016 The btcsuite developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
package wire
import (
"fmt"
"io"
)
// MsgExtMsg implements the Message interface and represents a bitcoin
// extmsg message.
type MsgExtMsg struct {
NumberOfFields uint64 // numberOfFields is set to 1, increment if new properties are added
MaxRecvPayloadLength uint64
}
// MaxExtMsgPayload is the maximum number of bytes a protoconf can be.
// NumberOfFields 8 bytes + MaxRecvPayloadLength 4 bytes
const MaxExtMsgPayload = 0xFFFFFFFFFFFFFFFF
// Bsvdecode decodes r using the bitcoin protocol encoding into the receiver.
// This is part of the Message interface implementation.
func (msg *MsgExtMsg) Bsvdecode(_ io.Reader, pver uint32, _ MessageEncoding) error {
if pver < ProtoconfVersion {
str := fmt.Sprintf("protoconf message invalid for protocol "+
"version %d", pver)
return messageError("MsgExtMsg.Bsvdecode", str)
}
// do nothing...
return nil
}
// BsvEncode encodes the receiver to w using the bitcoin protocol encoding.
// This is part of the Message interface implementation.
func (msg *MsgExtMsg) BsvEncode(w io.Writer, pver uint32, _ MessageEncoding) error {
if pver < ProtoconfVersion {
str := fmt.Sprintf("protoconf message invalid for protocol "+
"version %d", pver)
return messageError("MsgExtMsg.BsvEncode", str)
}
return writeElements(w, msg.NumberOfFields, msg.MaxRecvPayloadLength)
}
// Command returns the protocol command string for the message. This is part
// of the Message interface implementation.
func (msg *MsgExtMsg) Command() string {
return CmdProtoconf
}
// MaxPayloadLength returns the maximum length the payload can be for the
// receiver. This is part of the Message interface implementation.
func (msg *MsgExtMsg) MaxPayloadLength(_ uint32) uint64 {
return MaxProtoconfPayload
}
// NewMsgExtMsg returns a new bitcoin feefilter message that conforms to
// the Message interface. See MsgFeeFilter for details.
func NewMsgExtMsg(maxRecvPayloadLength uint64) *MsgExtMsg {
return &MsgExtMsg{
NumberOfFields: 1, // numberOfFields is set to 1, increment if new properties are added
MaxRecvPayloadLength: maxRecvPayloadLength,
}
}