()
| 437 | } |
| 438 | |
| 439 | func (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 | |
| 470 | func (c *Chain) processBlocks(ctx context.Context) { |
| 471 | for { |
no test coverage detected