pos

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2021 License: MIT Imports: 6 Imported by: 9

Documentation

Index

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) Copy

func (vv *Validators) Copy() *Validators

Copy constructs a copy.

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) IDs

func (vv *Validators) IDs() []idx.ValidatorID

IDs returns not sorted ids.

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) Quorum

func (vv *Validators) Quorum() Weight

Quorum limit of validators.

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 Weight

type Weight uint32

Weight amount.

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.

func (*WeightCounter) HasQuorum

func (s *WeightCounter) HasQuorum() bool

HasQuorum achieved.

func (*WeightCounter) Sum

func (s *WeightCounter) Sum() Weight

Sum of counted weights.

type WeightCounterProvider

type WeightCounterProvider func() *WeightCounter

WeightCounterProvider providers weight counter.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL