round

package
v0.0.0-...-648c852 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrClosedRound = errors.New("closed round access")

ErrClosedRound singles that Round is accessed after being closed

View Source
var ErrElapsedRound = errors.New("elapsed round")

ErrElapsedRound is thrown when a requested height was already provided to Manager.

Functions

This section is empty.

Types

type Manager

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

Manager registers and manages lifecycles for every new Round. It also provides a simple subscription mechanism in Manager.GetRound operations which are fulfilled with Manager.StartRound.

func NewManager

func NewManager() *Manager

NewManager instantiates a new Manager.

func (*Manager) GetRound

func (rm *Manager) GetRound(ctx context.Context, roundNum uint64) (*Round, error)

GetRound gets Round from local map by the number or subscribes for the Round to come, if not found.

func (*Manager) StartRound

func (rm *Manager) StartRound(roundNum uint64, qcomm rebro.QuorumCertificate) (*Round, error)

StartRound instantiates and starts a new Round. It adds the Round to the Manager, notifying all the Manager.GetRound waiters.

func (*Manager) Stop

func (rm *Manager) Stop(ctx context.Context) error

Stop performs Round.Finalize and Round.Stop on all the registered instances of Round and then terminates. This ensures we retain in-progress Round state.

func (*Manager) StopRound

func (rm *Manager) StopRound(ctx context.Context, roundNum uint64) error

StopRound stops Round and deletes it from the Manager together with the active subscriptions for it. It does not wait for the Round finalization and that's a caller's concern.

type Round

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

Round maintains state of broadcasting rounds and local pubsub system for certificates. It guards rebro.QuorumCertificate from concurrent access ensuring thread-safety. Round is not concerned of validity of any given input and solely acting as a state machine of the broadcasting round.

func NewRound

func NewRound(roundNum uint64, quorum rebro.QuorumCertificate) *Round

NewRound instantiates a new Round state machine wrapping rebro.QuorumCertificate. This passes full ownership of the rebro.QuorumCertificate fully to Round, thus it must not be used for writes until Round has been stopped.

func (*Round) AddCertificate

func (r *Round) AddCertificate(ctx context.Context, msg rebro.Message) error

AddCertificate add the given message to the Round forming a new rebro.Certificate on rebro.QuorumCertificate.

func (*Round) AddSignature

func (r *Round) AddSignature(ctx context.Context, id rebro.MessageID, sig crypto.Signature) error

AddSignature appends a Signature to one of the Round's Certificates.

func (*Round) DeleteCertificate

func (r *Round) DeleteCertificate(ctx context.Context, id rebro.MessageID) error

DeleteCertificate deletes certificate from the Round by the associated rebro.MessageID.

func (*Round) Finalize

func (r *Round) Finalize(ctx context.Context) error

Finalize awaits finalization of the Round's rebro.QuorumCertificate.

func (*Round) GetCertificate

func (r *Round) GetCertificate(ctx context.Context, id rebro.MessageID) (rebro.Certificate, error)

GetCertificate gets certificate from the Round by the associated rebro.MessageID.

func (*Round) RoundNumber

func (r *Round) RoundNumber() uint64

RoundNumber provides number of the Round.

func (*Round) Stop

func (r *Round) Stop(ctx context.Context) error

Stop gracefully stops the Round allowing early termination through context. It ensures all the in-progress state operations are completed before termination.

Jump to

Keyboard shortcuts

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