snowball

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2020 License: BSD-3-Clause Imports: 4 Imported by: 32

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BinarySlush

type BinarySlush interface {
	fmt.Stringer

	// Takes in the initial choice
	Initialize(initialPreference int)

	// Returns the currently preferred choice to be finalized
	Preference() int

	// RecordSuccessfulPoll records a successful poll towards finalizing the
	// specified choice
	RecordSuccessfulPoll(choice int)
}

BinarySlush is a slush instance deciding between two values. After performing a network sample of k nodes, if you have alpha votes for one of the choices, you should vote for that choice.

type BinarySnowball

type BinarySnowball interface{ BinarySnowflake }

BinarySnowball augments BinarySnowflake with a counter that tracks the total number of positive responses from a network sample.

type BinarySnowflake

type BinarySnowflake interface {
	fmt.Stringer

	// Takes in the beta value, and the initial choice
	Initialize(beta, initialPreference int)

	// Returns the currently preferred choice to be finalized
	Preference() int

	// RecordSuccessfulPoll records a successful poll towards finalizing the
	// specified choice
	RecordSuccessfulPoll(choice int)

	// RecordUnsuccessfulPoll resets the snowflake counter of this instance
	RecordUnsuccessfulPoll()

	// Return whether a choice has been finalized
	Finalized() bool
}

BinarySnowflake is a snowball instance deciding between two values After performing a network sample of k nodes, if you have alpha votes for one of the choices, you should vote for that choice. Otherwise, you should reset.

type Consensus

type Consensus interface {
	fmt.Stringer

	// Takes in alpha, beta1, beta2, and the initial choice
	Initialize(params Parameters, initialPreference ids.ID)

	// Returns the parameters that describe this snowball instance
	Parameters() Parameters

	// Adds a new choice to vote on
	Add(newChoice ids.ID)

	// Returns the currently preferred choice to be finalized
	Preference() ids.ID

	// RecordPoll records the results of a network poll. Assumes all choices
	// have been previously added.
	RecordPoll(votes ids.Bag)

	// RecordUnsuccessfulPoll resets the snowflake counters of this consensus
	// instance
	RecordUnsuccessfulPoll()

	// Return whether a choice has been finalized
	Finalized() bool
}

Consensus represents a general snow instance that can be used directly to process the results of network queries.

type Factory

type Factory interface {
	New() Consensus
}

Factory returns new instances of Consensus

type Flat

type Flat struct {
	// contains filtered or unexported fields
}

Flat is a naive implementation of a multi-choice snowball instance

func (*Flat) Initialize

func (f *Flat) Initialize(params Parameters, choice ids.ID)

Initialize implements the Consensus interface

func (*Flat) Parameters

func (f *Flat) Parameters() Parameters

Parameters implements the Consensus interface

func (*Flat) Preference

func (sb *Flat) Preference() ids.ID

Preference implements the NnarySnowball interface

func (*Flat) RecordPoll

func (f *Flat) RecordPoll(votes ids.Bag)

RecordPoll implements the Consensus interface

func (*Flat) RecordSuccessfulPoll

func (sb *Flat) RecordSuccessfulPoll(choice ids.ID)

RecordSuccessfulPoll implements the NnarySnowball interface

func (*Flat) String

func (sb *Flat) String() string

type FlatFactory

type FlatFactory struct{}

FlatFactory implements Factory by returning a flat struct

func (FlatFactory) New

func (FlatFactory) New() Consensus

New implements Factory

type NnarySlush

type NnarySlush interface {
	fmt.Stringer

	// Takes in the initial choice
	Initialize(initialPreference ids.ID)

	// Returns the currently preferred choice to be finalized
	Preference() ids.ID

	// RecordSuccessfulPoll records a successful poll towards finalizing the
	// specified choice. Assumes the choice was previously added.
	RecordSuccessfulPoll(choice ids.ID)
}

NnarySlush is a slush instance deciding between an unbounded number of values. After performing a network sample of k nodes, if you have alpha votes for one of the choices, you should vote for that choice.

type NnarySnowball

type NnarySnowball interface{ NnarySnowflake }

