Skip to content

Commit cf6bbc1

Browse files
committed
Also move the remarks to the README.
This messages is mostly related to the example, so I moved right next to it.
1 parent 29a8a30 commit cf6bbc1

File tree

4 files changed

+29
-33
lines changed

4 files changed

+29
-33
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ A module to store and interact with blocks.
1919

2020
The following is an example to iterate through an existing Geth DB (needs `level` to be installed separately).
2121

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+
2224
```javascript
2325
const level = require('level')
2426
const Blockchain = require('ethereumjs-blockchain')

docs/classes/blockchain.md

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
This class stores and interacts with blocks.
66

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-
97
## Hierarchy
108

119
**Blockchain**
@@ -54,7 +52,7 @@ _**remarks**_: This class performs write operations. Making a backup of your dat
5452

5553
**new Blockchain**(opts?: _[BlockchainOptions](../interfaces/blockchainoptions.md)_): [Blockchain](blockchain.md)
5654

57-
_Defined in [index.ts:131](https://github.com/ethereumjs/ethereumjs-blockchain/blob/f54802f/src/index.ts#L131)_
55+
_Defined in [index.ts:127](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L127)_
5856

5957
Creates new Blockchain object
6058

@@ -80,7 +78,7 @@ The old separated DB constructor parameters `opts.blockDB` and `opts.detailsDb`
8078

8179
**● db**: _`any`_
8280

83-
_Defined in [index.ts:124](https://github.com/ethereumjs/ethereumjs-blockchain/blob/f54802f/src/index.ts#L124)_
81+
_Defined in [index.ts:120](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L120)_
8482

8583
---
8684

@@ -90,7 +88,7 @@ _Defined in [index.ts:124](https://github.com/ethereumjs/ethereumjs-blockchain/b
9088

9189
**● dbManager**: _`DBManager`_
9290

93-
_Defined in [index.ts:125](https://github.com/ethereumjs/ethereumjs-blockchain/blob/f54802f/src/index.ts#L125)_
91+
_Defined in [index.ts:121](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L121)_
9492

9593
---
9694

@@ -100,7 +98,7 @@ _Defined in [index.ts:125](https://github.com/ethereumjs/ethereumjs-blockchain/b
10098

10199
**● ethash**: _`any`_
102100

103-
_Defined in [index.ts:126](https://github.com/ethereumjs/ethereumjs-blockchain/blob/f54802f/src/index.ts#L126)_
101+
_Defined in [index.ts:122](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L122)_
104102

105103
---
106104

@@ -110,7 +108,7 @@ _Defined in [index.ts:126](https://github.com/ethereumjs/ethereumjs-blockchain/b
110108

111109
**● validate**: _`boolean`_
112110

113-
_Defined in [index.ts:131](https://github.com/ethereumjs/ethereumjs-blockchain/blob/f54802f/src/index.ts#L131)_
111+
_Defined in [index.ts:127](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L127)_
114112

115113
A flag indicating if this Blockchain validates blocks or not.
116114

@@ -124,7 +122,7 @@ A flag indicating if this Blockchain validates blocks or not.
124122

125123
**get meta**(): `object`
126124

127-
_Defined in [index.ts:186](https://github.com/ethereumjs/ethereumjs-blockchain/blob/f54802f/src/index.ts#L186)_
125+
_Defined in [index.ts:182](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L182)_
128126

129127
Returns an object with metadata about the Blockchain. It's defined for backwards compatibility.
130128

@@ -140,7 +138,7 @@ Returns an object with metadata about the Blockchain. It's defined for backwards
140138

141139
**delBlock**(blockHash: _`Buffer`_, cb: _`any`_): `void`
142140

143-
_Defined in [index.ts:834](https://github.com/ethereumjs/ethereumjs-blockchain/blob/f54802f/src/index.ts#L834)_
141+
_Defined in [index.ts:830](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L830)_
144142

145143
Deletes a block from the blockchain. All child blocks in the chain are deleted and any encountered heads are set to the parent block.
146144

@@ -161,7 +159,7 @@ Deletes a block from the blockchain. All child blocks in the chain are deleted a
161159

162160
**getBlock**(blockTag: _`Buffer` \| `number` \| `BN`_, cb: _`any`_): `void`
163161

164-
_Defined in [index.ts:571](https://github.com/ethereumjs/ethereumjs-blockchain/blob/f54802f/src/index.ts#L571)_
162+
_Defined in [index.ts:567](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L567)_
165163

166164
Gets a block by its hash.
167165

@@ -182,7 +180,7 @@ Gets a block by its hash.
182180

183181
**getBlocks**(blockId: _`Buffer` \| `number`_, maxBlocks: _`number`_, skip: _`number`_, reverse: _`boolean`_, cb: _`any`_): `void`
184182

185-
_Defined in [index.ts:594](https://github.com/ethereumjs/ethereumjs-blockchain/blob/f54802f/src/index.ts#L594)_
183+
_Defined in [index.ts:590](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L590)_
186184

187185
Looks up many blocks relative to blockId
188186

@@ -206,7 +204,7 @@ Looks up many blocks relative to blockId
206204

207205
**getDetails**(\_: _`string`_, cb: _`any`_): `void`
208206

209-
_Defined in [index.ts:635](https://github.com/ethereumjs/ethereumjs-blockchain/blob/f54802f/src/index.ts#L635)_
207+
_Defined in [index.ts:631](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L631)_
210208

211209
This method used to return block details by its hash. It's only here for backwards compatibility.
212210

@@ -229,7 +227,7 @@ _**deprecated**_:
229227

230228
**getHead**(name: _`any`_, cb?: _`any`_): `void`
231229

232-
_Defined in [index.ts:282](https://github.com/ethereumjs/ethereumjs-blockchain/blob/f54802f/src/index.ts#L282)_
230+
_Defined in [index.ts:278](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L278)_
233231

234232
Returns the specified iterator head.
235233

@@ -250,7 +248,7 @@ Returns the specified iterator head.
250248

251249
**getLatestBlock**(cb: _`any`_): `void`
252250

253-
_Defined in [index.ts:322](https://github.com/ethereumjs/ethereumjs-blockchain/blob/f54802f/src/index.ts#L322)_
251+
_Defined in [index.ts:318](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L318)_
254252

255253
Returns the latest full block in the canonical chain.
256254

@@ -270,7 +268,7 @@ Returns the latest full block in the canonical chain.
270268

271269
**getLatestHeader**(cb: _`any`_): `void`
272270

273-
_Defined in [index.ts:305](https://github.com/ethereumjs/ethereumjs-blockchain/blob/f54802f/src/index.ts#L305)_
271+
_Defined in [index.ts:301](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L301)_
274272

275273
Returns the latest header in the canonical chain.
276274

@@ -290,7 +288,7 @@ Returns the latest header in the canonical chain.
290288

291289
**iterator**(name: _`string`_, onBlock: _`any`_, cb: _`any`_): `void`
292290

293-
_Defined in [index.ts:968](https://github.com/ethereumjs/ethereumjs-blockchain/blob/f54802f/src/index.ts#L968)_
291+
_Defined in [index.ts:964](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L964)_
294292

295293
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.
296294

@@ -312,7 +310,7 @@ Iterates through blocks starting at the specified iterator head and calls the on
312310

313311
**putBlock**(block: _`object`_, cb: _`any`_, isGenesis?: _`undefined` \| `false` \| `true`_): `void`
314312

315-
_Defined in [index.ts:351](https://github.com/ethereumjs/ethereumjs-blockchain/blob/f54802f/src/index.ts#L351)_
313+
_Defined in [index.ts:347](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L347)_
316314

317315
Adds a block to the blockchain.
318316

@@ -334,7 +332,7 @@ Adds a block to the blockchain.
334332

335333
**putBlocks**(blocks: _`Array`<`any`>_, cb: _`any`_): `void`
336334

337-
_Defined in [index.ts:335](https://github.com/ethereumjs/ethereumjs-blockchain/blob/f54802f/src/index.ts#L335)_
335+
_Defined in [index.ts:331](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L331)_
338336

339337
Adds many blocks to the blockchain.
340338

@@ -355,7 +353,7 @@ Adds many blocks to the blockchain.
355353

356354
**putGenesis**(genesis: _`any`_, cb: _`any`_): `void`
357355

358-
_Defined in [index.ts:272](https://github.com/ethereumjs/ethereumjs-blockchain/blob/f54802f/src/index.ts#L272)_
356+
_Defined in [index.ts:268](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L268)_
359357

360358
Puts the genesis block in the database
361359

@@ -376,7 +374,7 @@ Puts the genesis block in the database
376374

377375
**putHeader**(header: _`object`_, cb: _`any`_): `void`
378376

379-
_Defined in [index.ts:383](https://github.com/ethereumjs/ethereumjs-blockchain/blob/f54802f/src/index.ts#L383)_
377+
_Defined in [index.ts:379](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L379)_
380378

381379
Adds a header to the blockchain.
382380

@@ -397,7 +395,7 @@ Adds a header to the blockchain.
397395

398396
**putHeaders**(headers: _`Array`<`any`>_, cb: _`any`_): `void`
399397

400-
_Defined in [index.ts:367](https://github.com/ethereumjs/ethereumjs-blockchain/blob/f54802f/src/index.ts#L367)_
398+
_Defined in [index.ts:363](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L363)_
401399

402400
Adds many headers to the blockchain.
403401

@@ -418,7 +416,7 @@ Adds many headers to the blockchain.
418416

419417
**selectNeededHashes**(hashes: _`Array`<`any`>_, cb: _`any`_): `void`
420418

421-
_Defined in [index.ts:645](https://github.com/ethereumjs/ethereumjs-blockchain/blob/f54802f/src/index.ts#L645)_
419+
_Defined in [index.ts:641](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L641)_
422420

423421
Given an ordered array, returns to the callback an array of hashes that are not in the blockchain yet.
424422

docs/interfaces/blockchainoptions.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ This are the options that the Blockchain constructor can receive.
3030

3131
**● blockDb**: _`any`_
3232

33-
_Defined in [index.ts:58](https://github.com/ethereumjs/ethereumjs-blockchain/blob/f54802f/src/index.ts#L58)_
33+
_Defined in [index.ts:58](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L58)_
3434

3535
_**deprecated**_:
3636

@@ -42,7 +42,7 @@ _**deprecated**_:
4242

4343
**● chain**: _`string` \| `number`_
4444

45-
_Defined in [index.ts:30](https://github.com/ethereumjs/ethereumjs-blockchain/blob/f54802f/src/index.ts#L30)_
45+
_Defined in [index.ts:30](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L30)_
4646

4747
The chain id or name. Default: `"mainnet"`.
4848

@@ -54,7 +54,7 @@ The chain id or name. Default: `"mainnet"`.
5454

5555
**● common**: _`Common`_
5656

57-
_Defined in [index.ts:41](https://github.com/ethereumjs/ethereumjs-blockchain/blob/f54802f/src/index.ts#L41)_
57+
_Defined in [index.ts:41](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L41)_
5858

5959
An alternative way to specify the chain and hardfork is by passing a Common instance.
6060

@@ -66,7 +66,7 @@ An alternative way to specify the chain and hardfork is by passing a Common inst
6666

6767
**● db**: _`any`_
6868

69-
_Defined in [index.ts:47](https://github.com/ethereumjs/ethereumjs-blockchain/blob/f54802f/src/index.ts#L47)_
69+
_Defined in [index.ts:47](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L47)_
7070

7171
Database to store blocks and metadata. Should be a [levelup](https://github.com/rvagg/node-levelup) instance.
7272

@@ -78,7 +78,7 @@ Database to store blocks and metadata. Should be a [levelup](https://github.com/
7878

7979
**● detailsDb**: _`any`_
8080

81-
_Defined in [index.ts:63](https://github.com/ethereumjs/ethereumjs-blockchain/blob/f54802f/src/index.ts#L63)_
81+
_Defined in [index.ts:63](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L63)_
8282

8383
_**deprecated**_:
8484

@@ -90,7 +90,7 @@ _**deprecated**_:
9090

9191
**● hardfork**: _`string` \| `null`_
9292

93-
_Defined in [index.ts:36](https://github.com/ethereumjs/ethereumjs-blockchain/blob/f54802f/src/index.ts#L36)_
93+
_Defined in [index.ts:36](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L36)_
9494

9595
Hardfork for the blocks. If `undefined` or `null` is passed, it gets computed based on block numbers.
9696

@@ -102,7 +102,7 @@ Hardfork for the blocks. If `undefined` or `null` is passed, it gets computed ba
102102

103103
**● validate**: _`undefined` \| `false` \| `true`_
104104

105-
_Defined in [index.ts:53](https://github.com/ethereumjs/ethereumjs-blockchain/blob/f54802f/src/index.ts#L53)_
105+
_Defined in [index.ts:53](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L53)_
106106

107107
This the flag indicates if blocks should be validated (e.g. Proof-of-Work), latest HF rules supported: `Petersburg`.
108108

src/index.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,6 @@ export interface BlockchainOptions {
6565

6666
/**
6767
* This class stores and interacts with blocks.
68-
*
69-
* @remarks
70-
* This class performs write operations. Making a backup of your data before trying this module is
71-
* recommended. Otherwise, you can end up with a compromised DB state.
7268
*/
7369
export default class Blockchain {
7470
/**

0 commit comments

Comments
 (0)