Skip to content
This repository has been archived by the owner on Dec 10, 2020. It is now read-only.

Latest commit

 

History

History
1985 lines (1085 loc) · 46.5 KB

_sync_fetcher_fetcher_.fetcher.md

File metadata and controls

1985 lines (1085 loc) · 46.5 KB

ethereumjs-client"sync/fetcher/fetcher"Fetcher

Class: Fetcher

Base class for fetchers that retrieve various data from peers. Subclasses must request() and process() methods. Tasks can be arbitrary objects whose structure is defined by subclasses. A priority queue is used to ensure tasks are fetched inorder.

memberof module:sync/fetcher

Hierarchy

Implements

  • ReadableStream

Index

Constructors

Properties

Methods

Constructors

constructor

+ new Fetcher(options: FetcherOptions): Fetcher

Overrides void

Defined in lib/sync/fetcher/fetcher.ts:51

Create new fetcher

Parameters:

Name Type
options FetcherOptions

Returns: Fetcher

Properties

config

config: Config

Defined in lib/sync/fetcher/fetcher.ts:37


destroyed

destroyed: boolean

Inherited from Fetcher.destroyed

Defined in node_modules/@types/node/stream.d.ts:35


readable

readable: boolean

Inherited from Fetcher.readable

Defined in node_modules/@types/node/stream.d.ts:28


readableEncoding

readableEncoding: BufferEncoding | null

Inherited from Fetcher.readableEncoding

Defined in node_modules/@types/node/stream.d.ts:29


readableEnded

readableEnded: boolean

Inherited from Fetcher.readableEnded

Defined in node_modules/@types/node/stream.d.ts:30


readableFlowing

readableFlowing: boolean | null

Inherited from Fetcher.readableFlowing

Defined in node_modules/@types/node/stream.d.ts:31


readableHighWaterMark

readableHighWaterMark: number

Inherited from Fetcher.readableHighWaterMark

Defined in node_modules/@types/node/stream.d.ts:32


readableLength

readableLength: number

Inherited from Fetcher.readableLength

Defined in node_modules/@types/node/stream.d.ts:33


readableObjectMode

readableObjectMode: boolean

Inherited from Fetcher.readableObjectMode

Defined in node_modules/@types/node/stream.d.ts:34

Methods

[Symbol.asyncIterator]

[Symbol.asyncIterator](): AsyncIterableIterator‹any›

Inherited from Fetcher.[Symbol.asyncIterator]

Defined in node_modules/@types/node/stream.d.ts:124

Returns: AsyncIterableIterator‹any›


_destroy

_destroy(error: Error | null, callback: function): void

Inherited from Fetcher._destroy

Defined in node_modules/@types/node/stream.d.ts:47

Parameters:

error: Error | null

callback: function

▸ (error?: Error | null): void

Parameters:

Name Type
error? Error | null

Returns: void


_read

_read(): void

Overrides void

Defined in lib/sync/fetcher/fetcher.ts:116

Implements Readable._read() by pushing completed tasks to the read queue

Returns: void


addListener

addListener(event: "close", listener: function): this

Inherited from Fetcher.addListener

Overrides Sender.addListener

Defined in node_modules/@types/node/stream.d.ts:61

Event emitter The defined events on documents including:

  1. close
  2. data
  3. end
  4. error
  5. pause
  6. readable
  7. resume

Parameters:

event: "close"

listener: function

▸ (): void

Returns: this

addListener(event: "data", listener: function): this

Inherited from Fetcher.addListener

Overrides Sender.addListener

Defined in node_modules/@types/node/stream.d.ts:62

Parameters:

event: "data"

listener: function

▸ (chunk: any): void

Parameters:

Name Type
chunk any

Returns: this

addListener(event: "end", listener: function): this

Inherited from Fetcher.addListener

Overrides Sender.addListener

Defined in node_modules/@types/node/stream.d.ts:63

Parameters:

event: "end"

listener: function

▸ (): void

Returns: this

addListener(event: "error", listener: function): this

Inherited from Fetcher.addListener

Overrides Sender.addListener

Defined in node_modules/@types/node/stream.d.ts:64

Parameters:

event: "error"

listener: function

▸ (err: Error): void

Parameters:

Name Type
err Error

Returns: this

