From d03c992a2599644998648ad651831f8a07684810 Mon Sep 17 00:00:00 2001 From: Jonathan Moody <103143855+moodyjon@users.noreply.github.com> Date: Tue, 27 Sep 2022 17:34:41 -0500 Subject: [PATCH] Rename BlockchainService -> BlockchainBlockService. --- server/jsonrpc_blockchain.go | 16 ++++++++-------- server/jsonrpc_blockchain_test.go | 12 ++++++------ server/jsonrpc_service.go | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/server/jsonrpc_blockchain.go b/server/jsonrpc_blockchain.go index 1c5c86c..a0476fd 100644 --- a/server/jsonrpc_blockchain.go +++ b/server/jsonrpc_blockchain.go @@ -21,20 +21,20 @@ import ( "golang.org/x/exp/constraints" ) -// BlockchainService methods handle "blockchain.block.*" RPCs -type BlockchainService struct { +// BlockchainBlockService methods handle "blockchain.block.*" RPCs +type BlockchainBlockService struct { DB *db.ReadOnlyDBColumnFamily Chain *chaincfg.Params } // BlockchainAddressService methods handle "blockchain.address.*" RPCs type BlockchainAddressService struct { - BlockchainService + BlockchainBlockService } // BlockchainScripthashService methods handle "blockchain.scripthash.*" RPCs type BlockchainScripthashService struct { - BlockchainService + BlockchainBlockService } const CHUNK_SIZE = 96 @@ -80,7 +80,7 @@ func newBlockHeaderElectrum(header *[HEADER_SIZE]byte, height uint32) *BlockHead type BlockGetServerHeightReq struct{} type BlockGetServerHeightResp uint32 -func (s *BlockchainService) Get_server_height(r *http.Request, req *BlockGetServerHeightReq, resp **BlockGetServerHeightResp) error { +func (s *BlockchainBlockService) Get_server_height(r *http.Request, req *BlockGetServerHeightReq, resp **BlockGetServerHeightResp) error { if s.DB == nil || s.DB.LastState == nil { return fmt.Errorf("unknown height") } @@ -93,7 +93,7 @@ type BlockGetChunkReq uint32 type BlockGetChunkResp string // 'blockchain.block.get_chunk' -func (s *BlockchainService) Get_chunk(r *http.Request, req *BlockGetChunkReq, resp **BlockGetChunkResp) error { +func (s *BlockchainBlockService) 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 { @@ -114,7 +114,7 @@ type BlockGetHeaderResp struct { } // 'blockchain.block.get_header' -func (s *BlockchainService) Get_header(r *http.Request, req *BlockGetHeaderReq, resp **BlockGetHeaderResp) error { +func (s *BlockchainBlockService) Get_header(r *http.Request, req *BlockGetHeaderReq, resp **BlockGetHeaderResp) error { height := uint32(*req) headers, err := s.DB.GetHeaders(height, 1) if err != nil { @@ -144,7 +144,7 @@ type BlockHeadersResp struct { } // 'blockchain.block.headers' -func (s *BlockchainService) Headers(r *http.Request, req *BlockHeadersReq, resp **BlockHeadersResp) error { +func (s *BlockchainBlockService) Headers(r *http.Request, req *BlockHeadersReq, resp **BlockHeadersResp) error { count := min(req.Count, MAX_CHUNK_SIZE) db_headers, err := s.DB.GetHeaders(req.StartHeight, count) if err != nil { diff --git a/server/jsonrpc_blockchain_test.go b/server/jsonrpc_blockchain_test.go index a57bc35..64def31 100644 --- a/server/jsonrpc_blockchain_test.go +++ b/server/jsonrpc_blockchain_test.go @@ -58,7 +58,7 @@ func TestServerGetHeight(t *testing.T) { return } - s := &BlockchainService{ + s := &BlockchainBlockService{ DB: db, Chain: &chaincfg.RegressionNetParams, } @@ -88,7 +88,7 @@ func TestGetChunk(t *testing.T) { return } - s := &BlockchainService{ + s := &BlockchainBlockService{ DB: db, Chain: &chaincfg.RegressionNetParams, } @@ -131,7 +131,7 @@ func TestGetHeader(t *testing.T) { return } - s := &BlockchainService{ + s := &BlockchainBlockService{ DB: db, Chain: &chaincfg.RegressionNetParams, } @@ -161,7 +161,7 @@ func TestGetBalance(t *testing.T) { } s := &BlockchainAddressService{ - BlockchainService{ + BlockchainBlockService{ DB: db, Chain: &chaincfg.RegressionNetParams, }, @@ -192,7 +192,7 @@ func TestGetHistory(t *testing.T) { } s := &BlockchainAddressService{ - BlockchainService{ + BlockchainBlockService{ DB: db, Chain: &chaincfg.RegressionNetParams, }, @@ -223,7 +223,7 @@ func TestListUnspent(t *testing.T) { } s := &BlockchainAddressService{ - BlockchainService{ + BlockchainBlockService{ DB: db, Chain: &chaincfg.RegressionNetParams, }, diff --git a/server/jsonrpc_service.go b/server/jsonrpc_service.go index 0f91843..8845c5a 100644 --- a/server/jsonrpc_service.go +++ b/server/jsonrpc_service.go @@ -63,7 +63,7 @@ func (s *Server) StartJsonRPC() error { } // Register other "blockchain.{block,address,scripthash}.*" handlers. - blockchainSvc := &BlockchainService{s.DB, s.Chain} + blockchainSvc := &BlockchainBlockService{s.DB, s.Chain} err = s1.RegisterService(blockchainSvc, "blockchain_block") if err != nil { log.Errorf("RegisterService: %v\n", err)