synchronizer

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 6, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(viewDuration ViewDuration) consensus.Synchronizer

New creates a new Synchronizer.

Types

type Synchronizer

type Synchronizer struct {
	// contains filtered or unexported fields
}

Synchronizer synchronizes replicas to the same view.

func (*Synchronizer) AdvanceView added in v0.3.0

func (s *Synchronizer) AdvanceView(syncInfo consensus.SyncInfo)

AdvanceView attempts to advance to the next view using the given QC. qc must be either a regular quorum certificate, or a timeout certificate.

func (*Synchronizer) HighQC added in v0.3.0

func (s *Synchronizer) HighQC() consensus.QuorumCert

HighQC returns the highest known QC.

func (*Synchronizer) InitConsensusModule added in v0.3.0

func (s *Synchronizer) InitConsensusModule(mods *consensus.Modules, opts *consensus.OptionsBuilder)

InitConsensusModule gives the module a reference to the Modules object. It also allows the module to set module options using the OptionsBuilder.

func (*Synchronizer) LeafBlock added in v0.3.0

func (s *Synchronizer) LeafBlock() *consensus.Block

LeafBlock returns the current leaf block.

func (*Synchronizer) OnLocalTimeout added in v0.4.0

func (s *Synchronizer) OnLocalTimeout()

OnLocalTimeout is called when a local timeout happens.

func (*Synchronizer) OnNewView

func (s *Synchronizer) OnNewView(newView consensus.NewViewMsg)

OnNewView handles an incoming consensus.NewViewMsg

func (*Synchronizer) OnRemoteTimeout added in v0.3.0

func (s *Synchronizer) OnRemoteTimeout(timeout consensus.TimeoutMsg)

OnRemoteTimeout handles an incoming timeout from a remote replica.

func (*Synchronizer) Start

func (s *Synchronizer) Start(ctx context.Context)

Start starts the synchronizer with the given context.

func (*Synchronizer) SyncInfo added in v0.3.0

func (s *Synchronizer) SyncInfo() consensus.SyncInfo

SyncInfo returns the highest known QC or TC.

func (*Synchronizer) UpdateHighQC added in v0.3.0

func (s *Synchronizer) UpdateHighQC(qc consensus.QuorumCert)

UpdateHighQC updates HighQC if the given qc is higher than the old HighQC.

func (*Synchronizer) View added in v0.3.0

func (s *Synchronizer) View() consensus.View

View returns the current view.

func (*Synchronizer) ViewContext added in v0.3.0

func (s *Synchronizer) ViewContext() context.Context

ViewContext returns a context that is cancelled at the end of the view.

type ViewChangeEvent added in v0.3.0

type ViewChangeEvent struct {
	View    consensus.View
	Timeout bool
}

ViewChangeEvent is sent on the metrics event loop whenever a view change occurs.

type ViewDuration added in v0.3.0

type ViewDuration interface {
	// Duration returns the duration that the next view should last.
	Duration() time.Duration
	// ViewStarted is called by the synchronizer when starting a new view.
	ViewStarted()
	// ViewSucceeded is called by the synchronizer when a view ended successfully.
	ViewSucceeded()
	// ViewTimeout is called by the synchronizer when a view timed out.
	ViewTimeout()
}

ViewDuration determines the duration of a view. The view synchronizer uses this interface to set its timeouts.

func NewViewDuration added in v0.3.0

func NewViewDuration(sampleSize uint64, startTimeout, maxTimeout, multiplier float64) ViewDuration

NewViewDuration returns a ViewDuration that approximates the view duration based on durations of previous views. sampleSize determines the number of previous views that should be considered. startTimeout determines the view duration of the first views. When a timeout occurs, the next view duration will be multiplied by the multiplier.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL