Instrument GetCBFilter RPC

This commit is contained in:
pedro martelletto 2017-01-14 10:26:13 +00:00 committed by Olaoluwa Osuntokun
parent 76378e7167
commit f6dff40733

View file

@ -2148,6 +2148,23 @@ func handleGetBlockTemplate(s *rpcServer, cmd interface{}, closeChan <-chan stru
// handleGetCBFilter implements the getcbfilter command. // handleGetCBFilter implements the getcbfilter command.
func handleGetCBFilter(s *rpcServer, cmd interface{}, closeChan <-chan struct{}) (interface{}, error) { func handleGetCBFilter(s *rpcServer, cmd interface{}, closeChan <-chan struct{}) (interface{}, error) {
c := cmd.(*btcjson.GetCBFilterCmd)
hash, err := chainhash.NewHashFromStr(c.Hash)
if err != nil {
return nil, rpcDecodeHexError(c.Hash)
}
filterBytes, err := s.server.cbfIndex.GetFilterByBlockHash(hash)
if len(filterBytes) > 0 {
rpcsLog.Debugf("Found CB filter for %v", hash)
} else {
rpcsLog.Debugf("Could not find CB filter for %v: %v", hash, err)
return nil, &btcjson.RPCError{
Code: btcjson.ErrRPCBlockNotFound,
Message: "Block not found",
}
}
return nil, nil return nil, nil
} }