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 CommitParams(apply bool)
- func DumpVotingPowerRankers(w io.Writer, topN int) error
- func ExecuteSystemTx(scs *statedb.ContractState, txBody *types.TxBody, ...) ([]*types.Event, error)
- func GenProposalKey(id string) []byte
- func GetBpCount() int
- func GetGasPrice() *big.Int
- func GetGasPriceFromState(scs *statedb.ContractState) *big.Int
- func GetNamePrice() *big.Int
- func GetNamePriceFromState(scs *statedb.ContractState) *big.Int
- func GetNextBlockParam(proposalID string) *big.Int
- func GetParam(proposalID string) *big.Int
- func GetRankers(scs *statedb.ContractState) ([]string, error)
- func GetStaking(scs *statedb.ContractState, address []byte) (*types.Staking, error)
- func GetStakingMinimum() *big.Int
- func GetStakingMinimumFromState(scs *statedb.ContractState) *big.Int
- func GetStakingTotal(scs *statedb.ContractState) (*big.Int, error)
- func GetTotalVotingPower() *big.Int
- func GetVote(scs *statedb.ContractState, voter []byte, issue []byte) (*types.Vote, error)
- func GetVoteResult(scs *statedb.ContractState, id []byte, n int) (*types.VoteList, error)
- func GetVotes(scs *statedb.ContractState, address []byte) ([]*types.VoteInfo, error)
- func GetVotingCatalog() []types.VotingIssue
- func GetVotingIssues() []types.VotingIssue
- func GetVotingRewardAmount() *big.Int
- func InitSystemParams(g dataGetter, bpCount int)
- func InitVoteResult(scs *statedb.ContractState, voteResult map[string]*big.Int) error
- func InitVotingPowerRank(s dataGetter) (err error)
- func PickVotingRewardWinner(seed int64) (types.Address, error)
- 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(): types.NewAmount(50, types.Gaer), namePrice.ID(): types.NewAmount(1, types.Aergo), } )
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(): { ID: bpCount.ID(), Description: "", Blockfrom: 0, Blockto: 0, MultipleChoice: 1, Candidates: nil, }, stakingMin.ID(): { ID: stakingMin.ID(), Description: "", Blockfrom: 0, Blockto: 0, MultipleChoice: 1, Candidates: nil, }, gasPrice.ID(): { ID: gasPrice.ID(), Description: "", Blockfrom: 0, Blockto: 0, MultipleChoice: 1, Candidates: nil, }, namePrice.ID(): { ID: namePrice.ID(), Description: "", Blockfrom: 0, Blockto: 0, MultipleChoice: 1, Candidates: nil, }, }
Functions ¶
func BuildOrderedCandidates ¶
BuildOrderedCandidates returns a candidate list ordered by votes.xs
func CommitParams ¶ added in v2.4.9
func CommitParams(apply bool)
if a system param was changed, apply or discard its new value
func ExecuteSystemTx ¶
func ExecuteSystemTx(scs *statedb.ContractState, txBody *types.TxBody, sender, receiver *state.AccountState, blockInfo *types.BlockHeaderInfo) ([]*types.Event, error)
func GenProposalKey ¶
func GetBpCount ¶
func GetBpCount() int
func GetGasPrice ¶
func GetGasPriceFromState ¶
func GetGasPriceFromState(scs *statedb.ContractState) *big.Int
func GetNamePrice ¶
func GetNamePriceFromState ¶
func GetNamePriceFromState(scs *statedb.ContractState) *big.Int
func GetNextBlockParam ¶ added in v2.4.9
get the param value for the next block
func GetRankers ¶
func GetRankers(scs *statedb.ContractState) ([]string, error)
GetRankers returns the IDs of the top n rankers.
func GetStaking ¶
func GetStakingMinimum ¶
func GetStakingMinimumFromState ¶
func GetStakingMinimumFromState(scs *statedb.ContractState) *big.Int
func GetStakingTotal ¶
func GetStakingTotal(scs *statedb.ContractState) (*big.Int, error)
func GetTotalVotingPower ¶
func GetVoteResult ¶
GetVoteResult returns the top n voting result from the system account state.
func GetVotingCatalog ¶
func GetVotingCatalog() []types.VotingIssue
func GetVotingIssues ¶
func GetVotingIssues() []types.VotingIssue
func GetVotingRewardAmount ¶
func InitSystemParams ¶
func InitSystemParams(g dataGetter, bpCount int)
This is also called on chain reorganization
func InitVoteResult ¶
func InitVotingPowerRank ¶
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 Proposal ¶
type SystemContext ¶
type SystemContext struct { BlockInfo *types.BlockHeaderInfo Call *types.CallInfo Args []string Staked *types.Staking Vote *types.Vote // voting Proposal *Proposal // voting Sender *state.AccountState Receiver *state.AccountState // 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.AccountState, scs *statedb.ContractState, blockInfo *types.BlockHeaderInfo) (*SystemContext, error)
type VoteResult ¶
type VoteResult struct {
// contains filtered or unexported fields
}
func (*VoteResult) GetTotal ¶
func (voteResult *VoteResult) GetTotal() *big.Int
func (*VoteResult) Sync ¶
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.