wire: update compact filter messages to match wire.Message interface
This commit is contained in:
parent
3d1caa2f83
commit
7c2f7be2ea
6 changed files with 12 additions and 12 deletions
|
@ -4,6 +4,7 @@ wire
|
|||
[![Build Status](http://img.shields.io/travis/btcsuite/btcd.svg)](https://travis-ci.org/btcsuite/btcd)
|
||||
[![ISC License](http://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org)
|
||||
[![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg)](http://godoc.org/github.com/btcsuite/btcd/wire)
|
||||
=======
|
||||
|
||||
Package wire implements the bitcoin wire protocol. A comprehensive suite of
|
||||
tests with 100% test coverage is provided to ensure proper functionality.
|
||||
|
|
|
@ -46,7 +46,7 @@ func (msg *MsgCFHeaders) AddCFHeader(headerHash *chainhash.Hash) error {
|
|||
|
||||
// BtcDecode decodes r using the bitcoin protocol encoding into the receiver.
|
||||
// This is part of the Message interface implementation.
|
||||
func (msg *MsgCFHeaders) BtcDecode(r io.Reader, pver uint32) error {
|
||||
func (msg *MsgCFHeaders) BtcDecode(r io.Reader, pver uint32, _ MessageEncoding) error {
|
||||
// Read stop hash
|
||||
err := readElement(r, &msg.StopHash)
|
||||
if err != nil {
|
||||
|
@ -90,7 +90,7 @@ func (msg *MsgCFHeaders) BtcDecode(r io.Reader, pver uint32) error {
|
|||
|
||||
// BtcEncode encodes the receiver to w using the bitcoin protocol encoding.
|
||||
// This is part of the Message interface implementation.
|
||||
func (msg *MsgCFHeaders) BtcEncode(w io.Writer, pver uint32) error {
|
||||
func (msg *MsgCFHeaders) BtcEncode(w io.Writer, pver uint32, _ MessageEncoding) error {
|
||||
// Write stop hash
|
||||
err := writeElement(w, msg.StopHash)
|
||||
if err != nil {
|
||||
|
@ -140,7 +140,7 @@ func (msg *MsgCFHeaders) Deserialize(r io.Reader) error {
|
|||
// At the current time, there is no difference between the wire encoding
|
||||
// and the stable long-term storage format. As a result, make use of
|
||||
// BtcDecode.
|
||||
return msg.BtcDecode(r, 0)
|
||||
return msg.BtcDecode(r, 0, BaseEncoding)
|
||||
}
|
||||
|
||||
// Command returns the protocol command string for the message. This is part
|
||||
|
|
|
@ -24,7 +24,7 @@ type MsgCFilter struct {
|
|||
|
||||
// BtcDecode decodes r using the bitcoin protocol encoding into the receiver.
|
||||
// This is part of the Message interface implementation.
|
||||
func (msg *MsgCFilter) BtcDecode(r io.Reader, pver uint32) error {
|
||||
func (msg *MsgCFilter) BtcDecode(r io.Reader, pver uint32, _ MessageEncoding) error {
|
||||
var err error
|
||||
// Read the hash of the filter's block
|
||||
err = readElement(r, &msg.BlockHash)
|
||||
|
@ -44,7 +44,7 @@ func (msg *MsgCFilter) BtcDecode(r io.Reader, pver uint32) error {
|
|||
|
||||
// BtcEncode encodes the receiver to w using the bitcoin protocol encoding.
|
||||
// This is part of the Message interface implementation.
|
||||
func (msg *MsgCFilter) BtcEncode(w io.Writer, pver uint32) error {
|
||||
func (msg *MsgCFilter) BtcEncode(w io.Writer, pver uint32, _ MessageEncoding) error {
|
||||
size := len(msg.Data)
|
||||
if size > MaxCFilterDataSize {
|
||||
str := fmt.Sprintf("cfilter size too large for message "+
|
||||
|
@ -78,7 +78,7 @@ func (msg *MsgCFilter) Deserialize(r io.Reader) error {
|
|||
// At the current time, there is no difference between the wire encoding
|
||||
// and the stable long-term storage format. As a result, make use of
|
||||
// BtcDecode.
|
||||
return msg.BtcDecode(r, 0)
|
||||
return msg.BtcDecode(r, 0, BaseEncoding)
|
||||
}
|
||||
|
||||
// Command returns the protocol command string for the message. This is part
|
||||
|
|
|
@ -35,7 +35,7 @@ func (msg *MsgGetCFHeaders) AddBlockLocatorHash(hash *chainhash.Hash) error {
|
|||
|
||||
// BtcDecode decodes r using the bitcoin protocol encoding into the receiver.
|
||||
// This is part of the Message interface implementation.
|
||||
func (msg *MsgGetCFHeaders) BtcDecode(r io.Reader, pver uint32) error {
|
||||
func (msg *MsgGetCFHeaders) BtcDecode(r io.Reader, pver uint32, _ MessageEncoding) error {
|
||||
err := readElement(r, &msg.ProtocolVersion)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -75,7 +75,7 @@ func (msg *MsgGetCFHeaders) BtcDecode(r io.Reader, pver uint32) error {
|
|||
|
||||
// BtcEncode encodes the receiver to w using the bitcoin protocol encoding.
|
||||
// This is part of the Message interface implementation.
|
||||
func (msg *MsgGetCFHeaders) BtcEncode(w io.Writer, pver uint32) error {
|
||||
func (msg *MsgGetCFHeaders) BtcEncode(w io.Writer, pver uint32, _ MessageEncoding) error {
|
||||
// Limit to max block locator hashes per message.
|
||||
count := len(msg.BlockLocatorHashes)
|
||||
if count > MaxBlockLocatorsPerMsg {
|
||||
|
|
|
@ -15,7 +15,7 @@ type MsgGetCFilter struct {
|
|||
Extended bool
|
||||
}
|
||||
|
||||
func (msg *MsgGetCFilter) BtcDecode(r io.Reader, pver uint32) error {
|
||||
func (msg *MsgGetCFilter) BtcDecode(r io.Reader, pver uint32, _ MessageEncoding) error {
|
||||
err := readElement(r, &msg.BlockHash)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -25,7 +25,7 @@ func (msg *MsgGetCFilter) BtcDecode(r io.Reader, pver uint32) error {
|
|||
|
||||
// BtcEncode encodes the receiver to w using the bitcoin protocol encoding.
|
||||
// This is part of the Message interface implementation.
|
||||
func (msg *MsgGetCFilter) BtcEncode(w io.Writer, pver uint32) error {
|
||||
func (msg *MsgGetCFilter) BtcEncode(w io.Writer, pver uint32, _ MessageEncoding) error {
|
||||
err := writeElement(w, &msg.BlockHash)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -17,9 +17,8 @@ func TestServiceFlagStringer(t *testing.T) {
|
|||
{SFNodeGetUTXO, "SFNodeGetUTXO"},
|
||||
{SFNodeBloom, "SFNodeBloom"},
|
||||
{SFNodeWitness, "SFNodeWitness"},
|
||||
{0xffffffff, "SFNodeNetwork|SFNodeGetUTXO|SFNodeBloom|SFNodeWitness|0xfffffff0"},
|
||||
{SFNodeCF, "SFNodeCF"},
|
||||
{0xffffffff, "SFNodeNetwork|SFNodeGetUTXO|SFNodeBloom|SFNodeCF|0xfffffff0"},
|
||||
{0xffffffff, "SFNodeNetwork|SFNodeGetUTXO|SFNodeBloom|SFNodeWitness|SFNodeCF|0xffffffe0"},
|
||||
}
|
||||
|
||||
t.Logf("Running %d tests", len(tests))
|
||||
|
|
Loading…
Reference in a new issue