Make the service objects independent, so we don't have inheritance.
This commit is contained in:
parent
8c66d67a52
commit
b9cb9d8c5a
3 changed files with 13 additions and 18 deletions
|
@ -28,12 +28,14 @@ type BlockchainBlockService struct {
|
|||
|
||||
// BlockchainAddressService methods handle "blockchain.address.*" RPCs
|
||||
type BlockchainAddressService struct {
|
||||
BlockchainBlockService
|
||||
DB *db.ReadOnlyDBColumnFamily
|
||||
Chain *chaincfg.Params
|
||||
}
|
||||
|
||||
// BlockchainScripthashService methods handle "blockchain.scripthash.*" RPCs
|
||||
type BlockchainScripthashService struct {
|
||||
BlockchainBlockService
|
||||
DB *db.ReadOnlyDBColumnFamily
|
||||
Chain *chaincfg.Params
|
||||
}
|
||||
|
||||
const CHUNK_SIZE = 96
|
||||
|
|
|
@ -161,10 +161,8 @@ func TestGetBalance(t *testing.T) {
|
|||
}
|
||||
|
||||
s := &BlockchainAddressService{
|
||||
BlockchainBlockService{
|
||||
DB: db,
|
||||
Chain: &chaincfg.RegressionNetParams,
|
||||
},
|
||||
}
|
||||
|
||||
for _, addr := range regTestAddrs {
|
||||
|
@ -192,10 +190,8 @@ func TestGetHistory(t *testing.T) {
|
|||
}
|
||||
|
||||
s := &BlockchainAddressService{
|
||||
BlockchainBlockService{
|
||||
DB: db,
|
||||
Chain: &chaincfg.RegressionNetParams,
|
||||
},
|
||||
}
|
||||
|
||||
for _, addr := range regTestAddrs {
|
||||
|
@ -223,10 +219,8 @@ func TestListUnspent(t *testing.T) {
|
|||
}
|
||||
|
||||
s := &BlockchainAddressService{
|
||||
BlockchainBlockService{
|
||||
DB: db,
|
||||
Chain: &chaincfg.RegressionNetParams,
|
||||
},
|
||||
}
|
||||
|
||||
for _, addr := range regTestAddrs {
|
||||
|
|
|
@ -63,16 +63,15 @@ func (s *Server) StartJsonRPC() error {
|
|||
}
|
||||
|
||||
// Register other "blockchain.{block,address,scripthash}.*" handlers.
|
||||
blockchainSvc := &BlockchainBlockService{s.DB, s.Chain}
|
||||
err = s1.RegisterTCPService(blockchainSvc, "blockchain_block")
|
||||
err = s1.RegisterTCPService(&BlockchainBlockService{s.DB, s.Chain}, "blockchain_block")
|
||||
if err != nil {
|
||||
log.Errorf("RegisterService: %v\n", err)
|
||||
}
|
||||
err = s1.RegisterTCPService(&BlockchainAddressService{*blockchainSvc}, "blockchain_address")
|
||||
err = s1.RegisterTCPService(&BlockchainAddressService{s.DB, s.Chain}, "blockchain_address")
|
||||
if err != nil {
|
||||
log.Errorf("RegisterService: %v\n", err)
|
||||
}
|
||||
err = s1.RegisterTCPService(&BlockchainScripthashService{*blockchainSvc}, "blockchain_scripthash")
|
||||
err = s1.RegisterTCPService(&BlockchainScripthashService{s.DB, s.Chain}, "blockchain_scripthash")
|
||||
if err != nil {
|
||||
log.Errorf("RegisterService: %v\n", err)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue