Documentation
¶
Index ¶
- type DidHandleMessage
- type Options
- type Replica
- func (replica *Replica) Precommit(ctx context.Context, precommit process.Precommit)
- func (replica *Replica) Prevote(ctx context.Context, prevote process.Prevote)
- func (replica *Replica) Propose(ctx context.Context, propose process.Propose)
- func (replica *Replica) ResetHeight(ctx context.Context, newHeight process.Height)
- func (replica *Replica) Run(ctx context.Context)
- func (replica Replica) State(ctx context.Context) (process.Height, process.Round, process.Step, error)
- func (replica *Replica) TimeoutPrecommit(ctx context.Context, timeout timer.Timeout)
- func (replica *Replica) TimeoutPrevote(ctx context.Context, timeout timer.Timeout)
- func (replica *Replica) TimeoutPropose(ctx context.Context, timeout timer.Timeout)
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
StartingHeight process.Height
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
WithLogger updates the logger used in the Replica with the provided logger
func (Options) WithMqOptions ¶ added in v0.4.1
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) Precommit ¶ added in v0.4.0
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
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
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
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.
NOTE: All messages that are currently in the message queue for heights less than the given height will be dropped.
func (Replica) State ¶ added in v0.4.1
func (replica Replica) State(ctx context.Context) (process.Height, process.Round, process.Step, error)
State returns the current height, round and step of the underlying process.
func (*Replica) TimeoutPrecommit ¶ added in v0.4.1
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
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
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