Documentation
¶
Index ¶
- Variables
- type Candidate
- type CandidateMaxPQ
- func (pqStruct *CandidateMaxPQ) CandidateList() []*Candidate
- func (pqStruct CandidateMaxPQ) Len() int
- func (pqStruct CandidateMaxPQ) Less(i, j int) bool
- func (pqStruct *CandidateMaxPQ) Pop() interface{}
- func (pqStruct *CandidateMaxPQ) Push(x interface{})
- func (pqStruct CandidateMaxPQ) Swap(i, j int)
- func (pqStruct *CandidateMaxPQ) Top() interface{}
- type CandidateMinPQ
- func (pqStruct *CandidateMinPQ) CandidateList() []*Candidate
- func (pqStruct CandidateMinPQ) Len() int
- func (pqStruct CandidateMinPQ) Less(i, j int) bool
- func (pqStruct *CandidateMinPQ) Pop() interface{}
- func (pqStruct *CandidateMinPQ) Push(x interface{})
- func (pqStruct CandidateMinPQ) Swap(i, j int)
- func (pqStruct *CandidateMinPQ) Top() interface{}
- type Factory
- type State
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrInvalidAddr is the error that the address format is invalid, cannot be decoded ErrInvalidAddr = errors.New("address format is invalid") // ErrNotEnoughBalance is the error that the balance is not enough ErrNotEnoughBalance = errors.New("not enough balance") // ErrAccountNotExist is the error that the account does not exist ErrAccountNotExist = errors.New("the account does not exist") // ErrFailedToMarshalState is the error that the state marshaling is failed ErrFailedToMarshalState = errors.New("failed to marshal state") // ErrFailedToUnmarshalState is the error that the state un-marshaling is failed ErrFailedToUnmarshalState = errors.New("failed to unmarshal state") )
Functions ¶
This section is empty.
Types ¶
type Candidate ¶
type Candidate struct {
Address string
Votes *big.Int
PubKey []byte
// contains filtered or unexported fields
}
Candidate is used in the heap
type CandidateMaxPQ ¶
type CandidateMaxPQ struct {
Capacity int
// contains filtered or unexported fields
}
CandidateMaxPQ is a max Priority Queue
func (*CandidateMaxPQ) CandidateList ¶
func (pqStruct *CandidateMaxPQ) CandidateList() []*Candidate
CandidateList return a list of candidates
func (CandidateMaxPQ) Len ¶
func (pqStruct CandidateMaxPQ) Len() int
func (CandidateMaxPQ) Less ¶
func (pqStruct CandidateMaxPQ) Less(i, j int) bool
func (*CandidateMaxPQ) Pop ¶
func (pqStruct *CandidateMaxPQ) Pop() interface{}
Pop pops a candidate in the heap
func (*CandidateMaxPQ) Push ¶
func (pqStruct *CandidateMaxPQ) Push(x interface{})
Push pushes a candidate in the heap
func (CandidateMaxPQ) Swap ¶
func (pqStruct CandidateMaxPQ) Swap(i, j int)
func (*CandidateMaxPQ) Top ¶
func (pqStruct *CandidateMaxPQ) Top() interface{}
Top return the candidate with highest votes
type CandidateMinPQ ¶
type CandidateMinPQ struct {
Capacity int
// contains filtered or unexported fields
}
CandidateMinPQ is a min Priority Queue
func (*CandidateMinPQ) CandidateList ¶
func (pqStruct *CandidateMinPQ) CandidateList() []*Candidate
CandidateList return a list of candidates
func (CandidateMinPQ) Len ¶
func (pqStruct CandidateMinPQ) Len() int
func (CandidateMinPQ) Less ¶
func (pqStruct CandidateMinPQ) Less(i, j int) bool
func (*CandidateMinPQ) Pop ¶
func (pqStruct *CandidateMinPQ) Pop() interface{}
Pop pops a candidate in the heap
func (*CandidateMinPQ) Push ¶
func (pqStruct *CandidateMinPQ) Push(x interface{})
Push pushes a candidate in the heap
func (CandidateMinPQ) Swap ¶
func (pqStruct CandidateMinPQ) Swap(i, j int)
func (*CandidateMinPQ) Top ¶
func (pqStruct *CandidateMinPQ) Top() interface{}
Top returns the candidate with smallest votes
type Factory ¶
type Factory interface {
CreateState(string, uint64) (*State, error)
Balance(string) (*big.Int, error)
CommitStateChanges(uint64, []*action.Transfer, []*action.Vote) error
// Note that nonce starts with 1.
Nonce(string) (uint64, error)
State(string) (*State, error)
RootHash() common.Hash32B
Candidates() (uint64, []*Candidate)
}
Factory defines an interface for managing states
type State ¶
type State struct {
// 0 is reserved from actions in genesis block and coinbase transfers nonces
// other actions' nonces start from 1
Nonce uint64
Balance *big.Int
Address string
IsCandidate bool
VotingWeight *big.Int
Votee string
Voters map[string]*big.Int
}
State is the canonical representation of an account.
func (*State) AddBalance ¶
AddBalance adds balance for state
Click to show internal directories.
Click to hide internal directories.