system

package
v2.5.2 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

*

  • @file
  • @copyright defined in aergo/LICENSE.txt

*

  • @file
  • @copyright defined in aergo/LICENSE.txt

Index

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

func BuildOrderedCandidates(vote map[string]*big.Int) []string

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 DumpVotingPowerRankers

func DumpVotingPowerRankers(w io.Writer, topN int) error

func ExecuteSystemTx

func ExecuteSystemTx(scs *statedb.ContractState, txBody *types.TxBody,
	sender, receiver *state.AccountState, blockInfo *types.BlockHeaderInfo) ([]*types.Event, error)

func GenProposalKey

func GenProposalKey(id string) []byte

func GetBpCount

func GetBpCount() int

func GetGasPrice

func GetGasPrice() *big.Int

func GetGasPriceFromState

func GetGasPriceFromState(scs *statedb.ContractState) *big.Int

func GetNamePrice

func GetNamePrice() *big.Int

func GetNamePriceFromState

func GetNamePriceFromState(scs *statedb.ContractState) *big.Int

func GetNextBlockParam added in v2.4.9

func GetNextBlockParam(proposalID string) *big.Int

get the param value for the next block

func GetParam

func GetParam(proposalID string) *big.Int

get the param value for the current block

func GetRankers

func GetRankers(scs *statedb.ContractState) ([]string, error)

GetRankers returns the IDs of the top n rankers.

func GetStaking

func GetStaking(scs *statedb.ContractState, address []byte) (*types.Staking, error)

func GetStakingMinimum

func GetStakingMinimum() *big.Int

func GetStakingMinimumFromState

func GetStakingMinimumFromState(scs *statedb.ContractState) *big.Int

func GetStakingTotal

func GetStakingTotal(scs *statedb.ContractState) (*big.Int, error)

func GetTotalVotingPower

func GetTotalVotingPower() *big.Int

func GetVote

func GetVote(scs *statedb.ContractState, voter []byte, issue []byte) (*types.Vote, error)

GetVote return amount, to, err.

func GetVoteResult

func GetVoteResult(scs *statedb.ContractState, id []byte, n int) (*types.VoteList, error)

GetVoteResult returns the top n voting result from the system account state.

func GetVotes

func GetVotes(scs *statedb.ContractState, address []byte) ([]*types.VoteInfo, error)

func GetVotingCatalog

func GetVotingCatalog() []types.VotingIssue

func GetVotingIssues

func GetVotingIssues() []types.VotingIssue

func GetVotingRewardAmount

func GetVotingRewardAmount() *big.Int

func InitSystemParams

func InitSystemParams(g dataGetter, bpCount int)

This is also called on chain reorganization

func InitVoteResult

func InitVoteResult(scs *statedb.ContractState, voteResult map[string]*big.Int) error

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.

func PickVotingRewardWinner

func PickVotingRewardWinner(seed int64) (types.Address, error)

Types

type Proposal

type Proposal struct {
	ID             string
	Description    string
	Blockfrom      uint64
	Blockto        uint64
	MultipleChoice uint32
	Candidates     []string
	Default        *big.Int
}

func (*Proposal) GetKey

func (a *Proposal) GetKey() []byte

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) AddVote

func (voteResult *VoteResult) AddVote(vote *types.Vote) error

func (*VoteResult) GetTotal

func (voteResult *VoteResult) GetTotal() *big.Int

func (*VoteResult) SubVote

func (voteResult *VoteResult) SubVote(vote *types.Vote) error

func (*VoteResult) Sync

func (vr *VoteResult) Sync() error

Sync is write vote result data to state DB. if vote result over the threshold,

Jump to

Keyboard shortcuts

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