replica

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2021 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DidHandleMessage added in v0.4.1

type DidHandleMessage func()

DidHandleMessage is called by the Replica after it has finished handling an input message (i.e. Propose, Prevote, or Precommit), or timeout. The message could have been either accepted and inserted into the processing queue, or filtered out and dropped. The callback is also called when the context within which the Replica runs gets cancelled.

type Options added in v0.2.0

type Options struct {
	Logger           *zap.Logger
	MessageQueueOpts mq.Options
}

Options represent the options for a Hyperdrive Replica

func DefaultOptions added in v0.4.0

func DefaultOptions() Options

DefaultOptions returns the default options for a Hyperdrive Replica

func (Options) WithLogger added in v0.4.1

func (opts Options) WithLogger(logger *zap.Logger) Options

WithLogger updates the logger used in the Replica with the provided logger

func (Options) WithMqOptions added in v0.4.1

func (opts Options) WithMqOptions(mqOpts mq.Options) Options

WithMqOptions updates the Replica's message queue options

type Replica

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

A Replica represents a process in a replicated state machine that participates in the Hyperdrive Consensus Algorithm. It encapsulates a Hyperdrive Process and exposes an interface for the Hyperdrive user to insert messages (propose, prevote, precommit, timeouts). A Replica then handles these messages asynchronously, after sorting them in an increasing order of height and round. A Replica is instantiated by passing in the set of signatories participating in the consensus mechanism, and it filters out messages that have not been sent by one of the known set of allowed signatories.

func New

func New(
	opts Options,
	whoami id.Signatory,
	signatories []id.Signatory,
	linearTimer process.Timer,
	propose process.Proposer,
	validate process.Validator,
	commit process.Committer,
	catch process.Catcher,
	broadcast process.Broadcaster,
	didHandleMessage DidHandleMessage,
) *Replica

New instantiates and returns a pointer to a new Hyperdrive replica machine

func (Replica) CurrentHeight added in v0.4.1

func (replica Replica) CurrentHeight() process.Height

CurrentHeight returns the current height of the underlying process.

func (*Replica) Precommit added in v0.4.0

func (replica *Replica) Precommit(ctx context.Context, precommit process.Precommit)

Precommit adds a precommit message to the replica. This message will be asynchronously inserted into the replica's message queue asynchronously, and consumed when the replica does not have any immediate task to do

func (*Replica) Prevote added in v0.4.0

func (replica *Replica) Prevote(ctx context.Context, prevote process.Prevote)

Prevote adds a prevote message to the replica. This message will be asynchronously inserted into the replica's message queue asynchronously, and consumed when the replica does not have any immediate task to do

func (*Replica) Propose added in v0.4.0

func (replica *Replica) Propose(ctx context.Context, propose process.Propose)

Propose adds a propose message to the replica. This message will be asynchronously inserted into the replica's message queue asynchronously, and consumed when the replica does not have any immediate task to do

func (*Replica) ResetHeight added in v0.4.1

func (replica *Replica) ResetHeight(newHeight process.Height)

ResetHeight of the underlying process to a future height. This is should only be used when resynchronising the chain. If the given height is less than or equal to the current height, nothing happens.

func (*Replica) Run added in v0.4.0

func (replica *Replica) Run(ctx context.Context)

Run starts the Hyperdrive replica's process

func (Replica) State added in v0.4.1

func (replica Replica) State() (process.Height, process.Round, process.Step)

State returns the current height, round and step of the underlying process.

func (*Replica) TimeoutPrecommit added in v0.4.1

func (replica *Replica) TimeoutPrecommit(ctx context.Context, timeout timer.Timeout)

TimeoutPrecommit adds a precommit timeout message to the replica. This message will be filtered based on the replica's consensus height, and inserted asynchronously into the replica's message queue. It will be consumed when the replica does not have any immediate task to do

func (*Replica) TimeoutPrevote added in v0.4.1

func (replica *Replica) TimeoutPrevote(ctx context.Context, timeout timer.Timeout)

TimeoutPrevote adds a prevote timeout message to the replica. This message will be filtered based on the replica's consensus height, and inserted asynchronously into the replica's message queue. It will be consumed when the replica does not have any immediate task to do

func (*Replica) TimeoutPropose added in v0.4.1

func (replica *Replica) TimeoutPropose(ctx context.Context, timeout timer.Timeout)

TimeoutPropose adds a propose timeout message to the replica. This message will be filtered based on the replica's consensus height, and inserted asynchronously into the replica's message queue. It will be consumed when the replica does not have any immediate task to do

Jump to

Keyboard shortcuts

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