snowstorm

package
v1.1.0-codec.1 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2020 License: BSD-3-Clause Imports: 13 Imported by: 40

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conflicts

type Conflicts interface {
	// Add this transaction to conflict tracking
	Add(tx choices.Decidable) error

	// Conflicts returns true if there are no transactions currently tracked
	IsVirtuous(tx choices.Decidable) (bool, error)

	// Conflicts returns the transactions that conflict with the provided
	// transaction
	Conflicts(tx choices.Decidable) ([]choices.Decidable, error)

	// Mark this transaction as conditionally accepted
	Accept(txID ids.ID)

	// Updateable returns the transactions that can be accepted and rejected.
	// Assumes that returned transactions are accepted or rejected before the
	// next time this function is called. Acceptable transactions must have been
	// identified as having been confitionally accepted. If an acceptable
	// transaction was marked as having a conflict, then that conflict should be
	// returned in the same call as the acceptable transaction was returned or
	// in a prior call.
	Updateable() (acceptable []choices.Decidable, rejectable []choices.Decidable)
}

type Consensus

type Consensus interface {
	fmt.Stringer

	// Takes in the context, alpha, betaVirtuous, and betaRogue
	Initialize(*snow.Context, Conflicts, sbcon.Parameters) error

	// Returns the parameters that describe this snowstorm instance
	Parameters() sbcon.Parameters

	// Returns the set of virtuous transactions
	// that have not yet been accepted or rejected
	Virtuous() ids.Set

	// Returns the currently preferred transactions to be finalized
	Preferences() ids.Set

	// Returns true iff all remaining transactions are rogue. Note, it is
	// possible that after returning quiesce, a new decision may be added such
	// that this instance should no longer quiesce.
	Quiesce() bool

	// Returns true iff all added transactions have been finalized. Note, it is
	// possible that after returning finalized, a new decision may be added such
	// that this instance is no longer finalized.
	Finalized() bool

	// Returns true if transaction <Tx> is virtuous.
	// That is, no transaction has been added that conflicts with <Tx>
	IsVirtuous(choices.Decidable) (bool, error)

	// Returns the set of transactions conflicting with <Tx>
	Conflicts(choices.Decidable) (ids.Set, error)

	// Returns true iff transaction <Tx> has been added
	Issued(choices.Decidable) bool

	// Adds a new transaction to vote on. Returns if a critical error has
	// occurred.
	Add(choices.Decidable) error

	// Collects the results of a network poll. Assumes all transactions
	// have been previously added. Returns true is any statuses or preferences
	// changed. Returns if a critical error has occurred.
	RecordPoll(ids.Bag) (bool, error)
}

Consensus is a snowball instance deciding between an unbounded number of non-transitive conflicts. After performing a network sample of k nodes, you should call collect with the responses.

type Directed

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

Directed is an implementation of a multi-color, non-transitive, snowball instance

func (*Directed) Accepted

func (m *Directed) Accepted(id ids.ID)

Accepted marks that a transaction with the provided ID was accepted. It is assumed that Issued was previously called with this ID.

func (*Directed) Add

func (dg *Directed) Add(tx choices.Decidable) error

Add implements the Consensus interface

func (*Directed) Conflicts

func (dg *Directed) Conflicts(tx choices.Decidable) (ids.Set, error)

Conflicts implements the Consensus interface

func (*Directed) Finalized

func (dg *Directed) Finalized() bool

Finalized implements the ConflictGraph interface

func (*Directed) Initialize

func (dg *Directed) Initialize(
	ctx *snow.Context,
	conflicts Conflicts,
	params sbcon.Parameters,
) error

Initialize implements the Consensus interface

func (*Directed) IsVirtuous

func (dg *Directed) IsVirtuous(tx choices.Decidable) (bool, error)

IsVirtuous implements the Consensus interface

func (*Directed) Issued

func (dg *Directed) Issued(tx choices.Decidable) bool

Issued implements the Consensus interface

func (*Directed) Parameters

func (dg *Directed) Parameters() sbcon.Parameters

Parameters implements the Snowstorm interface

func (*Directed) Preferences

func (dg *Directed) Preferences() ids.Set

Preferences implements the ConflictGraph interface

func (*Directed) Quiesce

func (dg *Directed) Quiesce() bool

Quiesce implements the ConflictGraph interface

func (*Directed) RecordPoll

func (dg *Directed) RecordPoll(votes ids.Bag) (bool, error)

RecordPoll implements the Consensus interface

func (*Directed) Rejected

func (m *Directed) Rejected(id ids.ID)

Rejected marks that a transaction with the provided ID was rejected. It is assumed that Issued was previously called with this ID.

func (*Directed) String

func (dg *Directed) String() string

func (*Directed) Virtuous

func (dg *Directed) Virtuous() ids.Set

Virtuous implements the ConflictGraph interface

type DirectedFactory

type DirectedFactory struct{}

DirectedFactory implements Factory by returning a directed struct

func (DirectedFactory) New

func (DirectedFactory) New() Consensus

New implements Factory

type Factory

type Factory interface {
	New() Consensus
}

Factory returns new instances of Consensus

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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