Documentation ¶
Index ¶
- Constants
- Variables
- type Config
- type DagIndex
- type DagIndexer
- type EpochDBProducer
- type EpochState
- type EventSource
- type Genesis
- type IndexedMugamboBFT
- type LastDecidedState
- type MugamboBFT
- type Orderer
- type OrdererCallbacks
- type OrdererDagIndex
- type Store
- func (s *Store) AddRoot(selfParentFrame idx.Frame, root dag.Event)
- func (s *Store) ApplyGenesis(g *Genesis) error
- func (s *Store) Close() error
- func (s *Store) GetEpoch() idx.Epoch
- func (s *Store) GetEpochState() *EpochState
- func (s *Store) GetEventConfirmedOn(e hash.Event) idx.Frame
- func (s *Store) GetFrameRoots(f idx.Frame) []election.RootAndSlot
- func (s *Store) GetLastDecidedFrame() idx.Frame
- func (s *Store) GetLastDecidedState() *LastDecidedState
- func (s *Store) GetValidators() *pos.Validators
- func (s *Store) SetEpochState(e *EpochState)
- func (s *Store) SetEventConfirmedOn(e hash.Event, on idx.Frame)
- func (s *Store) SetLastDecidedState(v *LastDecidedState)
- type StoreCacheConfig
- type StoreConfig
Constants ¶
const ( FirstFrame = idx.Frame(1) FirstEpoch = idx.Epoch(1) )
Variables ¶
var (
ErrNoGenesis = errors.New("genesis not applied")
)
var (
ErrWrongFrame = errors.New("claimed frame mismatched with calculated")
)
Functions ¶
This section is empty.
Types ¶
type DagIndex ¶
type DagIndex interface { dagidx.VectorClock dagidx.ForklessCause }
type DagIndexer ¶
type DagIndexer interface { dagidx.VectorClock dagidx.ForklessCause Add(dag.Event) error Flush() DropNotFlushed() Reset(validators *pos.Validators, db kvdb.Store, getEvent func(hash.Event) dag.Event) }
type EpochDBProducer ¶
type EpochDBProducer func(epoch idx.Epoch) kvdb.DropableStore
type EpochState ¶
type EpochState struct { // stored values // these values change only after a change of epoch Epoch idx.Epoch Validators *pos.Validators }
type EventSource ¶
EventSource is a callback for getting events from an external storage.
type Genesis ¶
type Genesis struct { Epoch idx.Epoch Validators *pos.Validators }
Genesis stores genesis state
type IndexedMugamboBFT ¶ added in v1.0.2
type IndexedMugamboBFT struct { *MugamboBFT // contains filtered or unexported fields }
IndexedMugamboBFT performs events ordering and detects cheaters It's a wrapper around Orderer, which adds features which might potentially be application-specific: confirmed events traversal, DAG index updates and cheaters detection. Use this structure if need a general-purpose consensus. Instead, use lower-level abft.Orderer.
func NewIndexedMugamboBFT ¶ added in v1.0.2
func NewIndexedMugamboBFT(store *Store, input EventSource, dagIndexer DagIndexer, crit func(error), config Config) *IndexedMugamboBFT
New creates IndexedMugamboBFT instance.
func (*IndexedMugamboBFT) Bootstrap ¶ added in v1.0.2
func (p *IndexedMugamboBFT) Bootstrap(callback mugambobft.ConsensusCallbacks) error
func (*IndexedMugamboBFT) Build ¶ added in v1.0.2
func (p *IndexedMugamboBFT) Build(e dag.MutableEvent) error
Build fills consensus-related fields: Frame, IsRoot returns error if event should be dropped
type LastDecidedState ¶
type LastDecidedState struct { // fields can change only after a frame is decided LastDecidedFrame idx.Frame }
LastDecidedState is for persistent storing.
type MugamboBFT ¶ added in v1.0.2
type MugamboBFT struct { *Orderer // contains filtered or unexported fields }
MugamboBFT performs events ordering and detects cheaters It's a wrapper around Orderer, which adds features which might potentially be application-specific: confirmed events traversal, cheaters detection. Use this structure if need a general-purpose consensus. Instead, use lower-level abft.Orderer.
func NewMugamboBFT ¶ added in v1.0.2
func NewMugamboBFT(store *Store, input EventSource, dagIndex DagIndex, crit func(error), config Config) *MugamboBFT
New creates MugamboBFT instance.
func (*MugamboBFT) Bootstrap ¶ added in v1.0.2
func (p *MugamboBFT) Bootstrap(callback mugambobft.ConsensusCallbacks) error
func (*MugamboBFT) BootstrapWithOrderer ¶ added in v1.0.2
func (p *MugamboBFT) BootstrapWithOrderer(callback mugambobft.ConsensusCallbacks, ordererCallbacks OrdererCallbacks) error
func (*MugamboBFT) OrdererCallbacks ¶ added in v1.0.2
func (p *MugamboBFT) OrdererCallbacks() OrdererCallbacks
type Orderer ¶
type Orderer struct {
// contains filtered or unexported fields
}
Unlike processes events to reach finality on their order. Unlike abft.MugamboBFT, this raw level of abstraction doesn't track cheaters detection
func NewOrderer ¶
func NewOrderer(store *Store, input EventSource, dagIndex OrdererDagIndex, crit func(error), config Config) *Orderer
New creates Orderer instance. Unlike MugamboBFT, Orderer doesn't updates DAG indexes for events, and doesn't detect cheaters It has only one purpose - reaching consensus on events order.
func (*Orderer) Bootstrap ¶
func (p *Orderer) Bootstrap(callback OrdererCallbacks) error
Bootstrap restores abft's state from store.
type OrdererCallbacks ¶
type OrdererDagIndex ¶
type OrdererDagIndex interface { dagidx.ForklessCause }
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is a abft 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(mainDB kvdb.Store, getDB EpochDBProducer, crit func(error), 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 the complex mutable cache!
func (*Store) ApplyGenesis ¶
ApplyGenesis writes initial state.
func (*Store) GetEpochState ¶
func (s *Store) GetEpochState() *EpochState
GetEpochState returns stored epoch.
func (*Store) GetEventConfirmedOn ¶
GetEventConfirmedOn returns confirmed event hash.
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 the complex mutable cache!
func (*Store) GetLastDecidedFrame ¶
func (*Store) GetLastDecidedState ¶
func (s *Store) GetLastDecidedState() *LastDecidedState
GetLastDecidedState returns stored LastDecidedState. State is seldom read; so no cache.
func (*Store) GetValidators ¶
func (s *Store) GetValidators() *pos.Validators
GetValidators returns current validators
func (*Store) SetEpochState ¶
func (s *Store) SetEpochState(e *EpochState)
SetEpochState stores epoch.
func (*Store) SetEventConfirmedOn ¶
SetEventConfirmedOn stores confirmed event hash.
func (*Store) SetLastDecidedState ¶
func (s *Store) SetLastDecidedState(v *LastDecidedState)
SetLastDecidedState save LastDecidedState. LastDecidedState is seldom read; so no cache.
type StoreCacheConfig ¶
StoreCacheConfig is a cache config for store db.
type StoreConfig ¶
type StoreConfig struct {
Cache StoreCacheConfig
}
StoreConfig is a config for store db.
func DefaultStoreConfig ¶
func DefaultStoreConfig(scale cachescale.Func) StoreConfig
DefaultStoreConfig for livenet.