@@ -20,6 +20,52 @@ const Stoplight = require('flow-stoplight')
2020const  level  =  require ( 'level-mem' ) 
2121const  semaphore  =  require ( 'semaphore' ) 
2222
23+ export  type  Block  =  any 
24+ 
25+ export  interface  BlockchainInterface  { 
26+   /** 
27+    * Adds a block to the blockchain. 
28+    * 
29+    * @param  block - The block to be added to the blockchain. 
30+    * @param  cb - The callback. It is given two parameters `err` and the saved `block` 
31+    * @param  isGenesis - True if block is the genesis block. 
32+    */ 
33+   putBlock ( block : Block ,  cb : any ,  isGenesis ?: boolean ) : void 
34+ 
35+   /** 
36+    * Deletes a block from the blockchain. All child blocks in the chain are deleted and any 
37+    * encountered heads are set to the parent block. 
38+    * 
39+    * @param  blockHash - The hash of the block to be deleted 
40+    * @param  cb - A callback. 
41+    */ 
42+   delBlock ( blockHash : Buffer ,  cb : any ) : void 
43+ 
44+   /** 
45+    * Returns a block by its hash or number. 
46+    */ 
47+   getBlock ( blockTag : Buffer  |  number  |  BN ,  cb : ( err : Error  |  null ,  block ?: Block )  =>  void ) : void 
48+ 
49+   /** 
50+    * Iterates through blocks starting at the specified iterator head and calls the onBlock function 
51+    * on each block. 
52+    * 
53+    * @param  name - Name of the state root head 
54+    * @param  onBlock - Function called on each block with params (block, reorg, cb) 
55+    * @param  cb - A callback function 
56+    */ 
57+   iterator ( name : string ,  onBlock : any ,  cb : any ) : void 
58+ 
59+   /** 
60+    * This method is only here for backwards compatibility. It can be removed once 
61+    * [this PR](https://github.com/ethereumjs/ethereumjs-block/pull/72/files) gets merged, released, 
62+    * and ethereumjs-block is updated here. 
63+    * 
64+    * The method should just call `cb` with `null` as first argument. 
65+    */ 
66+   getDetails ( _ : string ,  cb : any ) : void 
67+ } 
68+ 
2369/** 
2470 * This are the options that the Blockchain constructor can receive. 
2571 */ 
@@ -56,7 +102,7 @@ export interface BlockchainOptions {
56102/** 
57103 * This class stores and interacts with blocks. 
58104 */ 
59- export  default  class  Blockchain  { 
105+ export  default  class  Blockchain  implements   BlockchainInterface   { 
60106  /** 
61107   * @hidden  
62108   */ 
0 commit comments