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
Copy file name to clipboardExpand all lines: README.md
+26Lines changed: 26 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -14,3 +14,29 @@ A module to store and interact with blocks.
14
14
# API
15
15
16
16
[./docs/](./docs/README.md)
17
+
18
+
# EXAMPLE USAGE
19
+
20
+
The following is an example to iterate through an existing Geth DB (needs `level` to be installed separately).
21
+
22
+
This module performs write operations. Making a backup of your data before trying it is recommended. Otherwise, you can end up with a compromised DB state.
23
+
24
+
```javascript
25
+
constlevel=require('level')
26
+
constBlockchain=require('ethereumjs-blockchain')
27
+
constutils=require('ethereumjs-util')
28
+
29
+
constgethDbPath='./chaindata'// Add your own path here. It will get modified, see remarks.
Copy file name to clipboardExpand all lines: docs/classes/blockchain.md
+25-57Lines changed: 25 additions & 57 deletions
Original file line number
Diff line number
Diff line change
@@ -4,30 +4,6 @@
4
4
5
5
This class stores and interacts with blocks.
6
6
7
-
_**remarks**_: This class performs write operations. Making a backup of your data before trying this module is recommended. Otherwise, you can end up with a compromised DB state.
8
-
9
-
_**example**_: The following is an example to iterate through an existing Geth DB (needs `level` to be installed separately).
10
-
11
-
```javascript
12
-
constlevel=require('level')
13
-
constBlockchain=require('ethereumjs-blockchain')
14
-
constutils=require('ethereumjs-util')
15
-
16
-
constgethDbPath='./chaindata'// Add your own path here. It will get modified, see remarks.
_Defined in [index.ts:112](https://github.com/ethereumjs/ethereumjs-blockchain/blob/c93b4dd/src/index.ts#L112)_
55
+
_Defined in [index.ts:127](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L127)_
80
56
81
57
Creates new Blockchain object
82
58
83
-
This constructor receives an object with different options, all of them are optional:
84
-
85
-
-`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'\]
86
-
-`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\]
87
-
-`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
88
-
-`opts.db` - Database to store blocks and metadata. Should be a [levelup](https://github.com/rvagg/node-levelup) instance.
89
-
-`opts.validate` - this the flag to validate blocks (e.g. Proof-of-Work), latest HF rules supported: `Constantinople`.
90
-
91
59
**Deprecation note**:
92
60
93
-
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 as `opts.db` and `opts.detailsDB` is ignored. On the storage level the DB formats are not compatible and it is not possible to load an old-format DB state into a post-`v3.0.0``Blockchain` object.
61
+
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 as `opts.db` and `opts.detailsDB` is ignored. On the storage level the DB formats are not compatible and it is not possible to load an old-format DB state into a post-`v3.0.0``Blockchain` object.
|`Default value` opts |[BlockchainOptions](../interfaces/blockchainoptions.md)| {} |An object with the options that this constructor takes. See [BlockchainOptions](../interfaces/blockchainoptions.md). |
100
68
101
69
**Returns:**[Blockchain](blockchain.md)
102
70
@@ -110,7 +78,7 @@ The old separated DB constructor parameters `opts.blockDB` and `opts.detailsDB`
110
78
111
79
**● db**: _`any`_
112
80
113
-
_Defined in [index.ts:105](https://github.com/ethereumjs/ethereumjs-blockchain/blob/c93b4dd/src/index.ts#L105)_
81
+
_Defined in [index.ts:120](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L120)_
114
82
115
83
---
116
84
@@ -120,7 +88,7 @@ _Defined in [index.ts:105](https://github.com/ethereumjs/ethereumjs-blockchain/b
120
88
121
89
**● dbManager**: _`DBManager`_
122
90
123
-
_Defined in [index.ts:106](https://github.com/ethereumjs/ethereumjs-blockchain/blob/c93b4dd/src/index.ts#L106)_
91
+
_Defined in [index.ts:121](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L121)_
124
92
125
93
---
126
94
@@ -130,7 +98,7 @@ _Defined in [index.ts:106](https://github.com/ethereumjs/ethereumjs-blockchain/b
130
98
131
99
**● ethash**: _`any`_
132
100
133
-
_Defined in [index.ts:107](https://github.com/ethereumjs/ethereumjs-blockchain/blob/c93b4dd/src/index.ts#L107)_
101
+
_Defined in [index.ts:122](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L122)_
134
102
135
103
---
136
104
@@ -140,7 +108,7 @@ _Defined in [index.ts:107](https://github.com/ethereumjs/ethereumjs-blockchain/b
140
108
141
109
**● validate**: _`boolean`_
142
110
143
-
_Defined in [index.ts:112](https://github.com/ethereumjs/ethereumjs-blockchain/blob/c93b4dd/src/index.ts#L112)_
111
+
_Defined in [index.ts:127](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L127)_
144
112
145
113
A flag indicating if this Blockchain validates blocks or not.
146
114
@@ -154,7 +122,7 @@ A flag indicating if this Blockchain validates blocks or not.
154
122
155
123
**get meta**(): `object`
156
124
157
-
_Defined in [index.ts:175](https://github.com/ethereumjs/ethereumjs-blockchain/blob/c93b4dd/src/index.ts#L175)_
125
+
_Defined in [index.ts:182](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L182)_
158
126
159
127
Returns an object with metadata about the Blockchain. It's defined for backwards compatibility.
160
128
@@ -170,7 +138,7 @@ Returns an object with metadata about the Blockchain. It's defined for backwards
_Defined in [index.ts:957](https://github.com/ethereumjs/ethereumjs-blockchain/blob/c93b4dd/src/index.ts#L957)_
291
+
_Defined in [index.ts:964](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L964)_
324
292
325
293
Iterates through blocks starting at the specified iterator head and calls the onBlock function on each block. The current location of an iterator head can be retrieved using the `getHead()` method.
326
294
@@ -342,7 +310,7 @@ Iterates through blocks starting at the specified iterator head and calls the on
0 commit comments