consensus

package
v0.7.6 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2021 License: Apache-2.0, BSD-2-Clause Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FPCParameters = &FPCParametersDefinition{}

FPCParameters contains the FPC configuration used by the consensus plugin.

View Source
var (
	// Plugin is the plugin instance of the consensus plugin.
	Plugin *node.Plugin
)
View Source
var StatementParameters = &StatementParametersDefinition{}

StatementParameters contains the FPC statement configuration used by the consensus plugin.

Functions

func OpinionGiverFunc

func OpinionGiverFunc() (givers []opinion.OpinionGiver, err error)

OpinionGiverFunc returns a slice of opinion givers.

func OpinionRetriever

func OpinionRetriever(id string, objectType vote.ObjectType) opinion.Opinion

OpinionRetriever returns the current opinion of the given id.

func OwnManaRetriever added in v0.7.6

func OwnManaRetriever() (float64, error)

OwnManaRetriever returns the current consensus mana of a vector

Types

type FPCParametersDefinition added in v0.7.6

type FPCParametersDefinition struct {
	// BindAddress defines on which address the FPC service should listen.
	BindAddress string `default:"0.0.0.0:10895" usage:"the bind address on which the FPC vote server binds to"`

	// Listen defines if the FPC service should listen.
	Listen bool `default:"true" usage:"if the FPC service should listen"`

	// RoundInterval defines how long a round lasts.
	RoundInterval time.Duration `default:"10s" usage:"FPC round interval"`

	// QuerySampleSize defines how many nodes will be queried each round.
	QuerySampleSize int `default:"21" usage:"Size of the voting quorum (k)"`

	// TotalRoundsFinalization defines the amount of rounds a vote context's opinion needs to stay the same to be considered final. Also called 'l'.
	TotalRoundsFinalization int `default:"10" usage:"The number of rounds opinion needs to stay the same to become final (l)"`

	// DRNGInstanceID the instanceID of the dRNG to be used with FPC.
	DRNGInstanceID uint32 `default:"1339" usage:"The instanceID of the dRNG to be used with FPC"`

	// AwaitOffset defines the max amount of time to wait for the next dRNG round after the expected time has elapsed.
	AwaitOffset time.Duration `default:"3s" usage:"The max amount of time to wait for the next dRNG round after the expected time has elapsed"`

	// DefaultRandomness defines default randomness used by FPC when no random is received from the dRNG.
	DefaultRandomness float64 `default:"0.5" usage:"The default randomness used by FPC when no random is received from the dRNG"`
}

FPCParametersDefinition contains the definition of parameters used by the FPC consensus.

type OpinionGiver

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

OpinionGiver is a wrapper for both statements and peers.

func (*OpinionGiver) ID

func (o *OpinionGiver) ID() identity.ID

ID returns the identifier of the underlying Peer.

func (*OpinionGiver) Mana added in v0.7.6

func (o *OpinionGiver) Mana() float64

Mana returns consensus mana value for an opinion giver

func (*OpinionGiver) Query

func (o *OpinionGiver) Query(ctx context.Context, conflictIDs, timestampIDs []string, delayedRoundStart ...time.Duration) (opinions opinion.Opinions, err error)

Query retrieves the opinions about the given conflicts and timestamps.

type OpinionGivers

type OpinionGivers map[identity.ID]OpinionGiver

OpinionGivers is a map of OpinionGiver.

type PeerOpinionGiver

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

PeerOpinionGiver implements the OpinionGiver interface based on a peer.

func (*PeerOpinionGiver) Address

func (pog *PeerOpinionGiver) Address() string

Address returns the FPC address of the underlying Peer.

func (*PeerOpinionGiver) ID

func (pog *PeerOpinionGiver) ID() identity.ID

ID returns the identifier of the underlying Peer.

func (*PeerOpinionGiver) Query

func (pog *PeerOpinionGiver) Query(ctx context.Context, conflictIDs, timestampIDs []string, _ ...time.Duration) (opinion.Opinions, error)

Query queries another node for its opinion.

type StatementParametersDefinition added in v0.7.6

type StatementParametersDefinition struct {
	// WaitForStatement is the time in seconds for which the node wait for receiving the new statement.
	WaitForStatement time.Duration `default:"5s" usage:"the time for which the node wait for receiving the new statement"`

	// WriteStatement defines if the node should write statements.
	WriteStatement bool `default:"true" usage:"if the node should make statements"`

	// ReadManaThreshold defines the Mana threshold to accept a statement.
	ReadManaThreshold float64 `default:"1.0" usage:"Value describing the percentage of top mana nodes to accept a statement from"`

	// WriteManaThreshold defines the Mana threshold to write a statement.
	WriteManaThreshold float64 `default:"0.7" usage:"Value describing the percentage of top mana nodes that can write a statement"`

	// CleanInterval defines the time interval [in minutes] for cleaning the statement registry.
	CleanInterval time.Duration `default:"5m" usage:"the time after which the node cleans the statement registry"`

	// DeleteAfter defines the time [in minutes] after which older statements are deleted from the registry.
	DeleteAfter time.Duration `default:"5m" usage:"the time after which older statements are deleted from the registry"`
}

StatementParametersDefinition contains the definition of the parameters used by the FPC statements in the tangle.

Jump to

Keyboard shortcuts

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