Documentation ¶
Index ¶
- Constants
- Variables
- func AwaitMessageToBeBooked(f func() (*tangle.Message, error), txID ledgerstate.TransactionID, ...) (*tangle.Message, error)
- func ConsensusMechanism() *fcob.ConsensusMechanism
- func ConsensusPlugin() *node.Plugin
- func GetAccessMana(nodeID identity.ID, optionalUpdateTime ...time.Time) (float64, time.Time, error)
- func GetAllManaMaps(optionalUpdateTime ...time.Time) (map[mana.Type]mana.NodeMap, error)
- func GetConsensusMana(nodeID identity.ID, optionalUpdateTime ...time.Time) (float64, time.Time, error)
- func GetHighestManaNodes(manaType mana.Type, n uint) ([]mana.Node, time.Time, error)
- func GetHighestManaNodesFraction(manaType mana.Type, p float64) ([]mana.Node, time.Time, error)
- func GetLoggedEvents(identityIDs []identity.ID, startTime time.Time, endTime time.Time) (map[identity.ID]*EventsLogs, error)
- func GetManaMap(manaType mana.Type, optionalUpdateTime ...time.Time) (mana.NodeMap, time.Time, error)
- func GetNeighborsMana(manaType mana.Type, neighbors []*gossip.Neighbor, ...) (mana.NodeMap, error)
- func GetOnlineNodes(manaType mana.Type) (onlineNodesMana []mana.Node, t time.Time, err error)
- func GetPastConsensusManaVector(t time.Time) (*mana.ConsensusBaseManaVector, []mana.Event, error)
- func GetPastConsensusManaVectorMetadata() *mana.ConsensusBasePastManaVectorMetadata
- func GetPendingMana(value float64, n time.Duration) float64
- func ManaEpoch(t time.Time) map[identity.ID]float64
- func ManaPlugin() *node.Plugin
- func OpinionGiverFunc() (givers []opinion.OpinionGiver, err error)
- func OpinionRetriever(id string, objectType vote.ObjectType) opinion.Opinion
- func OverrideMana(manaType mana.Type, nodeID identity.ID, bm *mana.AccessBaseMana)
- func OwnManaRetriever() (float64, error)
- func PendingManaOnOutput(outputID ledgerstate.OutputID) (float64, time.Time)
- func Plugin() *node.Plugin
- func QueryAllowed() (allowed bool)
- func Registry() *statement.Registry
- func SyncBeaconFollowerPlugin() *node.Plugin
- func SyncStatus() (bool, map[ed25519.PublicKey]Status)
- func Tangle() *tangle.Tangle
- func Voter() vote.DRNGRoundBasedVoter
- type AllowedPledge
- type EventsLogs
- type OpinionGiver
- type OpinionGivers
- type PeerOpinionGiver
- type Status
Constants ¶
const ( // DefaultAverageNetworkDelay contains the default average time it takes for a network to propagate through gossip. DefaultAverageNetworkDelay = 5 * time.Second )
const (
// PluginName is the name of the mana plugin.
PluginName = "Mana"
)
const (
// SyncBeaconFollowerPluginName is the plugin name of the sync beacon follower plugin.
SyncBeaconFollowerPluginName = "SyncBeaconFollower"
)
Variables ¶
var ErrMessageWasNotBookedInTime = errors.New("message could not be booked in time")
ErrMessageWasNotBookedInTime is returned if a message did not get booked within the defined await time.
var ( // ErrMissingFollowNodes is returned if the node starts with no follow nodes list ErrMissingFollowNodes = errors.New("follow nodes list is required") )
var ErrQueryNotAllowed = xerrors.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.
var FPCParameters = 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 (in seconds). RoundInterval int64 `default:"10" usage:"FPC round interval [s]"` // QuerySampleSize defines how many nodes will be queried each round. QuerySampleSize int `default:"21" usage:"Size of the voting quorum (k)"` // TotalRoundsFinalization 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)."` }{}
FPCParameters contains the configuration parameters used by the FPC consensus.
var ManaParameters = 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"` }{}
ManaParameters contains the configuration parameters used by the mana plugin.
var Parameters = 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"` // 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 string `` /* 140-byte string literal not displayed */ } // FCOB contains parameters related to the fast consensus of barcelona. FCOB struct { AverageNetworkDelay int `default:"5" usage:"the avg. network delay to use for FCoB rules"` } }{}
Parameters contains the configuration parameters used by the message layer.
var StatementParameters = struct { // WaitForStatement is the time in seconds for which the node wait for receiving the new statement. WaitForStatement int `default:"5" usage:"the time in seconds 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 int `default:"5" usage:"the time in minutes after which the node cleans the statement registry"` // DeleteAfter defines the time [in minutes] after which older statements are deleted from the registry. DeleteAfter int `default:"5" usage:"the time in minutes after which older statements are deleted from the registry"` }{}
StatementParameters contains the configuration parameters used by the FPC statements in the tangle.
var SyncBeaconFollowerParameters = struct { // FollowNodes defines the list of nodes this node should follow to determine its sync status. FollowNodes []string `` /* 157-byte string literal not displayed */ // MaxTimeWindowSec defines the maximum time window for which a sync payload would be considerable. MaxTimeWindowSec int `default:"10" usage:"the maximum time window for which a sync payload would be considerable"` // MaxTimeOffline defines the maximum time a beacon node can stay without receiving updates. MaxTimeOffline int `default:"70" usage:"the maximum time the node should stay synced without receiving updates"` // CleanupInterval defines the interval that old beacon status are cleaned up. CleanupInterval int `default:"10" usage:"the interval at which cleanups are done"` // SyncPercentage defines the percentage of following nodes that have to be synced. SyncPercentage float64 `default:"0.5" usage:"percentage of nodes being followed that need to be synced in order to consider the node synced"` }{}
SyncBeaconFollowerParameters contains the configuration parameters used by the syncbeacon follower plugin.
Functions ¶
func AwaitMessageToBeBooked ¶ added in v0.4.0
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 ConsensusMechanism ¶ added in v0.5.0
func ConsensusMechanism() *fcob.ConsensusMechanism
ConsensusMechanism return the FcoB ConsensusMechanism used by the Tangle.
func ConsensusPlugin ¶ added in v0.5.0
ConsensusPlugin returns the consensus plugin.
func GetAccessMana ¶ added in v0.5.5
GetAccessMana returns the access mana of the node specified.
func GetAllManaMaps ¶ added in v0.5.5
GetAllManaMaps returns the full mana maps for comparison with the perception of other nodes.
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
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
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 GetLoggedEvents ¶ added in v0.5.5
func GetLoggedEvents(identityIDs []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 ¶ 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
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 ¶ added in v0.5.5
GetPastConsensusManaVector builds a consensus base mana vector in the past.
func GetPastConsensusManaVectorMetadata ¶ added in v0.5.5
func GetPastConsensusManaVectorMetadata() *mana.ConsensusBasePastManaVectorMetadata
GetPastConsensusManaVectorMetadata gets the past consensus mana vector metadata.
func GetPendingMana ¶ added in v0.5.5
GetPendingMana returns the mana pledged by spending a `value` output that sat for `n` duration.
func OpinionGiverFunc ¶ added in v0.5.0
func OpinionGiverFunc() (givers []opinion.OpinionGiver, err error)
OpinionGiverFunc returns a slice of opinion givers.
func OpinionRetriever ¶ added in v0.5.0
func OpinionRetriever(id string, objectType vote.ObjectType) opinion.Opinion
OpinionRetriever returns the current opinion of the given id.
func OverrideMana ¶ added in v0.5.5
OverrideMana sets the nodes mana to a specific value. It can be useful for debugging, setting faucet mana, initialization, etc.. Triggers ManaUpdated
func OwnManaRetriever ¶ added in v0.5.5
OwnManaRetriever returns the current consensus mana of a vector
func PendingManaOnOutput ¶ added in v0.5.5
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 ¶ added in v0.5.5
func QueryAllowed() (allowed bool)
QueryAllowed returns if the mana plugin answers queries or not.
func SyncBeaconFollowerPlugin ¶ added in v0.5.0
SyncBeaconFollowerPlugin gets the plugin instance.
func SyncStatus ¶ added in v0.5.0
SyncStatus returns the detailed status per beacon node.
func Voter ¶ added in v0.5.0
func Voter() vote.DRNGRoundBasedVoter
Voter returns the DRNGRoundBasedVoter instance used by the FPC plugin.
Types ¶
type AllowedPledge ¶ added in v0.5.5
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 EventsLogs ¶ added in v0.5.5
type EventsLogs struct { Pledge []*mana.PledgedEvent `json:"pledge"` Revoke []*mana.RevokedEvent `json:"revoke"` }
EventsLogs represents the events logs.
type OpinionGiver ¶ added in v0.5.0
type OpinionGiver struct {
// contains filtered or unexported fields
}
OpinionGiver is a wrapper for both statements and peers.
func (*OpinionGiver) ID ¶ added in v0.5.0
func (o *OpinionGiver) ID() identity.ID
ID returns the identifier of the underlying Peer.
func (*OpinionGiver) Mana ¶ added in v0.5.5
func (o *OpinionGiver) Mana() float64
Mana returns consensus mana value for an opinion giver
type OpinionGivers ¶ added in v0.5.0
type OpinionGivers map[identity.ID]OpinionGiver
OpinionGivers is a map of OpinionGiver.
type PeerOpinionGiver ¶ added in v0.5.0
type PeerOpinionGiver struct {
// contains filtered or unexported fields
}
PeerOpinionGiver implements the OpinionGiver interface based on a peer.
func (*PeerOpinionGiver) Address ¶ added in v0.5.0
func (pog *PeerOpinionGiver) Address() string
Address returns the FPC address of the underlying Peer.
func (*PeerOpinionGiver) ID ¶ added in v0.5.0
func (pog *PeerOpinionGiver) ID() identity.ID
ID returns the identifier of the underlying Peer.