Set Heimdall client to nil when 'withoutheimdall' is set

This commit is contained in:
Jerry 2022-06-15 23:58:23 -07:00
parent 9bc9a45758
commit 9ec673870a
2 changed files with 8 additions and 2 deletions

View file

@ -960,7 +960,9 @@ func (c *Bor) APIs(chain consensus.ChainHeaderReader) []rpc.API {
// Close implements consensus.Engine. It's a noop for bor as there are no background threads.
func (c *Bor) Close() error {
c.closeOnce.Do(func() {
c.HeimdallClient.Close()
if c.HeimdallClient != nil {
c.HeimdallClient.Close()
}
})
return nil

View file

@ -243,7 +243,11 @@ func CreateConsensusEngine(stack *node.Node, chainConfig *params.ChainConfig, et
genesisContractsClient := contract.NewGenesisContractsClient(chainConfig, chainConfig.Bor.ValidatorContract, chainConfig.Bor.StateReceiverContract, blockchainAPI)
spanner := span.NewChainSpanner(blockchainAPI, contract.ValidatorSet(), chainConfig, common.HexToAddress(chainConfig.Bor.ValidatorContract))
return bor.New(chainConfig, db, blockchainAPI, spanner, heimdall.NewHeimdallClient(ethConfig.HeimdallURL), genesisContractsClient)
if ethConfig.WithoutHeimdall {
return bor.New(chainConfig, db, blockchainAPI, spanner, nil, genesisContractsClient)
} else {
return bor.New(chainConfig, db, blockchainAPI, spanner, heimdall.NewHeimdallClient(ethConfig.HeimdallURL), genesisContractsClient)
}
} else {
switch config.PowMode {
case ethash.ModeFake: