Documentation ¶
Index ¶
- Constants
- type Bus
- func (b *Bus) GetCandidate(pubkey types.Pubkey) *bus.Candidate
- func (b *Bus) GetCandidateByTendermintAddress(tmAddress types.TmAddress) *bus.Candidate
- func (b *Bus) GetStakes(pubkey types.Pubkey) []bus.Stake
- func (b *Bus) Punish(height uint64, address types.TmAddress) *big.Int
- func (b *Bus) SetOffline(pubkey types.Pubkey)
- type Candidate
- type Candidates
- func (c *Candidates) AddToBlockPubKey(p types.Pubkey)
- func (c *Candidates) ChangePubKey(old types.Pubkey, new types.Pubkey)
- func (c *Candidates) Commit() error
- func (c *Candidates) Count() int
- func (c *Candidates) Create(ownerAddress, rewardAddress, controlAddress types.Address, pubkey types.Pubkey, ...)
- func (c *Candidates) CreateWithID(ownerAddress, rewardAddress, controlAddress types.Address, pubkey types.Pubkey, ...)
- func (c *Candidates) Delegate(address types.Address, pubkey types.Pubkey, coin types.CoinID, value *big.Int, ...)
- func (c *Candidates) Edit(pubkey types.Pubkey, rewardAddress types.Address, ownerAddress types.Address, ...)
- func (c *Candidates) Exists(pubkey types.Pubkey) bool
- func (c *Candidates) Export(state *types.AppState)
- func (c *Candidates) GetCandidate(pubkey types.Pubkey) *Candidate
- func (c *Candidates) GetCandidateByTendermintAddress(address types.TmAddress) *Candidate
- func (c *Candidates) GetCandidateControl(pubkey types.Pubkey) types.Address
- func (c *Candidates) GetCandidateOwner(pubkey types.Pubkey) types.Address
- func (c *Candidates) GetCandidates() []*Candidate
- func (c *Candidates) GetNewCandidates(valCount int) []Candidate
- func (c *Candidates) GetStakeOfAddress(pubkey types.Pubkey, address types.Address, coin types.CoinID) *stake
- func (c *Candidates) GetStakeValueOfAddress(pubkey types.Pubkey, address types.Address, coin types.CoinID) *big.Int
- func (c *Candidates) GetStakes(pubkey types.Pubkey) []*stake
- func (c *Candidates) GetTotalStake(pubkey types.Pubkey) *big.Int
- func (c *Candidates) ID(pubKey types.Pubkey) uint32
- func (c *Candidates) IsBlockedPubKey(pubkey types.Pubkey) bool
- func (c *Candidates) IsChangedPublicKeys() bool
- func (c *Candidates) IsDelegatorStakeSufficient(address types.Address, pubkey types.Pubkey, coin types.CoinID, amount *big.Int) bool
- func (c *Candidates) IsNewCandidateStakeSufficient(coin types.CoinID, stake *big.Int, limit int) bool
- func (c *Candidates) LoadCandidates()
- func (c *Candidates) LoadCandidatesDeliver()
- func (c *Candidates) LoadStakes()
- func (c *Candidates) LoadStakesOfCandidate(pubkey types.Pubkey)
- func (c *Candidates) PubKey(id uint32) types.Pubkey
- func (c *Candidates) Punish(height uint64, address types.TmAddress) *big.Int
- func (c *Candidates) PunishByzantineCandidate(height uint64, tmAddress types.TmAddress)
- func (c *Candidates) RecalculateStakes(height uint64)
- func (c *Candidates) ResetIsChangedPublicKeys()
- func (c *Candidates) SetOffline(pubkey types.Pubkey)
- func (c *Candidates) SetOnline(pubkey types.Pubkey)
- func (c *Candidates) SetStakes(pubkey types.Pubkey, stakes []types.Stake, updates []types.Stake)
- func (c *Candidates) SetTotalStake(pubkey types.Pubkey, stake *big.Int)
- func (c *Candidates) SubStake(address types.Address, pubkey types.Pubkey, coin types.CoinID, value *big.Int)
- type RCandidates
Constants ¶
const ( CandidateStatusOffline = 0x01 CandidateStatusOnline = 0x02 UnbondPeriod = 518400 MaxDelegatorsPerCandidate = 1000 )
Common constants
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bus ¶
type Bus struct {
// contains filtered or unexported fields
}
func NewBus ¶
func NewBus(candidates *Candidates) *Bus
func (*Bus) GetCandidate ¶
GetCandidate returns candidate by a public key
func (*Bus) GetCandidateByTendermintAddress ¶
GetCandidateByTendermintAddress finds and returns candidate with given tendermint-address
func (*Bus) SetOffline ¶
SetOffline sets candidate status to CandidateStatusOffline
type Candidate ¶
type Candidate struct { PubKey types.Pubkey RewardAddress types.Address OwnerAddress types.Address ControlAddress types.Address Commission uint32 Status byte ID uint32 // contains filtered or unexported fields }
Candidate represents candidate object which is stored on disk
func (*Candidate) GetTmAddress ¶
GetTmAddress returns tendermint-address of a candidate
func (*Candidate) GetTotalBipStake ¶
GetTotalBipStake returns total stake value of a candidate
type Candidates ¶
type Candidates struct {
// contains filtered or unexported fields
}
Candidates struct is a store of Candidates state
func NewCandidates ¶
NewCandidates returns newly created Candidates state with a given bus and iavl
func (*Candidates) AddToBlockPubKey ¶ added in v1.2.0
func (c *Candidates) AddToBlockPubKey(p types.Pubkey)
AddToBlockPubKey blacklists given publickey
func (*Candidates) ChangePubKey ¶ added in v1.2.0
func (c *Candidates) ChangePubKey(old types.Pubkey, new types.Pubkey)
ChangePubKey change public key of a candidate from old to new
func (*Candidates) Commit ¶
func (c *Candidates) Commit() error
Commit writes changes to iavl, may return an error
func (*Candidates) Count ¶
func (c *Candidates) Count() int
Count returns current amount of candidates
func (*Candidates) Create ¶
func (c *Candidates) Create(ownerAddress, rewardAddress, controlAddress types.Address, pubkey types.Pubkey, commission uint32)
Create creates a new candidate with given params and adds it to state
func (*Candidates) CreateWithID ¶ added in v1.2.0
func (c *Candidates) CreateWithID(ownerAddress, rewardAddress, controlAddress types.Address, pubkey types.Pubkey, commission uint32, id uint32)
CreateWithID creates a new candidate with given params and adds it to state CreateWithID uses given ID to be associated with public key of a candidate
func (*Candidates) Delegate ¶
func (c *Candidates) Delegate(address types.Address, pubkey types.Pubkey, coin types.CoinID, value *big.Int, bipValue *big.Int)
Delegate adds a stake to a candidate
func (*Candidates) Edit ¶
func (c *Candidates) Edit(pubkey types.Pubkey, rewardAddress types.Address, ownerAddress types.Address, controlAddress types.Address)
Edit edits a candidate
func (*Candidates) Exists ¶
func (c *Candidates) Exists(pubkey types.Pubkey) bool
Exists returns wherever a candidate with given public key exists
func (*Candidates) Export ¶
func (c *Candidates) Export(state *types.AppState)
Export exports all data to the given state
func (*Candidates) GetCandidate ¶
func (c *Candidates) GetCandidate(pubkey types.Pubkey) *Candidate
GetCandidate returns candidate by a public key
func (*Candidates) GetCandidateByTendermintAddress ¶
func (c *Candidates) GetCandidateByTendermintAddress(address types.TmAddress) *Candidate
GetCandidateByTendermintAddress finds and returns candidate with given tendermint-address
func (*Candidates) GetCandidateControl ¶ added in v1.2.0
func (c *Candidates) GetCandidateControl(pubkey types.Pubkey) types.Address
GetCandidateControl returns candidate's control address
func (*Candidates) GetCandidateOwner ¶
func (c *Candidates) GetCandidateOwner(pubkey types.Pubkey) types.Address
GetCandidateOwner returns candidate's owner address
func (*Candidates) GetCandidates ¶
func (c *Candidates) GetCandidates() []*Candidate
GetCandidates returns a list of all candidates
func (*Candidates) GetNewCandidates ¶
func (c *Candidates) GetNewCandidates(valCount int) []Candidate
GetNewCandidates returns list of candidates that can be the new validators Skips offline candidates and candidates with stake less than minValidatorBipStake Result is sorted by candidates stakes and limited to valCount
func (*Candidates) GetStakeOfAddress ¶
func (c *Candidates) GetStakeOfAddress(pubkey types.Pubkey, address types.Address, coin types.CoinID) *stake
GetStakeOfAddress returns stake of address in given candidate and in given coin
func (*Candidates) GetStakeValueOfAddress ¶
func (c *Candidates) GetStakeValueOfAddress(pubkey types.Pubkey, address types.Address, coin types.CoinID) *big.Int
GetStakeValueOfAddress returns stake VALUE of address in given candidate and in given coin
func (*Candidates) GetStakes ¶
func (c *Candidates) GetStakes(pubkey types.Pubkey) []*stake
GetStakes returns list of stakes of candidate with given public key
func (*Candidates) GetTotalStake ¶
func (c *Candidates) GetTotalStake(pubkey types.Pubkey) *big.Int
GetTotalStake calculates and returns total stake of a candidate
func (*Candidates) ID ¶ added in v1.2.0
func (c *Candidates) ID(pubKey types.Pubkey) uint32
ID returns an id of candidate by it's public key
func (*Candidates) IsBlockedPubKey ¶ added in v1.2.0
func (c *Candidates) IsBlockedPubKey(pubkey types.Pubkey) bool
IsBlockedPubKey returns if given public key is blacklisted
func (*Candidates) IsChangedPublicKeys ¶ added in v1.2.0
func (c *Candidates) IsChangedPublicKeys() bool
func (*Candidates) IsDelegatorStakeSufficient ¶
func (c *Candidates) IsDelegatorStakeSufficient(address types.Address, pubkey types.Pubkey, coin types.CoinID, amount *big.Int) bool
IsDelegatorStakeSufficient determines if given stake is sufficient to add it to a candidate
func (*Candidates) IsNewCandidateStakeSufficient ¶
func (c *Candidates) IsNewCandidateStakeSufficient(coin types.CoinID, stake *big.Int, limit int) bool
IsNewCandidateStakeSufficient determines if given stake is sufficient to create new candidate
func (*Candidates) LoadCandidates ¶
func (c *Candidates) LoadCandidates()
LoadCandidates loads only list of candidates (for read)
func (*Candidates) LoadCandidatesDeliver ¶ added in v1.2.0
func (c *Candidates) LoadCandidatesDeliver()
LoadCandidatesDeliver loads full info about candidates (for edit)
func (*Candidates) LoadStakes ¶
func (c *Candidates) LoadStakes()
LoadStakes loads all stakes of candidates
func (*Candidates) LoadStakesOfCandidate ¶ added in v1.1.4
func (c *Candidates) LoadStakesOfCandidate(pubkey types.Pubkey)
LoadStakesOfCandidate loads stakes of given candidate from disk
func (*Candidates) PubKey ¶ added in v1.2.0
func (c *Candidates) PubKey(id uint32) types.Pubkey
PubKey returns a public key of candidate by it's ID
func (*Candidates) Punish ¶
Punish punished a candidate with given tendermint-address 1. Subs 1% from each stake 2. Calculate and return new total stake
func (*Candidates) PunishByzantineCandidate ¶
func (c *Candidates) PunishByzantineCandidate(height uint64, tmAddress types.TmAddress)
PunishByzantineCandidate finds candidate with given tmAddress and punishes it: 1. Subs 5% of each stake of a candidate 2. Unbond each stake of a candidate
func (*Candidates) RecalculateStakes ¶
func (c *Candidates) RecalculateStakes(height uint64)
RecalculateStakes recalculate stakes of all candidates: 1. Updates bip-values of each stake 2. Applies updates
func (*Candidates) ResetIsChangedPublicKeys ¶ added in v1.2.0
func (c *Candidates) ResetIsChangedPublicKeys()
func (*Candidates) SetOffline ¶
func (c *Candidates) SetOffline(pubkey types.Pubkey)
SetOffline sets candidate status to CandidateStatusOffline
func (*Candidates) SetOnline ¶
func (c *Candidates) SetOnline(pubkey types.Pubkey)
SetOnline sets candidate status to CandidateStatusOnline
func (*Candidates) SetTotalStake ¶
func (c *Candidates) SetTotalStake(pubkey types.Pubkey, stake *big.Int)
SetTotalStake sets candidate's total bip stake. Used in Import.
type RCandidates ¶ added in v1.2.0
type RCandidates interface { Export(state *types.AppState) Exists(pubkey types.Pubkey) bool IsBlockedPubKey(pubkey types.Pubkey) bool PubKey(id uint32) types.Pubkey Count() int IsNewCandidateStakeSufficient(coin types.CoinID, stake *big.Int, limit int) bool IsDelegatorStakeSufficient(address types.Address, pubkey types.Pubkey, coin types.CoinID, amount *big.Int) bool GetStakeValueOfAddress(pubkey types.Pubkey, address types.Address, coin types.CoinID) *big.Int GetCandidateOwner(pubkey types.Pubkey) types.Address GetCandidateControl(pubkey types.Pubkey) types.Address GetTotalStake(pubkey types.Pubkey) *big.Int LoadCandidates() LoadStakesOfCandidate(pubkey types.Pubkey) GetCandidate(pubkey types.Pubkey) *Candidate LoadStakes() GetCandidates() []*Candidate GetStakes(pubkey types.Pubkey) []*stake }
RCandidates interface represents Candidates state