Documentation
¶
Overview ¶
*
- @file
- @copyright defined in aergo/LICENSE.txt
*
- @file
- @copyright defined in aergo/LICENSE.txt
Index ¶
- Constants
- Variables
- func BuildOrderedCandidates(vote map[string]*big.Int) []string
- func ExecuteSystemTx(scs *state.ContractState, txBody *types.TxBody, sender, receiver *state.V, ...) ([]*types.Event, error)
- func GenProposalKey(id string) []byte
- func GetBpCount() int
- func GetGasPrice() *big.Int
- func GetGasPriceFromState(ar AccountStateReader) *big.Int
- func GetNamePrice() *big.Int
- func GetNamePriceFromState(scs *state.ContractState) *big.Int
- func GetParam(proposalID string) *big.Int
- func GetRankers(ar AccountStateReader) ([]string, error)
- func GetStaking(scs *state.ContractState, address []byte) (*types.Staking, error)
- func GetStakingMinimum() *big.Int
- func GetStakingMinimumFromState(scs *state.ContractState) *big.Int
- func GetStakingTotal(ar AccountStateReader) (*big.Int, error)
- func GetVote(scs *state.ContractState, voter []byte, issue []byte) (*types.Vote, error)
- func GetVoteResult(ar AccountStateReader, id []byte, n int) (*types.VoteList, error)
- func GetVoteResultEx(ar AccountStateReader, key []byte, n int) (*types.VoteList, error)
- func GetVotes(scs *state.ContractState, address []byte) ([]*types.VoteInfo, error)
- func GetVotingCatalog() []types.VotingIssue
- func GetVotingIssues() []types.VotingIssue
- func GetVotingRewardAmount() *big.Int
- func InitGovernance(consensus string)
- func InitSystemParams(g dataGetter, bpCount int)
- func InitVoteResult(scs *state.ContractState, voteResult map[string]*big.Int) error
- func InitVotingPowerRank(s dataGetter) (err error)
- func PickVotingRewardWinner(seed int64) (types.Address, error)
- type AccountStateReader
- type Proposal
- type SystemContext
- type VoteResult
Constants ¶
View Source
const ( PeerIDLength = 39 VotingDelay = 60 * 60 * 24 //block interval )
View Source
const (
RESET = -1
)
View Source
const StakingDelay = 60 * 60 * 24 //block interval
Variables ¶
View Source
var ( ErrNoVotingRewardWinner = errors.New("voting reward: no winner") ErrNoVotingRewardRank = errors.New("voting reward rank: not initialized") )
View Source
var ( //DefaultParams is for aergo v1 compatibility DefaultParams = map[string]*big.Int{ stakingMin.ID(): types.StakingMinimum, gasPrice.ID(): big.NewInt(1), namePrice.ID(): big.NewInt(1000000000000000000), } )
View Source
var (
ErrInvalidCandidate = errors.New("invalid candidate")
)
View Source
var ErrTxSystemOperatorIsNotSet = errors.New("operator is not set")
View Source
var SystemProposal = map[string]*Proposal{ bpCount.ID(): &Proposal{ ID: bpCount.ID(), Description: "", Blockfrom: 0, Blockto: 0, MultipleChoice: 1, Candidates: nil, }, stakingMin.ID(): &Proposal{ ID: stakingMin.ID(), Description: "", Blockfrom: 0, Blockto: 0, MultipleChoice: 1, Candidates: nil, }, gasPrice.ID(): &Proposal{ ID: gasPrice.ID(), Description: "", Blockfrom: 0, Blockto: 0, MultipleChoice: 1, Candidates: nil, }, namePrice.ID(): &Proposal{ ID: namePrice.ID(), Description: "", Blockfrom: 0, Blockto: 0, MultipleChoice: 1, Candidates: nil, }, }
Functions ¶
func BuildOrderedCandidates ¶ added in v0.8.3
BuildOrderedCandidates returns a candidate list ordered by votes.xs
func ExecuteSystemTx ¶
func GenProposalKey ¶ added in v1.3.3
func GetBpCount ¶ added in v1.3.3
func GetBpCount() int
func GetGasPrice ¶ added in v1.3.3
func GetGasPriceFromState ¶ added in v1.3.3
func GetGasPriceFromState(ar AccountStateReader) *big.Int
func GetNamePrice ¶ added in v1.0.0
func GetNamePriceFromState ¶ added in v1.3.3
func GetNamePriceFromState(scs *state.ContractState) *big.Int
func GetRankers ¶ added in v0.11.0
func GetRankers(ar AccountStateReader) ([]string, error)
GetRankers returns the IDs of the top n rankers.
func GetStaking ¶ added in v0.8.1
func GetStakingMinimum ¶ added in v1.3.3
func GetStakingMinimumFromState ¶ added in v1.3.3
func GetStakingMinimumFromState(scs *state.ContractState) *big.Int
func GetStakingTotal ¶ added in v1.0.0
func GetStakingTotal(ar AccountStateReader) (*big.Int, error)
func GetVoteResult ¶
GetVoteResult returns the top n voting result from the system account state.
func GetVoteResultEx ¶ added in v1.0.0
func GetVotingCatalog ¶ added in v1.3.3
func GetVotingCatalog() []types.VotingIssue
func GetVotingIssues ¶ added in v1.3.3
func GetVotingIssues() []types.VotingIssue
func GetVotingRewardAmount ¶ added in v1.3.3
func InitGovernance ¶ added in v1.3.3
func InitGovernance(consensus string)
func InitSystemParams ¶ added in v1.3.3
func InitSystemParams(g dataGetter, bpCount int)
func InitVoteResult ¶
func InitVotingPowerRank ¶ added in v1.3.3
func InitVotingPowerRank(s dataGetter) (err error)
InitVotingPowerRank reads the stored data from s and initializes the Voting Power Rank, which contains each voters's voting power.
Types ¶
type AccountStateReader ¶ added in v0.9.4
type AccountStateReader interface {
GetSystemAccountState() (*state.ContractState, error)
}
AccountStateReader is an interface for getting a system account state.
type Proposal ¶ added in v1.3.3
type SystemContext ¶ added in v1.0.0
type SystemContext struct { BlockInfo *types.BlockHeaderInfo Call *types.CallInfo Args []string Staked *types.Staking Vote *types.Vote // voting Proposal *Proposal // voting Sender *state.V Receiver *state.V // contains filtered or unexported fields }
SystemContext is context of executing aergo.system transaction and filled after validation.
func ValidateSystemTx ¶
func ValidateSystemTx(account []byte, txBody *types.TxBody, sender *state.V, scs *state.ContractState, blockInfo *types.BlockHeaderInfo) (*SystemContext, error)
type VoteResult ¶ added in v1.0.0
type VoteResult struct {
// contains filtered or unexported fields
}
func (*VoteResult) AddVote ¶ added in v1.0.0
func (voteResult *VoteResult) AddVote(vote *types.Vote) error
func (*VoteResult) GetTotal ¶ added in v1.3.3
func (voteResult *VoteResult) GetTotal() *big.Int
func (*VoteResult) SubVote ¶ added in v1.0.0
func (voteResult *VoteResult) SubVote(vote *types.Vote) error
func (*VoteResult) Sync ¶ added in v1.0.0
func (vr *VoteResult) Sync() error
Sync is write vote result data to state DB. if vote result over the threshold,
Click to show internal directories.
Click to hide internal directories.