addListener(event: "pause", listener: function): this

Inherited from Fetcher.addListener

Overrides Sender.addListener

Defined in node_modules/@types/node/stream.d.ts:65

Parameters:

event: "pause"

listener: function

▸ (): void

Returns: this

addListener(event: "readable", listener: function): this

Inherited from Fetcher.addListener

Overrides Sender.addListener

Defined in node_modules/@types/node/stream.d.ts:66

Parameters:

event: "readable"

listener: function

▸ (): void

Returns: this

addListener(event: "resume", listener: function): this

Inherited from Fetcher.addListener

Overrides Sender.addListener

Defined in node_modules/@types/node/stream.d.ts:67

Parameters:

event: "resume"

listener: function

▸ (): void

Returns: this

addListener(event: string | symbol, listener: function): this

Inherited from Fetcher.addListener

Overrides Sender.addListener

Defined in node_modules/@types/node/stream.d.ts:68

Parameters:

event: string | symbol

listener: function

▸ (...args: any[]): void

Parameters:

Name Type
...args any[]

Returns: this


dequeue

dequeue(): void

Defined in lib/sync/fetcher/fetcher.ts:102

Dequeue all done tasks that completed in order

Returns: void


destroy

destroy(error?: Error): void

Inherited from Fetcher.destroy

Defined in node_modules/@types/node/stream.d.ts:48

Parameters:

Name Type
error? Error

Returns: void


emit

emit(event: "close"): boolean

Inherited from Fetcher.emit

Overrides Sender.emit

Defined in node_modules/@types/node/stream.d.ts:70

Parameters:

Name Type
event "close"

Returns: boolean

emit(event: "data", chunk: any): boolean

Inherited from Fetcher.emit

Overrides Sender.emit

Defined in node_modules/@types/node/stream.d.ts:71

Parameters:

Name Type
event "data"
chunk any

Returns: boolean

emit(event: "end"): boolean

Inherited from Fetcher.emit

Overrides Sender.emit

Defined in node_modules/@types/node/stream.d.ts:72

Parameters:

Name Type
event "end"

Returns: boolean

emit(event: "error", err: Error): boolean

Inherited from Fetcher.emit

Overrides Sender.emit

Defined in node_modules/@types/node/stream.d.ts:73

Parameters:

Name Type
event "error"
err Error

Returns: boolean

emit(event: "pause"): boolean

Inherited from Fetcher.emit

Overrides Sender.emit

Defined in node_modules/@types/node/stream.d.ts:74

Parameters:

Name Type
event "pause"

Returns: boolean

emit(event: "readable"): boolean

Inherited from Fetcher.emit

Overrides Sender.emit

Defined in node_modules/@types/node/stream.d.ts:75

Parameters:

Name Type
event "readable"

Returns: boolean

emit(event: "resume"): boolean

Inherited from Fetcher.emit

Overrides Sender.emit

Defined in node_modules/@types/node/stream.d.ts:76

Parameters:

Name Type
event "resume"

Returns: boolean

emit(event: string | symbol, ...args: any[]): boolean

Inherited from Fetcher.emit

Overrides Sender.emit

Defined in node_modules/@types/node/stream.d.ts:77

Parameters:

Name Type
event string | symbol
...args any[]

Returns: boolean


enqueue

enqueue(job: any): void

Defined in lib/sync/fetcher/fetcher.ts:88

Enqueue job

Parameters:

Name Type Description
job any

Returns: void


error

error(error: Error, job?: any): void

Defined in lib/sync/fetcher/fetcher.ts:201

Handle error

Parameters:

Name Type Description
error Error error object
job? any task

Returns: void


eventNames

eventNames(): Array‹string | symbol›

Inherited from Sender.eventNames

Defined in node_modules/@types/node/events.d.ts:77

Returns: Array‹string | symbol›


expire

expire(job: any): void

Defined in lib/sync/fetcher/fetcher.ts:308

Expire job that has timed out and ban associated peer. Timed out tasks will be re-inserted into the queue.

Parameters:

Name Type
job any

Returns: void


Private failure

failure(job: any, error?: Error): void

Defined in lib/sync/fetcher/fetcher.ts:154

handle failed job completion

Parameters:

Name Type Description
job any failed job
error? Error

