messagelayer

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: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PluginName is the name of the mana plugin.
	PluginName = "Mana"
)

Variables

View Source
var (
	// ErrMessageWasNotBookedInTime is returned if a message did not get booked within the defined await time.
	ErrMessageWasNotBookedInTime = errors.New("message could not be booked in time")

	// ErrMessageWasNotIssuedInTime is returned if a message did not get issued within the defined await time.
	ErrMessageWasNotIssuedInTime = errors.New("message could not be issued in time")
)
View Source
var ErrQueryNotAllowed = errors.New("mana query not allowed, node is not synced, debug mode disabled")

ErrQueryNotAllowed is returned when the node is not synced and mana debug mode is disabled.

View Source
var ManaParameters = &ManaParametersDefinition{}

ManaParameters contains the mana configuration used by the messagelayer plugin.

View Source
var (
	// ManaPlugin is the plugin instance of the mana plugin.
	ManaPlugin = node.NewPlugin(PluginName, nil, node.Enabled, configureManaPlugin, runManaPlugin)
)
View Source
var Parameters = &ParametersDefinition{}

Parameters contains the general configuration used by the messagelayer plugin.

View Source
var (
	// Plugin is the plugin instance of the messagelayer plugin.
	Plugin *node.Plugin
)
View Source
var RateSetterParameters = &RateSetterParametersDefinition{}

RateSetterParameters contains the rate setter configuration used by the messagelayer plugin.

View Source
var SchedulerParameters = &SchedulerParametersDefinition{}

SchedulerParameters contains the scheduler configuration used by the messagelayer plugin.

Functions

func AwaitMessageToBeBooked

func AwaitMessageToBeBooked(f func() (*tangle.Message, error), txID ledgerstate.TransactionID, maxAwait time.Duration) (*tangle.Message, error)

AwaitMessageToBeBooked awaits maxAwait for the given message to get booked.

func AwaitMessageToBeIssued

func AwaitMessageToBeIssued(f func() (*tangle.Message, error), issuer ed25519.PublicKey, maxAwait time.Duration) (*tangle.Message, error)

AwaitMessageToBeIssued awaits maxAwait for the given message to get issued.

func FinalityGadget

func FinalityGadget() finality.Gadget

FinalityGadget is the finality gadget instance.

func GetAccessMana

func GetAccessMana(nodeID identity.ID, optionalUpdateTime ...time.Time) (float64, time.Time, error)

GetAccessMana returns the access mana of the node specified.

func GetAllManaMaps

func GetAllManaMaps(optionalUpdateTime ...time.Time) (map[mana.Type]mana.NodeMap, error)

GetAllManaMaps returns the full mana maps for comparison with the perception of other nodes.

func GetCMana

func GetCMana() map[identity.ID]float64

GetCMana is a wrapper for the approval weight.

func GetConsensusMana

func GetConsensusMana(nodeID identity.ID, optionalUpdateTime ...time.Time) (float64, time.Time, error)

GetConsensusMana returns the consensus mana of the node specified.

func GetHighestManaNodes

func GetHighestManaNodes(manaType mana.Type, n uint) ([]mana.Node, time.Time, error)

GetHighestManaNodes returns the n highest type mana nodes in descending order. It also updates the mana values for each node. If n is zero, it returns all nodes.

func GetHighestManaNodesFraction

func GetHighestManaNodesFraction(manaType mana.Type, p float64) ([]mana.Node, time.Time, error)

GetHighestManaNodesFraction returns the highest mana that own 'p' percent of total mana. It also updates the mana values for each node. If p is zero or greater than one, it returns all nodes.

func GetManaMap

func GetManaMap(manaType mana.Type, optionalUpdateTime ...time.Time) (mana.NodeMap, time.Time, error)

GetManaMap returns type mana perception of the node.

func GetNeighborsMana

func GetNeighborsMana(manaType mana.Type, neighbors []*gossip.Neighbor, optionalUpdateTime ...time.Time) (mana.NodeMap, error)

GetNeighborsMana returns the type mana of the nodes neighbors.

func GetOnlineNodes

func GetOnlineNodes(manaType mana.Type) (onlineNodesMana []mana.Node, t time.Time, err error)

GetOnlineNodes gets the list of currently known (and verified) peers in the network, and their respective mana values. Sorted in descending order based on mana. Zero mana nodes are excluded.

func GetPendingMana

func GetPendingMana(value float64, n time.Duration) float64

GetPendingMana returns the mana pledged by spending a `value` output that sat for `n` duration.

func GetTotalMana

func GetTotalMana(manaType mana.Type, optionalUpdateTime ...time.Time) (float64, time.Time, error)

GetTotalMana returns sum of mana of all nodes in the network.

func OverrideMana

func OverrideMana(manaType mana.Type, nodeID identity.ID, bm *mana.AccessBaseMana)

OverrideMana sets the nodes mana to a specific value. It can be useful for debugging, setting faucet mana, initialization, etc.. Triggers ManaUpdated.

func PendingManaOnOutput

func PendingManaOnOutput(outputID ledgerstate.OutputID) (float64, time.Time)

PendingManaOnOutput predicts how much mana (bm2) will be pledged to a node if the output specified is spent.

func QueryAllowed

func QueryAllowed() (allowed bool)

QueryAllowed returns if the mana plugin answers queries or not.

Types

type AllowedPledge

