Documentation ¶
Index ¶
- Constants
- Variables
- func BuildProof(config *params.AlgorandConfig, stateDb *state.StateDB, height uint64, ...) (err error)
- func GetCommitteeNumber(height uint64, step uint32) (uint64, uint64)
- func GetWeight(config *params.AlgorandConfig, miner common.Address, stateDb *state.StateDB, ...) (ownWeight, totalWeight uint64)
- func PrintVoteJournalEntry(ts, code uint64, data interface{}, from string) error
- func VerifyProof(config *params.AlgorandConfig, stateRoot common.Hash, height uint64, ...) error
- func VerifySignatureAndCredential(mv *MinerVerifier, signBytes []byte, signature ed25519.ForwardSecureSignature, ...) error
- type Backend
- type Broadcaster
- type Context
- func (ctx *Context) GetParentProposalBlockData(height uint64) *ProposalBlockData
- func (ctx *Context) GetParentRoundVoteSet(height uint64) (*RoundVoteSet, uint32)
- func (ctx *Context) GetProposalBlock(height uint64, value common.Hash) *ProposalBlockData
- func (ctx *Context) GetProposalLeader(height uint64, round uint32) *ProposalLeaderData
- func (ctx *Context) HR() (uint64, uint32)
- func (ctx *Context) HRS() string
- func (ctx *Context) IsMining() bool
- func (ctx *Context) NewBlock() error
- func (ctx *Context) OnReceive(code uint64, data interface{}, from string)
- func (ctx *Context) Pending() (*types.Block, *state.StateDB)
- func (ctx *Context) RoundVoteSet(height uint64, round uint32) *RoundVoteSet
- func (ctx *Context) SaveProposalBlock(data *ProposalBlockData)
- func (ctx *Context) SetExtra(extra []byte)
- func (ctx *Context) SetMiner(address common.Address)
- func (ctx *Context) Stake() uint64
- func (ctx *Context) Start()
- func (ctx *Context) StartMining()
- func (ctx *Context) Stop()
- func (ctx *Context) StopMining()
- func (ctx *Context) UpdateProposalLeader(value *ProposalLeaderData)
- type Credential
- type HandshakeData
- type HasProposalData
- type HasVoteData
- type HeightState
- type HeightVoteSet
- func (hvs *HeightVoteSet) AddVoteAndCount(vote *VoteData, threshold uint64) (added, potential, enough bool, err error)
- func (hvs *HeightVoteSet) EnsureRoundVoteSet(round uint32) *RoundVoteSet
- func (hvs *HeightVoteSet) GetCertVoteStorage(round uint32, value common.Hash) []*types.CertVoteStorage
- func (hvs *HeightVoteSet) GetCertVotesOfValue(round uint32, value common.Hash) []*VoteData
- func (hvs *HeightVoteSet) HasVote(round uint32, step uint32, user common.Address) bool
- func (hvs *HeightVoteSet) IsNextVoteEnoughForEmptyAtAnyStep(round uint32, empty common.Hash) bool
- func (hvs *HeightVoteSet) IsPotentialValue(round uint32, value common.Hash) bool
- func (hvs *HeightVoteSet) IsSoftVoteEnoughForNonEmpty(empty common.Hash, round uint32) (bool, common.Hash)
- func (hvs *HeightVoteSet) IsSoftVoteEnoughForNonEmptyForAnyRound(empty common.Hash) (bool, common.Hash)
- func (hvs *HeightVoteSet) RoundVoteSet(round uint32) *RoundVoteSet
- func (hvs *HeightVoteSet) SetHasVote(round uint32, step uint32, user common.Address)
- type JournalType
- type MinerKey
- func (mk *MinerKey) DecodeRLP(stream *rlp.Stream) error
- func (mk *MinerKey) EncodeRLP(writer io.Writer) error
- func (mk *MinerKey) Seed(height uint64, parentSeed ed25519.VrfOutput256, parentHash common.Hash) (seed ed25519.VrfOutput256, proof ed25519.VrfProof, err error)
- func (mk *MinerKey) Sign(height uint64, data []byte) (sig ed25519.ForwardSecureSignature, err error)
- func (mk *MinerKey) Sortition(height uint64, round, step uint32, parentSeed ed25519.VrfOutput256, ...) (hash ed25519.VrfOutput256, proof ed25519.VrfProof, j uint64, err error)
- func (mk *MinerKey) ToVerifier() *MinerVerifier
- func (mk *MinerKey) Update(height uint64) uint64
- func (mk *MinerKey) Validate(height uint64) bool
- type MinerKeyManager
- func (mkm *MinerKeyManager) Generate(miner, coinbase common.Address, start uint64, lifespan uint32) (mv *MinerVerifier, mk *MinerKey, err error)
- func (mkm *MinerKeyManager) GetMinerKey(miner common.Address, height uint64) (*MinerKey, error)
- func (mkm *MinerKeyManager) StartUpdateRoutine(bc *core.BlockChain)
- type MinerVerifier
- func (mv *MinerVerifier) AbiString() string
- func (mv *MinerVerifier) Coinbase() common.Address
- func (mv *MinerVerifier) GenesisString() string
- func (mv *MinerVerifier) String() string
- func (mv *MinerVerifier) Validate(height uint64) bool
- func (mv *MinerVerifier) VerifySeed(height uint64, parentSeed ed25519.VrfOutput256, parentHash common.Hash, ...) error
- func (mv *MinerVerifier) VerifySignature(height uint64, data []byte, sig ed25519.ForwardSecureSignature) error
- func (mv *MinerVerifier) VerifySortition(height uint64, round, step uint32, proof ed25519.VrfProof, ...) (err error, j uint64)
- type ProposalBlockData
- func (data *ProposalBlockData) LessThan(other *ProposalBlockData) bool
- func (data *ProposalBlockData) NewProposalLeaderData() *ProposalLeaderData
- func (data *ProposalBlockData) SignBytes() []byte
- func (data *ProposalBlockData) String() string
- func (data *ProposalBlockData) ToHasProposalData() *HasProposalData
- func (data *ProposalBlockData) ToProposalStorage() types.ProposalStorage
- func (data *ProposalBlockData) Valid(height uint64) bool
- type ProposalLeaderData
- type RoundVoteSet
- func (rvs *RoundVoteSet) AddVoteAndCount(vote *VoteData, threshold uint64) (added, newPotential, enough bool, err error)
- func (rvs *RoundVoteSet) GetCertMajorValue() common.Hash
- func (rvs *RoundVoteSet) GetCertVotesOfValue(value common.Hash) []*VoteData
- func (rvs *RoundVoteSet) GetPotentialCertifiedValues() []common.Hash
- func (rvs *RoundVoteSet) GetPotentialSoftedValues() []common.Hash
- func (rvs *RoundVoteSet) GetSoftMajorValue() common.Hash
- func (rvs *RoundVoteSet) HasPotentialValue(value common.Hash) bool
- func (rvs *RoundVoteSet) HasVote(step uint32, user common.Address) bool
- func (rvs *RoundVoteSet) IsNextVoteEnoughForEmptyAtAnyStep(empty common.Hash) bool
- func (rvs *RoundVoteSet) PickNextVoteToSend(other *RoundVoteSet) *VoteData
- func (rvs *RoundVoteSet) PickVoteToSend(other *RoundVoteSet) *VoteData
- func (rvs *RoundVoteSet) SetHasVote(step uint32, user common.Address)
- type Snapshot
- type State
- type StateBase
- func (s *StateBase) OnCertVoteEnough(value common.Hash, round uint32) StateEvent
- func (s *StateBase) OnEnter()
- func (s *StateBase) OnExit()
- func (s *StateBase) OnNextVoteEnough(value common.Hash, round uint32, step uint32) StateEvent
- func (s *StateBase) OnPotentialVoteEnough(value common.Hash, round, step uint32)
- func (s *StateBase) OnProposalDataComplete(data *ProposalBlockData) StateEvent
- func (s *StateBase) OnProposalLeaderReceived(value *ProposalLeaderData)
- func (s *StateBase) OnSoftVoteEnough(value common.Hash, round uint32)
- func (s *StateBase) OnTimeout()
- func (s *StateBase) SetContext(c *Context)
- func (s *StateBase) String() string
- type StateCertifying
- func (s *StateCertifying) OnEnter()
- func (s *StateCertifying) OnExit()
- func (s *StateCertifying) OnProposalDataComplete(data *ProposalBlockData) StateEvent
- func (s *StateCertifying) OnSoftVoteEnough(value common.Hash, round uint32)
- func (s *StateCertifying) OnTimeout()
- func (s *StateCertifying) String() string
- type StateEvent
- type StateFiltering
- type StateFirstFinishing
- type StateNewHeight
- type StateProposal
- type StateSecondFinishing
- func (s *StateSecondFinishing) OnEnter()
- func (s *StateSecondFinishing) OnExit()
- func (s *StateSecondFinishing) OnNextVoteEnough(value common.Hash, round uint32, step uint32) StateEvent
- func (s *StateSecondFinishing) OnProposalDataComplete(data *ProposalBlockData) StateEvent
- func (s *StateSecondFinishing) OnSoftVoteEnough(value common.Hash, round uint32)
- func (s *StateSecondFinishing) OnTimeout()
- func (s *StateSecondFinishing) String() string
- type StatusData
- type StepVoteSet
- type TimeoutInfo
- type TimeoutTicker
- type UserSet
- type VoteData
- type VoteJournal
- type VoteSet
Constants ¶
const ( DefaultLifespan = 100 MaxLifespan = 100 MaxMinerKeySize = 200 * 1024 * 1024 // for lifespan = 1 on interval size = 1,000,000 )
const ( HandshakeMsg = 0x00 StatusMsg = 0x01 ProposalLeaderMsg = 0x02 ProposalBlockMsg = 0x03 VoteMsg = 0x04 HasVoteMsg = 0x05 TimeoutMsg = 0x06 HasProposalLeaderMsg = 0x07 HasProposalBlockMsg = 0x08 )
protocol message codes
Variables ¶
var CodeToString = map[uint64]string{ HandshakeMsg: "HandshakeMsg", StatusMsg: "StatusMsg", ProposalLeaderMsg: "ProposalLeaderMsg", ProposalBlockMsg: "ProposalBlockMsg", VoteMsg: "VoteMsg", HasVoteMsg: "HasVoteMsg", TimeoutMsg: "TimeoutMsg", HasProposalLeaderMsg: "HasProposalLeaderMsg", HasProposalBlockMsg: "HasProposalBlockMsg", }
Functions ¶
func BuildProof ¶
func GetWeight ¶
func GetWeight(config *params.AlgorandConfig, miner common.Address, stateDb *state.StateDB, totalBalanceOfMiners *big.Int, hash ed25519.VrfOutput256) (ownWeight, totalWeight uint64)
GetWeight returns weight of a miner. It's caller's responsibility to check that addr is a miner of current block
func PrintVoteJournalEntry ¶
func VerifyProof ¶
func VerifySignatureAndCredential ¶
func VerifySignatureAndCredential(mv *MinerVerifier, signBytes []byte, signature ed25519.ForwardSecureSignature, credential *Credential, stateDb *state.StateDB, parentSeed ed25519.VrfOutput256, totalBalanceOfMiners *big.Int) error
Types ¶
type Backend ¶
type Backend interface { BlockChain() *core.BlockChain TxPool() *core.TxPool GossipInterval() time.Duration }
Backend wraps all methods required for mining.
type Broadcaster ¶
type Context ¶
type Context struct { HeightState // contains filtered or unexported fields }
func NewContext ¶
func (*Context) GetParentProposalBlockData ¶
func (ctx *Context) GetParentProposalBlockData(height uint64) *ProposalBlockData
func (*Context) GetParentRoundVoteSet ¶
func (ctx *Context) GetParentRoundVoteSet(height uint64) (*RoundVoteSet, uint32)
func (*Context) GetProposalBlock ¶
func (ctx *Context) GetProposalBlock(height uint64, value common.Hash) *ProposalBlockData
GetProposalBlock returns a READONLY proposalBlock of the value return nil if not exists
func (*Context) GetProposalLeader ¶
func (ctx *Context) GetProposalLeader(height uint64, round uint32) *ProposalLeaderData
GetProposalLeader returns a READONLY ProposalLeaderData of the leader return nil if not exists
func (*Context) RoundVoteSet ¶
func (ctx *Context) RoundVoteSet(height uint64, round uint32) *RoundVoteSet
func (*Context) SaveProposalBlock ¶
func (ctx *Context) SaveProposalBlock(data *ProposalBlockData)
SaveProposalBlock stores a copy of proposalBlock of the value
func (*Context) StartMining ¶
func (ctx *Context) StartMining()
func (*Context) StopMining ¶
func (ctx *Context) StopMining()
func (*Context) UpdateProposalLeader ¶
func (ctx *Context) UpdateProposalLeader(value *ProposalLeaderData)
UpdateProposalLeader stores a copy of ProposalLeaderData of the leader
type Credential ¶
type Credential struct { Address common.Address `json:"address" gencodec:"required"` Height uint64 `json:"height" gencodec:"required"` Round uint32 `json:"round" gencodec:"required"` Step uint32 `json:"step" gencodec:"required"` Proof ed25519.VrfProof `json:"proof" gencodec:"required"` // cached Weight uint64 `json:"weight" rlp:"-"` }
func NewCredentialFromCredentialStorage ¶
func NewCredentialFromCredentialStorage(storage *types.CredentialStorage, height uint64, round uint32, step uint32) Credential
func (*Credential) LessThan ¶
func (c *Credential) LessThan(other *Credential) bool
func (*Credential) String ¶
func (c *Credential) String() string
type HandshakeData ¶
type HasProposalData ¶
func (*HasProposalData) String ¶
func (data *HasProposalData) String() string
type HasVoteData ¶
func ToHasVote ¶
func ToHasVote(data *VoteData) *HasVoteData
func (*HasVoteData) String ¶
func (data *HasVoteData) String() string
type HeightState ¶
type HeightState struct { Height uint64 // readonly, do not need mutex Round uint32 // modify by inner-thread,the other threads only read, do not need mutex Step uint32 // only using in inner-thread, do not need mutex EmptyValue common.Hash StartingValue common.Hash ProposalLeader map[uint32]*ProposalLeaderData // round => leader's proposal value message ReceivedProposalBlock map[string]*ProposalBlockData // Value => all received proposal data WaitingBlockForValue common.Hash WaitingBlockForRound uint32 // contains filtered or unexported fields }
type HeightVoteSet ¶
type HeightVoteSet struct {
// contains filtered or unexported fields
}
HeightVoteSet saves all votes for this Height
func (*HeightVoteSet) AddVoteAndCount ¶
func (hvs *HeightVoteSet) AddVoteAndCount(vote *VoteData, threshold uint64) (added, potential, enough bool, err error)
AddVoteAndCheck adds and counts vote, added is true only if the vote value is not enough, enough is true only if the value is enough after added. So added && enough means the value is firstly enough. err will be set only if the vote is invalid. err should cause the peer removed.
func (*HeightVoteSet) EnsureRoundVoteSet ¶
func (hvs *HeightVoteSet) EnsureRoundVoteSet(round uint32) *RoundVoteSet
EnsureRoundVoteSet return the RoundVoteSet of round, create it if not exists
func (*HeightVoteSet) GetCertVoteStorage ¶
func (hvs *HeightVoteSet) GetCertVoteStorage(round uint32, value common.Hash) []*types.CertVoteStorage
func (*HeightVoteSet) GetCertVotesOfValue ¶
func (hvs *HeightVoteSet) GetCertVotesOfValue(round uint32, value common.Hash) []*VoteData
GetCertVotesOfValue returns cert votes for value in certain round
func (*HeightVoteSet) IsNextVoteEnoughForEmptyAtAnyStep ¶
func (hvs *HeightVoteSet) IsNextVoteEnoughForEmptyAtAnyStep(round uint32, empty common.Hash) bool
IsNextVoteEnoughForEmptyAtAnyStep returns if next vote is enough for empty
func (*HeightVoteSet) IsPotentialValue ¶
func (hvs *HeightVoteSet) IsPotentialValue(round uint32, value common.Hash) bool
func (*HeightVoteSet) IsSoftVoteEnoughForNonEmpty ¶
func (hvs *HeightVoteSet) IsSoftVoteEnoughForNonEmpty(empty common.Hash, round uint32) (bool, common.Hash)
IsSoftVoteEnoughForNonEmpty returns true with the value if some value's soft votes is enough in round
func (*HeightVoteSet) IsSoftVoteEnoughForNonEmptyForAnyRound ¶
func (hvs *HeightVoteSet) IsSoftVoteEnoughForNonEmptyForAnyRound(empty common.Hash) (bool, common.Hash)
IsSoftVoteEnoughForNonEmptyForAnyRound returns true with the value if some value's soft votes is enough in any round
func (*HeightVoteSet) RoundVoteSet ¶
func (hvs *HeightVoteSet) RoundVoteSet(round uint32) *RoundVoteSet
RoundVoteSet returns the RoundVoteSet of round, return nil if not exists
func (*HeightVoteSet) SetHasVote ¶
func (hvs *HeightVoteSet) SetHasVote(round uint32, step uint32, user common.Address)
SetHasVote sets we had received the vote for round and step by user
type JournalType ¶
type JournalType uint8
const ( VoteJournalEntry JournalType = 0 TimeoutJournalEntry JournalType = 1 )
type MinerKey ¶
type MinerKey struct {
// contains filtered or unexported fields
}
func NewEmptyMinerKey ¶
func NewEmptyMinerKey(config *params.AlgorandConfig) *MinerKey
func (*MinerKey) ToVerifier ¶
func (mk *MinerKey) ToVerifier() *MinerVerifier
type MinerKeyManager ¶
type MinerKeyManager struct {
// contains filtered or unexported fields
}
func NewMinerKeyManager ¶
func NewMinerKeyManager(config *params.AlgorandConfig, dataDir string) *MinerKeyManager
func (*MinerKeyManager) Generate ¶
func (mkm *MinerKeyManager) Generate(miner, coinbase common.Address, start uint64, lifespan uint32) (mv *MinerVerifier, mk *MinerKey, err error)
func (*MinerKeyManager) GetMinerKey ¶
func (*MinerKeyManager) StartUpdateRoutine ¶
func (mkm *MinerKeyManager) StartUpdateRoutine(bc *core.BlockChain)
type MinerVerifier ¶
type MinerVerifier struct {
// contains filtered or unexported fields
}
func GetMinerVerifier ¶
func GetMinerVerifier(config *params.AlgorandConfig, statedb *state.StateDB, miner common.Address, height uint64) *MinerVerifier
func (*MinerVerifier) AbiString ¶
func (mv *MinerVerifier) AbiString() string
func (*MinerVerifier) Coinbase ¶
func (mv *MinerVerifier) Coinbase() common.Address
func (*MinerVerifier) GenesisString ¶
func (mv *MinerVerifier) GenesisString() string
func (*MinerVerifier) String ¶
func (mv *MinerVerifier) String() string
func (*MinerVerifier) Validate ¶
func (mv *MinerVerifier) Validate(height uint64) bool
func (*MinerVerifier) VerifySeed ¶
func (mv *MinerVerifier) VerifySeed(height uint64, parentSeed ed25519.VrfOutput256, parentHash common.Hash, seed ed25519.VrfOutput256, proof ed25519.VrfProof) error
func (*MinerVerifier) VerifySignature ¶
func (mv *MinerVerifier) VerifySignature(height uint64, data []byte, sig ed25519.ForwardSecureSignature) error
func (*MinerVerifier) VerifySortition ¶
type ProposalBlockData ¶
type ProposalBlockData struct { Block *types.Block ESignValue ed25519.ForwardSecureSignature Credential }
func NewProposalBlockDataFromProposalStorage ¶
func NewProposalBlockDataFromProposalStorage(leader *types.ProposalStorage, block *types.Block) *ProposalBlockData
func (*ProposalBlockData) LessThan ¶
func (data *ProposalBlockData) LessThan(other *ProposalBlockData) bool
func (*ProposalBlockData) NewProposalLeaderData ¶
func (data *ProposalBlockData) NewProposalLeaderData() *ProposalLeaderData
func (*ProposalBlockData) SignBytes ¶
func (data *ProposalBlockData) SignBytes() []byte
func (*ProposalBlockData) String ¶
func (data *ProposalBlockData) String() string
func (*ProposalBlockData) ToHasProposalData ¶
func (data *ProposalBlockData) ToHasProposalData() *HasProposalData
func (*ProposalBlockData) ToProposalStorage ¶
func (data *ProposalBlockData) ToProposalStorage() types.ProposalStorage
func (*ProposalBlockData) Valid ¶
func (data *ProposalBlockData) Valid(height uint64) bool
type ProposalLeaderData ¶
type ProposalLeaderData struct { Value common.Hash ESignValue ed25519.ForwardSecureSignature Credential }
func NewProposalLeaderDataFromStorage ¶
func NewProposalLeaderDataFromStorage(value common.Hash, height uint64, storage *types.ProposalStorage) *ProposalLeaderData
func (*ProposalLeaderData) LessThan ¶
func (data *ProposalLeaderData) LessThan(other *ProposalLeaderData) bool
func (*ProposalLeaderData) SignBytes ¶
func (data *ProposalLeaderData) SignBytes() []byte
func (*ProposalLeaderData) String ¶
func (data *ProposalLeaderData) String() string
func (*ProposalLeaderData) ToHasProposalData ¶
func (data *ProposalLeaderData) ToHasProposalData() *HasProposalData
func (*ProposalLeaderData) Valid ¶
func (data *ProposalLeaderData) Valid(height uint64) bool
type RoundVoteSet ¶
type RoundVoteSet struct {
// contains filtered or unexported fields
}
RoundVoteSet saves all votes for this round
func NewRoundVoteSet ¶
func NewRoundVoteSet() *RoundVoteSet
func NewRoundVoteSetFromCertificates ¶
func NewRoundVoteSetFromCertificates(votes []*VoteData, threshold uint64) *RoundVoteSet
func (*RoundVoteSet) AddVoteAndCount ¶
func (rvs *RoundVoteSet) AddVoteAndCount(vote *VoteData, threshold uint64) (added, newPotential, enough bool, err error)
enough表示此类投票是否已经出现+2/3的值了,目前在err==nil的情况下,与传入的值一样
func (*RoundVoteSet) GetCertMajorValue ¶
func (rvs *RoundVoteSet) GetCertMajorValue() common.Hash
func (*RoundVoteSet) GetCertVotesOfValue ¶
func (rvs *RoundVoteSet) GetCertVotesOfValue(value common.Hash) []*VoteData
GetCertVotesOfValue returns cert votes of value
func (*RoundVoteSet) GetPotentialCertifiedValues ¶
func (rvs *RoundVoteSet) GetPotentialCertifiedValues() []common.Hash
func (*RoundVoteSet) GetPotentialSoftedValues ¶
func (rvs *RoundVoteSet) GetPotentialSoftedValues() []common.Hash
func (*RoundVoteSet) GetSoftMajorValue ¶
func (rvs *RoundVoteSet) GetSoftMajorValue() common.Hash
func (*RoundVoteSet) HasPotentialValue ¶
func (rvs *RoundVoteSet) HasPotentialValue(value common.Hash) bool
func (*RoundVoteSet) HasVote ¶
func (rvs *RoundVoteSet) HasVote(step uint32, user common.Address) bool
func (*RoundVoteSet) IsNextVoteEnoughForEmptyAtAnyStep ¶
func (rvs *RoundVoteSet) IsNextVoteEnoughForEmptyAtAnyStep(empty common.Hash) bool
func (*RoundVoteSet) PickNextVoteToSend ¶
func (rvs *RoundVoteSet) PickNextVoteToSend(other *RoundVoteSet) *VoteData
func (*RoundVoteSet) PickVoteToSend ¶
func (rvs *RoundVoteSet) PickVoteToSend(other *RoundVoteSet) *VoteData
func (*RoundVoteSet) SetHasVote ¶
func (rvs *RoundVoteSet) SetHasVote(step uint32, user common.Address)
type State ¶
type State interface { SetContext(c *Context) OnEnter() OnExit() OnTimeout() OnPotentialVoteEnough(value common.Hash, round uint32, step uint32) OnSoftVoteEnough(value common.Hash, round uint32) OnCertVoteEnough(value common.Hash, round uint32) StateEvent OnNextVoteEnough(value common.Hash, round uint32, step uint32) StateEvent OnProposalLeaderReceived(value *ProposalLeaderData) OnProposalDataComplete(data *ProposalBlockData) StateEvent String() string }
State defines interfaces of state
type StateBase ¶
type StateBase struct { *Context // contains filtered or unexported fields }
StateBase is the base of all states
func (*StateBase) OnCertVoteEnough ¶
func (s *StateBase) OnCertVoteEnough(value common.Hash, round uint32) StateEvent
func (*StateBase) OnNextVoteEnough ¶
func (*StateBase) OnPotentialVoteEnough ¶
func (*StateBase) OnProposalDataComplete ¶
func (s *StateBase) OnProposalDataComplete(data *ProposalBlockData) StateEvent
func (*StateBase) OnProposalLeaderReceived ¶
func (s *StateBase) OnProposalLeaderReceived(value *ProposalLeaderData)
ProposalValue only accept in Step 1. 一旦Step1结束了,leader就确定了,也就无需再处理本轮的其它ProposalValue了。 同时,确保了在Step 2/3/... 期间传播ProposalData是最终leader的data。 这样,就确保了传播出某个Value的SoftVote的节点,一定能传播出对应于该值的Data。
func (*StateBase) OnSoftVoteEnough ¶
func (*StateBase) SetContext ¶
type StateCertifying ¶
type StateCertifying struct { StateBase // contains filtered or unexported fields }
StateCertifying try to send cert vote
func (*StateCertifying) OnEnter ¶
func (s *StateCertifying) OnEnter()
func (*StateCertifying) OnExit ¶
func (s *StateCertifying) OnExit()
func (*StateCertifying) OnProposalDataComplete ¶
func (s *StateCertifying) OnProposalDataComplete(data *ProposalBlockData) StateEvent
func (*StateCertifying) OnSoftVoteEnough ¶
func (s *StateCertifying) OnSoftVoteEnough(value common.Hash, round uint32)
func (*StateCertifying) OnTimeout ¶
func (s *StateCertifying) OnTimeout()
func (*StateCertifying) String ¶
func (s *StateCertifying) String() string
type StateEvent ¶
type StateEvent int
const ( Unchanged StateEvent = 0 NewRound StateEvent = 1 HeightEnd StateEvent = 2 )
func (StateEvent) IsChanged ¶
func (se StateEvent) IsChanged() bool
type StateFiltering ¶
type StateFiltering struct {
StateBase
}
StateFiltering sends soft vote
func (*StateFiltering) OnEnter ¶
func (s *StateFiltering) OnEnter()
func (*StateFiltering) String ¶
func (s *StateFiltering) String() string
type StateFirstFinishing ¶
type StateFirstFinishing struct {
StateBase
}
func (*StateFirstFinishing) OnEnter ¶
func (s *StateFirstFinishing) OnEnter()
func (*StateFirstFinishing) String ¶
func (s *StateFirstFinishing) String() string
type StateNewHeight ¶
type StateNewHeight struct { StateBase // contains filtered or unexported fields }
StateNewHeight is the first state of each Height
func (*StateNewHeight) OnEnter ¶
func (s *StateNewHeight) OnEnter()
OnEnter initializes context for new height
func (*StateNewHeight) String ¶
func (s *StateNewHeight) String() string
type StateProposal ¶
type StateProposal struct { StateBase // contains filtered or unexported fields }
StateProposal is the first state of each Round
func (*StateProposal) OnEnter ¶
func (s *StateProposal) OnEnter()
OnEnter initializes for new Round, and proposes
func (*StateProposal) OnExit ¶
func (s *StateProposal) OnExit()
func (*StateProposal) OnTimeout ¶
func (s *StateProposal) OnTimeout()
func (*StateProposal) String ¶
func (s *StateProposal) String() string
type StateSecondFinishing ¶
type StateSecondFinishing struct { StateBase // contains filtered or unexported fields }
func (*StateSecondFinishing) OnEnter ¶
func (s *StateSecondFinishing) OnEnter()
func (*StateSecondFinishing) OnExit ¶
func (s *StateSecondFinishing) OnExit()
func (*StateSecondFinishing) OnNextVoteEnough ¶
func (s *StateSecondFinishing) OnNextVoteEnough(value common.Hash, round uint32, step uint32) StateEvent
func (*StateSecondFinishing) OnProposalDataComplete ¶
func (s *StateSecondFinishing) OnProposalDataComplete(data *ProposalBlockData) StateEvent
func (*StateSecondFinishing) OnSoftVoteEnough ¶
func (s *StateSecondFinishing) OnSoftVoteEnough(value common.Hash, round uint32)
func (*StateSecondFinishing) OnTimeout ¶
func (s *StateSecondFinishing) OnTimeout()
func (*StateSecondFinishing) String ¶
func (s *StateSecondFinishing) String() string
type StatusData ¶
type StepVoteSet ¶
type StepVoteSet struct { Values map[string]*VoteSet // value => value info MajorValue common.Hash // the major value reached 2/3+ (2t+1) PotentialValue []common.Hash // the potential values reached 1/3+ (t+1), maybe more than one // contains filtered or unexported fields }
StepVoteSet saves all votes for each step
func NewStepVoteSet ¶
func NewStepVoteSet() *StepVoteSet
func (*StepVoteSet) RandomNotIn ¶
func (svs *StepVoteSet) RandomNotIn(other *StepVoteSet) *VoteData
type TimeoutInfo ¶
type TimeoutInfo struct { Duration uint64 `json:"duration"` Height uint64 `json:"height"` Round uint32 `json:"round"` Step uint32 `json:"step"` }
internally generated messages which may update the state
func (*TimeoutInfo) String ¶
func (ti *TimeoutInfo) String() string
type TimeoutTicker ¶
type TimeoutTicker interface { Start() error Stop() Chan() <-chan TimeoutInfo // on which to receive a timeout ScheduleTimeout(ti TimeoutInfo) // reset the timer }
TimeoutTicker is a timer that schedules timeouts conditional on the height/round/step in the TimeoutInfo. The TimeoutInfo.Duration may be non-positive.
func NewTimeoutTicker ¶
func NewTimeoutTicker() TimeoutTicker
NewTimeoutTicker returns a new TimeoutTicker.
type VoteData ¶
type VoteData struct { Value common.Hash `json:"value" gencodec:"required"` ESignValue ed25519.ForwardSecureSignature `json:"eSignature" gencodec:"required"` Credential `json:"credential" gencodec:"required"` }
Vote represents votes produced by committee members
func RandomSelect ¶
type VoteJournal ¶
type VoteJournal struct {
// contains filtered or unexported fields
}
func NewVoteJournal ¶
func NewVoteJournal(path string) *VoteJournal
func (*VoteJournal) CloseFile ¶
func (j *VoteJournal) CloseFile() error
func (*VoteJournal) OpenFile ¶
func (j *VoteJournal) OpenFile() error