Documentation ¶
Index ¶
- Variables
- func StakeToBalance(stake Stake) *big.Int
- type GValidators
- type GenesisValidator
- type Stake
- type StakeCounter
- type StakeCounterProvider
- type Validators
- func (vv *Validators) Builder() ValidatorsBuilder
- func (vv *Validators) Copy() *Validators
- func (vv *Validators) DecodeRLP(s *rlp.Stream) error
- func (vv *Validators) EncodeRLP(w io.Writer) error
- func (vv *Validators) Exists(id idx.StakerID) bool
- func (vv *Validators) Get(id idx.StakerID) Stake
- func (vv *Validators) GetIdx(id idx.StakerID) idx.Validator
- func (vv *Validators) GetStakeByIdx(i idx.Validator) Stake
- func (vv *Validators) IDs() []idx.StakerID
- func (vv *Validators) Idxs() map[idx.StakerID]idx.Validator
- func (vv *Validators) Len() int
- func (vv Validators) NewCounter() *StakeCounter
- func (vv *Validators) Quorum() Stake
- func (vv *Validators) SortedIDs() []idx.StakerID
- func (vv *Validators) SortedStakes() []Stake
- func (vv *Validators) TotalStake() (sum Stake)
- type ValidatorsBuilder
Constants ¶
This section is empty.
Variables ¶
var ( // EmptyValidators is empty validators group EmptyValidators = NewBuilder().Build() )
Functions ¶
func StakeToBalance ¶
StakeToBalance converts validator's stake to balance Warning: for tests only!
Types ¶
type GValidators ¶
type GValidators []GenesisValidator
GValidators defines genesis validators
func (GValidators) Addresses ¶
func (gv GValidators) Addresses() []common.Address
Addresses returns not sorted genesis addresses
func (GValidators) Map ¶
func (gv GValidators) Map() map[idx.StakerID]GenesisValidator
Map converts GValidators to map
func (GValidators) TotalStake ¶
func (gv GValidators) TotalStake() *big.Int
TotalStake returns sum of stakes
func (GValidators) Validators ¶
func (gv GValidators) Validators() *Validators
Validators converts GValidators to Validators
type GenesisValidator ¶
GenesisValidator is helper structure to define genesis validators
type Stake ¶
type Stake uint64
Stake amount.
func BalanceToStake ¶
BalanceToStake balance to validator's stake
type StakeCounter ¶
type StakeCounter struct {
// contains filtered or unexported fields
}
StakeCounter counts stakes.
func (*StakeCounter) Count ¶
func (s *StakeCounter) Count(v idx.StakerID) bool
Count validator and return true if it hadn't counted before.
func (*StakeCounter) CountByIdx ¶
func (s *StakeCounter) CountByIdx(stakerIdx idx.Validator) bool
CountByIdx validator and return true if it hadn't counted before.
type StakeCounterProvider ¶
type StakeCounterProvider func() *StakeCounter
StakeCounterProvider providers stake counter.
type Validators ¶
type Validators struct {
// contains filtered or unexported fields
}
Validators group of an epoch with stakes. Optimized for BFT algorithm calculations. Read-only.
func ArrayToValidators ¶
func ArrayToValidators(ids []idx.StakerID, stakes []Stake) *Validators
ArrayToValidators builds new read-only Validators object from array
func EqualStakeValidators ¶
func EqualStakeValidators(ids []idx.StakerID, stake Stake) *Validators
EqualStakeValidators builds new read-only Validators object with equal stakes (for tests)
func (*Validators) Builder ¶
func (vv *Validators) Builder() ValidatorsBuilder
Builder returns a mutable copy of content
func (*Validators) DecodeRLP ¶
func (vv *Validators) DecodeRLP(s *rlp.Stream) error
DecodeRLP is for RLP deserialization.
func (*Validators) EncodeRLP ¶
func (vv *Validators) EncodeRLP(w io.Writer) error
EncodeRLP is for RLP serialization.
func (*Validators) Exists ¶
func (vv *Validators) Exists(id idx.StakerID) bool
Exists returns boolean true if address exists in Validators object
func (*Validators) Get ¶
func (vv *Validators) Get(id idx.StakerID) Stake
Get returns stake for validator by ID
func (*Validators) GetIdx ¶
func (vv *Validators) GetIdx(id idx.StakerID) idx.Validator
GetIdx returns index (offset) of validator in the group
func (*Validators) GetStakeByIdx ¶
func (vv *Validators) GetStakeByIdx(i idx.Validator) Stake
GetStakeByIdx returns stake for validator by index
func (*Validators) Idxs ¶
func (vv *Validators) Idxs() map[idx.StakerID]idx.Validator
Idxs gets deterministic total order of validators.
func (*Validators) Len ¶
func (vv *Validators) Len() int
Len returns count of validators in Validators objects
func (Validators) NewCounter ¶
func (vv Validators) NewCounter() *StakeCounter
NewCounter constructor.
func (*Validators) SortedIDs ¶
func (vv *Validators) SortedIDs() []idx.StakerID
SortedIDs returns deterministically sorted ids. The order is the same as for Idxs().
func (*Validators) SortedStakes ¶
func (vv *Validators) SortedStakes() []Stake
SortedStakes returns deterministically sorted stakes. The order is the same as for Idxs().
func (*Validators) TotalStake ¶
func (vv *Validators) TotalStake() (sum Stake)
TotalStake of validators.
type ValidatorsBuilder ¶
ValidatorsBuilder is a helper to create Validators object
func NewBuilder ¶
func NewBuilder() ValidatorsBuilder
NewBuilder creates new mutable ValidatorsBuilder
func (ValidatorsBuilder) Build ¶
func (vv ValidatorsBuilder) Build() *Validators
Build new read-only Validators object