/** * Override this to use a {@link BlockStore} that isn't the default of {@link SPVBlockStore}. */ protected BlockStore provideBlockStore(File file) throws BlockStoreException { return new SPVBlockStore(params, file); }
/** * Override this to use a {@link BlockStore} that isn't the default of {@link SPVBlockStore}. */ protected BlockStore provideBlockStore(File file) throws BlockStoreException { return new SPVBlockStore(params, file); }
/** * Override this to use a {@link BlockStore} that isn't the default of {@link SPVBlockStore}. */ protected BlockStore provideBlockStore(File file) throws BlockStoreException { return new SPVBlockStore(params, file); }
/** * Override this to use a {@link BlockStore} that isn't the default of {@link SPVBlockStore}. */ protected BlockStore provideBlockStore(File file) throws BlockStoreException { return new SPVBlockStore(params, file); }
@Bean public SPVBlockStore blockStore(NetworkParameters chainNetworkParameters) throws IOException, BlockStoreException { File blockStoreFile = Files.createTempFile("chain", "tmp").toFile(); blockStoreFile.deleteOnExit(); if (blockStoreFile.exists()) { blockStoreFile.delete(); } return new SPVBlockStore(chainNetworkParameters, blockStoreFile); }
BlockStore blockStore; try { blockStore = new SPVBlockStore(networkParameters, blockStoreFile); } catch (BlockStoreException bse) { try { blockStore = new SPVBlockStore(networkParameters, blockStoreFile); } catch (BlockStoreException bse2) { log.error("Unrecoverable failure in opening block store. This is bad.", bse2.getMessage());
} else if (args[1].equals("SPV")) { Preconditions.checkArgument(args.length == 3); store = new SPVBlockStore(params, new File(args[2])); } else { System.err.println("Unknown store " + args[1]);
BlockStore blockStore; try { blockStore = new SPVBlockStore(networkParameters, blockStoreFile); blockStore = new SPVBlockStore(networkParameters, blockStoreFile); if (storedBlockStack != null && !storedBlockStack.isEmpty()) { StoredBlock loopStoredBlock = null;
blockStore = new SPVBlockStore(Constants.NETWORK_PARAMETERS, blockChainFile);
if (!chainFile.delete()) throw new IOException("Failed to delete chain file in preparation for restore."); vStore = new SPVBlockStore(params, chainFile); if (!chainFile.delete()) throw new IOException("Failed to delete chain file in preparation for restore."); vStore = new SPVBlockStore(params, chainFile);
if (!chainFile.delete()) throw new IOException("Failed to delete chain file in preparation for restore."); vStore = new SPVBlockStore(params, chainFile); if (!chainFile.delete()) throw new IOException("Failed to delete chain file in preparation for restore."); vStore = new SPVBlockStore(params, chainFile);
if (!chainFile.delete()) throw new IOException("Failed to delete chain file in preparation for restore."); vStore = new SPVBlockStore(params, chainFile); if (!chainFile.delete()) throw new IOException("Failed to delete chain file in preparation for restore."); vStore = new SPVBlockStore(params, chainFile);
if (!chainFile.delete()) throw new IOException("Failed to delete chain file in preparation for restore."); vStore = new SPVBlockStore(params, chainFile); if (!chainFile.delete()) throw new IOException("Failed to delete chain file in preparation for restore."); vStore = new SPVBlockStore(params, chainFile);
public void init () { synchronized (initialized) { if (!initialized) { try { blockStore = new SPVBlockStore(Constants.getNetwork(), new File("blockheaders")); } catch (Exception e) { blockStore = new MemoryBlockStore(Constants.getNetwork()); } try { blockChain = new BlockChain(Constants.getNetwork(), blockStore); peerGroup = new PeerGroup(Constants.getNetwork(), blockChain); peerGroup.addPeerDiscovery(new DnsDiscovery(Constants.getNetwork())); peerGroup.setDownloadTxDependencies(false); peerGroup.setBloomFilteringEnabled(false); peerGroup.setFastCatchupTimeSecs(System.currentTimeMillis()); peerGroup.start(); peerGroup.addEventListener(new EventListener(), Threading.SAME_THREAD); registerShutdownHook(); final DownloadProgressTracker listener = new DownloadProgressTracker(); peerGroup.startBlockChainDownload(listener); } catch (Exception e) { throw new RuntimeException(e); } initialized = true; } } }
SPVBlockStore chainStore = new SPVBlockStore(params, chainFile); BlockChain chain = new BlockChain(params, chainStore); PeerGroup peers = new PeerGroup(params, chain);
store = new SPVBlockStore(params, chainFileName); chain = new BlockChain(params, wallet, store); if (reset) {
@Test public void basics() throws Exception { NetworkParameters params = UnitTestParams.get(); File f = File.createTempFile("spvblockstore", null); f.delete(); f.deleteOnExit(); SPVBlockStore store = new SPVBlockStore(params, f); Address to = new ECKey().toAddress(params); // Check the first block in a new store is the genesis block. StoredBlock genesis = store.getChainHead(); assertEquals(params.getGenesisBlock(), genesis.getHeader()); assertEquals(0, genesis.getHeight()); // Build a new block. StoredBlock b1 = genesis.build(genesis.getHeader().createNextBlock(to).cloneAsHeader()); store.put(b1); store.setChainHead(b1); store.close(); // Check we can get it back out again if we rebuild the store object. store = new SPVBlockStore(params, f); StoredBlock b2 = store.get(b1.getHeader().getHash()); assertEquals(b1, b2); // Check the chain head was stored correctly also. StoredBlock chainHead = store.getChainHead(); assertEquals(b1, chainHead); } }