Documentation
¶
Index ¶
- Variables
- func StartProduction(poll *Poll, id string) (ttpChan chan struct{})
- func UntilNext(period int64) time.Duration
- type Candidate
- type Poll
- func (p *Poll) GetCurrentSlotStart(timeStamp int64) int64
- func (p *Poll) GetMaxElected() int
- func (p *Poll) GetPosition(candidate string) int
- func (p *Poll) IsElected(candidate string) (result bool)
- func (p *Poll) IsValid(block *blockchain.BlockData, receivedAt int64) (valid bool, err error)
- func (p *Poll) Period() int64
- func (p *Poll) StartNewRound()
- func (p *Poll) SubmitVote(vote blockchain.Vote) (err error)
- type VoterInfo
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Epsilon = int64(10 * time.Millisecond) //viper.GetInt64("poll.epsilon")
Functions ¶
func StartProduction ¶
period - time between blocks production in seconds, ttp - time to produce ticker
Example ¶
viper.Set("poll.period", int64(time.Second)) poll := doElection() for candidate := range winners { startProduction(poll, candidate) } for candidate := range losers { startProduction(poll, candidate) } time.Sleep(10100 * time.Millisecond)
Output: forthh fifthh winner second thirdd forthh fifthh winner second thirdd
Types ¶
type Poll ¶
type Poll struct {
// contains filtered or unexported fields
}
func NewPoll ¶
Creates new structure that counts incoming votes and maintains list of maxDelegates top voted candidates. maxVotes is number of candidates one is allowed to vote for. freezePeriod is time required to elapse before voter can vote again
func (*Poll) GetCurrentSlotStart ¶
func (*Poll) GetMaxElected ¶
func (*Poll) GetPosition ¶
func (*Poll) IsValid ¶
Block validation from DPoS perspective: was block produced by right candidate at the right time?
func (*Poll) StartNewRound ¶
func (p *Poll) StartNewRound()
func (*Poll) SubmitVote ¶
func (p *Poll) SubmitVote(vote blockchain.Vote) (err error)
Click to show internal directories.
Click to hide internal directories.