Documentation ¶
Index ¶
- Variables
- type CandidateIndexer
- func (cd *CandidateIndexer) CandidateList(height uint64) (state.CandidateList, error)
- func (cd *CandidateIndexer) KickoutList(height uint64) (*vote.Blacklist, error)
- func (cd *CandidateIndexer) PutCandidateList(height uint64, candidates *state.CandidateList) error
- func (cd *CandidateIndexer) PutKickoutList(height uint64, kickoutList *vote.Blacklist) error
- func (cd *CandidateIndexer) Start(ctx context.Context) error
- func (cd *CandidateIndexer) Stop(ctx context.Context) error
- type CandidatesByHeight
- type GetBlockTime
- type GetCandidates
- type GetKickoutList
- type GetUnproductiveDelegate
- type NativeStaking
- type ProductivityByEpoch
- type Protocol
- func FindProtocol(registry *protocol.Registry) Protocol
- func MustGetProtocol(registry *protocol.Registry) Protocol
- func NewGovernanceChainCommitteeProtocol(candidatesIndexer *CandidateIndexer, candidatesByHeight CandidatesByHeight, ...) (Protocol, error)
- func NewLifeLongDelegatesProtocol(delegates []genesis.Delegate) Protocol
- func NewProtocol(cfg config.Config, candidateIndexer *CandidateIndexer, ...) (Protocol, error)
- func NewStakingCommand(hu config.HeightUpgrade, candIndexer *CandidateIndexer, stkV1 Protocol, ...) (Protocol, error)
- func NewStakingCommittee(ec committee.Committee, gs Protocol, readContract ReadContract, ...) (Protocol, error)
- type ReadContract
- type VoteTally
Constants ¶
This section is empty.
Variables ¶
var ( // CandidateNamespace is a namespace to store raw candidate CandidateNamespace = "candidates" // KickoutNamespace is a namespace to store kickoutlist KickoutNamespace = "kickout" // ErrIndexerNotExist is an error that shows not exist in candidate indexer DB ErrIndexerNotExist = errors.New("not exist in DB") )
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 ErrDelegatesNotExist = errors.New("delegates cannot be found")
ErrDelegatesNotExist is an error that the delegates cannot be prepared
var ErrInconsistentHeight = errors.New("data is inconsistent because the state height has been changed")
ErrInconsistentHeight is an error that result of "readFromStateDB" is not consistent with others
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 = `` /* 12350-byte string literal not displayed */
NsAbi is the ABI of native staking contract
Functions ¶
This section is empty.
Types ¶
type CandidateIndexer ¶ added in v0.11.0
type CandidateIndexer struct {
// contains filtered or unexported fields
}
CandidateIndexer is an indexer to store candidate/blacklist by given height
func NewCandidateIndexer ¶ added in v0.11.0
func NewCandidateIndexer(kv db.KVStore) (*CandidateIndexer, error)
NewCandidateIndexer creates a new CandidateIndexer
func (*CandidateIndexer) CandidateList ¶ added in v0.11.0
func (cd *CandidateIndexer) CandidateList(height uint64) (state.CandidateList, error)
CandidateList gets candidate list from indexer given epoch start height
func (*CandidateIndexer) KickoutList ¶ added in v0.11.0
func (cd *CandidateIndexer) KickoutList(height uint64) (*vote.Blacklist, error)
KickoutList gets kickout list from indexer given epoch start height
func (*CandidateIndexer) PutCandidateList ¶ added in v0.11.0
func (cd *CandidateIndexer) PutCandidateList(height uint64, candidates *state.CandidateList) error
PutCandidateList puts candidate list into indexer
func (*CandidateIndexer) PutKickoutList ¶ added in v0.11.0
func (cd *CandidateIndexer) PutKickoutList(height uint64, kickoutList *vote.Blacklist) error
PutKickoutList puts kickout list into indexer
type CandidatesByHeight ¶ added in v0.11.0
CandidatesByHeight returns the candidates of a given height
type GetBlockTime ¶
GetBlockTime defines a function to get block creation time
type GetCandidates ¶ added in v0.11.0
type GetCandidates func(protocol.StateReader, bool, ...protocol.StateOption) ([]*state.Candidate, uint64, error)
GetCandidates returns the current candidates
type GetKickoutList ¶ added in v0.11.0
type GetKickoutList func(protocol.StateReader, bool, ...protocol.StateOption) (*vote.Blacklist, uint64, error)
GetKickoutList returns current the blacklist
type GetUnproductiveDelegate ¶ added in v0.11.0
type GetUnproductiveDelegate func(protocol.StateReader) (*vote.UnproductiveDelegate, error)
GetUnproductiveDelegate returns unproductiveDelegate struct which contains a cache of upd info by epochs
type NativeStaking ¶ added in v0.8.4
type NativeStaking struct {
// contains filtered or unexported fields
}
NativeStaking represents native staking struct
func NewNativeStaking ¶ added in v0.8.4
func NewNativeStaking(readContract ReadContract) (*NativeStaking, error)
NewNativeStaking creates a NativeStaking instance
func (*NativeStaking) SetContract ¶ added in v0.9.0
func (ns *NativeStaking) SetContract(contract string)
SetContract sets the contract address
type ProductivityByEpoch ¶ added in v0.11.0
ProductivityByEpoch returns the number of produced blocks per delegate in an epoch
type Protocol ¶
type Protocol interface { protocol.Protocol protocol.GenesisStateCreator DelegatesByEpoch(context.Context, uint64) (state.CandidateList, error) CandidatesByHeight(context.Context, uint64) (state.CandidateList, error) // CalculateCandidatesByHeight calculates candidate and returns candidates by chain height CalculateCandidatesByHeight(context.Context, uint64) (state.CandidateList, error) }
Protocol defines the protocol of handling votes
func FindProtocol ¶ added in v0.11.0
FindProtocol finds the registered protocol from registry
func MustGetProtocol ¶ added in v0.11.0
MustGetProtocol return a registered protocol from registry
func NewGovernanceChainCommitteeProtocol ¶
func NewGovernanceChainCommitteeProtocol( candidatesIndexer *CandidateIndexer, candidatesByHeight CandidatesByHeight, getCandidates GetCandidates, getKickoutList GetKickoutList, getUnproductiveDelegate GetUnproductiveDelegate, electionCommittee committee.Committee, initGravityChainHeight uint64, getBlockTime GetBlockTime, numCandidateDelegates uint64, numDelegates uint64, initialCandidatesInterval time.Duration, sr protocol.StateReader, productivityByEpoch ProductivityByEpoch, productivityThreshold uint64, kickoutEpochPeriod uint64, kickoutIntensity uint32, maxKickoutPeriod uint64, ) (Protocol, error)
NewGovernanceChainCommitteeProtocol creates a Poll Protocol which fetch result from governance chain
func NewLifeLongDelegatesProtocol ¶
NewLifeLongDelegatesProtocol creates a poll protocol with life long delegates
func NewProtocol ¶ added in v0.11.0
func NewProtocol( cfg config.Config, candidateIndexer *CandidateIndexer, readContract ReadContract, candidatesByHeight CandidatesByHeight, getCandidates GetCandidates, kickoutListByEpoch GetKickoutList, getUnproductiveDelegate GetUnproductiveDelegate, electionCommittee committee.Committee, stakingV2 *staking.Protocol, getBlockTimeFunc GetBlockTime, sr protocol.StateReader, productivityByEpoch ProductivityByEpoch, ) (Protocol, error)
NewProtocol instantiates a rewarding protocol instance.
func NewStakingCommand ¶ added in v0.11.0
func NewStakingCommand( hu config.HeightUpgrade, candIndexer *CandidateIndexer, stkV1 Protocol, stkV2 *staking.Protocol, ) (Protocol, error)
NewStakingCommand creates a staking command center to manage staking committee and new native staking
func NewStakingCommittee ¶ added in v0.8.4
func NewStakingCommittee( ec committee.Committee, gs Protocol, readContract ReadContract, nativeStakingContractAddress string, nativeStakingContractCode string, scoreThreshold *big.Int, ) (Protocol, error)
NewStakingCommittee creates a staking committee which fetch result from governance chain and native staking
type ReadContract ¶ added in v0.11.0
ReadContract defines a callback function to read contract