core

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2019 License: GPL-3.0, LGPL-3.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultLifespan = 100
	MaxLifespan     = 100
	MaxMinerKeySize = 200 * 1024 * 1024 // for lifespan = 1 on interval size = 1,000,000
)
View Source
const (
	HandshakeMsg         = 0x00
	StatusMsg            = 0x01
	ProposalLeaderMsg    = 0x02
	ProposalBlockMsg     = 0x03
	VoteMsg              = 0x04
	HasVoteMsg           = 0x05
	TimeoutMsg           = 0x06
	HasProposalLeaderMsg = 0x07
	HasProposalBlockMsg  = 0x08
)

protocol message codes

Variables

View Source
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 BuildProof(config *params.AlgorandConfig, stateDb *state.StateDB, height uint64, leader common.Address, cvs []*types.CertVoteStorage, proofDb ethdb.Putter) (err error)

func GetCommitteeNumber

func GetCommitteeNumber(height uint64, step uint32) (uint64, uint64)

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 PrintVoteJournalEntry(ts, code uint64, data interface{}, from string) error

func VerifyProof

func VerifyProof(config *params.AlgorandConfig, stateRoot common.Hash, height uint64, leader common.Address, cvs []*types.CertVoteStorage, proof types.NodeList) error

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 Broadcaster interface {
	Broadcast(code uint64, data interface{})

	Publish(chanId []byte, msgCode uint64, data interface{})
	Sub(chanId []byte, timeout time.Duration)
	UnSub(chanId []byte)
	Request(chanId []byte, value common.Hash)
}

type Context

type Context struct {
	HeightState
	// contains filtered or unexported fields
}

func NewContext

func NewContext(eth Backend, broadcaster Broadcaster, config *params.ChainConfig, mux *event.TypeMux, engine consensus.Engine, algorandDataDir string, gasFloor, gasCeil uint64) *Context

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) HR

func (ctx *Context) HR() (uint64, uint32)

func (*Context) HRS

func (ctx *Context) HRS() string

func (*Context) IsMining

func (ctx *Context) IsMining() bool

func (*Context) NewBlock

func (ctx *Context) NewBlock() error

func (*Context) OnReceive

func (ctx *Context) OnReceive(code uint64, data interface{}, from string)

func (*Context) Pending

func (ctx *Context) Pending() (*types.Block, *state.StateDB)

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) SetExtra

func (ctx *Context) SetExtra(extra []byte)

func (*Context) SetMiner

func (ctx *Context) SetMiner(address common.Address)

func (*Context) Stake

func (ctx *Context) Stake() uint64

func (*Context) Start

func (ctx *Context) Start()

func (*Context) StartMining

func (ctx *Context) StartMining()

func (*Context) Stop

func (ctx *Context) Stop()

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 HandshakeData struct {
	Version uint32
	Height  uint64
	Round   uint32
}

type HasProposalData

type HasProposalData struct {
	Height uint64
	Round  uint32
	Proof  ed25519.VrfProof
	Value  common.Hash
}

func (*HasProposalData) String

func (data *HasProposalData) String() string

type HasVoteData

type HasVoteData struct {
	Address common.Address
	Height  uint64
	Round   uint32
	Step    uint32
}

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 NewHeightVoteSet

func NewHeightVoteSet() *HeightVoteSet

NewHeightVoteSet makes a new object

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) HasVote

func (hvs *HeightVoteSet) HasVote(round uint32, step uint32, user common.Address) bool

HasVote returns true if user had voted in certain round and step

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) DecodeRLP

func (mk *MinerKey) DecodeRLP(stream *rlp.Stream) error

func (*MinerKey) EncodeRLP

func (mk *MinerKey) EncodeRLP(writer io.Writer) error

func (*MinerKey) Seed

func (mk *MinerKey) Seed(height uint64, parentSeed ed25519.VrfOutput256, parentHash common.Hash) (seed ed25519.VrfOutput256, proof ed25519.VrfProof, err error)

func (*MinerKey) Sign

func (mk *MinerKey) Sign(height uint64, data []byte) (sig ed25519.ForwardSecureSignature, err error)

func (*MinerKey) Sortition

func (mk *MinerKey) Sortition(height uint64, round, step uint32, parentSeed ed25519.VrfOutput256, parentState *state.StateDB, totalBalanceOfMiners *big.Int) (hash ed25519.VrfOutput256, proof ed25519.VrfProof, j uint64, err error)

func (*MinerKey) ToVerifier

func (mk *MinerKey) ToVerifier() *MinerVerifier

func (*MinerKey) Update

func (mk *MinerKey) Update(height uint64) uint64

func (*MinerKey) Validate

func (mk *MinerKey) Validate(height uint64) bool

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 (mkm *MinerKeyManager) GetMinerKey(miner common.Address, height uint64) (*MinerKey, error)

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

func (mv *MinerVerifier) VerifySortition(height uint64, round, step uint32, proof ed25519.VrfProof, parentSeed ed25519.VrfOutput256, parentState *state.StateDB, totalBalanceOfMiners *big.Int) (err error, j uint64)

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 Snapshot

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

func (*Snapshot) Copy

func (s *Snapshot) Copy() *snapshotBlockState

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) OnEnter

func (s *StateBase) OnEnter()

func (*StateBase) OnExit

func (s *StateBase) OnExit()

func (*StateBase) OnNextVoteEnough

func (s *StateBase) OnNextVoteEnough(value common.Hash, round uint32, step uint32) StateEvent

func (*StateBase) OnPotentialVoteEnough

func (s *StateBase) OnPotentialVoteEnough(value common.Hash, round, step uint32)

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 (s *StateBase) OnSoftVoteEnough(value common.Hash, round uint32)

func (*StateBase) OnTimeout

func (s *StateBase) OnTimeout()

func (*StateBase) SetContext

func (s *StateBase) SetContext(c *Context)

func (*StateBase) String

func (s *StateBase) String() string

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 StatusData struct {
	Height uint64
	Round  uint32
}

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 UserSet

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

UserSet

func (*UserSet) Add

func (us *UserSet) Add(user common.Address)

func (*UserSet) Has

func (us *UserSet) Has(user common.Address) bool

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 NewVoteDataFromCertVoteStorage

func NewVoteDataFromCertVoteStorage(storage *types.CertVoteStorage, height uint64, round uint32, value common.Hash) *VoteData

func RandomSelect

func RandomSelect(from []*VoteData) *VoteData

func (*VoteData) SignBytes

func (data *VoteData) SignBytes() []byte

func (*VoteData) String

func (data *VoteData) String() string

func (*VoteData) Valid

func (data *VoteData) Valid(height uint64, emptyValue common.Hash) bool

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

func (*VoteJournal) Read

func (j *VoteJournal) Read(load func(ts, code uint64, data interface{}, from string) error) error

func (*VoteJournal) Write

func (j *VoteJournal) Write(code uint64, data interface{}, from string) error

type VoteSet

type VoteSet struct {
	Weight uint64 // sum of all voter's weight
	Votes  []*VoteData
}

VoteSet stores the value info for same value by same vote type in same round

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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