snowstorm

package
v0.0.0-...-3fa05c8 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2023 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Consensus

type Consensus interface {
	fmt.Stringer
	health.Checker

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

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

	// Adds a new transaction to vote on. Returns if a critical error has
	// occurred.
	Add(context.Context, Tx) error

	// Remove a transaction from the set of currently processing txs. It is
	// assumed that the provided transaction ID is currently processing.
	Remove(context.Context, ids.ID) error

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

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

	// Returns the currently preferred transactions to be finalized
	Preferences() set.Set[ids.ID]

	// Return the current virtuous transactions that are being voted on.
	VirtuousVoting() set.Set[ids.ID]

	// Returns the set of transactions conflicting with <Tx>
	Conflicts(Tx) set.Set[ids.ID]

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

	// 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
}

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 {
	metrics.Polls
	metrics.Latency
	// contains filtered or unexported fields
}

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

func (*Directed) Add

func (dg *Directed) Add(ctx context.Context, tx Tx) error

func (*Directed) Conflicts

func (dg *Directed) Conflicts(tx Tx) set.Set[ids.ID]

func (*Directed) Finalized

func (dg *Directed) Finalized() bool

func (*Directed) HealthCheck

func (dg *Directed) HealthCheck(context.Context) (interface{}, error)

HealthCheck returns information about the consensus health.

func (*Directed) Initialize

func (dg *Directed) Initialize(
	ctx *snow.ConsensusContext,
	params sbcon.Parameters,
) error

func (*Directed) IsVirtuous

func (dg *Directed) IsVirtuous(tx Tx) bool

func (*Directed) Issued

func (dg *Directed) Issued(tx Tx) bool

func (*Directed) Preferences

func (dg *Directed) Preferences() set.Set[ids.ID]

func (*Directed) Quiesce

func (dg *Directed) Quiesce() bool

func (*Directed) RecordPoll

func (dg *Directed) RecordPoll(ctx context.Context, votes bag.Bag[ids.ID]) (bool, error)

func (*Directed) Remove

func (dg *Directed) Remove(ctx context.Context, txID ids.ID) error

func (*Directed) String

func (dg *Directed) String() string

func (*Directed) Virtuous

func (dg *Directed) Virtuous() set.Set[ids.ID]

func (*Directed) VirtuousVoting

func (dg *Directed) VirtuousVoting() set.Set[ids.ID]

type DirectedFactory

type DirectedFactory struct{}

DirectedFactory implements Factory by returning a directed struct

func (DirectedFactory) New

func (DirectedFactory) New() Consensus

type Factory

type Factory interface {
	New() Consensus
}

Factory returns new instances of Consensus

type TestTx

type TestTx struct {
	choices.TestDecidable

	DependenciesV    []Tx
	DependenciesErrV error
	InputIDsV        []ids.ID
	HasWhitelistV    bool
	WhitelistV       set.Set[ids.ID]
	WhitelistErrV    error
	VerifyV          error
	BytesV           []byte
}

TestTx is a useful test tx

func (*TestTx) Bytes

func (t *TestTx) Bytes() []byte

func (*TestTx) Dependencies

func (t *TestTx) Dependencies() ([]Tx, error)

func (*TestTx) HasWhitelist

func (t *TestTx) HasWhitelist() bool

func (*TestTx) InputIDs

func (t *TestTx) InputIDs() []ids.ID

func (*TestTx) Verify

func (t *TestTx) Verify(context.Context) error

func (*TestTx) Whitelist

func (t *TestTx) Whitelist(context.Context) (set.Set[ids.ID], error)

type Tx

type Tx interface {
	choices.Decidable
	Whitelister

	// Dependencies is a list of transactions upon which this transaction
	// depends. Each element of Dependencies must be verified before Verify is
	// called on this transaction.
	//
	// Similarly, each element of Dependencies must be accepted before this
	// transaction is accepted.
	Dependencies() ([]Tx, error)

	// InputIDs is a set where each element is the ID of a piece of state that
	// will be consumed if this transaction is accepted.
	//
	// In the context of a UTXO-based payments system, for example, this would
	// be the IDs of the UTXOs consumed by this transaction
	InputIDs() []ids.ID

	// Verify that the state transition this transaction would make if it were
	// accepted is valid. If the state transition is invalid, a non-nil error
	// should be returned.
	//
	// It is guaranteed that when Verify is called, all the dependencies of
	// this transaction have already been successfully verified.
	Verify(context.Context) error

	// Bytes returns the binary representation of this transaction.
	//
	// This is used for sending transactions to peers. Another node should be
	// able to parse these bytes to the same transaction.
	Bytes() []byte
}

Tx consumes state.

type Whitelister

type Whitelister interface {
	// Returns [true] if the underlying instance does implement whitelisted
	// conflicts.
	HasWhitelist() bool

	// Whitelist returns the set of transaction IDs that are explicitly
	// whitelisted. Transactions that are not explicitly whitelisted are
	// considered conflicting.
	Whitelist(context.Context) (set.Set[ids.ID], error)
}

Whitelister defines the interface for specifying whitelisted operations.

Jump to

Keyboard shortcuts

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