Returns: void


fetch

fetch(): Promise‹undefined | false›

Defined in lib/sync/fetcher/fetcher.ts:246

Run the fetcher. Returns a promise that resolves once all tasks are completed.

Returns: Promise‹undefined | false›


getMaxListeners

getMaxListeners(): number

Inherited from Sender.getMaxListeners

Defined in node_modules/@types/node/events.d.ts:69

Returns: number


isPaused

isPaused(): boolean

Inherited from Fetcher.isPaused

Defined in node_modules/@types/node/stream.d.ts:42

Returns: boolean


listenerCount

listenerCount(event: string | symbol): number

Inherited from Sender.listenerCount

Defined in node_modules/@types/node/events.d.ts:73

Parameters:

Name Type
event string | symbol

Returns: number


listeners

listeners(event: string | symbol): Function[]

Inherited from Sender.listeners

Defined in node_modules/@types/node/events.d.ts:70

Parameters:

Name Type
event string | symbol

Returns: Function[]


next

next(): any

Defined in lib/sync/fetcher/fetcher.ts:168

Process next task

Returns: any


off

off(event: string | symbol, listener: function): this

Inherited from Sender.off

Defined in node_modules/@types/node/events.d.ts:66

Parameters:

event: string | symbol

listener: function

▸ (...args: any[]): void

Parameters:

Name Type
...args any[]

Returns: this


on

on(event: "close", listener: function): this

Inherited from Fetcher.on

Overrides Sender.on

Defined in node_modules/@types/node/stream.d.ts:79

Parameters:

event: "close"

listener: function

▸ (): void

Returns: this

on(event: "data", listener: function): this

Inherited from Fetcher.on

Overrides Sender.on

Defined in node_modules/@types/node/stream.d.ts:80

Parameters:

event: "data"

listener: function

▸ (chunk: any): void

Parameters:

Name Type
chunk any

Returns: this

on(event: "end", listener: function): this

Inherited from Fetcher.on

Overrides Sender.on

Defined in node_modules/@types/node/stream.d.ts:81

Parameters:

event: "end"

listener: function

▸ (): void

Returns: this

on(event: "error", listener: function): this

Inherited from Fetcher.on

Overrides Sender.on

Defined in node_modules/@types/node/stream.d.ts:82

Parameters:

event: "error"

listener: function

▸ (err: Error): void

Parameters:

Name Type
err Error

Returns: this

on(event: "pause", listener: function): this

Inherited from Fetcher.on

Overrides Sender.on

Defined in node_modules/@types/node/stream.d.ts:83

Parameters:

event: "pause"

listener: function

▸ (): void

Returns: this

on(event: "readable", listener: function): this

Inherited from Fetcher.on

Overrides Sender.on

Defined in node_modules/@types/node/stream.d.ts:84

Parameters:

event: "readable"

listener: function

▸ (): void

Returns: this

on(event: "resume", listener: function): this

Inherited from Fetcher.on

Overrides Sender.on

Defined in node_modules/@types/node/stream.d.ts:85

Parameters:

event: "resume"

listener: function

▸ (): void

Returns: this

on(event: string | symbol, listener: function): this

Inherited from Fetcher.on

Overrides Sender.on

Defined in node_modules/@types/node/stream.d.ts:86

Parameters:

event: string | symbol

listener: function

▸ (...args: any[]): void

Parameters:

Name Type
...args any[]

Returns: this


once

once(event: "close", listener: function): this

Inherited from Fetcher.once

Overrides Sender.once

Defined in node_modules/@types/node/stream.d.ts:88

Parameters:

event: "close"

listener: function

▸ (): void

Returns: this

once(event: "data", listener: function): this

Inherited from Fetcher.once

Overrides Sender.once

Defined in node_modules/@types/node/stream.d.ts:89

Parameters:

event: "data"

listener: function

▸ (chunk: any): void

Parameters:

Name Type
chunk any

Returns: this

once(event: "end", listener: function): this

Inherited from Fetcher.once

Overrides Sender.once

Defined in node_modules/@types/node/stream.d.ts:90

Parameters:

event: "end"

listener: function

▸ (): void

Returns: this

once(event: "error", listener: function): this

Inherited from Fetcher.once

Overrides Sender.once

