diff --git a/server/jsonrpc_blockchain.go b/server/jsonrpc_blockchain.go index 11e9fc0..dc091da 100644 --- a/server/jsonrpc_blockchain.go +++ b/server/jsonrpc_blockchain.go @@ -88,10 +88,10 @@ func min[Ord constraints.Ordered](x, y Ord) Ord { } type BlockGetChunkReq uint32 -type blockGetChunkResp string +type BlockGetChunkResp string // 'blockchain.block.get_chunk' -func (s *BlockchainService) Get_chunk(r *http.Request, req *BlockGetChunkReq, resp **blockGetChunkResp) error { +func (s *BlockchainService) Get_chunk(r *http.Request, req *BlockGetChunkReq, resp **BlockGetChunkResp) error { index := uint32(*req) db_headers, err := s.DB.GetHeaders(index*CHUNK_SIZE, CHUNK_SIZE) if err != nil { @@ -101,7 +101,7 @@ func (s *BlockchainService) Get_chunk(r *http.Request, req *BlockGetChunkReq, re for _, h := range db_headers { raw = append(raw, h[:]...) } - headers := blockGetChunkResp(hex.EncodeToString(raw)) + headers := BlockGetChunkResp(hex.EncodeToString(raw)) *resp = &headers return err } diff --git a/server/jsonrpc_blockchain_test.go b/server/jsonrpc_blockchain_test.go index 66503b2..339ec5d 100644 --- a/server/jsonrpc_blockchain_test.go +++ b/server/jsonrpc_blockchain_test.go @@ -27,7 +27,7 @@ func TestGetChunk(t *testing.T) { for index := 0; index < 10; index++ { req := BlockGetChunkReq(index) - var resp *blockGetChunkResp + var resp *BlockGetChunkResp err := s.Get_chunk(nil, &req, &resp) if err != nil { t.Errorf("index: %v handler err: %v", index, err) diff --git a/server/jsonrpc_service.go b/server/jsonrpc_service.go index 8f32d16..cd94e5d 100644 --- a/server/jsonrpc_service.go +++ b/server/jsonrpc_service.go @@ -1,7 +1,6 @@ package server import ( - "log" "net/http" "github.com/gorilla/mux" @@ -9,6 +8,7 @@ import ( "github.com/gorilla/rpc/json" "github.com/lbryio/herald.go/db" pb "github.com/lbryio/herald.go/protobuf/go" + log "github.com/sirupsen/logrus" ) type ClaimtrieService struct { @@ -41,13 +41,25 @@ func (s *Server) StartJsonRPC() error { // Register "blockchain.claimtrie.*"" handlers. claimtrieSvc := &ClaimtrieService{s.DB} - s1.RegisterService(claimtrieSvc, "blockchain_claimtrie") + err := s1.RegisterService(claimtrieSvc, "blockchain_claimtrie") + if err != nil { + log.Errorf("RegisterService: %v\n", err) + } // Register other "blockchain.{block,address,scripthash}.*" handlers. blockchainSvc := &BlockchainService{s.DB, s.Chain} - s1.RegisterService(&blockchainSvc, "blockchain_block") - s1.RegisterService(&BlockchainAddressService{*blockchainSvc}, "blockchain_address") - s1.RegisterService(&BlockchainScripthashService{*blockchainSvc}, "blockchain_scripthash") + err = s1.RegisterService(blockchainSvc, "blockchain_block") + if err != nil { + log.Errorf("RegisterService: %v\n", err) + } + err = s1.RegisterService(&BlockchainAddressService{*blockchainSvc}, "blockchain_address") + if err != nil { + log.Errorf("RegisterService: %v\n", err) + } + err = s1.RegisterService(&BlockchainScripthashService{*blockchainSvc}, "blockchain_scripthash") + if err != nil { + log.Errorf("RegisterService: %v\n", err) + } r := mux.NewRouter() r.Handle("/rpc", s1)