Documentation ¶
Overview ¶
Package isaacstates handles node states
Index ¶
- Constants
- Variables
- func FindMissingBallotsFromBallotboxFunc(local base.Address, params *isaac.LocalParams, ...) func(context.Context, base.StagePoint, bool) ([]base.Address, bool, error)
- func ImportBlocks(ctx context.Context, from, to base.Height, batchlimit int64, ...) error
- func IsNewVoteproofbyPoint(last LastPoint, point base.StagePoint, isMajority, isSuffrageConfirm bool) bool
- func RequestMissingBallots(localci quicstream.UDPConnInfo, ...) func(context.Context, base.StagePoint, []base.Address) error
- func VoteSuffrageVotingFunc(local base.LocalNode, params *isaac.LocalParams, ballotbox *Ballotbox, ...) func(context.Context, base.StagePoint, []base.Address) (base.Voteproof, error)
- type BallotBroadcaster
- type BallotStuckResolver
- type Ballotbox
- func (box *Ballotbox) Count(threshold base.Threshold) bool
- func (box *Ballotbox) LastPoint() LastPoint
- func (box *Ballotbox) MissingNodes(point base.StagePoint, threshold base.Threshold) ([]base.Address, bool, error)
- func (box *Ballotbox) SetCountAfter(d time.Duration) *Ballotbox
- func (box *Ballotbox) SetInterval(d time.Duration) *Ballotbox
- func (box *Ballotbox) SetIsValidVoteproofFunc(f func(base.Voteproof, base.Suffrage) error) *Ballotbox
- func (box *Ballotbox) SetLastPoint(point LastPoint) bool
- func (box *Ballotbox) SetLastPointFromVoteproof(vp base.Voteproof) bool
- func (box *Ballotbox) SetNewBallotFunc(f func(base.Ballot)) *Ballotbox
- func (box *Ballotbox) SetSuffrageVoteFunc(f func(base.SuffrageWithdrawOperation) error) *Ballotbox
- func (box *Ballotbox) StuckVoteproof(point base.StagePoint, threshold base.Threshold, ...) (vp base.Voteproof, _ error)
- func (box *Ballotbox) Vote(bl base.Ballot, threshold base.Threshold) (bool, error)
- func (box *Ballotbox) VoteSignFact(sf base.BallotSignFact, threshold base.Threshold) (bool, error)
- func (box *Ballotbox) Voted(point base.StagePoint, nodes []base.Address) []base.BallotSignFact
- func (box *Ballotbox) Voteproof() <-chan base.Voteproof
- type BootingHandler
- type BootingHandlerArgs
- type BrokenHandler
- type ConsensusHandler
- type ConsensusHandlerArgs
- type DefaultBallotBroadcaster
- type DefaultBallotStuckResolver
- func (c *DefaultBallotStuckResolver) Cancel(point base.StagePoint)
- func (c *DefaultBallotStuckResolver) Clean()
- func (c *DefaultBallotStuckResolver) NewPoint(ctx context.Context, point base.StagePoint) bool
- func (c *DefaultBallotStuckResolver) SetLogging(l *logging.Logging) *logging.Logging
- func (c *DefaultBallotStuckResolver) Voteproof() <-chan base.Voteproof
- type JoiningHandler
- type JoiningHandlerArgs
- type LastPoint
- type LastVoteproofs
- type LastVoteproofsHandler
- func (l *LastVoteproofsHandler) ForceSet(vp base.Voteproof) bool
- func (l *LastVoteproofsHandler) IsNew(vp base.Voteproof) bool
- func (l *LastVoteproofsHandler) Last() LastVoteproofs
- func (l *LastVoteproofsHandler) Set(vp base.Voteproof) bool
- func (l *LastVoteproofsHandler) Voteproofs(point base.StagePoint) (LastVoteproofs, bool)
- type MissingBallotsRequestMessage
- func (m MissingBallotsRequestMessage) ConnInfo() quicstream.UDPConnInfo
- func (m *MissingBallotsRequestMessage) DecodeJSON(b []byte, enc *jsonenc.Encoder) error
- func (m MissingBallotsRequestMessage) IsValid([]byte) error
- func (m MissingBallotsRequestMessage) MarshalJSON() ([]byte, error)
- func (m MissingBallotsRequestMessage) Nodes() []base.Address
- func (m MissingBallotsRequestMessage) Point() base.StagePoint
- type NewBlockImporterFunc
- type NewBootingHandlerType
- type NewBrokenHandlerType
- type NewConsensusHandlerType
- type NewImportBlocksFunc
- type NewJoiningHandlerType
- type NewStoppedHandlerType
- type NewSyncingHandlerType
- type StateType
- type States
- func (st *States) Current() StateType
- func (st *States) Hold() error
- func (st *States) MoveState(sctx switchContext) error
- func (st *States) SetHandler(state StateType, h newHandler) *States
- func (st *States) SetLogging(l *logging.Logging) *logging.Logging
- func (st *States) SetWhenStateSwitched(f func(StateType))
- func (st *States) WhenEmptyMembers()
- type StatesArgs
- type StoppedHandler
- type SuffrageVotingFindFunc
- type Syncer
- type SyncerArgs
- type SyncerBlockMapFunc
- type SyncerBlockMapItemFunc
- type SyncerLastBlockMapFunc
- type SyncingHandler
- type SyncingHandlerArgs
- type SyncingSwitchContext
Constants ¶
View Source
const ( StateEmpty = StateType("") // StateStopped indicates all processes is finished. StateStopped = StateType("STOPPED") // StateBooting indicates node checks it's state. StateBooting = StateType("BOOTING") // StateJoining indicates node is trying to join consensus. StateJoining = StateType("JOINING") // StateConsensus indicates node participates consensus with the other // nodes. StateConsensus = StateType("CONSENSUS") // StateSyncing indicates node is syncing block. StateSyncing = StateType("SYNCING") // StateHandover indicates node tries to replace the existing same node. StateHandover = StateType("HANDOVER") // StateBroken is used when something wrong in states. StateBroken = StateType("BROKEN") )
Variables ¶
View Source
var ErrIgnoreSwithingState = util.NewError("failed to switch state, but ignored")
View Source
var ErrSyncerCanNotCancel = util.NewError("can not cancel syncer")
View Source
var ErrUnpromising = util.NewError("unpromising broken error")
View Source
var MissingBallotsRequestsMessageHint = hint.MustNewHint("missing-ballots-request-message-v0.0.1")
Functions ¶
func ImportBlocks ¶
func ImportBlocks( ctx context.Context, from, to base.Height, batchlimit int64, blockMapf SyncerBlockMapFunc, blockMapItemf SyncerBlockMapItemFunc, newBlockImporter func(base.BlockMap) (isaac.BlockImporter, error), setLastVoteproofsFunc func(isaac.BlockReader) error, mergeBlockWriterDatabasesf func(context.Context) error, ) error
func IsNewVoteproofbyPoint ¶
func IsNewVoteproofbyPoint( last LastPoint, point base.StagePoint, isMajority, isSuffrageConfirm bool, ) bool
func RequestMissingBallots ¶
func RequestMissingBallots( localci quicstream.UDPConnInfo, broadcastf func(string, []byte, chan struct{}) error, ) func(context.Context, base.StagePoint, []base.Address) error
func VoteSuffrageVotingFunc ¶
func VoteSuffrageVotingFunc( local base.LocalNode, params *isaac.LocalParams, ballotbox *Ballotbox, sv *isaac.SuffrageVoting, getSuffragef isaac.GetSuffrageByBlockHeight, ) func(context.Context, base.StagePoint, []base.Address) (base.Voteproof, error)
Types ¶
type BallotBroadcaster ¶
type BallotStuckResolver ¶
type BallotStuckResolver interface { NewPoint(context.Context, base.StagePoint) bool Voteproof() <-chan base.Voteproof Clean() Cancel(base.StagePoint) }
type Ballotbox ¶
type Ballotbox struct { *util.ContextDaemon *logging.Logging // contains filtered or unexported fields }
func NewBallotbox ¶
func NewBallotbox( local base.Address, getSuffragef isaac.GetSuffrageByBlockHeight, ) *Ballotbox
func (*Ballotbox) MissingNodes ¶
func (*Ballotbox) SetIsValidVoteproofFunc ¶
func (*Ballotbox) SetLastPoint ¶
func (*Ballotbox) SetLastPointFromVoteproof ¶
func (*Ballotbox) SetNewBallotFunc ¶
func (*Ballotbox) SetSuffrageVoteFunc ¶
func (box *Ballotbox) SetSuffrageVoteFunc(f func(base.SuffrageWithdrawOperation) error) *Ballotbox
func (*Ballotbox) StuckVoteproof ¶
func (box *Ballotbox) StuckVoteproof( point base.StagePoint, threshold base.Threshold, withdraws []base.SuffrageWithdrawOperation, ) (vp base.Voteproof, _ error)
func (*Ballotbox) VoteSignFact ¶
func (*Ballotbox) Voted ¶
func (box *Ballotbox) Voted(point base.StagePoint, nodes []base.Address) []base.BallotSignFact
type BootingHandler ¶
type BootingHandler struct {
// contains filtered or unexported fields
}
type BootingHandlerArgs ¶
type BootingHandlerArgs struct { LastManifestFunc func() (base.Manifest, bool, error) NodeInConsensusNodesFunc isaac.NodeInConsensusNodesFunc }
func NewBootingHandlerArgs ¶
func NewBootingHandlerArgs() *BootingHandlerArgs
type BrokenHandler ¶
type BrokenHandler struct {
// contains filtered or unexported fields
}
type ConsensusHandler ¶
type ConsensusHandler struct {
// contains filtered or unexported fields
}
type ConsensusHandlerArgs ¶
type ConsensusHandlerArgs struct { ProposalProcessors *isaac.ProposalProcessors GetManifestFunc func(base.Height) (base.Manifest, error) WhenNewBlockSaved func(base.Height) WhenNewBlockConfirmed func(base.Height) // contains filtered or unexported fields }
func NewConsensusHandlerArgs ¶
func NewConsensusHandlerArgs() *ConsensusHandlerArgs
type DefaultBallotBroadcaster ¶
func NewDefaultBallotBroadcaster ¶
func NewDefaultBallotBroadcaster( local base.Address, pool isaac.BallotPool, broadcastFunc func(base.Ballot) error, ) *DefaultBallotBroadcaster
type DefaultBallotStuckResolver ¶
type DefaultBallotStuckResolver struct { *logging.Logging // contains filtered or unexported fields }
func NewDefaultBallotStuckResolver ¶
func NewDefaultBallotStuckResolver( initialWait, interval, resolveAfter time.Duration, findMissingBallotsf func(context.Context, base.StagePoint, bool) ([]base.Address, bool, error), requestMissingBallotsf func(context.Context, base.StagePoint, []base.Address) error, voteSuffrageVotingf func(context.Context, base.StagePoint, []base.Address) (base.Voteproof, error), ) *DefaultBallotStuckResolver
func (*DefaultBallotStuckResolver) Cancel ¶
func (c *DefaultBallotStuckResolver) Cancel(point base.StagePoint)
func (*DefaultBallotStuckResolver) Clean ¶
func (c *DefaultBallotStuckResolver) Clean()
func (*DefaultBallotStuckResolver) NewPoint ¶
func (c *DefaultBallotStuckResolver) NewPoint(ctx context.Context, point base.StagePoint) bool
func (*DefaultBallotStuckResolver) SetLogging ¶
func (c *DefaultBallotStuckResolver) SetLogging(l *logging.Logging) *logging.Logging
func (*DefaultBallotStuckResolver) Voteproof ¶
func (c *DefaultBallotStuckResolver) Voteproof() <-chan base.Voteproof
type JoiningHandler ¶
type JoiningHandler struct {
// contains filtered or unexported fields
}
type JoiningHandlerArgs ¶
type JoiningHandlerArgs struct { LastManifestFunc func() (base.Manifest, bool, error) JoinMemberlistFunc func(context.Context, base.Suffrage) error LeaveMemberlistFunc func(time.Duration) error WaitFirstVoteproof time.Duration // contains filtered or unexported fields }
func NewJoiningHandlerArgs ¶
func NewJoiningHandlerArgs(params *isaac.LocalParams) *JoiningHandlerArgs
type LastPoint ¶
type LastPoint struct { base.StagePoint // contains filtered or unexported fields }
type LastVoteproofs ¶
type LastVoteproofs struct {
// contains filtered or unexported fields
}
func (LastVoteproofs) ACCEPT ¶
func (l LastVoteproofs) ACCEPT() base.ACCEPTVoteproof
func (LastVoteproofs) Cap ¶
func (l LastVoteproofs) Cap() base.Voteproof
func (LastVoteproofs) INIT ¶
func (l LastVoteproofs) INIT() base.INITVoteproof
func (LastVoteproofs) PreviousBlockForNextRound ¶
func (l LastVoteproofs) PreviousBlockForNextRound(vp base.Voteproof) util.Hash
PreviousBlockForNextRound finds the previous block hash from last majority voteproof.
-------------------------------------- | m | v | | heights | -------------------------------------- | init | init | X | | | accept | init | O | m == v - 1 | | init | accept | O | m == v | | accept | accept | O | m == v - 1 | --------------------------------------
* 'm' is last majority voteproof * 'v' is draw voteproof, new incoming voteproof for next round
type LastVoteproofsHandler ¶
func NewLastVoteproofsHandler ¶
func NewLastVoteproofsHandler() *LastVoteproofsHandler
func (*LastVoteproofsHandler) ForceSet ¶
func (l *LastVoteproofsHandler) ForceSet(vp base.Voteproof) bool
func (*LastVoteproofsHandler) Last ¶
func (l *LastVoteproofsHandler) Last() LastVoteproofs
func (*LastVoteproofsHandler) Voteproofs ¶
func (l *LastVoteproofsHandler) Voteproofs(point base.StagePoint) (LastVoteproofs, bool)
type MissingBallotsRequestMessage ¶
type MissingBallotsRequestMessage struct { hint.BaseHinter // contains filtered or unexported fields }
func NewMissingBallotsRequestsMessage ¶
func NewMissingBallotsRequestsMessage( point base.StagePoint, nodes []base.Address, ci quicstream.UDPConnInfo, ) MissingBallotsRequestMessage
func (MissingBallotsRequestMessage) ConnInfo ¶
func (m MissingBallotsRequestMessage) ConnInfo() quicstream.UDPConnInfo
func (*MissingBallotsRequestMessage) DecodeJSON ¶
func (m *MissingBallotsRequestMessage) DecodeJSON(b []byte, enc *jsonenc.Encoder) error
func (MissingBallotsRequestMessage) IsValid ¶
func (m MissingBallotsRequestMessage) IsValid([]byte) error
func (MissingBallotsRequestMessage) MarshalJSON ¶
func (m MissingBallotsRequestMessage) MarshalJSON() ([]byte, error)
func (MissingBallotsRequestMessage) Nodes ¶
func (m MissingBallotsRequestMessage) Nodes() []base.Address
func (MissingBallotsRequestMessage) Point ¶
func (m MissingBallotsRequestMessage) Point() base.StagePoint
type NewBlockImporterFunc ¶
type NewBlockImporterFunc func(base.BlockMap) (isaac.BlockImporter, error)
type NewBootingHandlerType ¶
type NewBootingHandlerType struct {
*BootingHandler
}
func NewNewBootingHandlerType ¶
func NewNewBootingHandlerType( local base.LocalNode, params *isaac.LocalParams, args *BootingHandlerArgs, ) *NewBootingHandlerType
type NewBrokenHandlerType ¶
type NewBrokenHandlerType struct {
*BrokenHandler
}
func NewNewBrokenHandlerType ¶
func NewNewBrokenHandlerType( local base.LocalNode, params *isaac.LocalParams, ) *NewBrokenHandlerType
type NewConsensusHandlerType ¶
type NewConsensusHandlerType struct {
*ConsensusHandler
}
func NewNewConsensusHandlerType ¶
func NewNewConsensusHandlerType( local base.LocalNode, params *isaac.LocalParams, args *ConsensusHandlerArgs, ) *NewConsensusHandlerType
type NewImportBlocksFunc ¶
type NewJoiningHandlerType ¶
type NewJoiningHandlerType struct {
*JoiningHandler
}
func NewNewJoiningHandlerType ¶
func NewNewJoiningHandlerType( local base.LocalNode, params *isaac.LocalParams, args *JoiningHandlerArgs, ) *NewJoiningHandlerType
type NewStoppedHandlerType ¶
type NewStoppedHandlerType struct {
*StoppedHandler
}
func NewNewStoppedHandlerType ¶
func NewNewStoppedHandlerType( local base.LocalNode, params *isaac.LocalParams, ) *NewStoppedHandlerType
type NewSyncingHandlerType ¶
type NewSyncingHandlerType struct {
*SyncingHandler
}
func NewNewSyncingHandlerType ¶
func NewNewSyncingHandlerType( local base.LocalNode, params *isaac.LocalParams, args *SyncingHandlerArgs, ) *NewSyncingHandlerType
type States ¶
type States struct { *logging.Logging *util.ContextDaemon // contains filtered or unexported fields }
func NewStates ¶
func NewStates(local base.LocalNode, params *isaac.LocalParams, args *StatesArgs) *States
func (*States) SetHandler ¶
func (*States) SetWhenStateSwitched ¶
func (*States) WhenEmptyMembers ¶
func (st *States) WhenEmptyMembers()
type StatesArgs ¶
type StatesArgs struct { Ballotbox *Ballotbox BallotStuckResolver BallotStuckResolver LastVoteproofsHandler *LastVoteproofsHandler IsInSyncSourcePoolFunc func(base.Address) bool BallotBroadcaster BallotBroadcaster WhenStateSwitchedFunc func(StateType) }
func NewStatesArgs ¶
func NewStatesArgs() *StatesArgs
type StoppedHandler ¶
type StoppedHandler struct {
// contains filtered or unexported fields
}
type SuffrageVotingFindFunc ¶
type Syncer ¶
type Syncer struct { *logging.Logging *util.ContextDaemon // contains filtered or unexported fields }
type SyncerArgs ¶
type SyncerArgs struct { LastBlockMapFunc SyncerLastBlockMapFunc BlockMapFunc SyncerBlockMapFunc TempSyncPool isaac.TempSyncPool WhenStoppedFunc func() error RemovePrevBlockFunc func(base.Height) (bool, error) NewImportBlocksFunc NewImportBlocksFunc BatchLimit int64 LastBlockMapInterval time.Duration LastBlockMapTimeout time.Duration }
func NewSyncerArgs ¶
func NewSyncerArgs() SyncerArgs
type SyncerBlockMapFunc ¶
type SyncerBlockMapItemFunc ¶
type SyncerLastBlockMapFunc ¶
type SyncingHandler ¶
type SyncingHandler struct {
// contains filtered or unexported fields
}
type SyncingHandlerArgs ¶
type SyncingHandlerArgs struct { NodeInConsensusNodesFunc isaac.NodeInConsensusNodesFunc NewSyncerFunc func(base.Height) (isaac.Syncer, error) WhenFinishedFunc func(base.Height) JoinMemberlistFunc func(context.Context, base.Suffrage) error LeaveMemberlistFunc func(time.Duration) error WhenNewBlockSavedFunc func(base.Height) WaitStuckInterval time.Duration }
func NewSyncingHandlerArgs ¶
func NewSyncingHandlerArgs(params *isaac.LocalParams) *SyncingHandlerArgs
type SyncingSwitchContext ¶
type SyncingSwitchContext struct {
// contains filtered or unexported fields
}
func NewSyncingSwitchContextWithOK ¶
func NewSyncingSwitchContextWithOK(height base.Height, okf func(StateType) bool) SyncingSwitchContext
func (SyncingSwitchContext) MarshalZerologObject ¶
func (s SyncingSwitchContext) MarshalZerologObject(e *zerolog.Event)
Click to show internal directories.
Click to hide internal directories.