synchronizer

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package synchronizer implements the synchronizer module.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(viewDuration ViewDuration) modules.Synchronizer

New creates a new Synchronizer.

func TimeoutContext added in v0.5.0

func TimeoutContext(parent context.Context, eventLoop *eventloop.EventLoop) (context.Context, context.CancelFunc)

TimeoutContext returns a context that is canceled either when a timeout occurs, or when the view changes.

func ViewContext added in v0.5.0

func ViewContext(parent context.Context, eventLoop *eventloop.EventLoop, view *hotstuff.View) (context.Context, context.CancelFunc)

ViewContext returns a context that is canceled at the end of view. If view is nil or less than or equal to the current view, the context will be canceled at the next view change.

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 hotstuff.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() hotstuff.QuorumCert

HighQC returns the highest known QC.

func (*Synchronizer) InitModule added in v0.5.0

func (s *Synchronizer) InitModule(mods *modules.Core)

InitModule initializes the synchronizer.

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 hotstuff.NewViewMsg)

OnNewView handles an incoming consensus.NewViewMsg

func (*Synchronizer) OnRemoteTimeout added in v0.3.0

func (s *Synchronizer) OnRemoteTimeout(timeout hotstuff.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() hotstuff.SyncInfo

SyncInfo returns the highest known QC or TC.

func (*Synchronizer) View added in v0.3.0

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

View returns the current view.

type TimeoutEvent added in v0.5.0

type TimeoutEvent struct {
	View hotstuff.View
}

TimeoutEvent is sent on the eventloop when a local timeout occurs.

type ViewChangeEvent added in v0.3.0

type ViewChangeEvent struct {
	View    hotstuff.View
	Timeout bool
}

ViewChangeEvent is sent on the eventloop 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 NewFixedViewDuration added in v0.5.0

func NewFixedViewDuration(duration time.Duration) ViewDuration

NewFixedViewDuration returns a ViewDuration with a fixed duration.

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