NnarySnowball augments NnarySnowflake with a counter that tracks the total number of positive responses from a network sample.

type NnarySnowflake

type NnarySnowflake interface {
	fmt.Stringer

	// Takes in beta1, beta2, and the initial choice
	Initialize(betaVirtuous, betaRogue int, initialPreference ids.ID)

	// Adds a new possible choice
	Add(newChoice ids.ID)

	// Returns the currently preferred choice to be finalized
	Preference() ids.ID

	// RecordSuccessfulPoll records a successful poll towards finalizing the
	// specified choice. Assumes the choice was previously added.
	RecordSuccessfulPoll(choice ids.ID)

	// RecordUnsuccessfulPoll resets the snowflake counter of this instance
	RecordUnsuccessfulPoll()

	// Return whether a choice has been finalized
	Finalized() bool
}

NnarySnowflake is a snowflake instance deciding between an unbounded number of values. After performing a network sample of k nodes, if you have alpha votes for one of the choices, you should vote for that choice. Otherwise, you should reset.

type Parameters

type Parameters struct {
	Namespace                                            string
	Metrics                                              prometheus.Registerer
	K, Alpha, BetaVirtuous, BetaRogue, ConcurrentRepolls int
}

Parameters required for snowball consensus

func (Parameters) Valid

func (p Parameters) Valid() error

Valid returns nil if the parameters describe a valid initialization.

type Tree

type Tree struct {
	// contains filtered or unexported fields
}

Tree implements the snowball interface by using a modified patricia tree.

func (*Tree) Add

func (t *Tree) Add(choice ids.ID)

Add implements the Consensus interface

func (*Tree) Initialize

func (t *Tree) Initialize(params Parameters, choice ids.ID)

Initialize implements the Consensus interface

func (*Tree) Parameters

func (t *Tree) Parameters() Parameters

Parameters implements the Consensus interface

func (*Tree) RecordPoll

func (t *Tree) RecordPoll(votes ids.Bag)

RecordPoll implements the Consensus interface

func (*Tree) RecordUnsuccessfulPoll

func (t *Tree) RecordUnsuccessfulPoll()

RecordUnsuccessfulPoll implements the Consensus interface

func (*Tree) String

func (t *Tree) String() string

type TreeFactory

type TreeFactory struct{}

TreeFactory implements Factory by returning a tree struct

func (TreeFactory) New

func (TreeFactory) New() Consensus

New implements Factory

type UnarySnowball

type UnarySnowball interface {
	fmt.Stringer

	// Takes in the beta value
	Initialize(beta int)

	// RecordSuccessfulPoll records a successful poll towards finalizing
	RecordSuccessfulPoll()

	// RecordUnsuccessfulPoll resets the snowflake counter of this instance
	RecordUnsuccessfulPoll()

	// Return whether a choice has been finalized
	Finalized() bool

	// Returns a new binary snowball instance with the agreement parameters
	// transferred. Takes in the new beta value and the original choice
	Extend(beta, originalPreference int) BinarySnowball

	// Returns a new unary snowball instance with the same state
	Clone() UnarySnowball
}

UnarySnowball is a snowball instance deciding on one value. After performing a network sample of k nodes, if you have alpha votes for the choice, you should vote. Otherwise, you should reset.

type UnarySnowflake

type UnarySnowflake interface {
	fmt.Stringer

	// Takes in the beta value
	Initialize(beta int)

	// RecordSuccessfulPoll records a successful poll towards finalizing
	RecordSuccessfulPoll()

	// RecordUnsuccessfulPoll resets the snowflake counter of this instance
	RecordUnsuccessfulPoll()

	// Return whether a choice has been finalized
	Finalized() bool

	// Returns a new binary snowball instance with the agreement parameters
	// transferred. Takes in the new beta value and the original choice
	Extend(beta, originalPreference int) BinarySnowflake

	// Returns a new unary snowflake instance with the same state
	Clone() UnarySnowflake
}

UnarySnowflake is a snowflake instance deciding on one value. After performing a network sample of k nodes, if you have alpha votes for the choice, you should vote. Otherwise, you should reset.

Jump to

Keyboard shortcuts

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