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

Method syncHeads

blockproducer/chain.go:439–468  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

437}
438
439func (c *Chain) syncHeads() {
440 for {
441 var (
442 now = c.now()
443 nowHeight uint32
444 )
445 if now.Before(c.genesisTime) {
446 log.WithFields(log.Fields{
447 "local": c.getLocalBPInfo(),
448 }).Info("now time is before genesis time, waiting for genesis")
449 break
450 }
451 if nowHeight = c.heightOfTime(c.now()); c.getNextHeight() > nowHeight {
452 break
453 }
454 for c.getNextHeight() <= nowHeight {
455 // TODO(leventeliu): use the test mode flag to bypass the long-running synchronizing
456 // on startup by now, need better solution here.
457 if conf.GConf.StartupSyncHoles {
458 log.WithFields(log.Fields{
459 "local": c.getLocalBPInfo(),
460 "next_height": c.getNextHeight(),
461 "now_height": nowHeight,
462 }).Debug("synchronizing head blocks")
463 c.blockingSyncCurrentHead(c.ctx, conf.BPStartupRequiredReachableCount)
464 }
465 c.increaseNextHeight()
466 }
467 }
468}
469
470func (c *Chain) processBlocks(ctx context.Context) {
471 for {

Callers 1

StartMethod · 0.95

Calls 9

nowMethod · 0.95
getLocalBPInfoMethod · 0.95
heightOfTimeMethod · 0.95
getNextHeightMethod · 0.95
increaseNextHeightMethod · 0.95
WithFieldsFunction · 0.92
InfoMethod · 0.80
DebugMethod · 0.80

Tested by

no test coverage detected