mana

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2021 License: Apache-2.0, BSD-2-Clause Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CfgEmaCoefficient1 defines the coefficient used for Effective Base Mana 1 (moving average) calculation.
	CfgEmaCoefficient1 = "mana.emaCoefficient1"
	// CfgEmaCoefficient2 defines the coefficient used for Effective Base Mana 2 (moving average) calculation.
	CfgEmaCoefficient2 = "mana.emaCoefficient2"
	// CfgDecay defines the decay coefficient used for Base Mana 2 calculation.
	CfgDecay = "mana.decay"
	// CfgAllowedAccessPledge defines the list of nodes that access mana is allowed to be pledged to.
	CfgAllowedAccessPledge = "mana.allowedAccessPledge"
	// CfgAllowedAccessFilterEnabled defines if access mana pledge filter is enabled.
	CfgAllowedAccessFilterEnabled = "mana.allowedAccessFilterEnabled"
	// CfgAllowedConsensusPledge defines the list of nodes that consensus mana is allowed to be pledged to.
	CfgAllowedConsensusPledge = "mana.allowedConsensusPledge"
	// CfgAllowedConsensusFilterEnabled defines if consensus mana pledge filter is enabled.
	CfgAllowedConsensusFilterEnabled = "mana.allowedConsensusFilterEnabled"
	// CfgManaEnableResearchVectors determines if research mana vector should be used or not. To use the Mana Research
	// Grafana Dashboard, this should be set to true.
	CfgManaEnableResearchVectors = "mana.enableResearchVectors"
	// CfgPruneConsensusEventLogsInterval defines the interval to check and prune consensus event logs storage.
	CfgPruneConsensusEventLogsInterval = "mana.pruneConsensusEventLogsInterval"
	// CfgVectorsCleanupInterval defines the interval to clean empty mana nodes from the base mana vectors.
	CfgVectorsCleanupInterval = "mana.vectorsCleanupInterval"
	// CfgDebuggingEnabled defines if the mana plugin responds to queries while not being in sync or not.
	CfgDebuggingEnabled = "mana.debuggingEnabled"
)
View Source
const (
	PluginName = "Mana"
)

PluginName is the name of the mana plugin.

Variables

View Source
var (
	// ErrQueryNotAllowed is returned when the node is not synced and mana debug mode is disabled.
	ErrQueryNotAllowed = xerrors.New("mana query not allowed, node is not synced, debug mode disabled")
)

Functions

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 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 GetLoggedEvents

func GetLoggedEvents(IDs []identity.ID, startTime time.Time, endTime time.Time) (map[identity.ID]*EventsLogs, error)

GetLoggedEvents gets the events logs for the node IDs and time frame specified. If none is specified, it returns the logs for 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, 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 GetPastConsensusManaVector

func GetPastConsensusManaVector(t time.Time) (*mana.ConsensusBaseManaVector, []mana.Event, error)

GetPastConsensusManaVector builds a consensus base mana vector in the past.

func GetPastConsensusManaVectorMetadata

func GetPastConsensusManaVectorMetadata() *mana.ConsensusBasePastManaVectorMetadata

GetPastConsensusManaVectorMetadata gets the past consensus mana vector metadata.

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 GetWeightedRandomNodes

func GetWeightedRandomNodes(n uint, manaType mana.Type) (mana.NodeMap, error)

GetWeightedRandomNodes returns a weighted random selection of n nodes.

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 Plugin

func Plugin() *node.Plugin

Plugin gets the plugin instance.

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
}

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 EventsLogs

type EventsLogs struct {
	Pledge []*mana.PledgedEvent `json:"pledge"`
	Revoke []*mana.RevokedEvent `json:"revoke"`
}

EventsLogs represents the events logs.

Jump to

Keyboard shortcuts

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