// FinalizeBlocks continuously attempts to finalize blocks.
FinalizeBlocks continuously attempts to finalize blocks.
// FinalizeBlocks continuously attempts to finalize blocks .
func (l *Ledger) FinalizeBlocks() {
	defer l.consensus.Done()
	b := &backoff.Backoff{Min: 0 * time.Second, Max: 200 * time.Millisecond, Factor: 1.25, Jitter: true}
	for {
		select {
		case <-l.consensusStop:
			return
		default:
		}
		decided := l.finalizer.Decided()
		preferred := l.finalizer.Preferred()
		if preferred == nil {
			proposedBlock := l.proposeBlock()
			if proposedBlock != nil {
				logger := log.Consensus("proposal")
				logger.Debug().
					Hex("block_id", proposedBlock.ID[:]).
					Uint64("block_index", proposedBlock.Index).
					Int("num_transactions", len(proposedBlock.Transactions)).
					Msg("Proposing block...")
				l.finalizer.Prefer(&finalizationVote{
					voter: l.client.ID(),
					block: proposedBlock,
				})
				b.Reset()
			} else {
				t := time.NewTicker(b.Duration())
				select {
				case <-l.consensusStop:
					t.Stop()
					return
				case <-t.C:
					t.Stop()
				}
			}
		} else {
			if decided {
				l.finalize(*preferred.Value().(*Block))
			} else {
				l.query()
			}
		}
	}
}
func ( l * Ledger ) FinalizeBlocks ( ) { defer l . consensus . Done ( ) b := & backoff . Backoff { Min : 0 * time . Second , Max : 200 * time . Millisecond , Factor : 1.25 , Jitter : true } for { select { case <- l . consensusStop : return default : } decided := l . finalizer . Decided ( ) preferred := l . finalizer . Preferred ( ) if preferred == nil { proposedBlock := l . proposeBlock ( ) if proposedBlock != nil { logger := log . Consensus ( " " ) logger . Debug ( ) . Hex ( " " , proposedBlock . ID [ : ] ) . Uint64 ( " " , proposedBlock . Index ) . Int ( " " , len ( proposedBlock . Transactions ) ) . Msg ( " " ) l . finalizer . Prefer ( & finalizationVote { voter : l . client . ID ( ) , block : proposedBlock , } ) b . Reset ( ) } else { t := time . NewTicker ( b . Duration ( ) ) select { case <- l . consensusStop : t . Stop ( ) return case <- t . C : t . Stop ( ) } } } else { if decided { l . finalize ( * preferred . Value ( ) . ( * Block ) ) } else { l . query ( ) } } } }
FinalizeBlocks continuously attempts to finalize blocks.
FinalizeBlocks continuously attempts to finalize blocks .