poll

package
v0.8.1-rc1 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2019 License: Apache-2.0 Imports: 20 Imported by: 11

Documentation

Index

Constants

View Source
const (
	// ProtocolID defines the ID of this protocol
	ProtocolID = "poll"
)

Variables

View Source
var ErrDelegatesNotAsExpected = errors.New("delegates are not as expected")

ErrDelegatesNotAsExpected is an error that the delegates are not as expected

View Source
var ErrNoElectionCommittee = errors.New("no election committee specified")

ErrNoElectionCommittee is an error that the election committee is not specified

View Source
var ErrProposedDelegatesLength = errors.New("the proposed delegate list length")

ErrProposedDelegatesLength is an error that the proposed delegate list length is not right

Functions

This section is empty.

Types

type GetBlockTime

type GetBlockTime func(uint64) (time.Time, error)

GetBlockTime defines a function to get block creation time

type GetEpochHeight

type GetEpochHeight func(uint64) uint64

GetEpochHeight defines a function to get the corresponding epoch height given an epoch number

type GetEpochNum

type GetEpochNum func(uint64) uint64

GetEpochNum defines a function to get epoch number given a block height

type Protocol

type Protocol interface {
	// Initialize fetches the poll result for genesis block
	Initialize(context.Context, protocol.StateManager) error
	// Handle handles a vote
	Handle(context.Context, action.Action, protocol.StateManager) (*action.Receipt, error)
	// Validate validates a vote
	Validate(context.Context, action.Action) error
	// DelegatesByHeight returns the delegates by chain height
	DelegatesByHeight(uint64) (state.CandidateList, error)
	// ReadState read the state on blockchain via protocol
	ReadState(context.Context, protocol.StateManager, []byte, ...[]byte) ([]byte, error)
}

Protocol defines the protocol of handling votes

func NewGovernanceChainCommitteeProtocol

func NewGovernanceChainCommitteeProtocol(
	cm protocol.ChainManager,
	electionCommittee committee.Committee,
	initGravityChainHeight uint64,
	getBlockTime GetBlockTime,
	getEpochHeight GetEpochHeight,
	getEpochNum GetEpochNum,
	numCandidateDelegates uint64,
	numDelegates uint64,
	initialCandidatesInterval time.Duration,
) (Protocol, error)

NewGovernanceChainCommitteeProtocol creates a Poll Protocol which fetch result from governance chain

func NewLifeLongDelegatesProtocol

func NewLifeLongDelegatesProtocol(delegates []genesis.Delegate) Protocol

NewLifeLongDelegatesProtocol creates a poll protocol with life long delegates

Jump to

Keyboard shortcuts

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