Documentation
¶
Index ¶
- Constants
- func Sign(m Message, privKey ecdsa.PrivateKey) error
- func Verify(m Message) error
- type Blockchain
- type Broadcaster
- type Inbox
- func (inbox *Inbox) F() int
- func (inbox *Inbox) Insert(message Message) (n int, firstTime, firstTimeExceedingF, firstTimeExceeding2F, ... bool)
- func (inbox Inbox) MarshalBinary() ([]byte, error)
- func (inbox Inbox) MarshalJSON() ([]byte, error)
- func (inbox *Inbox) MessageType() MessageType
- func (inbox *Inbox) QueryByHeightRound(height block.Height, round block.Round) (n int)
- func (inbox *Inbox) QueryByHeightRoundBlockHash(height block.Height, round block.Round, blockHash id.Hash) (n int)
- func (inbox *Inbox) QueryByHeightRoundSignatory(height block.Height, round block.Round, sig id.Signatory) Message
- func (inbox *Inbox) QueryMessagesByHeightWithHigestRound(height block.Height) []Message
- func (inbox *Inbox) Reset(height block.Height)
- func (inbox *Inbox) UnmarshalBinary(data []byte) error
- func (inbox *Inbox) UnmarshalJSON(data []byte) error
- type LatestCommit
- type Message
- type MessageType
- type Messages
- type Observer
- type Precommit
- func (precommit *Precommit) BlockHash() id.Hash
- func (precommit *Precommit) Height() block.Height
- func (precommit Precommit) MarshalBinary() ([]byte, error)
- func (precommit Precommit) MarshalJSON() ([]byte, error)
- func (precommit *Precommit) Round() block.Round
- func (precommit *Precommit) Sig() id.Signature
- func (precommit *Precommit) SigHash() id.Hash
- func (precommit *Precommit) Signatory() id.Signatory
- func (precommit *Precommit) String() string
- func (precommit *Precommit) Type() MessageType
- func (precommit *Precommit) UnmarshalBinary(data []byte) error
- func (precommit *Precommit) UnmarshalJSON(data []byte) error
- type Precommits
- type Prevote
- func (prevote *Prevote) BlockHash() id.Hash
- func (prevote *Prevote) Height() block.Height
- func (prevote Prevote) MarshalBinary() ([]byte, error)
- func (prevote Prevote) MarshalJSON() ([]byte, error)
- func (prevote *Prevote) Round() block.Round
- func (prevote *Prevote) Sig() id.Signature
- func (prevote *Prevote) SigHash() id.Hash
- func (prevote *Prevote) Signatory() id.Signatory
- func (prevote *Prevote) String() string
- func (prevote *Prevote) Type() MessageType
- func (prevote *Prevote) UnmarshalBinary(data []byte) error
- func (prevote *Prevote) UnmarshalJSON(data []byte) error
- type Prevotes
- type Process
- func (p *Process) HandleMessage(m Message)
- func (p Process) MarshalBinary() ([]byte, error)
- func (p Process) MarshalJSON() ([]byte, error)
- func (p *Process) Start()
- func (p *Process) StartRound(round block.Round)
- func (p *Process) UnmarshalBinary(data []byte) error
- func (p *Process) UnmarshalJSON(data []byte) error
- type Processes
- type Propose
- func (propose *Propose) Block() block.Block
- func (propose *Propose) BlockHash() id.Hash
- func (propose *Propose) Height() block.Height
- func (propose Propose) MarshalBinary() ([]byte, error)
- func (propose Propose) MarshalJSON() ([]byte, error)
- func (propose *Propose) Round() block.Round
- func (propose *Propose) Sig() id.Signature
- func (propose *Propose) SigHash() id.Hash
- func (propose *Propose) Signatory() id.Signatory
- func (propose *Propose) String() string
- func (propose *Propose) Type() MessageType
- func (propose *Propose) UnmarshalBinary(data []byte) error
- func (propose *Propose) UnmarshalJSON(data []byte) error
- func (propose *Propose) ValidRound() block.Round
- type Proposer
- type Proposes
- type Scheduler
- type State
- type Step
- type Timer
- type Validator
Constants ¶
const ( NilMessageType = 0 ProposeMessageType = 1 PrevoteMessageType = 2 PrecommitMessageType = 3 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Blockchain ¶
type Blockchain interface {
InsertBlockAtHeight(block.Height, block.Block)
BlockAtHeight(block.Height) (block.Block, bool)
BlockExistsAtHeight(block.Height) bool
}
A Blockchain defines a storage interface for Blocks that is based around Height.
type Broadcaster ¶
type Broadcaster interface {
Broadcast(Message)
}
A Broadcaster sends a Message to as many Processes in the network as possible.
type Inbox ¶
type Inbox struct {
// contains filtered or unexported fields
}
func NewInbox ¶
func NewInbox(f int, messageType MessageType) *Inbox
func (Inbox) MarshalBinary ¶
MarshalBinary implements the `encoding.BinaryMarshaler` interface for the Inbox type.
func (Inbox) MarshalJSON ¶
MarshalJSON implements the `json.Marshaler` interface for the Inbox type.
func (*Inbox) MessageType ¶
func (inbox *Inbox) MessageType() MessageType
func (*Inbox) QueryByHeightRound ¶
func (*Inbox) QueryByHeightRoundBlockHash ¶
func (*Inbox) QueryByHeightRoundSignatory ¶
func (*Inbox) QueryMessagesByHeightWithHigestRound ¶
func (*Inbox) UnmarshalBinary ¶
UnmarshalBinary implements the `encoding.BinaryUnmarshaler` interface for the Inbox type.
func (*Inbox) UnmarshalJSON ¶
UnmarshalJSON implements the `json.Unmarshaler` interface for the Inbox type. Note : you need to be really careful when doing unmarshaling, specifically you need to initialize the inbox with the expected messageType. Otherwise it would panic.
type LatestCommit ¶
type MessageType ¶
type MessageType uint64
type Precommit ¶
type Precommit struct {
// contains filtered or unexported fields
}
func NewPrecommit ¶
func (Precommit) MarshalBinary ¶
MarshalBinary implements the `encoding.BinaryMarshaler` interface for the Precommit type.
func (Precommit) MarshalJSON ¶
MarshalJSON implements the `json.Marshaler` interface for the Precommit type.
func (*Precommit) Type ¶
func (precommit *Precommit) Type() MessageType
func (*Precommit) UnmarshalBinary ¶
UnmarshalBinary implements the `encoding.BinaryUnmarshaler` interface for the Precommit type.
func (*Precommit) UnmarshalJSON ¶
UnmarshalJSON implements the `json.Unmarshaler` interface for the Precommit type.
type Precommits ¶
type Precommits []Precommit
type Prevote ¶
type Prevote struct {
// contains filtered or unexported fields
}
func NewPrevote ¶
func (Prevote) MarshalBinary ¶
MarshalBinary implements the `encoding.BinaryMarshaler` interface for the Prevote type.
func (Prevote) MarshalJSON ¶
MarshalJSON implements the `json.Marshaler` interface for the Prevote type.
func (*Prevote) Type ¶
func (prevote *Prevote) Type() MessageType
func (*Prevote) UnmarshalBinary ¶
UnmarshalBinary implements the `encoding.BinaryUnmarshaler` interface for the Prevote type.
func (*Prevote) UnmarshalJSON ¶
UnmarshalJSON implements the `json.Unmarshaler` interface for the Prevote type.
type Process ¶
type Process struct {
// contains filtered or unexported fields
}
A Process defines a state machine in the distributed replicated state machine. See https://arxiv.org/pdf/1807.04938.pdf for more information.
func New ¶
func New(logger logrus.FieldLogger, signatory id.Signatory, blockchain Blockchain, state State, proposer Proposer, validator Validator, observer Observer, broadcaster Broadcaster, scheduler Scheduler, timer Timer) *Process
New Process initialised to the default state, starting in the first round.
func (*Process) HandleMessage ¶
HandleMessage is safe for concurrent use. See https://arxiv.org/pdf/1807.04938.pdf for more information.
func (Process) MarshalBinary ¶
MarshalBinary implements the `encoding.BinaryMarshaler` interface for the Process type, by marshaling its isolated State.
func (Process) MarshalJSON ¶
MarshalJSON implements the `json.Marshaler` interface for the Process type, by marshaling its isolated State.
func (*Process) StartRound ¶
StartRound is safe for concurrent use. See https://arxiv.org/pdf/1807.04938.pdf for more information.
func (*Process) UnmarshalBinary ¶
UnmarshalBinary implements the `encoding.BinaryUnmarshaler` interface for the Process type, by unmarshaling its isolated State.
func (*Process) UnmarshalJSON ¶
UnmarshalJSON implements the `json.Unmarshaler` interface for the Process type, by unmarshaling its isolated State.
type Processes ¶
type Processes []Process
Processes defines a wrapper type around the []Process type.
type Propose ¶
type Propose struct {
// contains filtered or unexported fields
}
func NewPropose ¶
func (Propose) MarshalBinary ¶
MarshalBinary implements the `encoding.BinaryMarshaler` interface for the Propose type.
func (Propose) MarshalJSON ¶
MarshalJSON implements the `json.Marshaler` interface for the Propose type.
func (*Propose) Type ¶
func (propose *Propose) Type() MessageType
func (*Propose) UnmarshalBinary ¶
UnmarshalBinary implements the `encoding.BinaryUnmarshaler` interface for the Propose type.
func (*Propose) UnmarshalJSON ¶
UnmarshalJSON implements the `json.Unmarshaler` interface for the Propose type.
func (*Propose) ValidRound ¶
type Scheduler ¶
A Scheduler determines which `id.Signatory` should be broadcasting proposals in at a given `block.Height` and `block.Round`.
type State ¶
type State struct {
CurrentHeight block.Height `json:"currentHeight"`
CurrentRound block.Round `json:"currentRound"`
CurrentStep Step `json:"currentStep"`
LockedBlock block.Block `json:"lockedBlock"` // the most recent block for which a precommit message has been sent
LockedRound block.Round `json:"lockedRound"` // the last round in which the process sent a precommit message that is not nil.
ValidBlock block.Block `json:"validBlock"` // store the most recent possible decision value
ValidRound block.Round `json:"validRound"` // is the last round in which valid value is updated
Proposals *Inbox `json:"proposals"`
Prevotes *Inbox `json:"prevotes"`
Precommits *Inbox `json:"precommits"`
}
The State of a Process. It is isolated from the Process so that it can be easily marshaled to/from JSON.
func DefaultState ¶
DefaultState returns a State with all values set to the default. See https://arxiv.org/pdf/1807.04938.pdf for more information.
func (State) MarshalBinary ¶
MarshalBinary implements the `encoding.BinaryMarshaler` interface for the State type.
func (*State) Reset ¶
Reset the State (not all values are reset). See https://arxiv.org/pdf/1807.04938.pdf for more information.
func (*State) UnmarshalBinary ¶
UnmarshalBinary implements the `encoding.BinaryUnmarshaler` interface for the State type.