system

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2019 License: MIT Imports: 17 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():   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

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

BuildOrderedCandidates returns a candidate list ordered by votes.xs

func ExecuteSystemTx

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

func GenProposalKey added in v1.3.3

func GenProposalKey(id string) []byte

func GetBpCount added in v1.3.3

func GetBpCount() int

func GetGasPrice added in v1.3.3

func GetGasPrice() *big.Int

func GetGasPriceFromState added in v1.3.3

func GetGasPriceFromState(ar AccountStateReader) *big.Int

func GetNamePrice added in v1.0.0

func GetNamePrice() *big.Int

func GetNamePriceFromState added in v1.3.3

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

func GetParam added in v1.3.3

func GetParam(proposalID string) *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 GetStaking(scs *state.ContractState, address []byte) (*types.Staking, error)

func GetStakingMinimum added in v1.3.3

func GetStakingMinimum() *big.Int

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 GetVote

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

GetVote return amount, to, err.

func GetVoteResult

func GetVoteResult(ar AccountStateReader, id []byte, n int) (*types.VoteList, error)

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

func GetVoteResultEx added in v1.0.0

func GetVoteResultEx(ar AccountStateReader, key []byte, n int) (*types.VoteList, error)

func GetVotes added in v1.3.3

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

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 GetVotingRewardAmount() *big.Int

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 InitVoteResult(scs *state.ContractState, voteResult map[string]*big.Int) error

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.

func PickVotingRewardWinner added in v1.3.3

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

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 Proposal struct {
	ID             string
	Description    string
	Blockfrom      uint64
	Blockto        uint64
	MultipleChoice uint32
	Candidates     []string
	Default        *big.Int
}

func (*Proposal) GetKey added in v1.3.3

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

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,

Jump to

Keyboard shortcuts

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