Add a GetCBFilter RPC command
This commit is contained in:
parent
43bf8db793
commit
76378e7167
4 changed files with 39 additions and 0 deletions
|
@ -278,6 +278,18 @@ func NewGetBlockTemplateCmd(request *TemplateRequest) *GetBlockTemplateCmd {
|
|||
Request: request,
|
||||
}
|
||||
}
|
||||
// GetCBFilterCmd defines the getcbfilter JSON-RPC command.
|
||||
type GetCBFilterCmd struct {
|
||||
Hash string
|
||||
}
|
||||
|
||||
// NewGetCBFilterCmd returns a new instance which can be used to issue a
|
||||
// getcbfilter JSON-RPC command.
|
||||
func NewGetCBFilterCmd(hash string) *GetCBFilterCmd {
|
||||
return &GetCBFilterCmd{
|
||||
Hash: hash,
|
||||
}
|
||||
}
|
||||
|
||||
// GetChainTipsCmd defines the getchaintips JSON-RPC command.
|
||||
type GetChainTipsCmd struct{}
|
||||
|
@ -756,6 +768,7 @@ func init() {
|
|||
MustRegisterCmd("getblockhash", (*GetBlockHashCmd)(nil), flags)
|
||||
MustRegisterCmd("getblockheader", (*GetBlockHeaderCmd)(nil), flags)
|
||||
MustRegisterCmd("getblocktemplate", (*GetBlockTemplateCmd)(nil), flags)
|
||||
MustRegisterCmd("getcbfilter", (*GetCBFilterCmd)(nil), flags)
|
||||
MustRegisterCmd("getchaintips", (*GetChainTipsCmd)(nil), flags)
|
||||
MustRegisterCmd("getconnectioncount", (*GetConnectionCountCmd)(nil), flags)
|
||||
MustRegisterCmd("getdifficulty", (*GetDifficultyCmd)(nil), flags)
|
||||
|
|
|
@ -317,6 +317,19 @@ func TestChainSvrCmds(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "getcbfilter",
|
||||
newCmd: func() (interface{}, error) {
|
||||
return btcjson.NewCmd("getcbfilter", "123")
|
||||
},
|
||||
staticCmd: func() interface{} {
|
||||
return btcjson.NewGetCBFilterCmd("123")
|
||||
},
|
||||
marshalled: `{"jsonrpc":"1.0","method":"getcbfilter","params":["123"],"id":1}`,
|
||||
unmarshalled: &btcjson.GetCBFilterCmd{
|
||||
Hash: "123",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "getchaintips",
|
||||
newCmd: func() (interface{}, error) {
|
||||
|
|
|
@ -142,6 +142,7 @@ var rpcHandlersBeforeInit = map[string]commandHandler{
|
|||
"getblockhash": handleGetBlockHash,
|
||||
"getblockheader": handleGetBlockHeader,
|
||||
"getblocktemplate": handleGetBlockTemplate,
|
||||
"getcbfilter": handleGetCBFilter,
|
||||
"getconnectioncount": handleGetConnectionCount,
|
||||
"getcurrentnet": handleGetCurrentNet,
|
||||
"getdifficulty": handleGetDifficulty,
|
||||
|
@ -258,6 +259,7 @@ var rpcLimited = map[string]struct{}{
|
|||
"getblockcount": {},
|
||||
"getblockhash": {},
|
||||
"getblockheader": {},
|
||||
"getcbfilter": {},
|
||||
"getcurrentnet": {},
|
||||
"getdifficulty": {},
|
||||
"getheaders": {},
|
||||
|
@ -2144,6 +2146,11 @@ func handleGetBlockTemplate(s *rpcServer, cmd interface{}, closeChan <-chan stru
|
|||
}
|
||||
}
|
||||
|
||||
// handleGetCBFilter implements the getcbfilter command.
|
||||
func handleGetCBFilter(s *rpcServer, cmd interface{}, closeChan <-chan struct{}) (interface{}, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// handleGetConnectionCount implements the getconnectioncount command.
|
||||
func handleGetConnectionCount(s *rpcServer, cmd interface{}, closeChan <-chan struct{}) (interface{}, error) {
|
||||
return s.cfg.ConnMgr.ConnectedCount(), nil
|
||||
|
|
|
@ -323,6 +323,11 @@ var helpDescsEnUS = map[string]string{
|
|||
"getblocktemplate--condition2": "mode=proposal, accepted",
|
||||
"getblocktemplate--result1": "An error string which represents why the proposal was rejected or nothing if accepted",
|
||||
|
||||
// GetCBFilterCmd help.
|
||||
"getcbfilter--synopsis": "Returns a block's committed bloom filter given its hash.",
|
||||
"getcbfilter-hash": "The hash of the block",
|
||||
"getcbfilter--result0": "The block's committed bloom filter",
|
||||
|
||||
// GetConnectionCountCmd help.
|
||||
"getconnectioncount--synopsis": "Returns the number of active connections to other peers.",
|
||||
"getconnectioncount--result0": "The number of connections",
|
||||
|
@ -668,6 +673,7 @@ var rpcResultTypes = map[string][]interface{}{
|
|||
"getblockheader": {(*string)(nil), (*btcjson.GetBlockHeaderVerboseResult)(nil)},
|
||||
"getblocktemplate": {(*btcjson.GetBlockTemplateResult)(nil), (*string)(nil), nil},
|
||||
"getblockchaininfo": {(*btcjson.GetBlockChainInfoResult)(nil)},
|
||||
"getcbfilter": {(*[]byte)(nil)},
|
||||
"getconnectioncount": {(*int32)(nil)},
|
||||
"getcurrentnet": {(*uint32)(nil)},
|
||||
"getdifficulty": {(*float64)(nil)},
|
||||
|
|
Loading…
Reference in a new issue