MCPcopy Create free account
hub / github.com/CPChain/chain / newEngine

Function newEngine

miner/engine.go:121–145  ·  view source on GitHub ↗
(config *configs.ChainConfig, cons consensus.Engine, coinbase common.Address, backend Backend, mux *event.TypeMux)

Source from the content-addressed store, hash-verified

119}
120
121func newEngine(config *configs.ChainConfig, cons consensus.Engine, coinbase common.Address, backend Backend, mux *event.TypeMux) *engine {
122 e := &engine{
123 config: config,
124 cons: cons,
125 backend: backend,
126 mux: mux,
127 txsCh: make(chan core.NewTxsEvent, txChanSize),
128 chainLatestCh: make(chan core.ChainLatestEvent, chainLatestChanSize),
129 chainSideCh: make(chan core.ChainSideEvent, chainSideChanSize),
130 quitCh: make(chan struct{}),
131 chainDb: backend.ChainDb(),
132 recv: make(chan *Result, resultQueueSize),
133 chain: backend.BlockChain(),
134 proc: backend.BlockChain().Validator(), // processor validator lock
135 coinbase: coinbase,
136 workers: make(map[Worker]struct{}),
137 }
138
139 // initially commit new work to make pending block and snapshot availableklk
140 if backend.BlockChain().SyncMode() == syncer.FullSync {
141 go e.update()
142 e.commitNewWork()
143 }
144 return e
145}
146
147func (e *engine) setCoinbase(addr common.Address) {
148 e.mu.Lock()

Callers 1

NewFunction · 0.85

Calls 6

updateMethod · 0.95
commitNewWorkMethod · 0.95
ValidatorMethod · 0.80
SyncModeMethod · 0.80
ChainDbMethod · 0.65
BlockChainMethod · 0.65

Tested by

no test coverage detected