mselection

package
v1.2.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 11, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

type HeaviestSelector struct {
	sync.Mutex
	// contains filtered or unexported fields
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL