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

Method makeCurrentWork

miner/engine.go:354–380  ·  view source on GitHub ↗

makeCurrentWork creates a new environment for the current cycle.

(parent *types.Block, header *types.Header)

Source from the content-addressed store, hash-verified

352
353// makeCurrentWork creates a new environment for the current cycle.
354func (e *engine) makeCurrentWork(parent *types.Block, header *types.Header) error {
355 pubState, err := e.chain.StateAt(parent.StateRoot())
356 if err != nil {
357 return err
358 }
359
360 privState, err := e.chain.StatePrivAt(parent.StateRoot())
361 if err != nil {
362 return err
363 }
364
365 work := &Work{
366 config: e.config,
367 signer: types.NewCep1Signer(e.config.ChainID),
368 pubState: pubState,
369 privState: privState,
370 header: header,
371 createdAt: time.Now(),
372 remoteDB: e.chain.RemoteDB(),
373 accm: e.backend.AccountManager(),
374 }
375
376 // Keep track of transactions which return errors so they can be removed
377 work.tcount = 0
378 e.currentWork = work
379 return nil
380}
381
382// commitNewWork creates a new block. Calling this function multiple times will abort the previous work on workers.
383func (e *engine) commitNewWork() {

Callers 1

commitNewWorkMethod · 0.95

Calls 6

StateRootMethod · 0.80
StatePrivAtMethod · 0.80
StateAtMethod · 0.65
NowMethod · 0.65
RemoteDBMethod · 0.65
AccountManagerMethod · 0.65

Tested by

no test coverage detected