Documentation ¶
Index ¶
- Variables
- type ConcurrentSyncer
- func (s *ConcurrentSyncer) Capacity() int
- func (s *ConcurrentSyncer) Queued() int
- func (s *ConcurrentSyncer) Run(logger *zap.Logger)
- func (s *ConcurrentSyncer) SyncDecidedByRange(ctx context.Context, logger *zap.Logger, id spectypes.MessageID, ...) error
- func (s *ConcurrentSyncer) SyncHighestDecided(ctx context.Context, logger *zap.Logger, id spectypes.MessageID, ...) error
- type Error
- type MessageHandler
- type Network
- type Operation
- type OperationSyncDecidedByRange
- type OperationSyncHighestDecided
- type Syncer
- type Timeouts
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type ConcurrentSyncer ¶
type ConcurrentSyncer struct {
// contains filtered or unexported fields
}
ConcurrentSyncer is a Syncer that runs the given Syncer's methods concurrently.
func NewConcurrent ¶
func NewConcurrent( ctx context.Context, syncer Syncer, concurrency int, timeouts Timeouts, errors chan<- Error, ) *ConcurrentSyncer
NewConcurrent returns a new Syncer that runs the given Syncer's methods concurrently. Unlike the standard syncer, syncing methods are non-blocking and return immediately without error. concurrency is the number of worker goroutines to spawn. errors is a channel to which any errors are sent. Pass nil to discard errors.
func (*ConcurrentSyncer) Capacity ¶
func (s *ConcurrentSyncer) Capacity() int
Capacity returns the maximum number of jobs that can be queued. When Queued() == Capacity(), then the next call will block until a job is finished.
func (*ConcurrentSyncer) Queued ¶
func (s *ConcurrentSyncer) Queued() int
Queued returns the number of jobs that are queued but not yet started.
func (*ConcurrentSyncer) Run ¶
func (s *ConcurrentSyncer) Run(logger *zap.Logger)
Run starts the worker goroutines and blocks until the context is done and any remaining jobs are finished.
func (*ConcurrentSyncer) SyncDecidedByRange ¶
func (*ConcurrentSyncer) SyncHighestDecided ¶
func (s *ConcurrentSyncer) SyncHighestDecided( ctx context.Context, logger *zap.Logger, id spectypes.MessageID, handler MessageHandler, ) error
type MessageHandler ¶
type MessageHandler func(msg spectypes.SSVMessage)
MessageHandler reacts to a message received from Syncer.
func Throttle ¶
func Throttle(handler MessageHandler, throttle time.Duration) MessageHandler
Throttle returns a MessageHandler that throttles the given handler.
type Network ¶
type Network interface { LastDecided(logger *zap.Logger, id spectypes.MessageID) ([]protocolp2p.SyncResult, error) GetHistory( logger *zap.Logger, id spectypes.MessageID, from, to specqbft.Height, targets ...string, ) ([]protocolp2p.SyncResult, specqbft.Height, error) }
Network is a subset of protocolp2p.Syncer, required by Syncer to retrieve messages from peers.
type Operation ¶
type Operation interface {
// contains filtered or unexported methods
}
Operation is a syncing operation that has been queued for execution.
type OperationSyncDecidedByRange ¶
type OperationSyncDecidedByRange struct { ID spectypes.MessageID From specqbft.Height To specqbft.Height Handler MessageHandler }
func (OperationSyncDecidedByRange) String ¶
func (o OperationSyncDecidedByRange) String() string
type OperationSyncHighestDecided ¶
type OperationSyncHighestDecided struct { ID spectypes.MessageID Handler MessageHandler }
func (OperationSyncHighestDecided) String ¶
func (o OperationSyncHighestDecided) String() string
type Syncer ¶
type Syncer interface { SyncHighestDecided(ctx context.Context, logger *zap.Logger, id spectypes.MessageID, handler MessageHandler) error SyncDecidedByRange( ctx context.Context, logger *zap.Logger, id spectypes.MessageID, from, to specqbft.Height, handler MessageHandler, ) error }
Syncer handles the syncing of decided messages.
type Timeouts ¶
type Timeouts struct { // SyncHighestDecided is the timeout for SyncHighestDecided. // Leave zero to not timeout. SyncHighestDecided time.Duration // SyncDecidedByRange is the timeout for SyncDecidedByRange. // Leave zero to not timeout. SyncDecidedByRange time.Duration }
Timeouts is a set of timeouts for each syncing operation.