Documentation ¶
Index ¶
- type Comparison
- type Value
- func (v Value) AcceptanceState() acceptance.State
- func (v Value) AddCumulativeWeight(weight int64) Value
- func (v Value) AttestorsWeight() int64
- func (v Value) Compare(other Value) Comparison
- func (v Value) CumulativeWeight() int64
- func (v Value) RemoveCumulativeWeight(weight int64) Value
- func (v Value) SetAcceptanceState(acceptanceState acceptance.State) Value
- func (v Value) SetAttestorsWeight(weight int64) Value
- func (v Value) SetCumulativeWeight(cumulativeWeight int64) Value
- func (v Value) SetValidatorsWeight(weight int64) Value
- func (v Value) String() string
- func (v Value) ValidatorsWeight() int64
- type Weight
- func (w *Weight) AcceptanceState() acceptance.State
- func (w *Weight) AddAttestor(seat account.SeatIndex) *Weight
- func (w *Weight) AddCumulativeWeight(delta int64) *Weight
- func (w *Weight) AddVoter(seat account.SeatIndex) *Weight
- func (w *Weight) Compare(other *Weight) Comparison
- func (w *Weight) CumulativeWeight() int64
- func (w *Weight) DeleteAttestor(seat account.SeatIndex) *Weight
- func (w *Weight) DeleteVoter(seat account.SeatIndex) *Weight
- func (w *Weight) RemoveCumulativeWeight(delta int64) *Weight
- func (w *Weight) ResetAttestors() *Weight
- func (w *Weight) SetAcceptanceState(acceptanceState acceptance.State) (previousState acceptance.State)
- func (w *Weight) SetCumulativeWeight(cumulativeWeight int64) *Weight
- func (w *Weight) String() string
- func (w *Weight) Value() Value
- func (w *Weight) WithAcceptanceState(acceptanceState acceptance.State) *Weight
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Comparison ¶
type Comparison = int
Comparison is the result of a comparison between two values.
const ( // Lighter is the result of a comparison between two values when the first value is lighter than the second value. Lighter Comparison = -1 // Equal is the result of a comparison between two values when the first value is equal to the second value. Equal Comparison = 0 // Heavier is the result of a comparison between two values when the first value is heavier than the second value. Heavier Comparison = 1 )
type Value ¶
type Value struct {
// contains filtered or unexported fields
}
Value represents an immutable multi-tiered weight value, which is used to determine the order of spenders.
func (Value) AcceptanceState ¶
func (v Value) AcceptanceState() acceptance.State
AcceptanceState returns the acceptance state of the Value.
func (Value) AddCumulativeWeight ¶
AddCumulativeWeight adds the given weight to the cumulative weight of the Value and returns the new Value.
func (Value) AttestorsWeight ¶
AttestorsWeight returns the weight of the validators.
func (Value) Compare ¶
func (v Value) Compare(other Value) Comparison
Compare compares the Value to the given other Value and returns the result of the comparison.
func (Value) CumulativeWeight ¶
CumulativeWeight returns the cumulative weight of the Value.
func (Value) RemoveCumulativeWeight ¶
RemoveCumulativeWeight removes the given weight from the cumulative weight of the Value and returns the new Value.
func (Value) SetAcceptanceState ¶
func (v Value) SetAcceptanceState(acceptanceState acceptance.State) Value
SetAcceptanceState sets the acceptance state of the Value and returns the new Value.
func (Value) SetAttestorsWeight ¶
SetAttestorsWeight sets the weight of the attestors and returns the new Value.
func (Value) SetCumulativeWeight ¶
SetCumulativeWeight sets the cumulative weight of the Value and returns the new Value.
func (Value) SetValidatorsWeight ¶
SetValidatorsWeight sets the weight of the validators and returns the new Value.
func (Value) ValidatorsWeight ¶
ValidatorsWeight returns the weight of the validators.
type Weight ¶
type Weight struct { // OnUpdate is an event that is triggered when the weight value is updated. OnUpdate *event.Event1[Value] // Voters is the set of voters contributing to the weight Voters ds.Set[account.SeatIndex] // Attestors is the set of attestors contributing to the weight. Attestors ds.Set[account.SeatIndex] // contains filtered or unexported fields }
Weight represents a mutable multi-tiered weight value that can be updated in-place.
func (*Weight) AcceptanceState ¶
func (w *Weight) AcceptanceState() acceptance.State
AcceptanceState returns the acceptance state of the weight.
func (*Weight) AddAttestor ¶
AddAttestor adds the given voter to the list of Attestors, updates the weight and returns the Weight (for chaining).
func (*Weight) AddCumulativeWeight ¶
AddCumulativeWeight adds the given weight to the cumulative weight and returns the Weight (for chaining).
func (*Weight) AddVoter ¶
AddVoter adds the given voter to the list of Voters, updates the weight and returns the Weight (for chaining).
func (*Weight) Compare ¶
func (w *Weight) Compare(other *Weight) Comparison
Compare compares the Weight to the given other Weight.
func (*Weight) CumulativeWeight ¶
CumulativeWeight returns the cumulative weight of the Weight.
func (*Weight) DeleteAttestor ¶
DeleteAttestor removes the given voter from the list of Attestors, updates the weight and returns the Weight (for chaining).
func (*Weight) DeleteVoter ¶
DeleteVoter removes the given voter from the list of Voters, updates the weight and returns the Weight (for chaining).
func (*Weight) RemoveCumulativeWeight ¶
RemoveCumulativeWeight removes the given weight from the cumulative weight and returns the Weight (for chaining).
func (*Weight) ResetAttestors ¶
ResetAttestors removes all voters from the list of Attestors, updates the weight and returns the Weight (for chaining).
func (*Weight) SetAcceptanceState ¶
func (w *Weight) SetAcceptanceState(acceptanceState acceptance.State) (previousState acceptance.State)
SetAcceptanceState sets the acceptance state of the weight and returns the previous acceptance state.
func (*Weight) SetCumulativeWeight ¶
SetCumulativeWeight sets the cumulative weight of the Weight and returns the Weight (for chaining).
func (*Weight) WithAcceptanceState ¶
func (w *Weight) WithAcceptanceState(acceptanceState acceptance.State) *Weight
WithAcceptanceState sets the acceptance state of the weight and returns the Weight instance.