Documentation ¶
Overview ¶
Package basicstates is the rewritten consensus states, based on primitive.
Index ¶
- Constants
- Variables
- func CheckBlockWithINITVoteproof(db storage.Database, voteproof base.Voteproof) error
- func LogSeal(sl seal.Seal) *zerolog.Event
- func NextINITBallotFromACCEPTVoteproof(db storage.Database, local node.Local, voteproof base.Voteproof, ...) (base.INITBallot, error)
- func NextINITBallotFromINITVoteproof(db storage.Database, local node.Local, ...) (base.INITBallot, error)
- type BallotChecker
- type BaseConsensusState
- func (st *BaseConsensusState) Enter(sctx StateSwitchContext) (func() error, error)
- func (st *BaseConsensusState) Exit(sctx StateSwitchContext) (func() error, error)
- func (st *BaseConsensusState) ProcessProposal(proposal base.Proposal) error
- func (st *BaseConsensusState) ProcessVoteproof(voteproof base.Voteproof) error
- type BaseState
- func (st *BaseState) BroadcastBallot(blt base.Ballot, toLocal bool) error
- func (st *BaseState) Enter(sctx StateSwitchContext) (func() error, error)
- func (st *BaseState) Exit(sctx StateSwitchContext) (func() error, error)
- func (st *BaseState) LastINITVoteproof() base.Voteproof
- func (st *BaseState) LastVoteproof() base.Voteproof
- func (st *BaseState) NewBlocks(blks []block.Block) error
- func (st *BaseState) NewProposal(proposal base.Proposal)
- func (st *BaseState) NewStateSwitchContext(next base.State) StateSwitchContext
- func (st *BaseState) NewVoteproof(voteproof base.Voteproof)
- func (*BaseState) ProcessProposal(base.Proposal) error
- func (st *BaseState) ProcessVoteproof(voteproof base.Voteproof) error
- func (st *BaseState) SetLastVoteproof(voteproof base.Voteproof) bool
- func (st *BaseState) SetStates(ss *States) State
- func (st *BaseState) StateSwitch(sctx StateSwitchContext) error
- func (st *BaseState) Timers() *localtime.Timers
- type BootingState
- type ConsensusState
- type ConsensusStuckChecker
- type DuplicatedError
- type EmptyState
- type Handover
- func (hd *Handover) IsReady() bool
- func (hd *Handover) OldNode() network.Channel
- func (hd *Handover) Refresh(chs ...network.Channel) error
- func (hd *Handover) SetLogging(l *logging.Logging) *logging.Logging
- func (hd *Handover) Start() error
- func (hd *Handover) Stop() error
- func (hd *Handover) UnderHandover() bool
- type HandoverState
- type JoiningState
- type State
- type StateSwitchContext
- func (sctx StateSwitchContext) Context() context.Context
- func (sctx StateSwitchContext) ContextWithValue(k util.ContextKey, v interface{}) StateSwitchContext
- func (sctx StateSwitchContext) Err() error
- func (sctx StateSwitchContext) Error() string
- func (sctx StateSwitchContext) FromState() base.State
- func (sctx StateSwitchContext) IsEmpty() bool
- func (sctx StateSwitchContext) IsValid([]byte) error
- func (sctx StateSwitchContext) MarshalText() ([]byte, error)
- func (sctx StateSwitchContext) MarshalZerologObject(e *zerolog.Event)
- func (sctx StateSwitchContext) Return() StateSwitchContext
- func (sctx StateSwitchContext) SetContext(ctx context.Context) StateSwitchContext
- func (sctx StateSwitchContext) SetError(err error) StateSwitchContext
- func (sctx StateSwitchContext) SetFromState(st base.State) StateSwitchContext
- func (sctx StateSwitchContext) SetToState(st base.State) StateSwitchContext
- func (sctx StateSwitchContext) SetVoteproof(voteproof base.Voteproof) StateSwitchContext
- func (sctx StateSwitchContext) ToState() base.State
- func (sctx StateSwitchContext) Voteproof() base.Voteproof
- type States
- func (ss *States) BlockSavedHook() *pm.Hooks
- func (ss *States) BroadcastBallot(blt base.Ballot, toLocal bool)
- func (ss *States) EndHandover(ci network.ConnInfo) error
- func (ss *States) Handover() states.Handover
- func (ss *States) LastINITVoteproof() base.Voteproof
- func (ss *States) LastVoteproof() base.Voteproof
- func (ss *States) NewBlocks(blks []block.Block) error
- func (ss *States) NewProposal(proposal base.Proposal)
- func (ss *States) NewSeal(sl seal.Seal) error
- func (ss *States) NewVoteproof(voteproof base.Voteproof)
- func (ss *States) SetLastVoteproof(voteproof base.Voteproof) bool
- func (ss *States) SetLogging(l *logging.Logging) *logging.Logging
- func (ss *States) Start() error
- func (ss *States) StartHandover() error
- func (ss *States) State() base.State
- func (ss *States) Stop() error
- func (ss *States) SwitchState(sctx StateSwitchContext) error
- func (ss *States) Timers() *localtime.Timers
- type StoppedState
- type SyncingState
- type VoteproofChecker
Constants ¶
View Source
const ( ContextValueError util.ContextKey = "error" ContextValueStateSwitchContext util.ContextKey = "state_switch_context" ContextValueNewSealContext util.ContextKey = "new_seal" ContextValueBlockSaved util.ContextKey = "block_saved" )
View Source
const ( TimerIDBroadcastINITBallot localtime.TimerID = "broadcast-init-ballot" TimerIDBroadcastJoingingINITBallot localtime.TimerID = "broadcast-joining-init-ballot" TimerIDBroadcastProposal localtime.TimerID = "broadcast-proposal" TimerIDBroadcastACCEPTBallot localtime.TimerID = "broadcast-accept-ballot" TimerIDSyncingWaitVoteproof localtime.TimerID = "syncing-wait-new-voteproof" TimerIDFindProposal localtime.TimerID = "find-proposal" )
Variables ¶
View Source
var BlockPrefixFailedProcessProposal = []byte("processproposalfailed")
View Source
var ConsensusStuckError = util.NewError("consensus looks stuck")
View Source
var EmptySwitchFunc = func() error { return nil }
View Source
var SyncByVoteproofError = util.NewError("sync by voteproof")
Functions ¶
Types ¶
type BallotChecker ¶
func NewBallotChecker ¶
func NewBallotChecker(blt base.Ballot, lvp base.Voteproof) *BallotChecker
func (*BallotChecker) CheckWithLastVoteproof ¶
func (bc *BallotChecker) CheckWithLastVoteproof() (bool, error)
type BaseConsensusState ¶
type BaseConsensusState struct { *logging.Logging *BaseState // contains filtered or unexported fields }
func NewBaseConsensusState ¶
func NewBaseConsensusState( st base.State, db storage.Database, policy *isaac.LocalPolicy, nodepool *network.Nodepool, suffrage base.Suffrage, proposalMaker *isaac.ProposalMaker, pps *prprocessor.Processors, ) *BaseConsensusState
func (*BaseConsensusState) Enter ¶
func (st *BaseConsensusState) Enter(sctx StateSwitchContext) (func() error, error)
Enter starts consensus state with the voteproof, - height of last init voteproof + 1
func (*BaseConsensusState) Exit ¶
func (st *BaseConsensusState) Exit(sctx StateSwitchContext) (func() error, error)
func (*BaseConsensusState) ProcessProposal ¶
func (st *BaseConsensusState) ProcessProposal(proposal base.Proposal) error
ProcessProposal processes incoming proposal, not from local
func (*BaseConsensusState) ProcessVoteproof ¶
func (st *BaseConsensusState) ProcessVoteproof(voteproof base.Voteproof) error
type BaseState ¶
type BaseState struct { States *States // contains filtered or unexported fields }
func NewBaseState ¶
func (*BaseState) BroadcastBallot ¶
func (*BaseState) LastINITVoteproof ¶
func (*BaseState) LastVoteproof ¶
func (*BaseState) NewProposal ¶
func (*BaseState) NewStateSwitchContext ¶
func (st *BaseState) NewStateSwitchContext(next base.State) StateSwitchContext
func (*BaseState) NewVoteproof ¶
func (*BaseState) ProcessVoteproof ¶
func (*BaseState) SetLastVoteproof ¶
func (*BaseState) StateSwitch ¶
func (st *BaseState) StateSwitch(sctx StateSwitchContext) error
type BootingState ¶
func NewBootingState ¶
func (*BootingState) Enter ¶
func (st *BootingState) Enter(sctx StateSwitchContext) (func() error, error)
type ConsensusState ¶
type ConsensusState struct {
*BaseConsensusState
}
func NewConsensusState ¶
func NewConsensusState( db storage.Database, policy *isaac.LocalPolicy, nodepool *network.Nodepool, suffrage base.Suffrage, proposalMaker *isaac.ProposalMaker, pps *prprocessor.Processors, ) *ConsensusState
func (*ConsensusState) Enter ¶
func (st *ConsensusState) Enter(sctx StateSwitchContext) (func() error, error)
func (*ConsensusState) Exit ¶
func (st *ConsensusState) Exit(sctx StateSwitchContext) (func() error, error)
type ConsensusStuckChecker ¶
type ConsensusStuckChecker struct {
// contains filtered or unexported fields
}
func (*ConsensusStuckChecker) IsOldLastVoteproofTime ¶
func (cc *ConsensusStuckChecker) IsOldLastVoteproofTime() (bool, error)
func (*ConsensusStuckChecker) IsValidState ¶
func (cc *ConsensusStuckChecker) IsValidState() (bool, error)
type DuplicatedError ¶
type DuplicatedError struct {
// contains filtered or unexported fields
}
func NewDuplicatedError ¶
func NewDuplicatedError(ch network.Channel, ni network.NodeInfo) DuplicatedError
func (DuplicatedError) Error ¶
func (DuplicatedError) Error() string
type EmptyState ¶
type EmptyState struct{}
func NewEmptyState ¶
func NewEmptyState() *EmptyState
func (*EmptyState) Enter ¶
func (*EmptyState) Enter(sctx StateSwitchContext) (func() error, error)
func (*EmptyState) Exit ¶
func (*EmptyState) Exit(StateSwitchContext) (func() error, error)
func (*EmptyState) ProcessProposal ¶
func (*EmptyState) ProcessProposal(base.Proposal) error
func (*EmptyState) ProcessVoteproof ¶
func (*EmptyState) ProcessVoteproof(base.Voteproof) error
func (*EmptyState) SetStates ¶
func (*EmptyState) SetStates(*States) State
type Handover ¶
type Handover struct { sync.Mutex *logging.Logging *util.ContextDaemon // contains filtered or unexported fields }
func NewHandover ¶
func (*Handover) UnderHandover ¶
type HandoverState ¶
type HandoverState struct { *BaseConsensusState // contains filtered or unexported fields }
func NewHandoverState ¶
func NewHandoverState( db storage.Database, policy *isaac.LocalPolicy, nodepool *network.Nodepool, suffrage base.Suffrage, pps *prprocessor.Processors, ) *HandoverState
func (*HandoverState) Enter ¶
func (st *HandoverState) Enter(sctx StateSwitchContext) (func() error, error)
func (*HandoverState) Exit ¶
func (st *HandoverState) Exit(sctx StateSwitchContext) (func() error, error)
func (*HandoverState) ProcessVoteproof ¶
func (st *HandoverState) ProcessVoteproof(voteproof base.Voteproof) error
type JoiningState ¶
func NewJoiningState ¶
func (*JoiningState) Enter ¶
func (st *JoiningState) Enter(sctx StateSwitchContext) (func() error, error)
func (*JoiningState) Exit ¶
func (st *JoiningState) Exit(sctx StateSwitchContext) (func() error, error)
func (*JoiningState) ProcessVoteproof ¶
func (st *JoiningState) ProcessVoteproof(voteproof base.Voteproof) error
ProcessVoteproof only receives the acceptable voteproof with last init voteproof
type StateSwitchContext ¶
type StateSwitchContext struct {
// contains filtered or unexported fields
}
func NewStateSwitchContext ¶
func NewStateSwitchContext(from, to base.State) StateSwitchContext
func (StateSwitchContext) Context ¶
func (sctx StateSwitchContext) Context() context.Context
func (StateSwitchContext) ContextWithValue ¶
func (sctx StateSwitchContext) ContextWithValue(k util.ContextKey, v interface{}) StateSwitchContext
func (StateSwitchContext) Err ¶
func (sctx StateSwitchContext) Err() error
func (StateSwitchContext) Error ¶
func (sctx StateSwitchContext) Error() string
func (StateSwitchContext) FromState ¶
func (sctx StateSwitchContext) FromState() base.State
func (StateSwitchContext) IsEmpty ¶
func (sctx StateSwitchContext) IsEmpty() bool
func (StateSwitchContext) IsValid ¶
func (sctx StateSwitchContext) IsValid([]byte) error
func (StateSwitchContext) MarshalText ¶
func (sctx StateSwitchContext) MarshalText() ([]byte, error)
func (StateSwitchContext) MarshalZerologObject ¶
func (sctx StateSwitchContext) MarshalZerologObject(e *zerolog.Event)
func (StateSwitchContext) Return ¶
func (sctx StateSwitchContext) Return() StateSwitchContext
func (StateSwitchContext) SetContext ¶
func (sctx StateSwitchContext) SetContext(ctx context.Context) StateSwitchContext
func (StateSwitchContext) SetError ¶
func (sctx StateSwitchContext) SetError(err error) StateSwitchContext
func (StateSwitchContext) SetFromState ¶
func (sctx StateSwitchContext) SetFromState(st base.State) StateSwitchContext
func (StateSwitchContext) SetToState ¶
func (sctx StateSwitchContext) SetToState(st base.State) StateSwitchContext
func (StateSwitchContext) SetVoteproof ¶
func (sctx StateSwitchContext) SetVoteproof(voteproof base.Voteproof) StateSwitchContext
func (StateSwitchContext) ToState ¶
func (sctx StateSwitchContext) ToState() base.State
func (StateSwitchContext) Voteproof ¶
func (sctx StateSwitchContext) Voteproof() base.Voteproof
type States ¶
type States struct { sync.RWMutex *logging.Logging *util.ContextDaemon // contains filtered or unexported fields }
func (*States) BlockSavedHook ¶
func (*States) BroadcastBallot ¶
BroadcastBallot broadcast seal to the known nodes, - suffrage nodes - if toLocal is true, sends to local
func (*States) LastINITVoteproof ¶
func (*States) LastVoteproof ¶
func (*States) NewProposal ¶
func (*States) NewVoteproof ¶
func (*States) StartHandover ¶
func (*States) SwitchState ¶
func (ss *States) SwitchState(sctx StateSwitchContext) error
type StoppedState ¶
type StoppedState struct {
*BaseState
}
func NewStoppedState ¶
func NewStoppedState() *StoppedState
type SyncingState ¶
type SyncingState struct { sync.RWMutex *logging.Logging *BaseState // contains filtered or unexported fields }
func NewSyncingState ¶
func (*SyncingState) Enter ¶
func (st *SyncingState) Enter(sctx StateSwitchContext) (func() error, error)
func (*SyncingState) Exit ¶
func (st *SyncingState) Exit(sctx StateSwitchContext) (func() error, error)
func (*SyncingState) ProcessVoteproof ¶
func (st *SyncingState) ProcessVoteproof(voteproof base.Voteproof) error
type VoteproofChecker ¶
func NewVoteproofChecker ¶
func (*VoteproofChecker) CheckACCEPTVoteproofProposal ¶
func (vc *VoteproofChecker) CheckACCEPTVoteproofProposal() (bool, error)
CheckACCEPTVoteproofProposal checks proposal of accept voteproof. If proposal not found in local, request to the voted nodes.
func (*VoteproofChecker) CheckINITVoteproofWithLocalBlock ¶
func (vc *VoteproofChecker) CheckINITVoteproofWithLocalBlock() (bool, error)
func (*VoteproofChecker) CheckPoint ¶
func (vc *VoteproofChecker) CheckPoint() (bool, error)
Click to show internal directories.
Click to hide internal directories.