consensus

package
v0.0.0-...-5fb01ef Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var Epsilon = int64(10 * time.Millisecond) //viper.GetInt64("poll.epsilon")

Functions

func StartProduction

func StartProduction(poll *Poll, id string) (ttpChan chan struct{})

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

func UntilNext

func UntilNext(period int64) time.Duration

Types

type Candidate

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

type Poll

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

func NewPoll

func NewPoll(maxDelegates int, maxVotes int, freezePeriod time.Duration, genesisStart int64) *Poll

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 (p *Poll) GetCurrentSlotStart(timeStamp int64) int64

func (*Poll) GetMaxElected

func (p *Poll) GetMaxElected() int

func (*Poll) GetPosition

func (p *Poll) GetPosition(candidate string) int

func (*Poll) IsElected

func (p *Poll) IsElected(candidate string) (result bool)

func (*Poll) IsValid

func (p *Poll) IsValid(block *blockchain.BlockData, receivedAt int64) (valid bool, err error)

Block validation from DPoS perspective: was block produced by right candidate at the right time?

func (*Poll) Period

func (p *Poll) Period() int64

func (*Poll) StartNewRound

func (p *Poll) StartNewRound()

func (*Poll) SubmitVote

func (p *Poll) SubmitVote(vote blockchain.Vote) (err error)

type VoterInfo

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

Jump to

Keyboard shortcuts

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