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

Function makeHeader

core/chain_makers.go:227–249  ·  view source on GitHub ↗
(chain consensus.ChainReader, parent *types.Block, state *state.StateDB, engine consensus.Engine)

Source from the content-addressed store, hash-verified

225}
226
227func makeHeader(chain consensus.ChainReader, parent *types.Block, state *state.StateDB, engine consensus.Engine) *types.Header {
228 var time *big.Int
229 if parent.Time() == nil {
230 time = big.NewInt(10)
231 } else {
232 time = new(big.Int).Add(parent.Time(), big.NewInt(10)) // block time is fixed at 10 seconds
233 }
234
235 header := &types.Header{}
236
237 header.Number = new(big.Int).Add(parent.Number(), common.Big1)
238 header.ParentHash = parent.Hash()
239
240 _ = engine.PrepareBlock(chain, header)
241
242 header.StateRoot = state.IntermediateRoot(true)
243 header.Coinbase = parent.Coinbase()
244 header.GasLimit = CalcGasLimit(parent)
245
246 header.Time = time
247
248 return header
249}
250
251// makeHeaderChain creates a deterministic chain of headers rooted at parent.
252func makeHeaderChain(parent *types.Header, n int, engine consensus.Engine, db database.Database, seed int) []*types.Header {

Callers 1

GenerateChainFunction · 0.85

Calls 8

CalcGasLimitFunction · 0.85
TimeMethod · 0.80
IntermediateRootMethod · 0.80
AddMethod · 0.65
HashMethod · 0.65
PrepareBlockMethod · 0.65
CoinbaseMethod · 0.65
NumberMethod · 0.45

Tested by

no test coverage detected