dag

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConeRootIndexes added in v1.0.5

func ConeRootIndexes(ctx context.Context, dbStorage *storage.Storage, cachedMsgMeta *storage.CachedMetadata, cmi milestone.Index) (youngestConeRootIndex milestone.Index, oldestConeRootIndex milestone.Index, err error)

ConeRootIndexes searches the cone root indexes for a given message. cachedMsgMeta has to be solid, otherwise youngestConeRootIndex and oldestConeRootIndex will be 0 if a message is missing in the cone.

func TraverseChildren added in v1.0.0

func TraverseChildren(ctx context.Context, dbStorage *storage.Storage, startMessageID hornet.MessageID, condition Predicate, consumer Consumer, walkAlreadyDiscovered bool, iteratorOptions ...storage.IteratorOption) error

TraverseChildren starts to traverse the children (future cone) of the given start message until the traversal stops due to no more messages passing the given condition. It is unsorted BFS because the children are not ordered in the database.

func TraverseParents added in v1.0.0

func TraverseParents(ctx context.Context, dbStorage *storage.Storage, parents hornet.MessageIDs, condition Predicate, consumer Consumer, onMissingParent OnMissingParent, onSolidEntryPoint OnSolidEntryPoint, traverseSolidEntryPoints bool) error

TraverseParents starts to traverse the parents (past cone) in the given order until the traversal stops due to no more messages passing the given condition. It is a DFS of the paths of the parents one after another. Caution: condition func is not in DFS order

func TraverseParentsOfMessage added in v1.0.0

func TraverseParentsOfMessage(ctx context.Context, dbStorage *storage.Storage, startMessageID hornet.MessageID, condition Predicate, consumer Consumer, onMissingParent OnMissingParent, onSolidEntryPoint OnSolidEntryPoint, traverseSolidEntryPoints bool) error

TraverseParentsOfMessage starts to traverse the parents (past cone) of the given start message until the traversal stops due to no more messages passing the given condition. It is a DFS of the paths of the parents one after another. Caution: condition func is not in DFS order

func UpdateConeRootIndexes added in v1.0.0

func UpdateConeRootIndexes(ctx context.Context, dbStorage *storage.Storage, metadataMemcache *storage.MetadataMemcache, messageIDs hornet.MessageIDs, cmi milestone.Index, iteratorOptions ...storage.IteratorOption) error

UpdateConeRootIndexes updates the cone root indexes of the future cone of all given messages. all the messages of the newly referenced cone already have updated cone root indexes. we have to walk the future cone, and update the past cone of all messages that reference an old cone. as a special property, invocations of the yielded function share the same 'already traversed' set to circumvent walking the future cone of the same messages multiple times.

Types

type ChildrenTraverser added in v1.0.0

type ChildrenTraverser struct {
	// contains filtered or unexported fields
}

func NewChildrenTraverser added in v1.0.0

func NewChildrenTraverser(dbStorage *storage.Storage, metadataMemcache ...*storage.MetadataMemcache) *ChildrenTraverser

NewChildrenTraverser create a new traverser to traverse the children (future cone)

func (*ChildrenTraverser) Cleanup added in v1.0.0

func (t *ChildrenTraverser) Cleanup(forceRelease bool)

Cleanup releases all the cached objects that have been traversed. This MUST be called by the user at the end.

func (*ChildrenTraverser) Traverse added in v1.0.0

func (t *ChildrenTraverser) Traverse(ctx context.Context, startMessageID hornet.MessageID, condition Predicate, consumer Consumer, walkAlreadyDiscovered bool, iteratorOptions ...storage.IteratorOption) error

Traverse starts to traverse the children (future cone) of the given start message until the traversal stops due to no more messages passing the given condition. It is unsorted BFS because the children are not ordered in the database.

type Consumer

type Consumer func(cachedMetadata *storage.CachedMetadata) error

Consumer consumes the given message metadata during traversal.

type OnMissingParent added in v1.0.0

type OnMissingParent func(parentMessageID hornet.MessageID) error

OnMissingParent gets called when during traversal a parent is missing.

type OnSolidEntryPoint added in v0.4.1

type OnSolidEntryPoint func(messageID hornet.MessageID)

OnSolidEntryPoint gets called when during traversal the startMsg or parent is a solid entry point.

type ParentTraverser added in v1.0.0

type ParentTraverser struct {
	// contains filtered or unexported fields
}

func NewParentTraverser added in v1.0.0

func NewParentTraverser(dbStorage *storage.Storage, metadataMemcache ...*storage.MetadataMemcache) *ParentTraverser

NewParentTraverser create a new traverser to traverse the parents (past cone)

func (*ParentTraverser) Cleanup added in v1.0.0

func (t *ParentTraverser) Cleanup(forceRelease bool)

Cleanup releases all the cached objects that have been traversed. This MUST be called by the user at the end.

func (*ParentTraverser) Traverse added in v1.0.0

func (t *ParentTraverser) Traverse(ctx context.Context, parents hornet.MessageIDs, condition Predicate, consumer Consumer, onMissingParent OnMissingParent, onSolidEntryPoint OnSolidEntryPoint, traverseSolidEntryPoints bool) error

Traverse starts to traverse the parents (past cone) in the given order until the traversal stops due to no more messages passing the given condition. It is a DFS of the paths of the parents one after another. Caution: condition func is not in DFS order

type Predicate

type Predicate func(cachedMetadata *storage.CachedMetadata) (bool, error)

Predicate defines whether a traversal should continue or not.

Jump to

Keyboard shortcuts

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