ethereumjs-client › "blockchain/chain" › Chain
Blockchain
memberof
module:blockchain
-
EventEmitter
↳ Chain
- addListener
- close
- emit
- eventNames
- getBlock
- getBlocks
- getHeaders
- getLatestBlock
- getLatestHeader
- getMaxListeners
- getTd
- listenerCount
- listeners
- off
- on
- once
- open
- prependListener
- prependOnceListener
- putBlocks
- putHeaders
- rawListeners
- removeAllListeners
- removeListener
- setMaxListeners
- update
- listenerCount
+ 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
• blockchain: Blockchain
Defined in lib/blockchain/chain.ts:83
• config: Config
Defined in lib/blockchain/chain.ts:80
• db: LevelUp
Defined in lib/blockchain/chain.ts:82
• opened: boolean
Defined in lib/blockchain/chain.ts:84
▪ defaultMaxListeners: number
Inherited from Sender.defaultMaxListeners
Defined in node_modules/@types/node/events.d.ts:45
▪ 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.
• get blocks(): ChainBlocks
Defined in lib/blockchain/chain.ts:167
Returns properties of the canonical blockchain.
Returns: ChainBlocks
• get genesis(): GenesisBlockParams
Defined in lib/blockchain/chain.ts:147
Genesis block parameters
Returns: GenesisBlockParams
• get headers(): ChainHeaders
Defined in lib/blockchain/chain.ts:159
Returns properties of the canonical headerchain.
Returns: ChainHeaders
• get networkId(): number
Defined in lib/blockchain/chain.ts:140
Network ID
Returns: number
▸ 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(): Promise‹boolean | void›
Defined in lib/blockchain/chain.ts:189
Closes chain
Returns: Promise‹boolean | void›
Returns false if chain is closed
▸ emit(event
: string | symbol, ...args
: any[]): boolean
Defined in node_modules/@types/node/events.d.ts:72
Parameters:
Name | Type |
---|---|
event |
string | symbol |
...args |
any[] |
Returns: boolean
▸ eventNames(): Array‹string | symbol›
Inherited from Sender.eventNames
Defined in node_modules/@types/node/events.d.ts:77
Returns: Array‹string | symbol›
▸ 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(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(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(): Promise‹Block›
Defined in lib/blockchain/chain.ts:324
Gets the latest block in the canonical chain
Returns: Promise‹Block›
▸ getLatestHeader(): Promise‹BlockHeader›
Defined in lib/blockchain/chain.ts:315
Gets the latest header in the canonical chain
Returns: Promise‹BlockHeader›
▸ getMaxListeners(): number
Inherited from Sender.getMaxListeners
Defined in node_modules/@types/node/events.d.ts:69
Returns: number
▸ 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(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(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(event
: string | symbol, listener
: function): this
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(event
: string | symbol, listener
: function): this
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(event
: string | symbol, listener
: function): this
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(): 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(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(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(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(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(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(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(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(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(): 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
▸ 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