fetcher

package
v0.0.0-...-59e56fa Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2020 License: MIT Imports: 12 Imported by: 0

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 Checker
	FirstCheck func(*inter.Event) error
}

type Checker

type Checker interface {
	Start()
	Stop()
	Overloaded() bool
	Enqueue(events inter.Events, onValidated heavycheck.OnValidatedFn) error
}

Checker is an interface that represents abstract logic for a checker object

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(ch 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, t 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 MockChecker

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

MockChecker is a mock checker made for tests only

func NewMockChecker

func NewMockChecker(resultError error) *MockChecker

NewMockChecker is a constructor for a mock checker

func (*MockChecker) Enqueue

func (m *MockChecker) Enqueue(events inter.Events, onValidated heavycheck.OnValidatedFn) error

Enqueue made for tests only

func (*MockChecker) Overloaded

func (m *MockChecker) Overloaded() bool

Overloaded is an empty implementation

func (*MockChecker) Start

func (m *MockChecker) Start()

Start is an empty implementation

func (*MockChecker) Stop

func (m *MockChecker) Stop()

Stop is an empty implementation

type MockTestData

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

MockTestData is a mock Checker for a testing purposes

func NewMockTestData

func NewMockTestData(resultError error) *MockTestData

NewMockTestData is a constructor for a mock test data

func (*MockTestData) GetEvents

func (m *MockTestData) GetEvents() inter.Events

GetEvents is a getter for events

func (*MockTestData) GetOnValidatedFn

func (m *MockTestData) GetOnValidatedFn() heavycheck.OnValidatedFn

GetOnValidatedFn is a getter for onValidated callback

func (*MockTestData) GetResult

func (m *MockTestData) GetResult() []error

GetResult is a getter for result

type PushEventFn

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

PushEventFn is a callback type to connect a received event

type SyncChecker

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

SyncChecker calls checker.Enqueue synchronously for a testing purposes

func (*SyncChecker) Enqueue

func (s *SyncChecker) Enqueue(events inter.Events, onValidated heavycheck.OnValidatedFn) error

func (*SyncChecker) Overloaded

func (s *SyncChecker) Overloaded() bool

func (*SyncChecker) Start

func (s *SyncChecker) Start()

func (*SyncChecker) Stop

func (s *SyncChecker) Stop()

Jump to

Keyboard shortcuts

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