Defined in node_modules/@types/node/stream.d.ts:91

Parameters:

event: "error"

listener: function

▸ (err: Error): void

Parameters:

Name Type
err Error

Returns: this

once(event: "pause", listener: function): this

Inherited from Fetcher.once

Overrides Sender.once

Defined in node_modules/@types/node/stream.d.ts:92

Parameters:

event: "pause"

listener: function

▸ (): void

Returns: this

once(event: "readable", listener: function): this

Inherited from Fetcher.once

Overrides Sender.once

Defined in node_modules/@types/node/stream.d.ts:93

Parameters:

event: "readable"

listener: function

▸ (): void

Returns: this

once(event: "resume", listener: function): this

Inherited from Fetcher.once

Overrides Sender.once

Defined in node_modules/@types/node/stream.d.ts:94

Parameters:

event: "resume"

listener: function

▸ (): void

Returns: this

once(event: string | symbol, listener: function): this

Inherited from Fetcher.once

Overrides Sender.once

Defined in node_modules/@types/node/stream.d.ts:95

Parameters:

event: string | symbol

listener: function

▸ (...args: any[]): void

Parameters:

Name Type
...args any[]

Returns: this


pause

pause(): this

Inherited from Fetcher.pause

Defined in node_modules/@types/node/stream.d.ts:40

Returns: this


peer

peer(_job?: any): Peer‹›

Defined in lib/sync/fetcher/fetcher.ts:280

Returns a peer that can process the given job

Parameters:

Name Type
_job? any

Returns: Peer‹›


pipe

pipeT›(destination: T, options?: undefined | object): T

Inherited from Fetcher.pipe

Defined in node_modules/@types/node/stream.d.ts:5

Type parameters:

T: WritableStream

Parameters:

Name Type
destination T
options? undefined | object

Returns: T


prependListener

prependListener(event: "close", listener: function): this

Inherited from Fetcher.prependListener

Overrides Sender.prependListener

Defined in node_modules/@types/node/stream.d.ts:97

Parameters:

event: "close"

listener: function

▸ (): void

Returns: this

prependListener(event: "data", listener: function): this

Inherited from Fetcher.prependListener

Overrides Sender.prependListener

Defined in node_modules/@types/node/stream.d.ts:98

Parameters:

event: "data"

listener: function

▸ (chunk: any): void

Parameters:

Name Type
chunk any

Returns: this

prependListener(event: "end", listener: function): this

Inherited from Fetcher.prependListener

Overrides Sender.prependListener

Defined in node_modules/@types/node/stream.d.ts:99

Parameters:

event: "end"

listener: function

▸ (): void

Returns: this

prependListener(event: "error", listener: function): this

Inherited from Fetcher.prependListener

Overrides Sender.prependListener

Defined in node_modules/@types/node/stream.d.ts:100

Parameters:

event: "error"

listener: function

▸ (err: Error): void

Parameters:

Name Type
err Error

Returns: this

prependListener(event: "pause", listener: function): this

Inherited from Fetcher.prependListener

Overrides Sender.prependListener

Defined in node_modules/@types/node/stream.d.ts:101

Parameters:

event: "pause"

listener: function

▸ (): void

Returns: this

prependListener(event: "readable", listener: function): this

Inherited from Fetcher.prependListener

Overrides Sender.prependListener

Defined in node_modules/@types/node/stream.d.ts:102

Parameters:

event: "readable"

listener: function

▸ (): void

Returns: this

prependListener(event: "resume", listener: function): this

Inherited from Fetcher.prependListener

Overrides Sender.prependListener

Defined in node_modules/@types/node/stream.d.ts:103

Parameters:

event: "resume"

listener: function

▸ (): void

Returns: this

prependListener(event: string | symbol, listener: function): this

Inherited from Fetcher.prependListener

Overrides Sender.prependListener

Defined in node_modules/@types/node/stream.d.ts:104

Parameters:

event: string | symbol

listener: function

▸ (...args: any[]): void

Parameters:

Name Type
...args any[]

Returns: this


prependOnceListener

prependOnceListener(event: "close", listener: function): this

Inherited from Fetcher.prependOnceListener

Overrides Sender.prependOnceListener

Defined in node_modules/@types/node/stream.d.ts:106

