Pass correct blockchain object to mempool

This commit is contained in:
Martin Boehm 2019-04-03 22:08:32 +02:00
parent 4512a57134
commit 4435dbbfb4
7 changed files with 12 additions and 12 deletions

View File

@ -124,7 +124,7 @@ func NewBlockChain(coin string, configfile string, pushHandler func(bchain.Notif
if err != nil {
return nil, nil, err
}
mempool, err := bc.CreateMempool()
mempool, err := bc.CreateMempool(bc)
if err != nil {
return nil, nil, err
}
@ -148,8 +148,8 @@ func (c *blockChainWithMetrics) Initialize() error {
return c.b.Initialize()
}
func (c *blockChainWithMetrics) CreateMempool() (bchain.Mempool, error) {
return c.b.CreateMempool()
func (c *blockChainWithMetrics) CreateMempool(chain bchain.BlockChain) (bchain.Mempool, error) {
return c.b.CreateMempool(chain)
}
func (c *blockChainWithMetrics) InitializeMempool(addrDescForOutpoint bchain.AddrDescForOutpointFunc, onNewTxAddr bchain.OnNewTxAddrFunc) error {

View File

@ -131,9 +131,9 @@ func (b *BitcoinRPC) Initialize() error {
}
// CreateMempool creates mempool if not already created, however does not initialize it
func (b *BitcoinRPC) CreateMempool() (bchain.Mempool, error) {
func (b *BitcoinRPC) CreateMempool(chain bchain.BlockChain) (bchain.Mempool, error) {
if b.Mempool == nil {
b.Mempool = bchain.NewMempoolBitcoinType(b, b.ChainConfig.MempoolWorkers, b.ChainConfig.MempoolSubWorkers)
b.Mempool = bchain.NewMempoolBitcoinType(chain, b.ChainConfig.MempoolWorkers, b.ChainConfig.MempoolSubWorkers)
}
return b.Mempool, nil
}

View File

@ -164,9 +164,9 @@ func (b *EthereumRPC) Initialize() error {
}
// CreateMempool creates mempool if not already created, however does not initialize it
func (b *EthereumRPC) CreateMempool() (bchain.Mempool, error) {
func (b *EthereumRPC) CreateMempool(chain bchain.BlockChain) (bchain.Mempool, error) {
if b.Mempool == nil {
b.Mempool = bchain.NewMempoolEthereumType(b)
b.Mempool = bchain.NewMempoolEthereumType(chain)
}
return b.Mempool, nil
}

View File

@ -209,7 +209,7 @@ type BlockChain interface {
// initialize the block chain connector
Initialize() error
// create mempool but do not initialize it
CreateMempool() (Mempool, error)
CreateMempool(BlockChain) (Mempool, error)
// initialize mempool, create ZeroMQ (or other) subscription
InitializeMempool(AddrDescForOutpointFunc, OnNewTxAddrFunc) error
// shutdown mempool, ZeroMQ and block chain connections

View File

@ -85,7 +85,7 @@ func setupPublicHTTPServer(t *testing.T) (*PublicServer, string) {
glog.Fatal("fakechain: ", err)
}
mempool, err := chain.CreateMempool()
mempool, err := chain.CreateMempool(chain)
if err != nil {
glog.Fatal("mempool: ", err)
}

View File

@ -17,8 +17,8 @@ func NewFakeBlockChain(parser bchain.BlockChainParser) (bchain.BlockChain, error
return &fakeBlockChain{&bchain.BaseChain{Parser: parser}}, nil
}
func (b *fakeBlockChain) CreateMempool() (bchain.Mempool, error) {
return bchain.NewMempoolBitcoinType(b, 1, 1), nil
func (b *fakeBlockChain) CreateMempool(chain bchain.BlockChain) (bchain.Mempool, error) {
return bchain.NewMempoolBitcoinType(chain, 1, 1), nil
}
func (c *fakeBlockChain) Initialize() error {

View File

@ -169,7 +169,7 @@ func initBlockChain(coinName string, cfg json.RawMessage) (bchain.BlockChain, bc
return nil, nil, fmt.Errorf("BlockChain initialization failed: %s", err)
}
mempool, err := cli.CreateMempool()
mempool, err := cli.CreateMempool(cli)
if err != nil {
return nil, nil, fmt.Errorf("Mempool creation failed: %s", err)
}