snowstorm

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2020 License: BSD-3-Clause Imports: 14 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

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

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

	// 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
	Add(Tx)

	// 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() ids.Set

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

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

	// Collects the results of a network poll. Assumes all transactions
	// have been previously added
	RecordPoll(ids.Bag)

	// 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 {
	// 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)

func (*Directed) Add

func (dg *Directed) Add(tx Tx)

Add implements the Consensus interface

func (*Directed) Conflicts

func (dg *Directed) Conflicts(tx Tx) ids.Set

Conflicts implements the Consensus interface

func (*Directed) Finalized

func (dg *Directed) Finalized() bool

Finalized implements the Consensus interface

func (*Directed) Initialize

func (dg *Directed) Initialize(ctx *snow.Context, params snowball.Parameters)

Initialize implements the Consensus interface

func (*Directed) IsVirtuous

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

IsVirtuous implements the Consensus interface

func (*Directed) Issued

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

Issued implements the Consensus interface

func (*Directed) Parameters

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

Parameters implements the Snowstorm interface

func (*Directed) Preferences

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

Preferences implements the Consensus interface

func (*Directed) Quiesce

func (dg *Directed) Quiesce() bool

Quiesce implements the Consensus interface

func (*Directed) RecordPoll

func (dg *Directed) RecordPoll(votes ids.Bag)

RecordPoll implements the Consensus interface

func (*Directed) Rejected

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

func (*Directed) String

func (dg *Directed) String() string

func (*Directed) Virtuous

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

Virtuous implements the Consensus 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

type Input

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

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

func (*Input) Accepted

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

func (*Input) Add

func (ig *Input) Add(tx Tx)

Add implements the ConflictGraph interface

func (*Input) Conflicts

func (ig *Input) Conflicts(tx Tx) ids.Set

Conflicts implements the ConflictGraph interface

func (*Input) Finalized

func (ig *Input) Finalized() bool

Finalized implements the ConflictGraph interface

func (*Input) Initialize

func (ig *Input) Initialize(ctx *snow.Context, params snowball.Parameters)

Initialize implements the ConflictGraph interface

func (*Input) IsVirtuous

func (ig *Input) IsVirtuous(tx Tx) bool

IsVirtuous implements the ConflictGraph interface

func (*Input) Issued

func (ig *Input) Issued(tx Tx) bool

Issued implements the ConflictGraph interface

func (*Input) Parameters

func (ig *Input) Parameters() snowball.Parameters

Parameters implements the Snowstorm interface

func (*Input) Preferences

func (ig *Input) Preferences() ids.Set

Preferences implements the ConflictGraph interface

func (*Input) Quiesce

func (ig *Input) Quiesce() bool

Quiesce implements the ConflictGraph interface

func (*Input) RecordPoll

func (ig *Input) RecordPoll(votes ids.Bag)

RecordPoll implements the ConflictGraph interface

func (*Input) Rejected

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

func (*Input) String

func (ig *Input) String() string

func (*Input) Virtuous

func (ig *Input) Virtuous() ids.Set

Virtuous implements the ConflictGraph interface

type InputFactory

type InputFactory struct{}

InputFactory implements Factory by returning an input struct

func (InputFactory) New

func (InputFactory) New() Consensus

New implements Factory

type TestTx

type TestTx struct {
	Identifier ids.ID
	Deps       []Tx
	Ins        ids.Set
	Stat       choices.Status
	Validity   error
	Bits       []byte
}

TestTx is a useful test transaction

func (*TestTx) Accept

func (tx *TestTx) Accept()

Accept implements the Consumer interface

func (*TestTx) Bytes

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

Bytes returns the bits

func (*TestTx) Dependencies

func (tx *TestTx) Dependencies() []Tx

Dependencies implements the Consumer interface

func (*TestTx) ID

func (tx *TestTx) ID() ids.ID

ID implements the Consumer interface

func (*TestTx) InputIDs

func (tx *TestTx) InputIDs() ids.Set

InputIDs implements the Consumer interface

func (*TestTx) Reject

func (tx *TestTx) Reject()

Reject implements the Consumer interface

func (*TestTx) Reset

func (tx *TestTx) Reset()

Reset sets the status to pending

func (*TestTx) Status

func (tx *TestTx) Status() choices.Status

Status implements the Consumer interface

func (*TestTx) Verify

func (tx *TestTx) Verify() error

Verify returns nil

type Tx

type Tx interface {
	choices.Decidable

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

	// 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.Set

	// 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() 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.

Jump to

Keyboard shortcuts

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