acceptance

package
v0.9.8 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2022 License: Apache-2.0, BSD-2-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultConflictTranslation is the default function to translate the approval weight to confirmation.State of a conflict.
	DefaultConflictTranslation ConflictThresholdTranslation = func(_ utxo.TransactionID, aw float64) confirmation.State {
		if aw >= acceptanceThreshold {
			return confirmation.Accepted
		}

		return confirmation.Pending
	}

	// DefaultBlockTranslation is the default function to translate the approval weight to confirmation.State of a block.
	DefaultBlockTranslation BlockThresholdTranslation = func(aw float64) confirmation.State {
		if aw >= acceptanceThreshold {
			return confirmation.Accepted
		}

		return confirmation.Pending
	}
)

Functions

This section is empty.

Types

type BlockThresholdTranslation

type BlockThresholdTranslation func(aw float64) confirmation.State

BlockThresholdTranslation is a function which translates approval weight to a confirmation.State.

type ConflictThresholdTranslation

type ConflictThresholdTranslation func(conflictID utxo.TransactionID, aw float64) confirmation.State

ConflictThresholdTranslation is a function which translates approval weight to a confirmation.State.

type Gadget

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

Gadget is a GadgetInterface which simply translates approval weight down to confirmation.State and then applies it to blocks, conflicts, transactions and outputs.

func NewSimpleFinalityGadget

func NewSimpleFinalityGadget(t *tangleold.Tangle, opts ...Option) *Gadget

NewSimpleFinalityGadget creates a new Gadget.

func (*Gadget) Events

func (s *Gadget) Events() *tangleold.ConfirmationEvents

Events returns the events this gadget exposes.

func (*Gadget) FirstUnconfirmedMarkerIndex

func (s *Gadget) FirstUnconfirmedMarkerIndex(sequenceID markers.SequenceID) (index markers.Index)

FirstUnconfirmedMarkerIndex returns the first Index in the given Sequence that was not confirmed, yet.

func (*Gadget) HandleConflict

func (s *Gadget) HandleConflict(conflictID utxo.TransactionID, aw float64) (err error)

HandleConflict receives a conflictID and its approval weight. It propagates the ConfirmationState according to AW to transactions in the conflict (UTXO future cone) and their outputs.

func (*Gadget) HandleMarker

func (s *Gadget) HandleMarker(marker markers.Marker, aw float64) (err error)

HandleMarker receives a marker and its current approval weight. It propagates the ConfirmationState according to AW to its past cone.

func (*Gadget) IsBlockConfirmed

func (s *Gadget) IsBlockConfirmed(blkID tangleold.BlockID) (confirmed bool)

IsBlockConfirmed returns whether the given block is confirmed.

func (*Gadget) IsConflictConfirmed

func (s *Gadget) IsConflictConfirmed(conflictID utxo.TransactionID) (confirmed bool)

IsConflictConfirmed returns whether the given conflict is confirmed.

func (*Gadget) IsMarkerConfirmed

func (s *Gadget) IsMarkerConfirmed(marker markers.Marker) (confirmed bool)

IsMarkerConfirmed returns whether the given marker is confirmed.

func (*Gadget) IsTransactionConfirmed

func (s *Gadget) IsTransactionConfirmed(transactionID utxo.TransactionID) (confirmed bool)

IsTransactionConfirmed returns whether the given transaction is confirmed.

type Option

type Option func(*Options)

Option is a function setting an option on an Options struct.

func WithBlockThresholdTranslation

func WithBlockThresholdTranslation(f BlockThresholdTranslation) Option

WithBlockThresholdTranslation returns an Option setting the BlockThresholdTranslation.

func WithConflictThresholdTranslation

func WithConflictThresholdTranslation(f ConflictThresholdTranslation) Option

WithConflictThresholdTranslation returns an Option setting the ConflictThresholdTranslation.

type Options

type Options struct {
	ConflictTransFunc ConflictThresholdTranslation
	BlockTransFunc    BlockThresholdTranslation
}

Options defines the options for a Gadget.

Jump to

Keyboard shortcuts

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