You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 6, 2020. It is now read-only.
Implements functions for retrieving, manipulating and storing Ethereum's blockchain
65
-
66
-
### `new Blockchain(opts)`
67
-
68
-
Creates new Blockchain object
69
-
70
-
-`opts.chain`**([String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)\|[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number))** The chain for the block [default: 'mainnet']
71
-
-`opts.hardfork`**[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Hardfork for the block [default: null, block number-based behavior]
72
-
-`opts.common`**[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Alternatively pass a Common instance (ethereumjs-common) instead of setting chain/hardfork directly
73
-
-`opts.db` - Database to store blocks and metadata. Should be a [levelup](https://github.com/rvagg/node-levelup) instance.
74
-
-`opts.validate` - this the flag to validate blocks (e.g. Proof-of-Work), latest HF rules supported: `Constantinople`.
75
-
76
-
[DEPRECATION NOTE]
77
-
The old separated DB constructor parameters `opts.blockDB` and `opts.detailsDB` from before the Geth DB-compatible `v3.0.0` release are deprecated and continued usage is discouraged. When provided `opts.blockDB` will be used
78
-
as `opts.db` and `opts.detailsDB` is ignored. On the storage level the DB formats are not compatible and it is not
79
-
possible to load an old-format DB state into a post-`v3.0.0``Blockchain` object.
80
-
81
-
### `BlockChain` methods
82
-
83
-
#### `blockchain.putGenesis(genesis, cb)`
84
-
85
-
Puts the genesis block in the database.
86
-
87
-
-`genesis` - the genesis block to be added
88
-
-`cb` - the callback. It is given two parameters `err` and the saved `block`
89
-
90
-
---
91
-
92
-
#### `blockchain.getHead(name, cb)`
93
-
94
-
Returns the specified iterator head.
95
-
96
-
-`name` - Optional name of the state root head (default: 'vm')
97
-
-`cb` - the callback. It is given two parameters `err` and the returned `block`
98
-
99
-
---
100
-
101
-
#### `blockchain.getLatestHeader(cb)`
102
-
103
-
Returns the latest header in the canonical chain.
104
-
105
-
-`cb` - the callback. It is given two parameters `err` and the returned `header`
106
-
107
-
---
108
-
109
-
#### `blockchain.getLatestBlock(cb)`
110
-
111
-
Returns the latest full block in the canonical chain.
112
-
113
-
-`cb` - the callback. It is given two parameters `err` and the returned `block`
114
-
115
-
---
116
-
117
-
#### `blockchain.putBlocks(blocks, cb)`
118
-
119
-
Adds many blocks to the blockchain.
120
-
121
-
-`blocks` - the blocks to be added to the blockchain
122
-
-`cb` - the callback. It is given two parameters `err` and the last of the saved `blocks`
123
-
124
-
---
125
-
126
-
#### `blockchain.putBlock(block, cb)`
127
-
128
-
Adds a block to the blockchain.
129
-
130
-
-`block` - the block to be added to the blockchain
131
-
-`cb` - the callback. It is given two parameters `err` and the saved `block`
132
-
133
-
---
134
-
135
-
#### `blockchain.getBlock(blockTag, cb)`
136
-
137
-
Gets a block by its blockTag.
138
-
139
-
-`blockTag` - the block's hash or number
140
-
-`cb` - the callback. It is given two parameters `err` and the found `block` (an instance of https://github.com/ethereumjs/ethereumjs-block) if any.
0 commit comments