mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
eth: fix tx looper startup and shutdown
This commit is contained in:
parent
b443c3c215
commit
c04c1c44fb
1 changed files with 6 additions and 14 deletions
|
|
@ -182,20 +182,7 @@ func newHandler(config *handlerConfig) (*handler, error) {
|
||||||
}
|
}
|
||||||
// Construct the downloader (long sync)
|
// Construct the downloader (long sync)
|
||||||
h.downloader = downloader.New(config.Database, h.eventMux, h.chain, nil, h.removePeer, h.enableSyncedFeatures)
|
h.downloader = downloader.New(config.Database, h.eventMux, h.chain, nil, h.removePeer, h.enableSyncedFeatures)
|
||||||
if ttd := h.chain.Config().TerminalTotalDifficulty; ttd != nil {
|
|
||||||
if h.chain.Config().TerminalTotalDifficultyPassed {
|
|
||||||
log.Info("Chain post-merge, sync via beacon client")
|
|
||||||
} else {
|
|
||||||
head := h.chain.CurrentBlock()
|
|
||||||
if td := h.chain.GetTd(head.Hash(), head.Number.Uint64()); td.Cmp(ttd) >= 0 {
|
|
||||||
log.Info("Chain post-TTD, sync via beacon client")
|
|
||||||
} else {
|
|
||||||
log.Warn("Chain pre-merge, sync via PoW (ensure beacon client is ready)")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if h.chain.Config().TerminalTotalDifficultyPassed {
|
|
||||||
log.Error("Chain configured post-merge, but without TTD. Are you debugging sync?")
|
|
||||||
}
|
|
||||||
fetchTx := func(peer string, hashes []common.Hash) error {
|
fetchTx := func(peer string, hashes []common.Hash) error {
|
||||||
p := h.peers.peer(peer)
|
p := h.peers.peer(peer)
|
||||||
if p == nil {
|
if p == nil {
|
||||||
|
|
@ -442,6 +429,9 @@ func (h *handler) Start(maxPeers int) {
|
||||||
h.txsSub = h.txpool.SubscribeTransactions(h.txsCh, false)
|
h.txsSub = h.txpool.SubscribeTransactions(h.txsCh, false)
|
||||||
go h.txBroadcastLoop()
|
go h.txBroadcastLoop()
|
||||||
|
|
||||||
|
// start sync handlers
|
||||||
|
h.txFetcher.Start()
|
||||||
|
|
||||||
// start peer handler tracker
|
// start peer handler tracker
|
||||||
h.wg.Add(1)
|
h.wg.Add(1)
|
||||||
go h.protoTracker()
|
go h.protoTracker()
|
||||||
|
|
@ -449,6 +439,8 @@ func (h *handler) Start(maxPeers int) {
|
||||||
|
|
||||||
func (h *handler) Stop() {
|
func (h *handler) Stop() {
|
||||||
h.txsSub.Unsubscribe() // quits txBroadcastLoop
|
h.txsSub.Unsubscribe() // quits txBroadcastLoop
|
||||||
|
h.txFetcher.Stop()
|
||||||
|
h.downloader.Terminate()
|
||||||
|
|
||||||
// Quit chainSync and txsync64.
|
// Quit chainSync and txsync64.
|
||||||
// After this is done, no new peers will be accepted.
|
// After this is done, no new peers will be accepted.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue