Documentation ¶
Index ¶
- Variables
- func TipCaller(handler interface{}, params ...interface{})
- func WalkerStatsCaller(handler interface{}, params ...interface{})
- type Events
- type Score
- type Tip
- type TipSelStats
- type TipSelectionFunc
- type TipSelector
- func (ts *TipSelector) AddTip(messageMeta *storage.MessageMetadata)
- func (ts *TipSelector) CleanUpReferencedTips() int
- func (ts *TipSelector) GetTipCount() (int, int)
- func (ts *TipSelector) SelectNonLazyTips() (hornet.MessageIDs, error)
- func (ts *TipSelector) SelectSemiLazyTips() (hornet.MessageIDs, error)
- func (ts *TipSelector) SelectSpammerTips() (isSemiLazy bool, tips hornet.MessageIDs, err error)
- func (ts *TipSelector) UpdateScores() int
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoTipsAvailable is returned when no tips are available in the node. ErrNoTipsAvailable = errors.New("no tips available") // ErrTipLazy is returned when the chosen tip was lazy already. ErrTipLazy = errors.New("tip already lazy") )
Functions ¶
func TipCaller ¶
func TipCaller(handler interface{}, params ...interface{})
TipCaller is used to signal tip events.
func WalkerStatsCaller ¶
func WalkerStatsCaller(handler interface{}, params ...interface{})
WalkerStatsCaller is used to signal tip selection events.
Types ¶
type Events ¶
type Events struct { // TipAdded is fired when a tip is added. TipAdded *events.Event // TipRemoved is fired when a tip is removed. TipRemoved *events.Event // TipSelPerformed is fired when a tipselection was performed. TipSelPerformed *events.Event }
Events represents events happening on the tip-selector.
type Tip ¶
type Tip struct { // Score is the score of the tip. Score Score // MessageID is the message ID of the tip. MessageID hornet.MessageID // TimeFirstChild is the timestamp the tip was referenced for the first time by another message. TimeFirstChild time.Time // ChildrenCount is the amount the tip was referenced by other messages. ChildrenCount *atomic.Uint32 }
Tip defines a tip.
type TipSelStats ¶
type TipSelStats struct { // The duration of the tip-selection for a single tip. Duration time.Duration `json:"duration"` }
TipSelStats holds the stats for a tipselection run.
type TipSelectionFunc ¶
type TipSelectionFunc = func() (hornet.MessageIDs, error)
TipSelectionFunc is a function which performs a tipselection and returns tips.
type TipSelector ¶
type TipSelector struct { // Events are the events that are triggered by the TipSelector. Events Events // contains filtered or unexported fields }
TipSelector manages a list of tips and emits events for their removal and addition.
func New ¶
func New(storage *storage.Storage, serverMetrics *metrics.ServerMetrics, maxDeltaMsgYoungestConeRootIndexToCMI int, maxDeltaMsgOldestConeRootIndexToCMI int, belowMaxDepth int, retentionRulesTipsLimitNonLazy int, maxReferencedTipAgeNonLazy time.Duration, maxChildrenNonLazy uint32, spammerTipsThresholdNonLazy int, retentionRulesTipsLimitSemiLazy int, maxReferencedTipAgeSemiLazy time.Duration, maxChildrenSemiLazy uint32, spammerTipsThresholdSemiLazy int) *TipSelector
New creates a new tip-selector.
func (*TipSelector) AddTip ¶
func (ts *TipSelector) AddTip(messageMeta *storage.MessageMetadata)
AddTip adds the given message as a tip.
func (*TipSelector) CleanUpReferencedTips ¶
func (ts *TipSelector) CleanUpReferencedTips() int
CleanUpReferencedTips checks if tips were referenced before and removes them if they reached their maximum age.
func (*TipSelector) GetTipCount ¶ added in v1.0.0
func (ts *TipSelector) GetTipCount() (int, int)
GetTipCount returns the current amount of available tips in the non-lazy and semi-lazy pool.
func (*TipSelector) SelectNonLazyTips ¶
func (ts *TipSelector) SelectNonLazyTips() (hornet.MessageIDs, error)
SelectNonLazyTips selects two non-lazy tips.
func (*TipSelector) SelectSemiLazyTips ¶
func (ts *TipSelector) SelectSemiLazyTips() (hornet.MessageIDs, error)
SelectSemiLazyTips selects two semi-lazy tips.
func (*TipSelector) SelectSpammerTips ¶ added in v0.5.1
func (ts *TipSelector) SelectSpammerTips() (isSemiLazy bool, tips hornet.MessageIDs, err error)
func (*TipSelector) UpdateScores ¶
func (ts *TipSelector) UpdateScores() int
UpdateScores updates the scores of the tips and removes lazy ones.