Documentation ¶
Index ¶
- Constants
- type Candidate
- type State
- func (s *State) AddVotePowerToCandidate(id []byte, amount *util.Uint128) error
- func (s *State) BeginBatch() error
- func (s *State) Clone() (*State, error)
- func (s *State) Commit() error
- func (s *State) DelCandidate(cid []byte) error
- func (s *State) Flush() error
- func (s *State) GetCandidate(cid []byte) (*Candidate, error)
- func (s *State) GetCandidates() ([]*Candidate, error)
- func (s *State) GetProposer(index int) (common.Address, error)
- func (s *State) Prepare() error
- func (s *State) PutCandidate(cid []byte, candidate *Candidate) error
- func (s *State) PutProposer(index int, addr common.Address) error
- func (s *State) Reset() error
- func (s *State) RollBack() error
- func (s *State) RootBytes() ([]byte, error)
- func (s *State) SetDynasty(dynasty []common.Address) error
- func (s *State) SortByVotePower() ([]common.Address, error)
- func (s *State) SubVotePowerToCandidate(id []byte, amount *util.Uint128) error
Constants ¶
View Source
const ( CandidatePrefix = "c_" // alias account prefix for account state trie DynastyPrefix = "d_" // alias account prefix for account state trie )
TODO applying prefix Prefixes for blockState trie
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Candidate ¶
type Candidate struct { ID []byte // candidate id = txHash Addr common.Address Collateral *util.Uint128 // candidate collateral VotePower *util.Uint128 // sum of voters' staking URL string Timestamp int64 }
Candidate is struct for save candidate state
type State ¶
type State struct {
// contains filtered or unexported fields
}
State is a structure for dpos state
func NewDposState ¶
func NewDposState(candidateStateHash []byte, dynastyStateHash []byte, stor storage.Storage) (*State, error)
NewDposState returns new dpos state
func (*State) AddVotePowerToCandidate ¶
AddVotePowerToCandidate add vote power to candidate
func (*State) DelCandidate ¶
DelCandidate del candidate from candidate state
func (*State) GetCandidate ¶
GetCandidate returns candidate from candidate state
func (*State) GetCandidates ¶
GetCandidates returns candidate list from candidate state.
func (*State) GetProposer ¶
GetProposer returns proposer address of index
func (*State) PutCandidate ¶
PutCandidate puts candidate to candidate state
func (*State) PutProposer ¶
PutProposer sets proposer address to index
func (*State) SetDynasty ¶
SetDynasty set dynastyState by using dynasty slice
func (*State) SortByVotePower ¶
SortByVotePower returns Descending ordered candidate slice
Click to show internal directories.
Click to hide internal directories.