Skip to content

Commit

Permalink
Add type for second getblockfilter param
Browse files Browse the repository at this point in the history
  • Loading branch information
lindlof committed May 26, 2020
1 parent 6b1d7b6 commit 6626f7a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
15 changes: 12 additions & 3 deletions btcjson/chainsvrcmds.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,18 +163,27 @@ func NewGetBlockCountCmd() *GetBlockCountCmd {
return &GetBlockCountCmd{}
}

// FilterTypeName defines the type used in the getblockfilter JSON-RPC command for the
// filter type field.
type FilterTypeName string

const (
// Basic is the basic filter type defined in BIP0158.
FilterTypeBasic FilterTypeName = "basic"
)

// GetBlockFilterCmd defines the getblockfilter JSON-RPC command.
type GetBlockFilterCmd struct {
BlockHash string // The hash of the block
FilterType *string // The type name of the filter, default=basic
BlockHash string // The hash of the block
FilterType *FilterTypeName // The type name of the filter, default=basic
}

// NewGetBlockFilterCmd returns a new instance which can be used to issue a
// getblockfilter JSON-RPC command.
//
// The parameters which are pointers indicate they are optional. Passing nil
// for optional parameters will use the default value.
func NewGetBlockFilterCmd(blockHash string, filterType *string) *GetBlockFilterCmd {
func NewGetBlockFilterCmd(blockHash string, filterType *FilterTypeName) *GetBlockFilterCmd {
return &GetBlockFilterCmd{
BlockHash: blockHash,
FilterType: filterType,
Expand Down
6 changes: 3 additions & 3 deletions rpcclient/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,15 +388,15 @@ func (r FutureGetBlockFilterResult) Receive() (*btcjson.GetBlockFilterResult, er
// returned instance.
//
// See GetBlockFilter for the blocking version and more details.
func (c *Client) GetBlockFilterAsync(blockHash chainhash.Hash, filterType *string) FutureGetBlockFilterResult {
func (c *Client) GetBlockFilterAsync(blockHash chainhash.Hash, filterType *btcjson.FilterTypeName) FutureGetBlockFilterResult {
hash := blockHash.String()

cmd := btcjson.NewGetBlockFilterCmd(hash, filterType)
return c.sendCmd(cmd)
}

// GetBlockFilter retrieves a BIP 157 content filter for a particular block.
func (c *Client) GetBlockFilter(blockHash chainhash.Hash, filterType *string) (*btcjson.GetBlockFilterResult, error) {
// GetBlockFilter retrieves a BIP0157 content filter for a particular block.
func (c *Client) GetBlockFilter(blockHash chainhash.Hash, filterType *btcjson.FilterTypeName) (*btcjson.GetBlockFilterResult, error) {
return c.GetBlockFilterAsync(blockHash, filterType).Receive()
}

Expand Down

0 comments on commit 6626f7a

Please sign in to comment.