mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
use an elegant way to close the coroutine instead of closing it inside a function
This commit is contained in:
parent
ffac091de8
commit
fea1f5bbf8
1 changed files with 9 additions and 5 deletions
|
|
@ -312,7 +312,10 @@ func (pool *LegacyPool) Init(gasTip uint64, head *types.Header, reserve txpool.A
|
|||
// Start the reorg loop early, so it can handle requests generated during
|
||||
// journal loading.
|
||||
pool.wg.Add(1)
|
||||
go pool.scheduleReorgLoop()
|
||||
go func() {
|
||||
defer pool.wg.Done()
|
||||
pool.scheduleReorgLoop()
|
||||
}()
|
||||
|
||||
// If local transactions and journaling is enabled, load from disk
|
||||
if pool.journal != nil {
|
||||
|
|
@ -324,7 +327,11 @@ func (pool *LegacyPool) Init(gasTip uint64, head *types.Header, reserve txpool.A
|
|||
}
|
||||
}
|
||||
pool.wg.Add(1)
|
||||
go pool.loop()
|
||||
go func() {
|
||||
defer pool.wg.Done()
|
||||
pool.loop()
|
||||
}()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -332,7 +339,6 @@ func (pool *LegacyPool) Init(gasTip uint64, head *types.Header, reserve txpool.A
|
|||
// outside blockchain events as well as for various reporting and transaction
|
||||
// eviction events.
|
||||
func (pool *LegacyPool) loop() {
|
||||
defer pool.wg.Done()
|
||||
|
||||
var (
|
||||
prevPending, prevQueued, prevStales int
|
||||
|
|
@ -1188,8 +1194,6 @@ func (pool *LegacyPool) queueTxEvent(tx *types.Transaction) {
|
|||
// call those methods directly, but request them being run using requestReset and
|
||||
// requestPromoteExecutables instead.
|
||||
func (pool *LegacyPool) scheduleReorgLoop() {
|
||||
defer pool.wg.Done()
|
||||
|
||||
var (
|
||||
curDone chan struct{} // non-nil while runReorg is active
|
||||
nextDone = make(chan struct{})
|
||||
|
|
|
|||
Loading…
Reference in a new issue