Skip to content

Commit c9722da

Browse files
authored
Merge pull request ethereumjs#100 from ethereumjs/remove-deprecated-db-options
Remove deprecated db options
2 parents 8190375 + baa6b68 commit c9722da

File tree

4 files changed

+27
-89
lines changed

4 files changed

+27
-89
lines changed

docs/classes/blockchain.md

+20-24
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,10 @@ This class stores and interacts with blocks.
5252

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

55-
_Defined in [index.ts:127](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L127)_
55+
_Defined in [index.ts:117](https://github.com/ethereumjs/ethereumjs-blockchain/blob/8190375/src/index.ts#L117)_
5656

5757
Creates new Blockchain object
5858

59-
**Deprecation note**:
60-
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.
62-
6359
**Parameters:**
6460

6561
| Name | Type | Default value | Description |
@@ -78,7 +74,7 @@ The old separated DB constructor parameters `opts.blockDB` and `opts.detailsDb`
7874

7975
**● db**: _`any`_
8076

81-
_Defined in [index.ts:120](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L120)_
77+
_Defined in [index.ts:110](https://github.com/ethereumjs/ethereumjs-blockchain/blob/8190375/src/index.ts#L110)_
8278

8379
---
8480

@@ -88,7 +84,7 @@ _Defined in [index.ts:120](https://github.com/ethereumjs/ethereumjs-blockchain/b
8884

8985
**● dbManager**: _`DBManager`_
9086

91-
_Defined in [index.ts:121](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L121)_
87+
_Defined in [index.ts:111](https://github.com/ethereumjs/ethereumjs-blockchain/blob/8190375/src/index.ts#L111)_
9288

9389
---
9490

@@ -98,7 +94,7 @@ _Defined in [index.ts:121](https://github.com/ethereumjs/ethereumjs-blockchain/b
9894

9995
**● ethash**: _`any`_
10096

101-
_Defined in [index.ts:122](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L122)_
97+
_Defined in [index.ts:112](https://github.com/ethereumjs/ethereumjs-blockchain/blob/8190375/src/index.ts#L112)_
10298

10399
---
104100

@@ -108,7 +104,7 @@ _Defined in [index.ts:122](https://github.com/ethereumjs/ethereumjs-blockchain/b
108104

109105
**● validate**: _`boolean`_
110106

111-
_Defined in [index.ts:127](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L127)_
107+
_Defined in [index.ts:117](https://github.com/ethereumjs/ethereumjs-blockchain/blob/8190375/src/index.ts#L117)_
112108

113109
A flag indicating if this Blockchain validates blocks or not.
114110

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

123119
**get meta**(): `object`
124120

125-
_Defined in [index.ts:182](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L182)_
121+
_Defined in [index.ts:164](https://github.com/ethereumjs/ethereumjs-blockchain/blob/8190375/src/index.ts#L164)_
126122

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

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

139135
**delBlock**(blockHash: _`Buffer`_, cb: _`any`_): `void`
140136

141-
_Defined in [index.ts:830](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L830)_
137+
_Defined in [index.ts:812](https://github.com/ethereumjs/ethereumjs-blockchain/blob/8190375/src/index.ts#L812)_
142138

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

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

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

162-
_Defined in [index.ts:567](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L567)_
158+
_Defined in [index.ts:549](https://github.com/ethereumjs/ethereumjs-blockchain/blob/8190375/src/index.ts#L549)_
163159

164160
Gets a block by its hash.
165161

@@ -180,7 +176,7 @@ Gets a block by its hash.
180176

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

183-
_Defined in [index.ts:590](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L590)_
179+
_Defined in [index.ts:572](https://github.com/ethereumjs/ethereumjs-blockchain/blob/8190375/src/index.ts#L572)_
184180

185181
Looks up many blocks relative to blockId
186182

@@ -204,7 +200,7 @@ Looks up many blocks relative to blockId
204200

205201
**getDetails**(\_: _`string`_, cb: _`any`_): `void`
206202

207-
_Defined in [index.ts:631](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L631)_
203+
_Defined in [index.ts:613](https://github.com/ethereumjs/ethereumjs-blockchain/blob/8190375/src/index.ts#L613)_
208204

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

@@ -227,7 +223,7 @@ _**deprecated**_:
227223

228224
**getHead**(name: _`any`_, cb?: _`any`_): `void`
229225

230-
_Defined in [index.ts:278](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L278)_
226+
_Defined in [index.ts:260](https://github.com/ethereumjs/ethereumjs-blockchain/blob/8190375/src/index.ts#L260)_
231227

232228
Returns the specified iterator head.
233229

@@ -248,7 +244,7 @@ Returns the specified iterator head.
248244

249245
**getLatestBlock**(cb: _`any`_): `void`
250246

251-
_Defined in [index.ts:318](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L318)_
247+
_Defined in [index.ts:300](https://github.com/ethereumjs/ethereumjs-blockchain/blob/8190375/src/index.ts#L300)_
252248

253249
Returns the latest full block in the canonical chain.
254250

@@ -268,7 +264,7 @@ Returns the latest full block in the canonical chain.
268264

269265
**getLatestHeader**(cb: _`any`_): `void`
270266

271-
_Defined in [index.ts:301](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L301)_
267+
_Defined in [index.ts:283](https://github.com/ethereumjs/ethereumjs-blockchain/blob/8190375/src/index.ts#L283)_
272268

273269
Returns the latest header in the canonical chain.
274270

@@ -288,7 +284,7 @@ Returns the latest header in the canonical chain.
288284

289285
**iterator**(name: _`string`_, onBlock: _`any`_, cb: _`any`_): `void`
290286

291-
_Defined in [index.ts:964](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L964)_
287+
_Defined in [index.ts:946](https://github.com/ethereumjs/ethereumjs-blockchain/blob/8190375/src/index.ts#L946)_
292288

293289
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.
294290

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

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

313-
_Defined in [index.ts:347](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L347)_
309+
_Defined in [index.ts:329](https://github.com/ethereumjs/ethereumjs-blockchain/blob/8190375/src/index.ts#L329)_
314310

315311
Adds a block to the blockchain.
316312

@@ -332,7 +328,7 @@ Adds a block to the blockchain.
332328

333329
**putBlocks**(blocks: _`Array`<`any`>_, cb: _`any`_): `void`
334330

335-
_Defined in [index.ts:331](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L331)_
331+
_Defined in [index.ts:313](https://github.com/ethereumjs/ethereumjs-blockchain/blob/8190375/src/index.ts#L313)_
336332

337333
Adds many blocks to the blockchain.
338334

@@ -353,7 +349,7 @@ Adds many blocks to the blockchain.
353349

354350
**putGenesis**(genesis: _`any`_, cb: _`any`_): `void`
355351

356-
_Defined in [index.ts:268](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L268)_
352+
_Defined in [index.ts:250](https://github.com/ethereumjs/ethereumjs-blockchain/blob/8190375/src/index.ts#L250)_
357353

358354
Puts the genesis block in the database
359355

@@ -374,7 +370,7 @@ Puts the genesis block in the database
374370

375371
**putHeader**(header: _`object`_, cb: _`any`_): `void`
376372

377-
_Defined in [index.ts:379](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L379)_
373+
_Defined in [index.ts:361](https://github.com/ethereumjs/ethereumjs-blockchain/blob/8190375/src/index.ts#L361)_
378374

379375
Adds a header to the blockchain.
380376

@@ -395,7 +391,7 @@ Adds a header to the blockchain.
395391

396392
**putHeaders**(headers: _`Array`<`any`>_, cb: _`any`_): `void`
397393

398-
_Defined in [index.ts:363](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L363)_
394+
_Defined in [index.ts:345](https://github.com/ethereumjs/ethereumjs-blockchain/blob/8190375/src/index.ts#L345)_
399395

400396
Adds many headers to the blockchain.
401397

@@ -416,7 +412,7 @@ Adds many headers to the blockchain.
416412

417413
**selectNeededHashes**(hashes: _`Array`<`any`>_, cb: _`any`_): `void`
418414

419-
_Defined in [index.ts:641](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L641)_
415+
_Defined in [index.ts:623](https://github.com/ethereumjs/ethereumjs-blockchain/blob/8190375/src/index.ts#L623)_
420416

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

docs/interfaces/blockchainoptions.md

+5-31
Original file line numberDiff line numberDiff line change
@@ -12,37 +12,23 @@ This are the options that the Blockchain constructor can receive.
1212

1313
### Properties
1414

15-
- [blockDb](blockchainoptions.md#blockdb)
1615
- [chain](blockchainoptions.md#chain)
1716
- [common](blockchainoptions.md#common)
1817
- [db](blockchainoptions.md#db)
19-
- [detailsDb](blockchainoptions.md#detailsdb)
2018
- [hardfork](blockchainoptions.md#hardfork)
2119
- [validate](blockchainoptions.md#validate)
2220

2321
---
2422

2523
## Properties
2624

27-
<a id="blockdb"></a>
28-
29-
### `<Optional>` blockDb
30-
31-
**● blockDb**: _`any`_
32-
33-
_Defined in [index.ts:58](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L58)_
34-
35-
_**deprecated**_:
36-
37-
---
38-
3925
<a id="chain"></a>
4026

4127
### `<Optional>` chain
4228

4329
**● chain**: _`string` \| `number`_
4430

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

4733
The chain id or name. Default: `"mainnet"`.
4834

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

5541
**● common**: _`Common`_
5642

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

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

@@ -66,31 +52,19 @@ An alternative way to specify the chain and hardfork is by passing a Common inst
6652

6753
**● db**: _`any`_
6854

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

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

7359
---
7460

75-
<a id="detailsdb"></a>
76-
77-
### `<Optional>` detailsDb
78-
79-
**● detailsDb**: _`any`_
80-
81-
_Defined in [index.ts:63](https://github.com/ethereumjs/ethereumjs-blockchain/blob/29a8a30/src/index.ts#L63)_
82-
83-
_**deprecated**_:
84-
85-
---
86-
8761
<a id="hardfork"></a>
8862

8963
### `<Optional>` hardfork
9064

9165
**● hardfork**: _`string` \| `null`_
9266

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

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

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

10377
**● validate**: _`undefined` \| `false` \| `true`_
10478

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

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

src/index.ts

+1-24
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,6 @@ export interface BlockchainOptions {
5151
* supported: `Petersburg`.
5252
*/
5353
validate?: boolean
54-
55-
/**
56-
* @deprecated
57-
*/
58-
blockDb?: any
59-
60-
/**
61-
* @deprecated
62-
*/
63-
detailsDb?: any
6454
}
6555

6656
/**
@@ -129,13 +119,6 @@ export default class Blockchain {
129119
/**
130120
* Creates new Blockchain object
131121
*
132-
* **Deprecation note**:
133-
*
134-
* The old separated DB constructor parameters `opts.blockDB` and `opts.detailsDb` from before the Geth DB-compatible
135-
* `v3.0.0` release are deprecated and continued usage is discouraged. When provided `opts.blockDB` will be used as
136-
* `opts.db` and `opts.detailsDB` is ignored. On the storage level the DB formats are not compatible and it is not
137-
* possible to load an old-format DB state into a post-`v3.0.0` `Blockchain` object.
138-
*
139122
* @param opts - An object with the options that this constructor takes. See [[BlockchainOptions]].
140123
*/
141124
constructor(opts: BlockchainOptions = {}) {
@@ -150,14 +133,8 @@ export default class Blockchain {
150133
this._common = new Common(chain, hardfork)
151134
}
152135

153-
// backwards compatibility with older constructor interfaces
154-
if (opts.constructor.name === 'LevelUP') {
155-
opts = { db: opts }
156-
}
157-
this.db = opts.db || opts.blockDb
158-
159136
// defaults
160-
this.db = this.db ? this.db : level()
137+
this.db = opts.db ? opts.db : level()
161138
this.dbManager = new DBManager(this.db, this._common)
162139
this.validate = opts.validate === undefined ? true : opts.validate
163140
this.ethash = this.validate ? new Ethash(this.db) : null

test/index.ts

+1-10
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const level = require('level-mem')
1111
const testData = require('./testdata.json')
1212

1313
test('blockchain test', function(t) {
14-
t.plan(73)
14+
t.plan(70)
1515
const blockchain = new Blockchain()
1616
let genesisBlock: any
1717
const blocks: any[] = []
@@ -57,15 +57,6 @@ test('blockchain test', function(t) {
5757
done()
5858
})
5959
},
60-
function alternateConstructors(done) {
61-
const db = level()
62-
let blockchain = new Blockchain(db)
63-
t.equals(db, blockchain.db, 'support constructor with db parameter')
64-
blockchain = new Blockchain({ detailsDb: db, blockDb: db })
65-
t.equals(db, blockchain.db, 'support blockDb and detailsDb params')
66-
t.notOk((<any>blockchain).detailsDb, 'ignore detailsDb param')
67-
done()
68-
},
6960
function addgenesis(done) {
7061
genesisBlock = new Block()
7162
genesisBlock.setGenesisParams()

0 commit comments

Comments
 (0)