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

Method mainCycle

sqlchain/chain.go:694–714  ·  view source on GitHub ↗

mainCycle runs main cycle of the sql-chain.

(ctx context.Context)

Source from the content-addressed store, hash-verified

692
693// mainCycle runs main cycle of the sql-chain.
694func (c *Chain) mainCycle(ctx context.Context) {
695 for {
696 select {
697 case <-ctx.Done():
698 c.logEntry().WithError(ctx.Err()).Info("abort main cycle")
699 return
700 default:
701 if err := c.syncHead(); err != nil {
702 if err != ErrInitiating {
703 c.logEntry().WithError(err).Error("failed to sync head")
704 continue
705 }
706 }
707 if t, d := c.rt.nextTick(); d > 0 {
708 time.Sleep(d)
709 } else {
710 c.runCurrentTurn(t, d)
711 }
712 }
713 }
714}
715
716// sync synchronizes blocks and queries from the other peers.
717func (c *Chain) sync() (err error) {

Callers

nothing calls this directly

Calls 7

logEntryMethod · 0.95
syncHeadMethod · 0.95
runCurrentTurnMethod · 0.95
InfoMethod · 0.80
WithErrorMethod · 0.80
ErrorMethod · 0.80
nextTickMethod · 0.45

Tested by

no test coverage detected