votes

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2023 License: Apache-2.0, BSD-2-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockedVotePower

type MockedVotePower struct {
	VotePower int
}

func (MockedVotePower) Compare

func (p MockedVotePower) Compare(other MockedVotePower) int

type Opinion

type Opinion uint8

Opinion is a type that represents the Opinion of a node on a certain Conflict.

const (
	// UndefinedOpinion represents the zero value of the Opinion type.
	UndefinedOpinion Opinion = iota
	Like
	Dislike
)

func (Opinion) String

func (o Opinion) String() string

type TestFramework

type TestFramework struct {
	Validators *sybilprotection.WeightedSet
	// contains filtered or unexported fields
}

func NewTestFramework

func NewTestFramework(test *testing.T, validators *sybilprotection.WeightedSet) *TestFramework

NewTestFramework is the constructor of the TestFramework.

func (*TestFramework) CreateValidator

func (t *TestFramework) CreateValidator(alias string, weight int64)

func (*TestFramework) CreateValidatorWithID

func (t *TestFramework) CreateValidatorWithID(alias string, id identity.ID, weight int64, skipWeightUpdate ...bool)

func (*TestFramework) Validator

func (t *TestFramework) Validator(alias string) (v identity.ID)

func (*TestFramework) ValidatorsSet

func (t *TestFramework) ValidatorsSet(aliases ...string) (validators *advancedset.AdvancedSet[identity.ID])

type Vote

type Vote[ConflictIDType comparable, VotePowerType constraints.Comparable[VotePowerType]] struct {
	Voter      identity.ID
	ConflictID ConflictIDType
	Opinion    Opinion
	VotePower  VotePowerType
}

func NewVote

func NewVote[ConflictIDType comparable, VotePowerType constraints.Comparable[VotePowerType]](voter identity.ID, votePower VotePowerType, opinion Opinion) (voteWithOpinion *Vote[ConflictIDType, VotePowerType])

NewVote derives a Vote for th.

func (*Vote[ConflictIDType, VotePowerType]) WithConflictID

func (v *Vote[ConflictIDType, VotePowerType]) WithConflictID(conflictID ConflictIDType) (voteWithConflictID *Vote[ConflictIDType, VotePowerType])

WithConflictID derives a vote for the given ConflictID.

func (*Vote[ConflictIDType, VotePowerType]) WithOpinion

func (v *Vote[ConflictIDType, VotePowerType]) WithOpinion(opinion Opinion) (voteWithOpinion *Vote[ConflictIDType, VotePowerType])

WithOpinion derives a vote for the given Opinion.

func (*Vote[ConflictIDType, VotePowerType]) WithVotePower

func (v *Vote[ConflictIDType, VotePowerType]) WithVotePower(power VotePowerType) (voteWithOpinion *Vote[ConflictIDType, VotePowerType])

WithVotePower derives a vote for the given VotePower.

type Votes

type Votes[ConflictIDType comparable, VotePowerType constraints.Comparable[VotePowerType]] struct {
	// contains filtered or unexported fields
}

func NewVotes

func NewVotes[ConflictIDType comparable, VotePowerType constraints.Comparable[VotePowerType]]() *Votes[ConflictIDType, VotePowerType]

func (*Votes[ConflictIDType, VotePowerType]) Add

func (v *Votes[ConflictIDType, VotePowerType]) Add(vote *Vote[ConflictIDType, VotePowerType]) (added bool, opinionChanged bool)

func (*Votes[ConflictIDType, VotePowerType]) Delete

func (v *Votes[ConflictIDType, VotePowerType]) Delete(vote *Vote[ConflictIDType, VotePowerType]) (deleted bool)

func (*Votes[ConflictIDType, VotePowerType]) Vote

func (v *Votes[ConflictIDType, VotePowerType]) Vote(voter identity.ID) (vote *Vote[ConflictIDType, VotePowerType], exists bool)

func (*Votes[ConflictIDType, VotePowerType]) Voters

func (v *Votes[ConflictIDType, VotePowerType]) Voters() (voters *advancedset.AdvancedSet[identity.ID])

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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