Documentation ¶
Index ¶
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 ¶
This section is empty.
Types ¶
type HeaviestSelector ¶
HeaviestSelector implements the heaviest branch selection strategy.
func New ¶
func New(minHeaviestBranchUnconfirmedTransactionsThreshold int, maxHeaviestBranchTipsPerCheckpoint int, randomTipsPerCheckpoint int, heaviestBranchSelectionDeadline time.Duration) *HeaviestSelector
New creates a new HeaviestSelector instance.
func (*HeaviestSelector) GetTrackedTailsCount ¶
func (s *HeaviestSelector) GetTrackedTailsCount() (trackedTails int)
GetTrackedTailsCount returns the amount of known bundle tails.
func (*HeaviestSelector) OnNewSolidBundle ¶
func (s *HeaviestSelector) OnNewSolidBundle(bndl *tangle.Bundle) (trackedTailsCount int)
OnNewSolidBundle adds a new bundle to be processed by s. The bundle must be solid and OnNewSolidBundle must be called in the order of solidification. The bundle must also not be below max depth.
func (*HeaviestSelector) SelectTips ¶
func (s *HeaviestSelector) SelectTips(minRequiredTips int) (hornet.Hashes, error)
SelectTips tries to collect tips that confirm the most recent transactions since the last reset of the selector. best tips are determined by counting the referenced transactions (heaviest branches) and by "removing" the transactions of the referenced cone of the already choosen tips in the bitsets of the available tips. only tips are considered that were present at the beginning of the SelectTips call, to prevent attackers from creating heavier branches while we are searching the best tips. "maxHeaviestBranchTipsPerCheckpoint" is the amount of tips that are collected if the current best tip is not below "UnconfirmedTransactionsThreshold" before. a minimum amount of selected tips can be enforced, even if none of the heaviest branches matches the "minHeaviestBranchUnconfirmedTransactionsThreshold" criteria. if at least one heaviest branch tip was found, "randomTipsPerCheckpoint" random tips are added to add some additional randomness to prevent parasite chain attacks. the selection is cancelled after a fixed deadline. in this case, it returns the current collected tips.