Documentation ¶
Index ¶
- 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.ValidatorID) bool
- func (vv *Validators) Get(id idx.ValidatorID) Weight
- func (vv *Validators) GetID(i idx.Validator) idx.ValidatorID
- func (vv *Validators) GetIdx(id idx.ValidatorID) idx.Validator
- func (vv *Validators) GetWeightByIdx(i idx.Validator) Weight
- func (vv *Validators) IDs() []idx.ValidatorID
- func (vv *Validators) Idxs() map[idx.ValidatorID]idx.Validator
- func (vv *Validators) Len() idx.Validator
- func (vv Validators) NewCounter() *WeightCounter
- func (vv *Validators) Quorum() Weight
- func (vv *Validators) SortedIDs() []idx.ValidatorID
- func (vv *Validators) SortedWeights() []Weight
- func (vv *Validators) TotalWeight() (sum Weight)
- type ValidatorsBigBuilder
- type ValidatorsBuilder
- type Weight
- type WeightCounter
- type WeightCounterProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Validators ¶
type Validators struct {
// contains filtered or unexported fields
}
Validators group of an epoch with weights. Optimized for BFT algorithm calculations. Read-only.
func ArrayToValidators ¶
func ArrayToValidators(ids []idx.ValidatorID, weights []Weight) *Validators
ArrayToValidators builds new read-only Validators object from array
func EqualWeightValidators ¶
func EqualWeightValidators(ids []idx.ValidatorID, weight Weight) *Validators
EqualWeightValidators builds new read-only Validators object with equal weights (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.ValidatorID) bool
Exists returns boolean true if address exists in Validators object
func (*Validators) Get ¶
func (vv *Validators) Get(id idx.ValidatorID) Weight
get returns weight for validator by ID
func (*Validators) GetID ¶
func (vv *Validators) GetID(i idx.Validator) idx.ValidatorID
GetID returns index validator ID by index (offset) of validator in the group
func (*Validators) GetIdx ¶
func (vv *Validators) GetIdx(id idx.ValidatorID) idx.Validator
GetIdx returns index (offset) of validator in the group
func (*Validators) GetWeightByIdx ¶
func (vv *Validators) GetWeightByIdx(i idx.Validator) Weight
GetWeightByIdx returns weight for validator by index
func (*Validators) Idxs ¶
func (vv *Validators) Idxs() map[idx.ValidatorID]idx.Validator
Idxs gets deterministic total order of validators.
func (*Validators) Len ¶
func (vv *Validators) Len() idx.Validator
Len returns count of validators in Validators objects
func (Validators) NewCounter ¶
func (vv Validators) NewCounter() *WeightCounter
NewCounter constructor.
func (*Validators) SortedIDs ¶
func (vv *Validators) SortedIDs() []idx.ValidatorID
SortedIDs returns deterministically sorted ids. The order is the same as for Idxs().
func (*Validators) SortedWeights ¶
func (vv *Validators) SortedWeights() []Weight
SortedWeights returns deterministically sorted weights. The order is the same as for Idxs().
func (*Validators) TotalWeight ¶
func (vv *Validators) TotalWeight() (sum Weight)
TotalWeight of validators.
type ValidatorsBigBuilder ¶
type ValidatorsBigBuilder map[idx.ValidatorID]*big.Int
ValidatorsBuilderBig is a helper to create Validators object out of bigint numbers
func NewBigBuilder ¶
func NewBigBuilder() ValidatorsBigBuilder
NewBigBuilder creates new mutable ValidatorsBigBuilder
func (ValidatorsBigBuilder) Build ¶
func (vv ValidatorsBigBuilder) Build() *Validators
Build new read-only Validators object
func (ValidatorsBigBuilder) Set ¶
func (vv ValidatorsBigBuilder) Set(id idx.ValidatorID, weight *big.Int)
Set appends item to ValidatorsBuilder object
func (ValidatorsBigBuilder) TotalWeight ¶
func (vv ValidatorsBigBuilder) TotalWeight() *big.Int
Build new read-only Validators object
type ValidatorsBuilder ¶
type ValidatorsBuilder map[idx.ValidatorID]Weight
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
func (ValidatorsBuilder) Set ¶
func (vv ValidatorsBuilder) Set(id idx.ValidatorID, weight Weight)
Set appends item to ValidatorsBuilder object
type WeightCounter ¶
type WeightCounter struct {
// contains filtered or unexported fields
}
WeightCounter counts weights.
func (*WeightCounter) Count ¶
func (s *WeightCounter) Count(v idx.ValidatorID) bool
Count validator and return true if it hadn't counted before.
func (*WeightCounter) CountByIdx ¶
func (s *WeightCounter) CountByIdx(validatorIdx idx.Validator) bool
CountByIdx validator and return true if it hadn't counted before.
type WeightCounterProvider ¶
type WeightCounterProvider func() *WeightCounter
WeightCounterProvider providers weight counter.