1// Copyright (c) 2014-2015 The btcsuite developers
2// Use of this source code is governed by an ISC
3// license that can be found in the LICENSE file.
4
5package wire
6
7import (
8	"fmt"
9	"io"
10)
11
12// MsgFilterClear implements the Message interface and represents a bitcoin
13// filterclear message which is used to reset a Bloom filter.
14//
15// This message was not added until protocol version BIP0037Version and has
16// no payload.
17type MsgFilterClear struct{}
18
19// BtcDecode decodes r using the bitcoin protocol encoding into the receiver.
20// This is part of the Message interface implementation.
21func (msg *MsgFilterClear) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error {
22	if pver < BIP0037Version {
23		str := fmt.Sprintf("filterclear message invalid for protocol "+
24			"version %d", pver)
25		return messageError("MsgFilterClear.BtcDecode", str)
26	}
27
28	return nil
29}
30
31// BtcEncode encodes the receiver to w using the bitcoin protocol encoding.
32// This is part of the Message interface implementation.
33func (msg *MsgFilterClear) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error {
34	if pver < BIP0037Version {
35		str := fmt.Sprintf("filterclear message invalid for protocol "+
36			"version %d", pver)
37		return messageError("MsgFilterClear.BtcEncode", str)
38	}
39
40	return nil
41}
42
43// Command returns the protocol command string for the message.  This is part
44// of the Message interface implementation.
45func (msg *MsgFilterClear) Command() string {
46	return CmdFilterClear
47}
48
49// MaxPayloadLength returns the maximum length the payload can be for the
50// receiver.  This is part of the Message interface implementation.
51func (msg *MsgFilterClear) MaxPayloadLength(pver uint32) uint32 {
52	return 0
53}
54
55// NewMsgFilterClear returns a new bitcoin filterclear message that conforms to the Message
56// interface.  See MsgFilterClear for details.
57func NewMsgFilterClear() *MsgFilterClear {
58	return &MsgFilterClear{}
59}
60