mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 12:46:44 +00:00
miner, XDPoS, XDC: close chanels by owner, close XFN-41 (#1641)
This commit is contained in:
parent
013646403c
commit
5fa42ea2d0
3 changed files with 11 additions and 2 deletions
|
|
@ -254,6 +254,9 @@ func XDC(ctx *cli.Context) error {
|
||||||
defer stack.Close()
|
defer stack.Close()
|
||||||
startNode(ctx, stack, backend, cfg)
|
startNode(ctx, stack, backend, cfg)
|
||||||
stack.Wait()
|
stack.Wait()
|
||||||
|
if engine, ok := backend.Engine().(*XDPoS.XDPoS); ok {
|
||||||
|
engine.Stop()
|
||||||
|
}
|
||||||
return nil
|
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
|
// NewFullFaker creates an ethash consensus engine with a full fake scheme that
|
||||||
// accepts all blocks as valid, without checking any consensus rules whatsoever.
|
// accepts all blocks as valid, without checking any consensus rules whatsoever.
|
||||||
func NewFaker(db ethdb.Database, chainConfig *params.ChainConfig) *XDPoS {
|
func NewFaker(db ethdb.Database, chainConfig *params.ChainConfig) *XDPoS {
|
||||||
|
|
|
||||||
|
|
@ -277,9 +277,7 @@ func (w *worker) update() {
|
||||||
// timeout waiting for v1 inital value
|
// timeout waiting for v1 inital value
|
||||||
minePeriod := 2
|
minePeriod := 2
|
||||||
MinePeriodCh := w.engine.(*XDPoS.XDPoS).MinePeriodCh
|
MinePeriodCh := w.engine.(*XDPoS.XDPoS).MinePeriodCh
|
||||||
defer close(MinePeriodCh)
|
|
||||||
NewRoundCh := w.engine.(*XDPoS.XDPoS).NewRoundCh
|
NewRoundCh := w.engine.(*XDPoS.XDPoS).NewRoundCh
|
||||||
defer close(NewRoundCh)
|
|
||||||
|
|
||||||
timeout := time.NewTimer(time.Duration(minePeriod) * time.Second)
|
timeout := time.NewTimer(time.Duration(minePeriod) * time.Second)
|
||||||
defer timeout.Stop()
|
defer timeout.Stop()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue