messagelayer

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2022 License: Apache-2.0, BSD-2-Clause Imports: 33 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 added in v0.4.0

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

AwaitMessageToBeBooked awaits maxAwait for the given message to get booked.

func AwaitMessageToBeIssued added in v0.6.2

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 added in v0.8.0

func FinalityGadget() finality.Gadget

FinalityGadget is the finality gadget instance.

func GetAccessMana added in v0.5.5

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

GetAccessMana returns the access mana of the node specified.

func GetAllManaMaps added in v0.5.5

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 added in v0.5.8

func GetCMana() map[identity.ID]float64

GetCMana is a wrapper for the approval weight.

func GetConsensusMana added in v0.5.5

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

GetConsensusMana returns the consensus mana of the node specified.

func GetHighestManaNodes added in v0.5.5

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 added in v0.5.5

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 added in v0.5.5

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

GetManaMap returns type mana perception of the node.

func GetNeighborsMana added in v0.5.5

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 added in v0.5.5

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 GetTotalMana added in v0.6.2

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

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

func QueryAllowed added in v0.5.5

func QueryAllowed() (allowed bool)

QueryAllowed returns if the mana plugin answers queries or not.

Types

type AllowedPledge added in v0.5.5

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

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

func GetAllowedPledgeNodes added in v0.5.5

func GetAllowedPledgeNodes(manaType mana.Type) AllowedPledge

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

type ManaParametersDefinition added in v0.7.4

type ManaParametersDefinition struct {
	// 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 added in v0.7.4

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:"1m" 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:"20m" 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 added in v0.7.4

type RateSetterParametersDefinition struct {
	// Initial defines the initial rate of rate setting.
	Initial float64 `default:"0" usage:"the initial rate of rate setting. Set 0 to automatically estimate the value based on access mana."`
	// RateSettingPause defines for how long to pause updates after decrease of rate.
	RateSettingPause time.Duration `default:"2s" usage:"for how long to pause updates after decrease of rate"`
	// Enable is the flag that enables the rate setting mechanism on node startup.
	Enable bool `default:"true" usage:"whether to enable rate setter"`
}

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

type SchedulerParametersDefinition added in v0.7.4

type SchedulerParametersDefinition struct {
	// MaxBufferSize defines the maximum buffer size (in number of blocks).
	MaxBufferSize int `default:"300" usage:"maximum buffer size (in number of messages)"` // 300 blocks
	// Rate defines the frequency to schedule a message.
	Rate string `default:"34ms" usage:"message scheduling interval [time duration string]"` // 29.4 blocks per second
	// ConfirmedMessageThreshold time threshold after which confirmed blocks are not scheduled [time duration string]
	ConfirmedMessageThreshold string `default:"1m" usage:"time threshold after which confirmed blocks 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