iotex-core: github.com/iotexproject/iotex-core/action/protocol/poll Index | Files

package poll

import "github.com/iotexproject/iotex-core/action/protocol/poll"

Index

Package Files

nativeStaking.abi.go nativestaking.go protocol.go staking_committee.go

Constants

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

Variables

var (

    // ErrNoData is an error that there's no data in the contract
    ErrNoData = errors.New("no data")
    // ErrEndOfData is an error that reaching end of data in the contract
    ErrEndOfData = errors.New("end of data")
)
var ErrDelegatesNotAsExpected = errors.New("delegates are not as expected")

ErrDelegatesNotAsExpected is an error that the delegates are not as expected

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

ErrNoElectionCommittee is an error that the election committee is not specified

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

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

var NsAbi = "" /* 12352 byte string literal not displayed */

NsAbi is the ABI of native staking contract

type GetBlockTime Uses

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

GetBlockTime defines a function to get block creation time

type GetEpochHeight Uses

type GetEpochHeight func(uint64) uint64

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

type GetEpochNum Uses

type GetEpochNum func(uint64) uint64

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

type GetTipBlockTime Uses

type GetTipBlockTime func() (time.Time, error)

GetTipBlockTime defines a function to get tip block creation time

type NativeStaking Uses

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

NativeStaking represents native staking struct

func NewNativeStaking Uses

func NewNativeStaking(cm protocol.ChainManager, getTipBlockTime GetTipBlockTime) (*NativeStaking, error)

NewNativeStaking creates a NativeStaking instance

func (*NativeStaking) SetContract Uses

func (ns *NativeStaking) SetContract(contract string)

SetContract sets the contract address

func (*NativeStaking) Votes Uses

func (ns *NativeStaking) Votes() (*VoteTally, time.Time, error)

Votes returns the votes on height

type Protocol Uses

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)
    // SetContract sets the native staking contract address
    SetNativeStakingContract(string)
}

Protocol defines the protocol of handling votes

func NewGovernanceChainCommitteeProtocol Uses

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 Uses

func NewLifeLongDelegatesProtocol(delegates []genesis.Delegate) Protocol

NewLifeLongDelegatesProtocol creates a poll protocol with life long delegates

func NewProtocol Uses

func NewProtocol(
    cfg config.Config,
    cm protocol.ChainManager,
    electionCommittee committee.Committee,
    getBlockTimeFunc GetBlockTime,
    getBlockTipHeightFunc GetTipBlockTime,
    rp *rolldpos.Protocol) (Protocol, error)

NewProtocol instantiates a rewarding protocol instance.

func NewStakingCommittee Uses

func NewStakingCommittee(
    hu config.HeightUpgrade,
    ec committee.Committee,
    gs Protocol,
    cm protocol.ChainManager,
    getTipBlockTime GetTipBlockTime,
    getEpochHeight GetEpochHeight,
    getEpochNum GetEpochNum,
    nativeStakingContractAddress string,
    nativeStakingContractCode string,
    rp *rolldpos.Protocol,
    scoreThreshold *big.Int,
) (Protocol, error)

NewStakingCommittee creates a staking committee which fetch result from governance chain and native staking

type VoteTally Uses

type VoteTally struct {
    Candidates map[[12]byte]*state.Candidate
    Buckets    []*types.Bucket
}

VoteTally is a map of candidates on native chain

Package poll imports 28 packages (graph) and is imported by 4 packages. Updated 2019-11-11. Refresh now. Tools for package owners.