Documentation ¶
Index ¶
- type BranchSeq
- type HighestBeforeSeq
- func (self *HighestBeforeSeq) CollectFrom(_other vecengine.HighestBeforeI, num idx.Validator)
- func (self *HighestBeforeSeq) GatherFrom(to idx.Validator, _other vecengine.HighestBeforeI, from []idx.Validator)
- func (b HighestBeforeSeq) Get(i idx.Validator) BranchSeq
- func (b *HighestBeforeSeq) InitWithEvent(i idx.Validator, e dag.Event)
- func (b *HighestBeforeSeq) IsEmpty(i idx.Validator) bool
- func (b *HighestBeforeSeq) IsForkDetected(i idx.Validator) bool
- func (b *HighestBeforeSeq) MinSeq(i idx.Validator) idx.Event
- func (b *HighestBeforeSeq) Seq(i idx.Validator) idx.Event
- func (b *HighestBeforeSeq) Set(i idx.Validator, seq BranchSeq)
- func (b *HighestBeforeSeq) SetForkDetected(i idx.Validator)
- func (b HighestBeforeSeq) Size() int
- type Index
- func (vi *Index) ForklessCause(aID, bID hash.Event) bool
- func (vi *Index) GetEngineCallbacks() vecengine.Callbacks
- func (vi *Index) GetHighestBefore(id hash.Event) *HighestBeforeSeq
- func (vi *Index) GetLowestAfter(id hash.Event) *LowestAfterSeq
- func (vi *Index) GetMergedHighestBefore(id hash.Event) *HighestBeforeSeq
- func (vi *Index) Reset(validators *pos.Validators, db kvdb.Store, getEvent func(hash.Event) dag.Event)
- func (vi *Index) SetHighestBefore(id hash.Event, seq *HighestBeforeSeq)
- func (vi *Index) SetLowestAfter(id hash.Event, seq *LowestAfterSeq)
- type IndexCacheConfig
- type IndexConfig
- type LowestAfterSeq
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BranchSeq ¶
BranchSeq encodes Seq and MinSeq into 8 bytes
func (BranchSeq) IsForkDetected ¶
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 ¶
func (b HighestBeforeSeq) Get(i idx.Validator) BranchSeq
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) IsForkDetected ¶
func (b *HighestBeforeSeq) IsForkDetected(i idx.Validator) bool
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)
type Index ¶
Engine 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 ¶
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 (*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
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 ¶
func (b LowestAfterSeq) Get(i idx.Validator) idx.Event
Get i's position in the byte-encoded vector clock
func (*LowestAfterSeq) InitWithEvent ¶
func (b *LowestAfterSeq) InitWithEvent(i idx.Validator, e dag.Event)