Documentation ¶
Index ¶
- Variables
- func RandomInsecure(min int, max int) int
- 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(blockMeta *storage.BlockMetadata)
- func (ts *TipSelector) CleanUpReferencedTips() int
- func (ts *TipSelector) SelectNonLazyTips() (iotago.BlockIDs, error)
- func (ts *TipSelector) SelectSemiLazyTips() (iotago.BlockIDs, error)
- func (ts *TipSelector) SelectTipsWithSemiLazyAllowed() (tips iotago.BlockIDs, err error)
- func (ts *TipSelector) TipCount() (int, int)
- func (ts *TipSelector) UpdateScores() (int, error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoTipsAvailable is returned when no tips are available in the node. ErrNoTipsAvailable = errors.New("no tips available") )
Functions ¶
func RandomInsecure ¶
RandomInsecure returns a random int in the range of min to max. the result is not cryptographically secure. RandomInsecure is inclusive max value.
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 // BlockID is the block ID of the tip. BlockID iotago.BlockID // TimeFirstChild is the timestamp the tip was referenced for the first time by another block. TimeFirstChild time.Time // ChildrenCount is the amount the tip was referenced by other blocks. 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 ¶
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( shutdownCtx context.Context, tipScoreCalculator *tangle.TipScoreCalculator, syncManager *syncmanager.SyncManager, serverMetrics *metrics.ServerMetrics, retentionRulesTipsLimitNonLazy int, maxReferencedTipAgeNonLazy time.Duration, maxChildrenNonLazy uint32, retentionRulesTipsLimitSemiLazy int, maxReferencedTipAgeSemiLazy time.Duration, maxChildrenSemiLazy uint32) *TipSelector
New creates a new tip-selector.
func (*TipSelector) AddTip ¶
func (ts *TipSelector) AddTip(blockMeta *storage.BlockMetadata)
AddTip adds the given block 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) SelectNonLazyTips ¶
func (ts *TipSelector) SelectNonLazyTips() (iotago.BlockIDs, error)
SelectNonLazyTips selects two non-lazy tips.
func (*TipSelector) SelectSemiLazyTips ¶
func (ts *TipSelector) SelectSemiLazyTips() (iotago.BlockIDs, error)
SelectSemiLazyTips selects two semi-lazy tips.
func (*TipSelector) SelectTipsWithSemiLazyAllowed ¶
func (ts *TipSelector) SelectTipsWithSemiLazyAllowed() (tips iotago.BlockIDs, err error)
SelectTipsWithSemiLazyAllowed tries to select semi-lazy tips first, but uses non-lazy tips instead if not enough semi-lazy tips are found. This functionality may be useful for healthy spammers.
func (*TipSelector) TipCount ¶
func (ts *TipSelector) TipCount() (int, int)
TipCount returns the current amount of available tips in the non-lazy and semi-lazy pool.
func (*TipSelector) UpdateScores ¶
func (ts *TipSelector) UpdateScores() (int, error)
UpdateScores updates the scores of the tips and removes lazy ones.