vecfc

package
v0.0.0-...-e884aa9 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BranchSeq

type BranchSeq struct {
	Seq    idx.Event
	MinSeq idx.Event
}

BranchSeq encodes Seq and MinSeq into 8 bytes

func (BranchSeq) IsForkDetected

func (seq BranchSeq) IsForkDetected() bool

IsForkDetected returns true if observed fork by a creator (in combination of branches)

type HighestBeforeSeq

type HighestBeforeSeq []byte

HighestBeforeSeq is a vector of highest events (their Seq + IsForkDetected) which are observed by source event

func NewHighestBeforeSeq

func NewHighestBeforeSeq(size idx.Validator) *HighestBeforeSeq

NewHighestBeforeSeq creates new HighestBeforeSeq vector.

func (*HighestBeforeSeq) CollectFrom

func (self *HighestBeforeSeq) CollectFrom(_other vecengine.HighestBeforeI, num idx.Validator)

func (*HighestBeforeSeq) GatherFrom

func (self *HighestBeforeSeq) GatherFrom(to idx.Validator, _other vecengine.HighestBeforeI, from []idx.Validator)

func (HighestBeforeSeq) Get

Get i's position in the byte-encoded vector clock

func (*HighestBeforeSeq) InitWithEvent

func (b *HighestBeforeSeq) InitWithEvent(i idx.Validator, e dag.Event)

func (*HighestBeforeSeq) IsEmpty

func (b *HighestBeforeSeq) IsEmpty(i idx.Validator) bool

func (*HighestBeforeSeq) IsForkDetected

func (b *HighestBeforeSeq) IsForkDetected(i idx.Validator) bool

func (*HighestBeforeSeq) MinSeq

func (b *HighestBeforeSeq) MinSeq(i idx.Validator) idx.Event

func (*HighestBeforeSeq) Seq

func (*HighestBeforeSeq) Set

func (b *HighestBeforeSeq) Set(i idx.Validator, seq BranchSeq)

Set i's position in the byte-encoded vector clock

func (*HighestBeforeSeq) SetForkDetected

func (b *HighestBeforeSeq) SetForkDetected(i idx.Validator)

func (HighestBeforeSeq) Size

func (b HighestBeforeSeq) Size() int

Size of the vector clock

type Index

type Index struct {
	*vecengine.Engine
	// contains filtered or unexported fields
}

Index is a data to detect forkless-cause condition, calculate median timestamp, detect forks.

func NewIndex

func NewIndex(crit func(error), config IndexConfig) *Index

NewIndex creates Index instance.

func NewIndexWithEngine

func NewIndexWithEngine(crit func(error), config IndexConfig, engine *vecengine.Engine) *Index

func (*Index) ForklessCause

func (vi *Index) ForklessCause(aID, bID hash.Event) bool

ForklessCause calculates "sufficient coherence" between the events. The A.HighestBefore array remembers the sequence number of the last event by each validator that is an ancestor of A. The array for B.LowestAfter remembers the sequence number of the earliest event by each validator that is a descendant of B. Compare the two arrays, and find how many elements in the A.HighestBefore array are greater than or equal to the corresponding element of the B.LowestAfter array. If there are more than 2n/3 such matches, then the A and B have achieved sufficient coherency.

If B1 and B2 are forks, then they cannot BOTH forkless-cause any specific event A, unless more than 1/3W are Byzantine. This great property is the reason why this function exists, providing the base for the BFT algorithm.

func (*Index) GetEngineCallbacks

func (vi *Index) GetEngineCallbacks() vecengine.Callbacks

func (*Index) GetHighestBefore

func (vi *Index) GetHighestBefore(id hash.Event) *HighestBeforeSeq

GetHighestBefore reads the vector from DB

func (*Index) GetLowestAfter

func (vi *Index) GetLowestAfter(id hash.Event) *LowestAfterSeq

GetLowestAfter reads the vector from DB

func (*Index) GetMergedHighestBefore

func (vi *Index) GetMergedHighestBefore(id hash.Event) *HighestBeforeSeq

GetMergedHighestBefore returns HighestBefore vector clock without branches, where branches are merged into one

func (*Index) Reset

func (vi *Index) Reset(validators *pos.Validators, db kvdb.Store, getEvent func(hash.Event) dag.Event)

Reset resets buffers.

func (*Index) SetHighestBefore

func (vi *Index) SetHighestBefore(id hash.Event, seq *HighestBeforeSeq)

SetHighestBefore stores the vectors into DB

func (*Index) SetLowestAfter

func (vi *Index) SetLowestAfter(id hash.Event, seq *LowestAfterSeq)

SetLowestAfter stores the vector into DB

type IndexCacheConfig

type IndexCacheConfig struct {
	ForklessCausePairs   int
	HighestBeforeSeqSize uint
	LowestAfterSeqSize   uint
}

IndexCacheConfig - config for cache sizes of Engine

type IndexConfig

type IndexConfig struct {
	Caches IndexCacheConfig
}

IndexConfig - Engine config (cache sizes)

func DefaultConfig

func DefaultConfig(scale cachescale.Func) IndexConfig

DefaultConfig returns default index config

func LiteConfig

func LiteConfig() IndexConfig

LiteConfig returns default index config for tests

type LowestAfterSeq

type LowestAfterSeq []byte

LowestAfterSeq is a vector of lowest events (their Seq) which do observe the source event

func NewLowestAfterSeq

func NewLowestAfterSeq(size idx.Validator) *LowestAfterSeq

NewLowestAfterSeq creates new LowestAfterSeq vector.

func (LowestAfterSeq) Get

Get i's position in the byte-encoded vector clock

func (*LowestAfterSeq) InitWithEvent

func (b *LowestAfterSeq) InitWithEvent(i idx.Validator, e dag.Event)

func (*LowestAfterSeq) Set

func (b *LowestAfterSeq) Set(i idx.Validator, seq idx.Event)

Set i's position in the byte-encoded vector clock

func (LowestAfterSeq) Size

func (b LowestAfterSeq) Size() idx.Validator

Size of the vector clock

func (*LowestAfterSeq) Visit

func (b *LowestAfterSeq) Visit(i idx.Validator, e dag.Event) bool

Jump to

Keyboard shortcuts

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