ancestor

package
v0.0.0-...-59e56fa Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindBestParents

func FindBestParents(max int, options hash.Events, selfParent *hash.Event, strategy SearchStrategy) (*hash.Event, hash.Events)

FindBestParents returns estimated parents subset, according to provided strategy max is max num of parents to link with (including self-parent) returns set of parents to link, len(res) <= max

Types

type CasualityStrategy

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

CasualityStrategy uses vector clock to check which parents observe "more" than others The strategy uses "observing more" as a search criteria

func NewCasualityStrategy

func NewCasualityStrategy(vecClock *vector.Index, validators *pos.Validators) *CasualityStrategy

NewCasualityStrategy creates new CasualityStrategy with provided vector clock

func (*CasualityStrategy) Find

func (st *CasualityStrategy) Find(options hash.Events) hash.Event

Find chooses the hash from the specified options

func (*CasualityStrategy) Init

func (st *CasualityStrategy) Init(selfParent *hash.Event)

Init must be called before using the strategy

type RandomStrategy

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

RandomStrategy is used in tests, when vector clock isn't available

func NewRandomStrategy

func NewRandomStrategy(r *rand.Rand) *RandomStrategy

func (*RandomStrategy) Find

func (st *RandomStrategy) Find(heads hash.Events) hash.Event

Find chooses the hash from the specified options

func (*RandomStrategy) Init

func (st *RandomStrategy) Init(myLast *hash.Event)

type SearchStrategy

type SearchStrategy interface {
	// Init must be called before using the strategy
	Init(selfParent *hash.Event)
	// Find chooses the hash from the specified options
	Find(options hash.Events) hash.Event
}

SearchStrategy defines a criteria used to estimate the "best" subset of parents to emit event with.

Jump to

Keyboard shortcuts

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