Parameters:

event: "close"

listener: function

▸ (): void

Returns: this

prependOnceListener(event: "data", listener: function): this

Inherited from Fetcher.prependOnceListener

Overrides Sender.prependOnceListener

Defined in node_modules/@types/node/stream.d.ts:107

Parameters:

event: "data"

listener: function

▸ (chunk: any): void

Parameters:

Name Type
chunk any

Returns: this

prependOnceListener(event: "end", listener: function): this

Inherited from Fetcher.prependOnceListener

Overrides Sender.prependOnceListener

Defined in node_modules/@types/node/stream.d.ts:108

Parameters:

event: "end"

listener: function

▸ (): void

Returns: this

prependOnceListener(event: "error", listener: function): this

Inherited from Fetcher.prependOnceListener

Overrides Sender.prependOnceListener

Defined in node_modules/@types/node/stream.d.ts:109

Parameters:

event: "error"

listener: function

▸ (err: Error): void

Parameters:

Name Type
err Error

Returns: this

prependOnceListener(event: "pause", listener: function): this

Inherited from Fetcher.prependOnceListener

Overrides Sender.prependOnceListener

Defined in node_modules/@types/node/stream.d.ts:110

Parameters:

event: "pause"

listener: function

▸ (): void

Returns: this

prependOnceListener(event: "readable", listener: function): this

Inherited from Fetcher.prependOnceListener

Overrides Sender.prependOnceListener

Defined in node_modules/@types/node/stream.d.ts:111

Parameters:

event: "readable"

listener: function

▸ (): void

Returns: this

prependOnceListener(event: "resume", listener: function): this

Inherited from Fetcher.prependOnceListener

Overrides Sender.prependOnceListener

Defined in node_modules/@types/node/stream.d.ts:112

Parameters:

event: "resume"

listener: function

▸ (): void

Returns: this

prependOnceListener(event: string | symbol, listener: function): this

Inherited from Fetcher.prependOnceListener

Overrides Sender.prependOnceListener

Defined in node_modules/@types/node/stream.d.ts:113

Parameters:

event: string | symbol

listener: function

▸ (...args: any[]): void

Parameters:

Name Type
...args any[]

Returns: this


process

process(_job?: any, _peer?: any, _result?: any): void

Defined in lib/sync/fetcher/fetcher.ts:300

Process the reply for the given job

Parameters:

Name Type
_job? any
_peer? any
_result? any

Returns: void


push

push(chunk: any, encoding?: BufferEncoding): boolean

Inherited from Fetcher.push

Defined in node_modules/@types/node/stream.d.ts:46

Parameters:

Name Type
chunk any
encoding? BufferEncoding

Returns: boolean


rawListeners

rawListeners(event: string | symbol): Function[]

Inherited from Sender.rawListeners

Defined in node_modules/@types/node/events.d.ts:71

Parameters:

Name Type
event string | symbol

Returns: Function[]


read

read(size?: undefined | number): any

Inherited from Fetcher.read

Defined in node_modules/@types/node/stream.d.ts:38

Parameters:

Name Type
size? undefined | number

Returns: any


removeAllListeners

removeAllListeners(event?: string | symbol): this

Inherited from Sender.removeAllListeners

Defined in node_modules/@types/node/events.d.ts:67

Parameters:

Name Type
event? string | symbol

Returns: this


removeListener

removeListener(event: "close", listener: function): this

Inherited from Fetcher.removeListener

Overrides Sender.removeListener

Defined in node_modules/@types/node/stream.d.ts:115

Parameters:

event: "close"

listener: function

▸ (): void

Returns: this

removeListener(event: "data", listener: function): this

Inherited from Fetcher.removeListener

Overrides Sender.removeListener

Defined in node_modules/@types/node/stream.d.ts:116

Parameters:

event: "data"

listener: function

▸ (chunk: any): void

Parameters:

Name Type
chunk any

Returns: this

removeListener(event: "end", listener: function): this

Inherited from Fetcher.removeListener

Overrides Sender.removeListener

Defined in node_modules/@types/node/stream.d.ts:117

Parameters:

event: "end"

listener: function

▸ (): void

Returns: this

removeListener(event: "error", listener: function): this

Inherited from Fetcher.removeListener

Overrides Sender.removeListener

