mirror of
https://github.com/FlipsideCrypto/dcrd.git
synced 2026-02-06 10:56:47 +00:00
wire: Fix MsgCFTypes maximum payload length.
This commit fixes and improves MsgCFTypes maximum payload length. The counter of FilterType in MsgCFTypes is varInt which for 256 FilterType it has 3 bytes size.
This commit is contained in:
parent
9c6dfab8da
commit
bf2ae11be8
@ -120,8 +120,9 @@ func (msg *MsgCFTypes) Command() string {
|
||||
// MaxPayloadLength returns the maximum length the payload can be for the
|
||||
// receiver. This is part of the Message interface implementation.
|
||||
func (msg *MsgCFTypes) MaxPayloadLength(pver uint32) uint32 {
|
||||
// 2 bytes for filter count, and 1 byte for up to 256 filter types.
|
||||
return 258
|
||||
// 3 bytes for filter count, 1 byte up to 256 bytes filter types.
|
||||
return uint32(VarIntSerializeSize(MaxFilterTypesPerMsg)) +
|
||||
MaxFilterTypesPerMsg
|
||||
}
|
||||
|
||||
// NewMsgCFTypes returns a new cftypes message that conforms to the Message
|
||||
|
||||
@ -31,8 +31,9 @@ func TestCFTypes(t *testing.T) {
|
||||
}
|
||||
|
||||
// Ensure max payload is expected value for latest protocol version.
|
||||
// Filters count 2 bytes + 1 byte up to 256 bytes for each filter type.
|
||||
wantPayload := uint32(258)
|
||||
// Filters count (varInt) 3 bytes + 1 byte up to 256 bytes for each
|
||||
// filter type.
|
||||
wantPayload := uint32(259)
|
||||
maxPayload := msg.MaxPayloadLength(pver)
|
||||
if maxPayload != wantPayload {
|
||||
t.Errorf("MaxPayloadLength: wrong max payload length for "+
|
||||
|
||||
Loading…
Reference in New Issue
Block a user