replica

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2020 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockIterator added in v0.2.0

type BlockIterator interface {
	// NextBlock returns the `block.Txs`, `block.Plan` and the parent
	// `block.State` for the given `block.Height`.
	NextBlock(block.Kind, block.Height, Shard) (block.Txs, block.Plan, block.State)
}

type BlockStorage added in v0.2.0

type BlockStorage interface {
	Blockchain(shard Shard) process.Blockchain
	LatestBlock(shard Shard) block.Block
	LatestBaseBlock(shard Shard) block.Block
}

BlockStorage extends the `process.Blockchain` interface with the functionality to load the last committed `block.Standard`, and the last committed `block.Base`.

type Broadcaster added in v0.2.0

type Broadcaster interface {
	Broadcast(Message)
	Cast(id.Signatory, Message)
}

A Broadcaster is used to send signed, shard-specific, Messages to one or all Replicas in the network.

type Message added in v0.2.0

type Message struct {
	Message process.Message
	Shard   Shard
}

A Message sent/received by a Replica is composed of a Shard and the underlying `process.Message` data. It is expected that a Replica will sign the underlying `process.Message` data before sending the Message.

func (Message) Marshal added in v0.4.2

func (message Message) Marshal(w io.Writer, m int) (int, error)

Marshal this message into binary.

func (Message) SizeHint added in v0.4.2

func (message Message) SizeHint() int

SizeHint returns the number of bytes requires to store this message in binary.

func (*Message) Unmarshal added in v0.4.2

func (message *Message) Unmarshal(r io.Reader, m int) (int, error)

Unmarshal into this message from binary.

type Messages added in v0.2.0

type Messages []Message

type Observer added in v0.2.0

type Observer interface {
	DidCommitBlock(block.Height, Shard)
	DidReceiveSufficientNilPrevotes(messages process.Messages, f int)
	IsSignatory(Shard) bool
}

type Options added in v0.2.0

type Options struct {
	// Logging
	Logger logrus.FieldLogger

	// Timeout options for proposing, prevoting, and precommiting
	BackOffExp  float64
	BackOffBase time.Duration
	BackOffMax  time.Duration
}

Options define a set of properties that can be used to parameterise the Replica and its behaviour.

type ProcessStorage added in v0.2.0

type ProcessStorage interface {
	SaveState(state *process.State, shard Shard)
	RestoreState(state *process.State, shard Shard)
}

ProcessStorage saves and restores `process.State` to persistent memory. This guarantees that in the event of an unexpected shutdown, the Replica will only drop the `process.Message` that was currently being handling.

type Replica

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

A Replica represents one Process in a replicated state machine that is bound to a specific Shard. It signs Messages before sending them to other Replicas, and verifies Messages before accepting them from other Replicas.

func New

func New(options Options, pStorage ProcessStorage, blockStorage BlockStorage, blockIterator BlockIterator, validator Validator, observer Observer, broadcaster Broadcaster, shard Shard, privKey ecdsa.PrivateKey) Replica

func (*Replica) HandleMessage added in v0.2.0

func (replica *Replica) HandleMessage(m Message)

func (*Replica) Rebase added in v0.2.0

func (replica *Replica) Rebase(sigs id.Signatories)

func (*Replica) Start added in v0.2.0

func (replica *Replica) Start()

type Replicas added in v0.2.0

type Replicas []Replica

type Shard added in v0.2.0

type Shard [32]byte

Shard uniquely identifies the Shard being maintained by the Replica.

func (Shard) Equal added in v0.2.0

func (shard Shard) Equal(other Shard) bool

Equal compares one Shard with another.

func (Shard) Marshal added in v0.4.2

func (shard Shard) Marshal(w io.Writer, m int) (int, error)

func (Shard) SizeHint added in v0.4.2

func (shard Shard) SizeHint() int

func (Shard) String added in v0.2.0

func (shard Shard) String() string

String implements the `fmt.Stringer` interface.

func (*Shard) Unmarshal added in v0.4.2

func (shard *Shard) Unmarshal(r io.Reader, m int) (int, error)

type Shards added in v0.2.0

type Shards []Shard

type Validator

type Validator interface {
	IsBlockValid(block block.Block, checkHistory bool, shard Shard) (process.NilReasons, error)
}

Jump to

Keyboard shortcuts

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