@Test public void clear() throws Exception { SPVBlockStore store = new SPVBlockStore(UNITTEST, blockStoreFile); Address to = LegacyAddress.fromKey(UNITTEST, new ECKey()); StoredBlock genesis = store.getChainHead(); StoredBlock b1 = genesis.build(genesis.getHeader().createNextBlock(to).cloneAsHeader()); store.put(b1); store.setChainHead(b1); assertEquals(b1.getHeader().getHash(), store.getChainHead().getHeader().getHash()); store.clear(); assertNull(store.get(b1.getHeader().getHash())); assertEquals(UNITTEST.getGenesisBlock().getHash(), store.getChainHead().getHeader().getHash()); store.close(); }
public void clear() throws Exception { lock.lock(); try { blockCache.clear(); notFoundCache.clear(); buffer.position(0); long fileLength = randomAccessFile.length(); for (int i = 0; i < fileLength; i++) { buffer.put((byte)0); } buffer.position(0); initNewStore(params); } finally { lock.unlock(); } }
SPVBlockStore implements BlockStore { public void clear() throws Exception { lock.lock(); try { blockCache.clear(); notFoundCache.clear(); buffer.position(0); long fileLength = randomAccessFile.length(); for (int i = 0; i < fileLength; i++) { buffer.put((byte)0); } buffer.position(0); initNewStore(params); } finally { lock.unlock(); } } }
SPVBlockStore implements BlockStore { public void clear() throws Exception { lock.lock(); try { blockCache.clear(); notFoundCache.clear(); buffer.position(0); long fileLength = randomAccessFile.length(); for (int i = 0; i < fileLength; i++) { buffer.put((byte)0); } buffer.position(0); initNewStore(params); } finally { lock.unlock(); } } SPVBlockStore(NetworkParameters params, File file);  SPVBlockStore(NetworkParameters params, File file, int capacity, boolean grow); }
SPVBlockStore implements BlockStore { public void clear() throws Exception { lock.lock(); try { blockCache.clear(); notFoundCache.clear(); buffer.position(0); long fileLength = randomAccessFile.length(); for (int i = 0; i < fileLength; i++) { buffer.put((byte)0); } buffer.position(0); initNewStore(params); } finally { lock.unlock(); } } SPVBlockStore(NetworkParameters params, File file);  SPVBlockStore(NetworkParameters params, File file, int capacity, boolean grow); static final int getFileSize(int capacity); @Override void put(StoredBlock block); @Override @Nullable StoredBlock get(Sha256Hash hash); @Override StoredBlock getChainHead(); @Override void setChainHead(StoredBlock chainHead); @Override void close(); @Override NetworkParameters getParams(); void clear(); }
SPVBlockStore implements BlockStore { public void clear() throws Exception { lock.lock(); try { blockCache.clear(); notFoundCache.clear(); buffer.position(0); long fileLength = randomAccessFile.length(); for (int i = 0; i < fileLength; i++) { buffer.put((byte)0); } buffer.position(0); initNewStore(params); } finally { lock.unlock(); } } SPVBlockStore(NetworkParameters params, File file);  SPVBlockStore(NetworkParameters params, File file, int capacity, boolean grow); static final int getFileSize(int capacity); @Override void put(StoredBlock block); @Override @Nullable StoredBlock get(Sha256Hash hash); @Override StoredBlock getChainHead(); @Override void setChainHead(StoredBlock chainHead); @Override void close(); @Override NetworkParameters getParams(); void clear(); static final int DEFAULT_CAPACITY; static final String HEADER_MAGIC; }