finality

package
v0.8.18 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2022 License: Apache-2.0, BSD-2-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultBranchGoFTranslation is the default function to translate the approval weight to gof.GradeOfFinality of a branch.
	DefaultBranchGoFTranslation BranchThresholdTranslation = func(branchID ledgerstate.BranchID, aw float64) gof.GradeOfFinality {
		switch {
		case aw >= lowLowerBound && aw < mediumLowerBound:
			return gof.Low
		case aw >= mediumLowerBound && aw < highLowerBound:
			return gof.Medium
		case aw >= highLowerBound:
			return gof.High
		default:
			return gof.None
		}
	}

	// DefaultMessageGoFTranslation is the default function to translate the approval weight to gof.GradeOfFinality of a message.
	DefaultMessageGoFTranslation MessageThresholdTranslation = func(aw float64) gof.GradeOfFinality {
		switch {
		case aw >= lowLowerBound && aw < mediumLowerBound:
			return gof.Low
		case aw >= mediumLowerBound && aw < highLowerBound:
			return gof.Medium
		case aw >= highLowerBound:
			return gof.High
		default:
			return gof.None
		}
	}
)

Functions

This section is empty.

Types

type BranchThresholdTranslation

type BranchThresholdTranslation func(branchID ledgerstate.BranchID, aw float64) gof.GradeOfFinality

BranchThresholdTranslation is a function which translates approval weight to a gof.GradeOfFinality.

type Gadget

type Gadget interface {
	HandleMarker(marker *markers.Marker, aw float64) (err error)
	HandleBranch(branchID ledgerstate.BranchID, aw float64) (err error)
	tangle.ConfirmationOracle
}

Gadget is an interface that describes the finality gadget.

type MessageThresholdTranslation

type MessageThresholdTranslation func(aw float64) gof.GradeOfFinality

MessageThresholdTranslation is a function which translates approval weight to a gof.GradeOfFinality.

type Option

type Option func(*Options)

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

func WithBranchGoFReachedLevel

func WithBranchGoFReachedLevel(branchGradeOfFinality gof.GradeOfFinality) Option

WithBranchGoFReachedLevel returns an Option setting the branch reached grade of finality level.

func WithBranchThresholdTranslation

func WithBranchThresholdTranslation(f BranchThresholdTranslation) Option

WithBranchThresholdTranslation returns an Option setting the BranchThresholdTranslation.

func WithMessageGoFReachedLevel

func WithMessageGoFReachedLevel(msgGradeOfFinality gof.GradeOfFinality) Option

WithMessageGoFReachedLevel returns an Option setting the message reached grade of finality level.

func WithMessageThresholdTranslation

func WithMessageThresholdTranslation(f MessageThresholdTranslation) Option

WithMessageThresholdTranslation returns an Option setting the MessageThresholdTranslation.

type Options

type Options struct {
	BranchTransFunc        BranchThresholdTranslation
	MessageTransFunc       MessageThresholdTranslation
	BranchGoFReachedLevel  gof.GradeOfFinality
	MessageGoFReachedLevel gof.GradeOfFinality
}

Options defines the options for a SimpleFinalityGadget.

type SimpleFinalityGadget

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

SimpleFinalityGadget is a Gadget which simply translates approval weight down to gof.GradeOfFinality and then applies it to messages, branches, transactions and outputs.

func NewSimpleFinalityGadget

func NewSimpleFinalityGadget(t *tangle.Tangle, opts ...Option) *SimpleFinalityGadget

NewSimpleFinalityGadget creates a new SimpleFinalityGadget.

func (*SimpleFinalityGadget) Events

Events returns the events this gadget exposes.

func (*SimpleFinalityGadget) FirstUnconfirmedMarkerIndex

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

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

func (*SimpleFinalityGadget) HandleBranch

func (s *SimpleFinalityGadget) HandleBranch(branchID ledgerstate.BranchID, aw float64) (err error)

HandleBranch receives a branchID and its approval weight. It propagates the GoF according to AW to transactions in the branch (UTXO future cone) and their outputs.

func (*SimpleFinalityGadget) HandleMarker

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

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

func (*SimpleFinalityGadget) IsBranchConfirmed

func (s *SimpleFinalityGadget) IsBranchConfirmed(branchID ledgerstate.BranchID) (confirmed bool)

IsBranchConfirmed returns whether the given branch is confirmed.

func (*SimpleFinalityGadget) IsMarkerConfirmed

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

IsMarkerConfirmed returns whether the given marker is confirmed.

func (*SimpleFinalityGadget) IsMessageConfirmed

func (s *SimpleFinalityGadget) IsMessageConfirmed(msgID tangle.MessageID) (confirmed bool)

IsMessageConfirmed returns whether the given message is confirmed.

func (*SimpleFinalityGadget) IsOutputConfirmed

func (s *SimpleFinalityGadget) IsOutputConfirmed(outputID ledgerstate.OutputID) (confirmed bool)

IsOutputConfirmed returns whether the given output is confirmed.

func (*SimpleFinalityGadget) IsTransactionConfirmed

func (s *SimpleFinalityGadget) IsTransactionConfirmed(transactionID ledgerstate.TransactionID) (confirmed bool)

IsTransactionConfirmed returns whether the given transaction is confirmed.

Jump to

Keyboard shortcuts

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