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
30
51
31
52
### `new Blockchain(opts)`
32
53
Creates new Blockchain object
33
-
-`opts.blockDB` - the database where Blocks are stored and retreived by hash. Should be a [levelup](https://github.com/rvagg/node-levelup) instance.
34
-
-`opts.detailsDB` - the database where Block number resolutions and other metadata is stored. Should be a [levelup](https://github.com/rvagg/node-levelup) instance.
54
+
-`opts.db` - Database to store blocks and metadata. Should be a [levelup](https://github.com/rvagg/node-levelup) instance.
35
55
-`opts.validate` - this the flag to validate blocks (e.g. Proof-of-Work).
36
56
37
-
### `BlockChain` Properties
38
-
-`head` - The Head, the block that has the most weight
39
-
-`parentHead`- The parent of the head block
40
-
-`genesisHash` - The hash of the genesis block
41
-
-`height` - The height of the blockchain
42
-
-`totallDifficulty` - The totall difficulty which is the some of a the difficulty of all the prevous blocks
57
+
[DEPRECATION NOTE]
58
+
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
59
+
as `opts.db` and `opts.detailsDB` is ignored. On the storage level the DB formats are not compatible and it is not
60
+
possible to load an old-format DB state into a post-``v3.0.0````Blockchain`` object.
43
61
44
62
### `BlockChain` methods
45
63
46
-
#### `blockchain.putBlock(block, callback)`
64
+
#### `blockchain.putGenesis(genesis, cb)`
65
+
Puts the genesis block in the database.
66
+
-`genesis` - the genesis block to be added
67
+
-`cb` - the callback. It is given two parameters `err` and the saved `block`
-`callback` - the callback. It is given two parameters `err` and the found `block` (an instance of https://github.com/ethereumjs/ethereumjs-block) if any.
94
+
-`cb` - the callback. It is given two parameters `err` and the found `block` (an instance of https://github.com/ethereumjs/ethereumjs-block) if any.
Gets a segment of the blockchain starting at the parent hash and contuning for `count ` blocks returning an array of block hashes orders from oldest to youngest.
76
-
-`parentHash` - the block to start from. Given as a `Buffer` or a hex `String`
77
-
-`count` - a `Number` specifing how many block hashes to return
78
-
-`callback` - the callback which is give an array of block hashes
gets a section of the blockchain in a form of an array starting at the parent hash, up `count` blocks
85
-
-`startingHashes` - an array of hashes or a single hash to start returning the chain from. The first hash in the array that is found in the blockchain will be used.
86
-
-`count` - the max number of blocks to return
87
-
-`callback` - the callback. It is given two parameters `err` and `blockchain`. `err` is any errors. If none of the starting hashes were found `err` will be `notFound`. `blockchain` is an array of blocks.
120
+
#### `blockchain.delBlock(blockHash, cb)`
121
+
Deletes a block from the blockchain. All child blocks in the chain are deleted and any encountered heads are set to the parent block
122
+
-`blockHash` - the hash of the block to be deleted
0 commit comments