Defined in node_modules/@types/node/stream.d.ts:118

Parameters:

event: "error"

listener: function

▸ (err: Error): void

Parameters:

Name Type
err Error

Returns: this

removeListener(event: "pause", listener: function): this

Inherited from Fetcher.removeListener

Overrides Sender.removeListener

Defined in node_modules/@types/node/stream.d.ts:119

Parameters:

event: "pause"

listener: function

▸ (): void

Returns: this

removeListener(event: "readable", listener: function): this

Inherited from Fetcher.removeListener

Overrides Sender.removeListener

Defined in node_modules/@types/node/stream.d.ts:120

Parameters:

event: "readable"

listener: function

▸ (): void

Returns: this

removeListener(event: "resume", listener: function): this

Inherited from Fetcher.removeListener

Overrides Sender.removeListener

Defined in node_modules/@types/node/stream.d.ts:121

Parameters:

event: "resume"

listener: function

▸ (): void

Returns: this

removeListener(event: string | symbol, listener: function): this

Inherited from Fetcher.removeListener

Overrides Sender.removeListener

Defined in node_modules/@types/node/stream.d.ts:122

Parameters:

event: string | symbol

listener: function

▸ (...args: any[]): void

Parameters:

Name Type
...args any[]

Returns: this


request

request(_job?: any, _peer?: any): Promise‹any›

Defined in lib/sync/fetcher/fetcher.ts:290

Request results from peer for the given job. Resolves with the raw result.

Parameters:

Name Type
_job? any
_peer? any

Returns: Promise‹any›


resume

resume(): this

Inherited from Fetcher.resume

Defined in node_modules/@types/node/stream.d.ts:41

Returns: this


setEncoding

setEncoding(encoding: BufferEncoding): this

Inherited from Fetcher.setEncoding

Defined in node_modules/@types/node/stream.d.ts:39

Parameters:

Name Type
encoding BufferEncoding

Returns: this


setMaxListeners

setMaxListeners(n: number): this

Inherited from Sender.setMaxListeners

Defined in node_modules/@types/node/events.d.ts:68

Parameters:

Name Type
n number

Returns: this


store

store(_result?: any): Promise‹void›

Defined in lib/sync/fetcher/fetcher.ts:328

Store fetch result. Resolves once store operation is complete.

Parameters:

Name Type
_result? any

Returns: Promise‹void›


Private success

success(job: any, result: any): void

Defined in lib/sync/fetcher/fetcher.ts:126

handle successful job completion

Parameters:

Name Type Description
job any successful job
result any job result

Returns: void


tasks

tasks(): object[]

Defined in lib/sync/fetcher/fetcher.ts:80

Generate list of tasks to fetch

Returns: object[]

tasks


unpipe

unpipe(destination?: NodeJS.WritableStream): this

Inherited from Fetcher.unpipe

Defined in node_modules/@types/node/stream.d.ts:43

Parameters:

Name Type
destination? NodeJS.WritableStream

Returns: this


unshift

unshift(chunk: any, encoding?: BufferEncoding): void

Inherited from Fetcher.unshift

Defined in node_modules/@types/node/stream.d.ts:44

Parameters:

Name Type
chunk any
encoding? BufferEncoding

Returns: void


wait

wait(delay?: undefined | number): Promise‹void›

Defined in lib/sync/fetcher/fetcher.ts:332

Parameters:

Name Type
delay? undefined | number

Returns: Promise‹void›


wrap

wrap(oldStream: ReadableStream): this

Inherited from Fetcher.wrap

Defined in node_modules/@types/node/stream.d.ts:45

Parameters:

Name Type
oldStream ReadableStream

Returns: this


write

write(): void

Defined in lib/sync/fetcher/fetcher.ts:211

Setup writer pipe and start writing fetch results. A pipe is used in order to support backpressure from storing results.

Returns: void


Static from

from(iterable: Iterable‹any› | AsyncIterable‹any›, options?: ReadableOptions): Readable

Inherited from Fetcher.from

Defined in node_modules/@types/node/stream.d.ts:26

A utility method for creating Readable Streams out of iterators.

Parameters:

Name Type
iterable Iterable‹any› | AsyncIterable‹any›
options? ReadableOptions

Returns: Readable