mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-19 21:31:37 +00:00
miner, XDPoS, XDC: close chanels by owner, close XFN-41 (#1641)
This commit is contained in:
parent
5a26279c1c
commit
d451580b37
3 changed files with 11 additions and 3 deletions
|
|
@ -267,6 +267,9 @@ func XDC(ctx *cli.Context) error {
|
|||
defer stack.Close()
|
||||
startNode(ctx, stack, backend, cfg, false)
|
||||
stack.Wait()
|
||||
if engine, ok := backend.Engine().(*XDPoS.XDPoS); ok {
|
||||
engine.Stop()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -119,6 +119,14 @@ func New(chainConfig *params.ChainConfig, db ethdb.Database) *XDPoS {
|
|||
}
|
||||
}
|
||||
|
||||
// Stop stops the consensus engine:
|
||||
// - close chanel MinePeriodCh
|
||||
// - close chanel NewRoundCh
|
||||
func (x *XDPoS) Stop() {
|
||||
close(x.MinePeriodCh)
|
||||
close(x.NewRoundCh)
|
||||
}
|
||||
|
||||
// NewFullFaker creates an ethash consensus engine with a full fake scheme that
|
||||
// accepts all blocks as valid, without checking any consensus rules whatsoever.
|
||||
func NewFaker(db ethdb.Database, chainConfig *params.ChainConfig) *XDPoS {
|
||||
|
|
@ -224,7 +232,6 @@ func (x *XDPoS) VerifyHeaders(chain consensus.ChainReader, headers []*types.Head
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
if v1headers != nil {
|
||||
x.EngineV1.VerifyHeaders(chain, v1headers, v1fullVerifies, abort, results)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -277,9 +277,7 @@ func (w *worker) update() {
|
|||
// timeout waiting for v1 initial value
|
||||
minePeriod := 2
|
||||
MinePeriodCh := w.engine.(*XDPoS.XDPoS).MinePeriodCh
|
||||
defer close(MinePeriodCh)
|
||||
NewRoundCh := w.engine.(*XDPoS.XDPoS).NewRoundCh
|
||||
defer close(NewRoundCh)
|
||||
|
||||
timeout := time.NewTimer(time.Duration(minePeriod) * time.Second)
|
||||
defer timeout.Stop()
|
||||
|
|
|
|||
Loading…
Reference in a new issue