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

Latest commit

 

History

History
710 lines (400 loc) · 16.4 KB

_blockchain_chain_.chain.md

File metadata and controls

710 lines (400 loc) · 16.4 KB

ethereumjs-client"blockchain/chain"Chain

Class: Chain

Blockchain

memberof module:blockchain

Hierarchy

  • EventEmitter

    Chain

Index

Constructors

Properties

Accessors

Methods

Constructors

constructor

+ new Chain(options: ChainOptions): Chain

Overrides void

Defined in lib/blockchain/chain.ts:96

Create new chain

Parameters:

Name Type Description
options ChainOptions

Returns: Chain

Properties

blockchain

blockchain: Blockchain

Defined in lib/blockchain/chain.ts:83


config

config: Config

Defined in lib/blockchain/chain.ts:80


db

db: LevelUp

Defined in lib/blockchain/chain.ts:82


opened

opened: boolean

Defined in lib/blockchain/chain.ts:84


Static defaultMaxListeners

defaultMaxListeners: number

Inherited from Sender.defaultMaxListeners

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


Static errorMonitor

errorMonitor: keyof symbol

Inherited from Sender.errorMonitor

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

This symbol shall be used to install a listener for only monitoring 'error' events. Listeners installed using this symbol are called before the regular 'error' listeners are called.

Installing a listener using this symbol does not change the behavior once an 'error' event is emitted, therefore the process will still crash if no regular 'error' listener is installed.

Accessors

blocks

get blocks(): ChainBlocks

Defined in lib/blockchain/chain.ts:167

Returns properties of the canonical blockchain.

Returns: ChainBlocks


genesis

get genesis(): GenesisBlockParams

Defined in lib/blockchain/chain.ts:147

Genesis block parameters

Returns: GenesisBlockParams


headers

get headers(): ChainHeaders

Defined in lib/blockchain/chain.ts:159

Returns properties of the canonical headerchain.

Returns: ChainHeaders


networkId

get networkId(): number

Defined in lib/blockchain/chain.ts:140

Network ID

Returns: number

Methods

addListener

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

Inherited from Sender.addListener

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

Parameters:

event: string | symbol

listener: function

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

Parameters:

Name Type
...args any[]

Returns: this


close

close(): Promise‹boolean | void›

Defined in lib/blockchain/chain.ts:189

Closes chain

Returns: Promise‹boolean | void›

Returns false if chain is closed


emit

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

Inherited from Sender.emit

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

Parameters:

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

Returns: boolean


eventNames

eventNames(): Array‹string | symbol›

Inherited from Sender.eventNames

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

Returns: Array‹string | symbol›


getBlock

getBlock(block: Buffer | BN): Promise‹Block›

Defined in lib/blockchain/chain.ts:255

Gets a block by its hash or number

Parameters:

Name Type
block Buffer | BN

Returns: Promise‹Block›


getBlocks

getBlocks(block: Buffer | BN, max: number, skip: number, reverse: boolean): Promise‹Block[]›

Defined in lib/blockchain/chain.ts:240

Get blocks from blockchain

Parameters:

Name Type Default Description
block Buffer | BN - hash or number to start from
max number 1 maximum number of blocks to get
skip number 0 number of blocks to skip
reverse boolean false get blocks in reverse

Returns: Promise‹Block[]›


getHeaders

getHeaders(block: Buffer | BN, max: number, skip: number, reverse: boolean): Promise‹BlockHeader[]›

Defined in lib/blockchain/chain.ts:284

Get headers from blockchain

Parameters:

Name Type Description
block Buffer | BN block hash or number to start from
max number maximum number of headers to get
skip number number of headers to skip
reverse boolean get headers in reverse

Returns: Promise‹BlockHeader[]›


getLatestBlock

getLatestBlock(): Promise‹Block›

Defined in lib/blockchain/chain.ts:324

Gets the latest block in the canonical chain

Returns: Promise‹Block›


getLatestHeader

getLatestHeader(): Promise‹BlockHeader›

Defined in lib/blockchain/chain.ts:315

Gets the latest header in the canonical chain

Returns: Promise‹BlockHeader›


getMaxListeners

getMaxListeners(): number

Inherited from Sender.getMaxListeners

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

Returns: number


getTd

getTd(hash: Buffer, num: BN): Promise‹BN›

Defined in lib/blockchain/chain.ts:335

Gets total difficulty for a block

Parameters:

Name Type
hash Buffer
num BN

Returns: Promise‹BN›


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[]


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: string | symbol, listener: function): this

Inherited from Sender.on

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

Parameters:

event: string | symbol

listener: function

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

Parameters:

Name Type
...args any[]

Returns: this


once

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

Inherited from Sender.once

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

Parameters:

event: string | symbol

listener: function

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

Parameters:

Name Type
...args any[]

Returns: this


open

open(): Promise‹boolean | void›

Defined in lib/blockchain/chain.ts:175

Open blockchain and wait for database to load

Returns: Promise‹boolean | void›

Returns false if chain is already open


prependListener

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

Inherited from Sender.prependListener

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

Parameters:

event: string | symbol

listener: function

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

Parameters:

Name Type
...args any[]

Returns: this


prependOnceListener

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

Inherited from Sender.prependOnceListener

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

Parameters:

event: string | symbol

listener: function

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

Parameters:

Name Type
...args any[]

Returns: this


putBlocks

putBlocks(blocks: Block[]): Promise‹void›

Defined in lib/blockchain/chain.ts:264

Insert new blocks into blockchain

Parameters:

Name Type Description
blocks Block[] list of blocks to add

Returns: Promise‹void›


putHeaders

putHeaders(headers: BlockHeader[]): Promise‹void›

Defined in lib/blockchain/chain.ts:299

Insert new headers into blockchain

Parameters:

Name Type
headers BlockHeader[]

Returns: Promise‹void›


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[]


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: string | symbol, listener: function): this

Inherited from Sender.removeListener

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

Parameters:

event: string | symbol

listener: function

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

Parameters:

Name Type
...args any[]

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


update

update(): Promise‹boolean | void›

Defined in lib/blockchain/chain.ts:202

Update blockchain properties (latest block, td, height, etc...)

Returns: Promise‹boolean | void›

Returns false if chain is closed


Static listenerCount

listenerCount(emitter: EventEmitter, event: string | symbol): number

Inherited from Sender.listenerCount

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

deprecated since v4.0.0

Parameters:

Name Type
emitter EventEmitter
event string | symbol

Returns: number