blocklayer

package
v0.9.8 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2022 License: Apache-2.0, BSD-2-Clause Imports: 35 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// NotarizationPluginName is the name of the notarization plugin.
	NotarizationPluginName = "Notarization"
)
View Source
const (
	// PluginName is the name of the mana plugin.
	PluginName = "Mana"
)
View Source
const (
	// SnapshotPluginName is the name of the snapshot plugin.
	SnapshotPluginName = "Snapshot"
)

Variables

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

	// ErrBlockWasNotIssuedInTime is returned if a block did not get issued within the defined await time.
	ErrBlockWasNotIssuedInTime = errors.New("block 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 blocklayer 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 NotarizationParameters = &NotarizationParametersDefinition{}

NotarizationParameters contains the configuration used by the notarization plugin.

View Source
var (
	NotarizationPlugin *node.Plugin
)
View Source
var Parameters = &ParametersDefinition{}

Parameters contains the general configuration used by the blocklayer plugin.

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

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

View Source
var SchedulerParameters = &SchedulerParametersDefinition{}

SchedulerParameters contains the scheduler configuration used by the blocklayer plugin.

View Source
var (
	SnapshotPlugin *node.Plugin
)

Functions

func AcceptanceGadget

func AcceptanceGadget() *acceptance.Gadget

AcceptanceGadget is the finality gadget instance.

func AwaitBlockToBeBooked

func AwaitBlockToBeBooked(f func() (*tangleold.Block, error), txID utxo.TransactionID, maxAwait time.Duration) (*tangleold.Block, error)

AwaitBlockToBeBooked awaits maxAwait for the given block to get booked.

func AwaitBlockToBeIssued

func AwaitBlockToBeIssued(f func() (*tangleold.Block, error), issuer ed25519.PublicKey, maxAwait time.Duration) (*tangleold.Block, error)

AwaitBlockToBeIssued awaits maxAwait for the given block to get issued.

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

func GetConfirmedEI() epoch.Index

GetConfirmedEI is a wrapper for the weightProvider to get confirmed epoch index.

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 GetLatestEC

func GetLatestEC() (ecRecord *epoch.ECRecord, latestConfirmedEpoch epoch.Index, err error)

GetLatestEC returns the latest commitment that a new block should commit to.

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 []*p2p.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 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 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 {
	// 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"`
	// Number of epochs past the latest committable epoch for which the base mana vector becomes effective.
	EpochDelay uint `default:"2" usage:"number of epochs past the latest committable epoch for which the base mana vector becomes effective"`
}

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

type NotarizationParametersDefinition

type NotarizationParametersDefinition struct {
	// MinEpochCommittableAge defines the min age of a committable epoch.
	MinEpochCommittableAge time.Duration `default:"1m" usage:"min age of a committable epoch"`
	// BootstrapWindow when notarization manager is considered to be bootstrapped
	BootstrapWindow time.Duration `default:"2m" usage:"when notarization manager is considered to be bootstrapped"`
	// SnapshotDepth defines how many epoch diffs are stored in the snapshot, starting from the full ledgerstate
	SnapshotDepth int `default:"5" usage:"defines how many epoch diffs are stored in the snapshot, starting from the full ledgerstate"`
}

NotarizationParametersDefinition contains the definition of the parameters used by the notarization 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 blocks in its past cone will not be selected.
	TimeSinceConfirmationThreshold time.Duration `default:"30s" 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 block.
		GenesisNode string `` /* 138-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:"20s" 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"`

	// GenesisTime resets the genesis time to the specified value, Unix time in seconds.
	GenesisTime int64 `default:"0" usage:"resets the genesis time to the specified value, unix time in seconds"`
}

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

type RateSetterParametersDefinition

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:"1s" 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

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