type AllowedPledge struct {
	IsFilterEnabled bool
	Allowed         set.Set[identity.ID]
}

AllowedPledge represents the nodes that mana is allowed to be pledged to.

func GetAllowedPledgeNodes

func GetAllowedPledgeNodes(manaType mana.Type) AllowedPledge

GetAllowedPledgeNodes returns the list of nodes that type mana is allowed to be pledged to.

type ManaParametersDefinition

type ManaParametersDefinition struct {
	// EmaCoefficient1 defines the coefficient used for Effective Base Mana 1 (moving average) calculation.
	EmaCoefficient1 float64 `default:"0.00003209" usage:"coefficient used for Effective Base Mana 1 (moving average) calculation"`
	// EmaCoefficient2 defines the coefficient used for Effective Base Mana 2 (moving average) calculation.
	EmaCoefficient2 float64 `default:"0.0057762265" usage:"coefficient used for Effective Base Mana 1 (moving average) calculation"`
	// Decay defines the decay coefficient used for Base Mana 2 calculation.
	Decay float64 `default:"0.00003209" usage:"decay coefficient used for Base Mana 2 calculation"`
	// AllowedAccessPledge defines the list of nodes that access mana is allowed to be pledged to.
	AllowedAccessPledge []string `usage:"list of nodes that access mana is allowed to be pledged to"`
	// AllowedAccessFilterEnabled defines if access mana pledge filter is enabled.
	AllowedAccessFilterEnabled bool `default:"false" usage:"list of nodes that consensus mana is allowed to be pledge to"`
	// AllowedConsensusPledge defines the list of nodes that consensus mana is allowed to be pledged to.
	AllowedConsensusPledge []string `usage:"list of nodes that consensus mana is allowed to be pledge to"`
	// AllowedConsensusFilterEnabled defines if consensus mana pledge filter is enabled.
	AllowedConsensusFilterEnabled bool `default:"false" usage:"if filtering on consensus mana pledge nodes is enabled"`
	// EnableResearchVectors determines if research mana vector should be used or not. To use the Mana Research
	// Grafana Dashboard, this should be set to true.
	EnableResearchVectors bool `default:"false" usage:"enable mana research vectors"`
	// PruneConsensusEventLogsInterval defines the interval to check and prune consensus event logs storage.
	PruneConsensusEventLogsInterval time.Duration `default:"5m" usage:"interval to check and prune consensus event storage"`
	// VectorsCleanupInterval defines the interval to clean empty mana nodes from the base mana vectors.
	VectorsCleanupInterval time.Duration `default:"30m" usage:"interval to cleanup empty mana nodes from the mana vectors"`
	// DebuggingEnabled defines if the mana plugin responds to queries while not being in sync or not.
	DebuggingEnabled bool `default:"false" usage:"if mana plugin responds to queries while not in sync"`
	// SnapshotResetTime defines if the aMana Snapshot should be reset to the current Time.
	SnapshotResetTime bool `default:"false" usage:"when loading snapshot reset to current time when true"`
}

ManaParametersDefinition contains the definition of the parameters used by the mana plugin.

type ParametersDefinition

type ParametersDefinition struct {
	// TangleWidth can be used to specify the number of tips the Tangle tries to maintain.
	TangleWidth int `default:"0" usage:"the width of the Tangle"`
	// TimeSinceConfirmationThreshold is used to set the limit for which tips with old unconfirmed messages in its past cone will not be selected.
	TimeSinceConfirmationThreshold time.Duration `default:"12m" usage:"Time Since Confirmation (TSC) threshold"`
	// Snapshot contains snapshots related configuration parameters.
	Snapshot struct {
		// File is the path to the snapshot file.
		File string `default:"./snapshot.bin" usage:"the path to the snapshot file"`
		// GenesisNode is the identity of the node that is allowed to attach to the Genesis message.
		GenesisNode string `` /* 140-byte string literal not displayed */
	}

	// TangleTimeWindow defines the time window in which the node considers itself as synced according to TangleTime.
	TangleTimeWindow time.Duration `default:"2m" usage:"the time window in which the node considers itself as synced according to TangleTime"`

	// StartSynced defines if the node should start as synced.
	StartSynced bool `default:"false" usage:"start as synced"`
}

ParametersDefinition contains the definition of the parameters used by the messagelayer plugin.

type RateSetterParametersDefinition

type RateSetterParametersDefinition struct {
	// Initial defines the initial rate of rate setting.
	Initial float64 `default:"100000" usage:"the initial rate of rate setting"`
}

RateSetterParametersDefinition contains the definition of the parameters used by the Rate Setter.

type SchedulerParametersDefinition

type SchedulerParametersDefinition struct {
	// MaxBufferSize defines the maximum buffer size (in bytes).
	MaxBufferSize int `default:"100000000" usage:"maximum buffer size (in bytes)"` // 100 MB
	// Rate defines the frequency to schedule a message. `default:"5ms" usage:"message scheduling interval [time duration string]"`
	Rate string `default:"5ms" usage:"message scheduling interval [time duration string]"`
	// ConfirmedMessageThreshold time threshold after which confirmed messages are not scheduled [time duration string]
	ConfirmedMessageThreshold string `default:"1m" usage:"time threshold after which confirmed messages are not scheduled [time duration string]"`
}

SchedulerParametersDefinition contains the definition of the parameters used by the Scheduler.

Jump to

Keyboard shortcuts

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