dagprocessor

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2023 License: MIT Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBusy = errors.New("failed to acquire events semaphore")
)

Functions

This section is empty.

Types

type Callback

type Callback struct {
	Event EventCallback
	// PeerMisbehaviour is a callback type for dropping a peer detected as malicious.
	PeerMisbehaviour func(peer string, err error) bool
	HighestLamport   func() idx.Lamport
}

type Config

type Config struct {
	EventsBufferLimit dag.Metric

	EventsSemaphoreTimeout time.Duration

	MaxUnorderedInsertions int
}

func DefaultConfig

func DefaultConfig(scale cachescale.Func) Config

func (Config) MaxTasks

func (c Config) MaxTasks() int

type EventCallback

type EventCallback struct {
	Process         func(e dag.Event) error
	Released        func(e dag.Event, peer string, err error)
	Get             func(hash.Event) dag.Event
	Exists          func(hash.Event) bool
	OnlyInterested  func(ids hash.Events) hash.Events
	CheckParents    func(e dag.Event, parents dag.Events) error
	CheckParentless func(tasks []queuedcheck.EventTask, checked func(res []queuedcheck.EventTask))
}

type Processor

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

Processor is responsible for processing incoming events

func New

func New(eventsSemaphore *datasemaphore.DataSemaphore, cfg Config, callback Callback) *Processor

New creates an event processor

func (*Processor) Clear

func (f *Processor) Clear()

Clear

func (*Processor) Enqueue

func (f *Processor) Enqueue(peer string, events dag.Events, ordered bool, notifyAnnounces func(hash.Events), done func()) error

func (*Processor) IsBuffered

func (f *Processor) IsBuffered(id hash.Event) bool

func (*Processor) Overloaded

func (f *Processor) Overloaded() bool

Overloaded returns true if too much events are being processed or requested

func (*Processor) Start

func (f *Processor) Start()

Start boots up the events processor.

func (*Processor) Stop

func (f *Processor) Stop()

Stop interrupts the processor, canceling all the pending operations. Stop waits until all the internal goroutines have finished.

func (*Processor) TasksCount

func (f *Processor) TasksCount() int

func (*Processor) TotalBuffered

func (f *Processor) TotalBuffered() dag.Metric

Jump to

Keyboard shortcuts

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