Documentation ¶
Index ¶
- Variables
- type HeaviestSelector
- func (s *HeaviestSelector) OnNewSolidMessage(msgMeta *storage.MessageMetadata) (trackedMessagesCount int)
- func (s *HeaviestSelector) Reset()
- func (s *HeaviestSelector) SelectTips(minRequiredTips int) (hornet.MessageIDs, error)
- func (s *HeaviestSelector) TrackedMessagesCount() (trackedMessagesCount 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") )
Functions ¶
This section is empty.
Types ¶
type HeaviestSelector ¶
HeaviestSelector implements the heaviest branch selection strategy.
func New ¶
func New(minHeaviestBranchUnreferencedMessagesThreshold int, maxHeaviestBranchTipsPerCheckpoint int, randomTipsPerCheckpoint int, heaviestBranchSelectionTimeout time.Duration) *HeaviestSelector
New creates a new HeaviestSelector instance.
func (*HeaviestSelector) OnNewSolidMessage ¶ added in v1.2.2
func (s *HeaviestSelector) OnNewSolidMessage(msgMeta *storage.MessageMetadata) (trackedMessagesCount int)
OnNewSolidMessage adds a new message to be processed by s. The message must be solid and OnNewSolidMessage must be called in the order of solidification. The message must also not be below max depth.
func (*HeaviestSelector) Reset ¶ added in v1.2.2
func (s *HeaviestSelector) Reset()
Reset resets the tracked messages map and tips list of s.
func (*HeaviestSelector) SelectTips ¶
func (s *HeaviestSelector) SelectTips(minRequiredTips int) (hornet.MessageIDs, error)
SelectTips tries to collect tips that confirm the most recent messages since the last reset of the selector. best tips are determined by counting the referenced messages (heaviest branches) and by "removing" the messages of the referenced cone of the already chosen 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 "UnreferencedMessagesThreshold" before. a minimum amount of selected tips can be enforced, even if none of the heaviest branches matches the "minHeaviestBranchUnreferencedMessagesThreshold" 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 canceled after a fixed deadline. in this case, it returns the current collected tips.
func (*HeaviestSelector) TrackedMessagesCount ¶ added in v1.2.2
func (s *HeaviestSelector) TrackedMessagesCount() (trackedMessagesCount int)
TrackedMessagesCount returns the amount of known messages.