public void resetStore() { // only used in unit tests. // bit dangerous and deletes files! try { db.close(); uncommited = null; uncommitedDeletes = null; autoCommit = true; bloom = new BloomFilter(); utxoCache = new LRUCache(openOutCache, 0.75f); } catch (IOException e) { log.error("Exception in resetStore.", e); } File f = new File(filename); if (f.isDirectory()) { for (File c : f.listFiles()) c.delete(); } openDB(); } }
void dumpStats() { long wallTimeNanos = totalStopwatch.elapsed(TimeUnit.NANOSECONDS); long dbtime = 0; for (String name : methodCalls.keySet()) { long calls = methodCalls.get(name); long time = methodTotalTime.get(name); dbtime += time; long average = time / calls; double proportion = (time + 0.0) / (wallTimeNanos + 0.0); log.info(name + " c:" + calls + " r:" + time + " a:" + average + " p:" + String.format("%.2f", proportion)); } double dbproportion = (dbtime + 0.0) / (wallTimeNanos + 0.0); double hitrate = (hit + 0.0) / (hit + miss + 0.0); log.info("Cache size:" + utxoCache.size() + " hit:" + hit + " miss:" + miss + " rate:" + String.format("%.2f", hitrate)); bloom.printStat(); log.info("hasTxOut call:" + hasCall + " True:" + hasTrue + " False:" + hasFalse); log.info("Wall:" + totalStopwatch + " percent:" + String.format("%.2f", dbproportion)); String stats = db.getProperty("leveldb.stats"); System.out.println(stats); }
public LevelDBFullPrunedBlockStore(NetworkParameters params, String filename, int blockCount, long leveldbReadCache, int leveldbWriteCache, int openOutCache, boolean instrument, int exitBlock) { this.params = params; fullStoreDepth = blockCount; this.instrument = instrument; this.exitBlock = exitBlock; methodStartTime = new HashMap<String, Stopwatch>(); methodCalls = new HashMap<String, Long>(); methodTotalTime = new HashMap<String, Long>(); this.filename = filename; this.leveldbReadCache = leveldbReadCache; this.leveldbWriteCache = leveldbWriteCache; this.openOutCache = openOutCache; bloom = new BloomFilter(); totalStopwatch = Stopwatch.createStarted(); openDB(); bloom.reloadCache(db); // Reset after bloom filter loaded totalStopwatch = Stopwatch.createStarted(); }
beginMethod("hasUnspentOutputs"); hasCall++; if (!bloom.wasAdded(hash)) { if (instrument) endMethod("hasUnspentOutputs");
bloom.add(out.getHash()); ByteArrayOutputStream bos = new ByteArrayOutputStream(); try {
beginMethod("hasUnspentOutputs"); hasCall++; if (!bloom.wasAdded(hash)) { if (instrument) endMethod("hasUnspentOutputs");
beginMethod("hasUnspentOutputs"); hasCall++; if (!bloom.wasAdded(hash)) { if (instrument) endMethod("hasUnspentOutputs");
bloom.add(out.getHash()); ByteArrayOutputStream bos = new ByteArrayOutputStream(); try {
bloom.add(out.getHash()); ByteArrayOutputStream bos = new ByteArrayOutputStream(); try {
bloom.add(out.getHash()); ByteArrayOutputStream bos = new ByteArrayOutputStream(); try {
beginMethod("hasUnspentOutputs"); hasCall++; if (!bloom.wasAdded(hash)) { if (instrument) endMethod("hasUnspentOutputs");
public void reloadCache(DB db) { // LevelDB is great at scanning consecutive keys. // This take seconds even with 20m keys to add. log.info("Loading Bloom Filter"); DBIterator iterator = db.iterator(); byte[] key = getKey(KeyType.OPENOUT_ALL); for (iterator.seek(key); iterator.hasNext(); iterator.next()) { ByteBuffer bbKey = ByteBuffer.wrap(iterator.peekNext().getKey()); byte firstByte = bbKey.get(); // remove the KeyType.OPENOUT_ALL // byte. if (key[0] != firstByte) { printStat(); return; } byte[] hash = new byte[32]; bbKey.get(hash); add(hash); } try { iterator.close(); } catch (IOException e) { log.error("Error closing iterator", e); } printStat(); }
public void reloadCache(DB db) { // LevelDB is great at scanning consecutive keys. // This take seconds even with 20m keys to add. log.info("Loading Bloom Filter"); DBIterator iterator = db.iterator(); byte[] key = getKey(KeyType.OPENOUT_ALL); for (iterator.seek(key); iterator.hasNext(); iterator.next()) { ByteBuffer bbKey = ByteBuffer.wrap(iterator.peekNext().getKey()); byte firstByte = bbKey.get(); // remove the KeyType.OPENOUT_ALL // byte. if (key[0] != firstByte) { printStat(); return; } byte[] hash = new byte[32]; bbKey.get(hash); add(hash); } try { iterator.close(); } catch (IOException e) { log.error("Error closing iterator", e); } printStat(); }
public void reloadCache(DB db) { // LevelDB is great at scanning consecutive keys. // This take seconds even with 20m keys to add. log.info("Loading Bloom Filter"); DBIterator iterator = db.iterator(); byte[] key = getKey(KeyType.OPENOUT_ALL); for (iterator.seek(key); iterator.hasNext(); iterator.next()) { ByteBuffer bbKey = ByteBuffer.wrap(iterator.peekNext().getKey()); byte firstByte = bbKey.get(); // remove the KeyType.OPENOUT_ALL // byte. if (key[0] != firstByte) { printStat(); return; } byte[] hash = new byte[32]; bbKey.get(hash); add(hash); } try { iterator.close(); } catch (IOException e) { log.error("Error closing iterator", e); } printStat(); }
public void reloadCache(DB db) { // LevelDB is great at scanning consecutive keys. // This take seconds even with 20m keys to add. log.info("Loading Bloom Filter"); DBIterator iterator = db.iterator(); byte[] key = getKey(KeyType.OPENOUT_ALL); for (iterator.seek(key); iterator.hasNext(); iterator.next()) { ByteBuffer bbKey = ByteBuffer.wrap(iterator.peekNext().getKey()); byte firstByte = bbKey.get(); // remove the KeyType.OPENOUT_ALL // byte. if (key[0] != firstByte) { printStat(); return; } byte[] hash = new byte[32]; bbKey.get(hash); add(hash); } try { iterator.close(); } catch (IOException e) { log.error("Error closing iterator", e); } printStat(); }
void dumpStats() { long wallTimeNanos = totalStopwatch.elapsed(TimeUnit.NANOSECONDS); long dbtime = 0; for (String name : methodCalls.keySet()) { long calls = methodCalls.get(name); long time = methodTotalTime.get(name); dbtime += time; long average = time / calls; double proportion = (time + 0.0) / (wallTimeNanos + 0.0); log.info(name + " c:" + calls + " r:" + time + " a:" + average + " p:" + String.format("%.2f", proportion)); } double dbproportion = (dbtime + 0.0) / (wallTimeNanos + 0.0); double hitrate = (hit + 0.0) / (hit + miss + 0.0); log.info("Cache size:" + utxoCache.size() + " hit:" + hit + " miss:" + miss + " rate:" + String.format("%.2f", hitrate)); bloom.printStat(); log.info("hasTxOut call:" + hasCall + " True:" + hasTrue + " False:" + hasFalse); log.info("Wall:" + totalStopwatch + " percent:" + String.format("%.2f", dbproportion)); String stats = db.getProperty("leveldb.stats"); System.out.println(stats); }
public void resetStore() { // only used in unit tests. // bit dangerous and deletes files! try { db.close(); uncommited = null; uncommitedDeletes = null; autoCommit = true; bloom = new BloomFilter(); utxoCache = new LRUCache(openOutCache, 0.75f); } catch (IOException e) { log.error("Exception in resetStore.", e); } File f = new File(filename); if (f.isDirectory()) { for (File c : f.listFiles()) c.delete(); } openDB(); } }
public void resetStore() { // only used in unit tests. // bit dangerous and deletes files! try { db.close(); uncommited = null; uncommitedDeletes = null; autoCommit = true; bloom = new BloomFilter(); utxoCache = new LRUCache(openOutCache, 0.75f); } catch (IOException e) { log.error("Exception in resetStore.", e); } File f = new File(filename); if (f.isDirectory()) { for (File c : f.listFiles()) c.delete(); } openDB(); } }
void dumpStats() { long wallTimeNanos = totalStopwatch.elapsed(TimeUnit.NANOSECONDS); long dbtime = 0; for (String name : methodCalls.keySet()) { long calls = methodCalls.get(name); long time = methodTotalTime.get(name); dbtime += time; long average = time / calls; double proportion = (time + 0.0) / (wallTimeNanos + 0.0); log.info(name + " c:" + calls + " r:" + time + " a:" + average + " p:" + String.format("%.2f", proportion)); } double dbproportion = (dbtime + 0.0) / (wallTimeNanos + 0.0); double hitrate = (hit + 0.0) / (hit + miss + 0.0); log.info("Cache size:" + utxoCache.size() + " hit:" + hit + " miss:" + miss + " rate:" + String.format("%.2f", hitrate)); bloom.printStat(); log.info("hasTxOut call:" + hasCall + " True:" + hasTrue + " False:" + hasFalse); log.info("Wall:" + totalStopwatch + " percent:" + String.format("%.2f", dbproportion)); String stats = db.getProperty("leveldb.stats"); System.out.println(stats); }
void dumpStats() { long wallTimeNanos = totalStopwatch.elapsed(TimeUnit.NANOSECONDS); long dbtime = 0; for (String name : methodCalls.keySet()) { long calls = methodCalls.get(name); long time = methodTotalTime.get(name); dbtime += time; long average = time / calls; double proportion = (time + 0.0) / (wallTimeNanos + 0.0); log.info(name + " c:" + calls + " r:" + time + " a:" + average + " p:" + String.format("%.2f", proportion)); } double dbproportion = (dbtime + 0.0) / (wallTimeNanos + 0.0); double hitrate = (hit + 0.0) / (hit + miss + 0.0); log.info("Cache size:" + utxoCache.size() + " hit:" + hit + " miss:" + miss + " rate:" + String.format("%.2f", hitrate)); bloom.printStat(); log.info("hasTxOut call:" + hasCall + " True:" + hasTrue + " False:" + hasFalse); log.info("Wall:" + totalStopwatch + " percent:" + String.format("%.2f", dbproportion)); String stats = db.getProperty("leveldb.stats"); System.out.println(stats); }