synchronization

package
v0.21.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 30, 2021 License: AGPL-3.0 Imports: 21 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	PollInterval time.Duration
	ScanInterval time.Duration
}

func DefaultConfig

func DefaultConfig() *Config

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

Engine is the synchronization engine, responsible for synchronizing chain state.

func New

func New(
	log zerolog.Logger,
	metrics module.EngineMetrics,
	net module.Network,
	me module.Local,
	blocks storage.Blocks,
	comp network.Engine,
	core module.SyncCore,
	finalizedHeader *FinalizedHeaderCache,
	participantsProvider identifier.IdentifierProvider,
	opts ...OptionFunc,
) (*Engine, error)

New creates a new main chain synchronization engine.

func (*Engine) Done

func (e *Engine) Done() <-chan struct{}

Done returns a done channel that is closed once the engine has fully stopped.

func (*Engine) Process

func (e *Engine) Process(channel network.Channel, originID flow.Identifier, event interface{}) error

Process processes the given event from the node with the given origin ID in a blocking manner. It returns the potential processing error when done.

func (*Engine) ProcessLocal

func (e *Engine) ProcessLocal(event interface{}) error

ProcessLocal processes an event originating on the local node.

func (*Engine) Ready

func (e *Engine) Ready() <-chan struct{}

Ready returns a ready channel that is closed once the engine has fully started.

func (*Engine) Submit

func (e *Engine) Submit(channel network.Channel, originID flow.Identifier, event interface{})

Submit submits the given event from the node with the given origin ID for processing in a non-blocking manner. It returns instantly and logs a potential processing error internally when done.

func (*Engine) SubmitLocal

func (e *Engine) SubmitLocal(event interface{})

SubmitLocal submits an event originating on the local node.

type FinalizedHeaderCache added in v0.21.0

type FinalizedHeaderCache struct {
	// contains filtered or unexported fields
}

FinalizedHeaderCache represents the cached value of the latest finalized header. It is used in Engine to access latest valid data.

func NewFinalizedHeaderCache added in v0.21.0

func NewFinalizedHeaderCache(log zerolog.Logger, state protocol.State, finalizationDistributor *pubsub.FinalizationDistributor) (*FinalizedHeaderCache, error)

NewFinalizedHeaderCache creates a new finalized header cache.

func (*FinalizedHeaderCache) Done added in v0.21.0

func (f *FinalizedHeaderCache) Done() <-chan struct{}

func (*FinalizedHeaderCache) Get added in v0.21.0

func (f *FinalizedHeaderCache) Get() *flow.Header

Get returns the last locally cached finalized header.

func (*FinalizedHeaderCache) Ready added in v0.21.0

func (f *FinalizedHeaderCache) Ready() <-chan struct{}

type OptionFunc

type OptionFunc func(*Config)

func WithPollInterval

func WithPollInterval(interval time.Duration) OptionFunc

WithPollInterval sets a custom interval at which we scan for poll items

func WithScanInterval

func WithScanInterval(interval time.Duration) OptionFunc

WithScanInterval sets a custom interval at which we scan for pending items and batch them for requesting.

type RequestHandlerEngine added in v0.21.0

type RequestHandlerEngine struct {
	// contains filtered or unexported fields
}

func NewRequestHandlerEngine added in v0.21.0

func NewRequestHandlerEngine(
	log zerolog.Logger,
	metrics module.EngineMetrics,
	con network.Conduit,
	me module.Local,
	blocks storage.Blocks,
	core module.SyncCore,
	finalizedHeader *FinalizedHeaderCache,
	queueMissingHeights bool,
) *RequestHandlerEngine

func (*RequestHandlerEngine) Done added in v0.21.0

func (r *RequestHandlerEngine) Done() <-chan struct{}

Done returns a done channel that is closed once the engine has fully stopped.

func (*RequestHandlerEngine) Process added in v0.21.0

func (r *RequestHandlerEngine) Process(channel network.Channel, originID flow.Identifier, event interface{}) error

Process processes the given event from the node with the given origin ID in a blocking manner. It returns the potential processing error when done.

func (*RequestHandlerEngine) ProcessLocal added in v0.21.0

func (r *RequestHandlerEngine) ProcessLocal(event interface{}) error

ProcessLocal processes an event originating on the local node.

func (*RequestHandlerEngine) Ready added in v0.21.0

func (r *RequestHandlerEngine) Ready() <-chan struct{}

Ready returns a ready channel that is closed once the engine has fully started.

func (*RequestHandlerEngine) Submit added in v0.21.0

func (r *RequestHandlerEngine) Submit(channel network.Channel, originID flow.Identifier, event interface{})

Submit submits the given event from the node with the given origin ID for processing in a non-blocking manner. It returns instantly and logs a potential processing error internally when done.

func (*RequestHandlerEngine) SubmitLocal added in v0.21.0

func (r *RequestHandlerEngine) SubmitLocal(event interface{})

SubmitLocal submits an event originating on the local node.

type RequestHeap added in v0.19.0

type RequestHeap struct {
	// contains filtered or unexported fields
}

RequestHeap is a special structure that implements engine.MessageStore interface and indexes requests by originator. If request will be sent by same originator then it will replace the old one. Comparing to default FIFO queue this one can contain MAX one request for origin ID. Getting value from queue as well as ejecting is pseudo-random.

func NewRequestHeap added in v0.19.0

func NewRequestHeap(limit uint) *RequestHeap

func (*RequestHeap) Get added in v0.19.0

func (q *RequestHeap) Get() (*engine.Message, bool)

Get returns pseudo-random element from request storage using go map properties.

func (*RequestHeap) Put added in v0.19.0

func (q *RequestHeap) Put(message *engine.Message) bool

Put stores message into requests map using OriginID as key. Returns always true

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL