Skip to content

NewPoW

Source (upstream pre-purge) Current
File miner/miner.go miner_pow.go
Symbol New NewPoW
Ref dde2da0ef~1 etc/v1.17.3-full-node

PoW miner constructor. Creates powWorker and initializes lifecycle channels. Downloader event coordination (update loop) moved to eth/backend_mining_pow.go to avoid import cycle with eth/downloader.

3-way merge — purge → getc ← upstream

pre-purgeupstreamcommon≈ adapted (origin inferred by similarity)fork-only
// NewPoW creates a new miner with PoW mining support.
// The downloader event loop (update) is managed by the eth backend
// to avoid an import cycle with eth/downloader.
func NewPoW(eth Backend, config Config, engine consensus.Engine, mux *event.TypeMux) *Miner {
m := &Miner{
config: &config,
chainConfig: eth.BlockChain().Config(),
engine: engine,
txpool: eth.TxPool(),
chain: eth.BlockChain(),
pending: &pending{},
mux: mux,
exitCh: make(chan struct{}),
startCh: make(chan struct{}),
stopCh: make(chan struct{}),
}
m.powWorker = newPowWorker(m, eth.BlockChain(), eth.TxPool(), engine, mux)
return m
}
core-geth validation — +13 -8 | | | |---|---| | File | [`miner.go`](https://github.com/etclabscore/core-geth/blob/v1.12.20/miner/miner.go) | | Symbol | `New` | | Ref | `v1.12.20` |
--- a/core-geth/miner/miner.go
+++ b/etc/miner/miner_pow.go
@@ -1,14 +1,19 @@
-func New(eth Backend, config *Config, chainConfig ctypes.ChainConfigurator, mux *event.TypeMux, engine consensus.Engine, isLocalBlock func(header *types.Header) bool) *Miner {
-   miner := &Miner{
-       mux:     mux,
-       eth:     eth,
+// NewPoW creates a new miner with PoW mining support.
+// The downloader event loop (update) is managed by the eth backend
+// to avoid an import cycle with eth/downloader.
+func NewPoW(eth Backend, config Config, engine consensus.Engine, mux *event.TypeMux) *Miner {
+   m := &Miner{
+       config:      &config,
+       chainConfig: eth.BlockChain().Config(),
        engine:  engine,
+       txpool:      eth.TxPool(),
+       chain:       eth.BlockChain(),
+       pending:     &pending{},
+       mux:         mux,
        exitCh:  make(chan struct{}),
        startCh: make(chan struct{}),
        stopCh:  make(chan struct{}),
-       worker:  newWorker(config, chainConfig, engine, eth, mux, isLocalBlock, true),
    }
-   miner.wg.Add(1)
-   go miner.update()
-   return miner
+   m.powWorker = newPowWorker(m, eth.BlockChain(), eth.TxPool(), engine, mux)
+   return m
 }

← Miner