vecengine

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BranchesInfo

type BranchesInfo struct {
	BranchIDLastSeq     []idx.Event       // branchID -> highest e.Seq in the branch
	BranchIDCreatorIdxs []idx.Validator   // branchID -> validator idx
	BranchIDByCreators  [][]idx.Validator // validator idx -> list of branch IDs
}

BranchesInfo contains information about global branches of each validator

type Callbacks

type Callbacks struct {
	GetHighestBefore func(hash.Event) HighestBeforeI
	GetLowestAfter   func(hash.Event) LowestAfterI
	SetHighestBefore func(hash.Event, HighestBeforeI)
	SetLowestAfter   func(hash.Event, LowestAfterI)
	NewHighestBefore func(idx.Validator) HighestBeforeI
	NewLowestAfter   func(idx.Validator) LowestAfterI
	OnDbReset        func(db kvdb.Store)
	OnDropNotFlushed func()
}

type Engine

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

func NewIndex

func NewIndex(crit func(error), callbacks Callbacks) *Engine

NewIndex creates Engine instance.

func (*Engine) Add

func (vi *Engine) Add(e dag.Event) error

Add calculates vector clocks for the event and saves into DB.

func (*Engine) AtLeastOneFork

func (vi *Engine) AtLeastOneFork() bool

func (*Engine) BranchesInfo

func (vi *Engine) BranchesInfo() *BranchesInfo

func (*Engine) DfsSubgraph

func (vi *Engine) DfsSubgraph(head dag.Event, walk func(hash.Event) (godeeper bool)) error

DfsSubgraph iterates all the event which are observed by head, and accepted by a filter Excluding head filter MAY BE called twice for the same event.

func (*Engine) DropNotFlushed

func (vi *Engine) DropNotFlushed()

DropNotFlushed not connected clocks. Call it if event has failed.

func (*Engine) Flush

func (vi *Engine) Flush()

Flush writes vector clocks to persistent store.

func (*Engine) GetEventBranchID

func (vi *Engine) GetEventBranchID(id hash.Event) idx.Validator

GetEventBranchID reads the event's global branch ID

func (*Engine) GetMergedHighestBefore

func (vi *Engine) GetMergedHighestBefore(id hash.Event) HighestBeforeI

func (*Engine) InitBranchesInfo

func (vi *Engine) InitBranchesInfo()

InitBranchesInfo loads BranchesInfo from store

func (*Engine) Reset

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

Reset resets buffers.

func (*Engine) SetEventBranchID

func (vi *Engine) SetEventBranchID(id hash.Event, branchID idx.Validator)

SetEventBranchID stores the event's global branch ID

type HighestBeforeI

type HighestBeforeI interface {
	InitWithEvent(i idx.Validator, e dag.Event)
	IsEmpty(i idx.Validator) bool
	IsForkDetected(i idx.Validator) bool
	Seq(i idx.Validator) idx.Event
	MinSeq(i idx.Validator) idx.Event
	SetForkDetected(i idx.Validator)
	CollectFrom(other HighestBeforeI, branches idx.Validator)
	GatherFrom(to idx.Validator, other HighestBeforeI, from []idx.Validator)
}

type LowestAfterI

type LowestAfterI interface {
	InitWithEvent(i idx.Validator, e dag.Event)
	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