Documentation ¶
Index ¶
- func GetStartingRound(eventBroker wire.EventBroker, db database.DB, keys user.Keys) error
- func InitAcceptedBlockUpdate(subscriber wire.EventSubscriber) (chan block.Block, *wire.TopicListener)
- func InitBidListUpdate(subscriber wire.EventSubscriber) chan user.Bid
- func InitBlockRegenerationCollector(subscriber wire.EventSubscriber) chan AsyncState
- func InitRoundUpdate(subscriber wire.EventSubscriber) <-chan uint64
- func LaunchNotification(eventbus wire.EventSubscriber, deserializer wire.EventDeserializer, ...) <-chan wire.Event
- func UpdateRound(bus wire.EventPublisher, round uint64)
- type Accumulator
- type AccumulatorHandler
- type AccumulatorStore
- func (sec *AccumulatorStore) All() []wire.Event
- func (sec *AccumulatorStore) Clear()
- func (sec *AccumulatorStore) Contains(event wire.Event, identifier string) bool
- func (sec *AccumulatorStore) Get(identifier string) []wire.Event
- func (sec *AccumulatorStore) Insert(event wire.Event, identifier string) int
- type AsyncState
- type EventFilter
- type EventHandler
- type EventQueue
- type Republisher
- type State
- type StepSubscriber
- type SyncState
- type Threshold
- type Timer
- type Validator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetStartingRound ¶
func InitAcceptedBlockUpdate ¶
func InitAcceptedBlockUpdate(subscriber wire.EventSubscriber) (chan block.Block, *wire.TopicListener)
InitAcceptedBlockUpdate init listener to get updates about lastly accepted block in the chain
func InitBidListUpdate ¶
func InitBidListUpdate(subscriber wire.EventSubscriber) chan user.Bid
InitBidListUpdate creates and initiates a channel for the updates in the BidList
func InitBlockRegenerationCollector ¶
func InitBlockRegenerationCollector(subscriber wire.EventSubscriber) chan AsyncState
InitBlockRegenerationCollector initializes a regeneration channel, creates a regenerationCollector, and subscribes this collector to the BlockRegenerationTopic. The channel is then returned.
func InitRoundUpdate ¶
func InitRoundUpdate(subscriber wire.EventSubscriber) <-chan uint64
InitRoundUpdate initializes a Round update channel and fires up the TopicListener as well. Its purpose is to lighten up a bit the amount of arguments in creating the handler for the collectors. Also it removes the need to store subscribers on the consensus process
func LaunchNotification ¶
func LaunchNotification(eventbus wire.EventSubscriber, deserializer wire.EventDeserializer, topic string) <-chan wire.Event
func UpdateRound ¶
func UpdateRound(bus wire.EventPublisher, round uint64)
UpdateRound is a shortcut for propagating a round
Types ¶
type Accumulator ¶
type Accumulator struct { WorkerTimeOut time.Duration wire.Store CollectedVotesChan chan []wire.Event // contains filtered or unexported fields }
Accumulator is a generic event accumulator, that will accumulate events until it reaches a certain threshold.
func NewAccumulator ¶
func NewAccumulator(handler AccumulatorHandler, store wire.Store, state State, checkStep bool) *Accumulator
NewAccumulator initializes a worker pool, starts up an Accumulator and returns it.
func (*Accumulator) Accumulate ¶
func (a *Accumulator) Accumulate()
func (*Accumulator) CreateWorkers ¶
func (a *Accumulator) CreateWorkers()
func (*Accumulator) Process ¶
func (a *Accumulator) Process(ev wire.Event)
Process a received Event, by passing it to a worker in the worker pool (if the event sender is part of the voting committee).
type AccumulatorHandler ¶
type AccumulatorHandler interface { EventHandler committee.Committee ExtractIdentifier(wire.Event, *bytes.Buffer) error }
AccumulatorHandler is a generic event handler with some added functionality, that is specific to the accumulator.
type AccumulatorStore ¶
type AccumulatorStore struct {
// contains filtered or unexported fields
}
AccumulatorStore is a helper struct for common operations on stored Event Arrays AccumulatorStore is an helper for common operations on stored Event Arrays
func NewAccumulatorStore ¶
func NewAccumulatorStore() *AccumulatorStore
NewAccumulatorStore returns an initialized AccumulatorStore.
func (*AccumulatorStore) All ¶
func (sec *AccumulatorStore) All() []wire.Event
All returns all of the Events currently in the AccumulatorStore.
func (*AccumulatorStore) Clear ¶
func (sec *AccumulatorStore) Clear()
Clear up the AccumulatorStore.
func (*AccumulatorStore) Contains ¶
func (sec *AccumulatorStore) Contains(event wire.Event, identifier string) bool
Contains checks if we already collected this event
func (*AccumulatorStore) Get ¶
func (sec *AccumulatorStore) Get(identifier string) []wire.Event
Get a set of Events, stored under a specified identifier.
func (*AccumulatorStore) Insert ¶
func (sec *AccumulatorStore) Insert(event wire.Event, identifier string) int
Insert the Event keeping track of the identifier (step, block hash, voted hash) it belongs to. It silently ignores duplicates (meaning it does not store an event in case it is already found at the identifier specified). It returns the number of events stored at specified identifier *after* the store operation
type AsyncState ¶
AsyncState is a representation of the consensus state at any given point in time. Can be used to 'date' messages that are passed between consensus components.
type EventFilter ¶
type EventFilter struct { Accumulator *Accumulator // contains filtered or unexported fields }
EventFilter is a generic wire.Collector that can be used by consensus components for filtering and passing down messages. It coordinates an EventQueue to manage Events coming too early and delegates consensus specific logic to the handler.
func NewEventFilter ¶
func NewEventFilter(handler AccumulatorHandler, state State, checkStep bool) *EventFilter
NewEventFilter returns an initialized EventFilter.
func (*EventFilter) Collect ¶
func (ef *EventFilter) Collect(buffer *bytes.Buffer) error
Collect an event buffer, deserialize it, and then pass it to the proper component.
func (*EventFilter) FlushQueue ¶
func (ef *EventFilter) FlushQueue()
FlushQueue will retrieve all queued events for a certain point in consensus, and hand them off to the Processor.
func (*EventFilter) ResetAccumulator ¶
func (ef *EventFilter) ResetAccumulator()
func (*EventFilter) UpdateRound ¶
func (ef *EventFilter) UpdateRound(round uint64)
UpdateRound updates the state for the EventFilter, and empties the queue of obsolete events.
type EventHandler ¶
type EventHandler interface { wire.EventVerifier wire.EventMarshaller wire.EventDeserializer ExtractHeader(wire.Event) *header.Header }
EventHandler encapsulates logic specific to the various EventFilters. Each EventFilter needs to verify, prioritize and extract information from Events. EventHandler is the interface that abstracts these operations away. The implementors of this interface is the real differentiator of the various consensus components
type EventQueue ¶
type EventQueue struct {
// contains filtered or unexported fields
}
EventQueue is a Queue of Events grouped by rounds and steps. It is threadsafe through a sync.RWMutex.
func NewEventQueue ¶
func NewEventQueue() *EventQueue
NewEventQueue creates a new EventQueue. It is primarily used by Collectors to temporarily store messages not yet relevant to the collection process.
func (*EventQueue) Flush ¶
func (eq *EventQueue) Flush(round uint64) []wire.Event
Flush all events stored for a specific round from the queue, and return them.
type Republisher ¶
type Republisher struct {
// contains filtered or unexported fields
}
Republisher is responsible for gossiping a received event buffer.
func NewRepublisher ¶
func NewRepublisher(publisher wire.EventPublisher, topic topics.Topic) *Republisher
NewRepublisher returns a Republisher containing the specified parameters.
type State ¶
type State interface { fmt.Stringer Round() uint64 Step() uint8 SubscribeStep() *StepSubscriber Update(uint64) IncrementStep() Cmp(round uint64, step uint8) (int, int) }
State comprises the methods to maintain a state of the consensus.
type StepSubscriber ¶
type StepSubscriber struct { StateChan chan struct{} // contains filtered or unexported fields }
StepSubscriber notifies its owner of a change in the state's step.
type SyncState ¶
SyncState is an implementation of State which can be shared by multiple processes. It also notifies subscribers of changes in the state's step.
func (*SyncState) Cmp ¶
Cmp returns negative number if the SyncState is in the future, 0 if they are the same and positive if the SyncState is in the past.
func (*SyncState) IncrementStep ¶
func (s *SyncState) IncrementStep()
IncrementStep increments the SyncState step by 1. It also notifies any subscribers of the state change.
func (*SyncState) SubscribeStep ¶
func (s *SyncState) SubscribeStep() *StepSubscriber
SubscribeStep returns a StepSubscriber which notifies its owner of a change in the state's step.
type Threshold ¶
type Threshold struct {
// contains filtered or unexported fields
}
Threshold is a number which proof scores should be compared against. If a proof score does not exceed the Threshold value, it should be discarded.
type Timer ¶
type Timer struct { TimeOutChan chan struct{} // contains filtered or unexported fields }
func (*Timer) IncreaseTimeOut ¶
func (t *Timer) IncreaseTimeOut()
func (*Timer) ResetTimeOut ¶
func (t *Timer) ResetTimeOut()