(ctx context.Context, requiredReachable uint32)
| 617 | } |
| 618 | |
| 619 | func (c *Chain) blockingSyncCurrentHead(ctx context.Context, requiredReachable uint32) (err error) { |
| 620 | var ( |
| 621 | ticker *time.Ticker |
| 622 | interval = 1 * time.Second |
| 623 | ) |
| 624 | if c.tick < interval { |
| 625 | interval = c.tick |
| 626 | } |
| 627 | ticker = time.NewTicker(interval) |
| 628 | defer ticker.Stop() |
| 629 | for { |
| 630 | if c.syncCurrentHead(ctx, requiredReachable) { |
| 631 | return |
| 632 | } |
| 633 | select { |
| 634 | case <-ticker.C: |
| 635 | case <-ctx.Done(): |
| 636 | err = ctx.Err() |
| 637 | return |
| 638 | } |
| 639 | } |
| 640 | } |
| 641 | |
| 642 | // syncCurrentHead synchronizes a block at the current height of the local peer from the known |
| 643 | // remote peers. The return value `ok` indicates that there're at least `requiredReachable-1` |
no test coverage detected