saifi009 / bitcoinj

Automatically exported from code.google.com/p/bitcoinj
0 stars 0 forks source link

Patch for allowing alternative BlockStores into BlockChain #6

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Index: src/com/google/bitcoin/core/BlockChain.java
===================================================================
--- src/com/google/bitcoin/core/BlockChain.java (revision 40)
+++ src/com/google/bitcoin/core/BlockChain.java (working copy)
@@ -68,8 +68,11 @@
     private final ArrayList<Block> unconnectedBlocks = new ArrayList<Block>();

     public BlockChain(NetworkParameters params, Wallet wallet) {
-        // TODO: Let the user pass in a BlockStore object so they can choose 
how to store the headers.
-        blockStore = new MemoryBlockStore();
+   this(params, wallet, new MemoryBlockStore());
+    }
+    
+    public BlockChain(NetworkParameters params, Wallet wallet, final 
BlockStore blockStore) {
+        this.blockStore = blockStore; 
         try {
             // Set up the genesis block. When we start out fresh, it is by definition the top of the chain.
             Block genesisHeader = params.genesisBlock.cloneAsHeader();

Original issue reported on code.google.com by andreas....@gmail.com on 26 Mar 2011 at 12:17

GoogleCodeExporter commented 9 years ago
Also fixed with my own change. Specifying a store is now required, it does not 
default to the memory store.

Original comment by hearn@google.com on 28 Mar 2011 at 6:02