Documentation ¶
Index ¶
- Variables
- type Checkpoint
- type EpochState
- type Event
- type EventSource
- type Events
- type FrameInfo
- type GenesisMismatchError
- type GenesisState
- type Poset
- func (p *Poset) Bootstrap(callback inter.ConsensusCallbacks)
- func (p *Poset) GetConsensusTime(id hash.Event) (inter.Timestamp, error)
- func (p *Poset) GetEpoch() idx.Epoch
- func (p *Poset) GetEpochValidators() (*pos.Validators, idx.Epoch)
- func (p *Poset) GetEvent(h hash.Event) *Event
- func (p *Poset) GetEventHeader(epoch idx.Epoch, h hash.Event) *inter.EventHeaderData
- func (p *Poset) GetGenesisHash() common.Hash
- func (p *Poset) GetValidators() *pos.Validators
- func (p *Poset) GetVectorIndex() *vector.Index
- func (p *Poset) LastBlock() (idx.Block, hash.Event)
- func (p *Poset) Prepare(e *inter.Event) *inter.Event
- func (p *Poset) ProcessEvent(e *inter.Event) (err error)
- type Store
- func (s *Store) AddRoot(root *inter.Event)
- func (s *Store) ApplyGenesis(g *genesis.Genesis, genesisAtropos hash.Event, appHash common.Hash) error
- func (s *Store) Close()
- func (s *Store) GetCheckpoint() *Checkpoint
- func (s *Store) GetEpoch() *EpochState
- func (s *Store) GetEventConfirmedOn(e hash.Event) idx.Frame
- func (s *Store) GetFrameInfo(e idx.Epoch, f idx.Frame) *FrameInfo
- func (s *Store) GetFrameRoots(f idx.Frame) []election.RootAndSlot
- func (s *Store) GetGenesis() *EpochState
- func (s *Store) GetGenesisHash() common.Hash
- func (s *Store) RecreateEpochDb(n idx.Epoch)
- func (s *Store) SetCheckpoint(cp *Checkpoint)
- func (s *Store) SetEpoch(e *EpochState)
- func (s *Store) SetEventConfirmedOn(e hash.Event, on idx.Frame)
- func (s *Store) SetFrameInfo(e idx.Epoch, f idx.Frame, info *FrameInfo)
- func (s *Store) SetGenesis(e *EpochState)
- type StoreConfig
Constants ¶
This section is empty.
Variables ¶
var ( ErrWrongEpochHash = errors.New("mismatched prev epoch hash") ErrNonZeroEpochHash = errors.New("prev epoch hash isn't zero for non-first event") ErrCheatersObserved = errors.New("Cheaters observed by self-parent aren't allowed as parents") ErrWrongFrame = errors.New("Claimed frame mismatched with calculated") ErrWrongIsRoot = errors.New("Claimed isRoot mismatched with calculated") ErrWrongMedianTime = errors.New("Claimed medianTime mismatched with calculated") )
Functions ¶
This section is empty.
Types ¶
type Checkpoint ¶
type Checkpoint struct { // fields can change only after a frame is decided LastDecidedFrame idx.Frame LastBlockN idx.Block LastAtropos hash.Event AppHash common.Hash }
Checkpoint is for persistent storing.
type EpochState ¶
type EpochState struct { // stored values // these values change only after a change of epoch EpochN idx.Epoch PrevEpoch GenesisState Validators *pos.Validators }
type EventSource ¶
type EventSource interface { HasEvent(hash.Event) bool GetEvent(hash.Event) *inter.Event GetEventHeader(idx.Epoch, hash.Event) *inter.EventHeaderData }
EventSource is a callback for getting events from an external storage.
type Events ¶
type Events []*Event
Events is a ordered slice of events.
type FrameInfo ¶
type FrameInfo struct { TimeOffset int64 // may be negative TimeRatio inter.Timestamp LastConsensusTime inter.Timestamp }
FrameInfo stores persistent data, associated with a frame
func (*FrameInfo) CalcConsensusTime ¶
CalcConsensusTime calcs consensus timestamp, using frame's time offset/ratio
type GenesisMismatchError ¶
GenesisMismatchError is raised when trying to overwrite an existing genesis block with an incompatible one.
func (*GenesisMismatchError) Error ¶
func (e *GenesisMismatchError) Error() string
Error implements error interface.
type GenesisState ¶
type GenesisState struct { Epoch idx.Epoch Time inter.Timestamp // consensus time of the last Atropos LastAtropos hash.Event AppHash common.Hash }
GenesisState stores state of previous Epoch
func (*GenesisState) EpochName ¶
func (g *GenesisState) EpochName() string
func (*GenesisState) Hash ¶
func (g *GenesisState) Hash() common.Hash
type Poset ¶
type Poset struct { *Checkpoint EpochState logger.Instance // contains filtered or unexported fields }
Poset processes events to get consensus.
func New ¶
func New(dag lachesis.DagConfig, store *Store, input EventSource) *Poset
New creates Poset instance. It does not start any process.
func (*Poset) Bootstrap ¶
func (p *Poset) Bootstrap(callback inter.ConsensusCallbacks)
Bootstrap restores poset's state from store.
func (*Poset) GetConsensusTime ¶
GetConsensusTime calc consensus timestamp for given event, if event is confirmed.
func (*Poset) GetEpochValidators ¶
func (p *Poset) GetEpochValidators() (*pos.Validators, idx.Epoch)
GetEpochValidators returns validators of current epoch, and the epoch. Don't mutate validators.
func (*Poset) GetEventHeader ¶
GetEventHeader returns event header.
func (*Poset) GetGenesisHash ¶
GetGenesisHash returns PrevEpochHash of first epoch.
func (*Poset) GetValidators ¶
func (p *Poset) GetValidators() *pos.Validators
GetValidators returns validators of current epoch. Don't mutate validators.
func (*Poset) GetVectorIndex ¶
GetVectorIndex returns vector clock.
type Store ¶
Store is a poset persistent storage working over parent key-value database.
func NewMemStore ¶
func NewMemStore() *Store
NewMemStore creates store over memory map. Store is always blank.
func NewStore ¶
func NewStore(dbs *flushable.SyncedPool, cfg StoreConfig) *Store
NewStore creates store over key-value db.
func (*Store) AddRoot ¶
AddRoot stores the new root Not safe for concurrent use due to complex mutable cache!
func (*Store) ApplyGenesis ¶
func (s *Store) ApplyGenesis(g *genesis.Genesis, genesisAtropos hash.Event, appHash common.Hash) error
ApplyGenesis writes initial state.
func (*Store) GetCheckpoint ¶
func (s *Store) GetCheckpoint() *Checkpoint
GetCheckpoint returns stored Checkpoint. State is seldom read; so no cache.
func (*Store) GetEventConfirmedOn ¶
GetEventConfirmedOn returns confirmed event hash.
func (*Store) GetFrameInfo ¶
GetFrameInfo returns stored frame.
func (*Store) GetFrameRoots ¶
func (s *Store) GetFrameRoots(f idx.Frame) []election.RootAndSlot
GetFrameRoots returns all the roots in the specified frame Not safe for concurrent use due to complex mutable cache!
func (*Store) GetGenesis ¶
func (s *Store) GetGenesis() *EpochState
GetGenesis returns stored first epoch.
func (*Store) GetGenesisHash ¶
GetGenesisHash returns PrevEpochHash of first epoch.
func (*Store) RecreateEpochDb ¶
RecreateEpochDb makes new epoch DB and drops prev.
func (*Store) SetCheckpoint ¶
func (s *Store) SetCheckpoint(cp *Checkpoint)
SetCheckpoint save Checkpoint. Checkpoint is seldom read; so no cache.
func (*Store) SetEventConfirmedOn ¶
SetEventConfirmedOn stores confirmed event hash.
func (*Store) SetFrameInfo ¶
SetFrameInfo stores event.
type StoreConfig ¶
type StoreConfig struct { // Cache size for Roots. Roots int }
StoreConfig is a config for store db.