fetcher

package
v1.0.0-rc.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2021 License: MIT Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Callback

type Callback struct {
	PushEvent      PushEventFn
	OnlyInterested FilterInterestedFn
	DropPeer       DropPeerFn

	HeavyCheck *heavycheck.Checker
	FirstCheck func(*inter.Event) error
}

type DropPeerFn

type DropPeerFn func(peer string)

DropPeerFn is a callback type for dropping a peer detected as malicious.

type EventsRequesterFn

type EventsRequesterFn func(hash.Events) error

EventsRequesterFn is a callback type for sending a event retrieval request.

type Fetcher

type Fetcher struct {
	logger.Periodic
	// contains filtered or unexported fields
}

Fetcher is responsible for accumulating event announcements from various peers and scheduling them for retrieval.

func New

func New(callback Callback) *Fetcher

New creates a event fetcher to retrieve events based on hash announcements.

func (*Fetcher) Enqueue

func (f *Fetcher) Enqueue(peer string, inEvents inter.Events, t time.Time, fetchEvents EventsRequesterFn) error

Enqueue tries to fill gaps the fetcher's future import queue.

func (*Fetcher) Notify

func (f *Fetcher) Notify(peer string, hashes hash.Events, time time.Time, fetchEvents EventsRequesterFn) error

Notify announces the fetcher of the potential availability of a new event in the network.

func (*Fetcher) Overloaded

func (f *Fetcher) Overloaded() bool

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

func (*Fetcher) OverloadedPeer

func (f *Fetcher) OverloadedPeer(peer string) bool

OverloadedPeer returns true if too much events are being processed or requested from the peer

func (*Fetcher) Start

func (f *Fetcher) Start()

Start boots up the announcement based synchroniser, accepting and processing hash notifications and event fetches until termination requested.

func (*Fetcher) Stop

func (f *Fetcher) Stop()

Stop terminates the announcement based synchroniser, canceling all pending operations.

type FilterInterestedFn

type FilterInterestedFn func(ids hash.Events) hash.Events

FilterInterestedFn returns only event which may be requested.

type PushEventFn

type PushEventFn func(e *inter.Event, peer string)

PushEventFn is a callback type to connect a received event

Jump to

Keyboard shortcuts

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