MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / produceBlock

Method produceBlock

blockproducer/chain.go:378–400  ·  view source on GitHub ↗
(now time.Time)

Source from the content-addressed store, hash-verified

376}
377
378func (c *Chain) produceBlock(now time.Time) (err error) {
379 var (
380 priv *asymmetric.PrivateKey
381 b *types.BPBlock
382 )
383
384 if priv, err = kms.GetLocalPrivateKey(); err != nil {
385 return
386 }
387 if b, err = c.produceAndStoreBlock(now, priv); err != nil {
388 return
389 }
390
391 log.WithFields(log.Fields{
392 "block_time": b.Timestamp(),
393 "block_hash": b.BlockHash().Short(4),
394 "parent_hash": b.ParentHash().Short(4),
395 }).Debug("produced new block")
396
397 // Broadcast to other block producers
398 c.nonblockingBroadcastBlock(b)
399 return
400}
401
402// advanceNextHeight does the check and runs block producing if its my turn.
403func (c *Chain) advanceNextHeight(now time.Time, d time.Duration) {

Callers 3

advanceNextHeightMethod · 0.95
TestChainFunction · 0.45
produceAndStoreBlockMethod · 0.45

Calls 9

produceAndStoreBlockMethod · 0.95
GetLocalPrivateKeyFunction · 0.92
WithFieldsFunction · 0.92
DebugMethod · 0.80
ShortMethod · 0.80
TimestampMethod · 0.45
BlockHashMethod · 0.45
ParentHashMethod · 0.45

Tested by 1

TestChainFunction · 0.36