From f6dff40733b78e1180b19d80e583801c03f3ec9c Mon Sep 17 00:00:00 2001 From: pedro martelletto Date: Sat, 14 Jan 2017 10:26:13 +0000 Subject: [PATCH] Instrument GetCBFilter RPC --- rpcserver.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/rpcserver.go b/rpcserver.go index 312a6596..a73351dd 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -2148,6 +2148,23 @@ 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) { + 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 }