private void initFromDb() throws BlockStoreException { Sha256Hash hash = Sha256Hash.wrap(batchGet(getKey(KeyType.CHAIN_HEAD_SETTING))); this.chainHeadBlock = get(hash); this.chainHeadHash = hash; if (this.chainHeadBlock == null) { throw new BlockStoreException("corrupt database block store - head block not found"); } hash = Sha256Hash.wrap(batchGet(getKey(KeyType.VERIFIED_CHAIN_HEAD_SETTING))); this.verifiedChainHeadBlock = get(hash); this.verifiedChainHeadHash = hash; if (this.verifiedChainHeadBlock == null) { throw new BlockStoreException("corrupt databse block store - verified head block not found"); } }
private void initFromDb() throws BlockStoreException { Sha256Hash hash = Sha256Hash.wrap(batchGet(getKey(KeyType.CHAIN_HEAD_SETTING))); this.chainHeadBlock = get(hash); this.chainHeadHash = hash; if (this.chainHeadBlock == null) { throw new BlockStoreException("corrupt database block store - head block not found"); } hash = Sha256Hash.wrap(batchGet(getKey(KeyType.VERIFIED_CHAIN_HEAD_SETTING))); this.verifiedChainHeadBlock = get(hash); this.verifiedChainHeadHash = hash; if (this.verifiedChainHeadBlock == null) { throw new BlockStoreException("corrupt databse block store - verified head block not found"); } }
private void initFromDb() throws BlockStoreException { Sha256Hash hash = Sha256Hash.wrap(batchGet(getKey(KeyType.CHAIN_HEAD_SETTING))); this.chainHeadBlock = get(hash); this.chainHeadHash = hash; if (this.chainHeadBlock == null) { throw new BlockStoreException("corrupt database block store - head block not found"); } hash = Sha256Hash.wrap(batchGet(getKey(KeyType.VERIFIED_CHAIN_HEAD_SETTING))); this.verifiedChainHeadBlock = get(hash); this.verifiedChainHeadHash = hash; if (this.verifiedChainHeadBlock == null) { throw new BlockStoreException("corrupt databse block store - verified head block not found"); } }
private void initFromDb() throws BlockStoreException { Sha256Hash hash = Sha256Hash.wrap(batchGet(getKey(KeyType.CHAIN_HEAD_SETTING))); this.chainHeadBlock = get(hash); this.chainHeadHash = hash; if (this.chainHeadBlock == null) { throw new BlockStoreException("corrupt database block store - head block not found"); } hash = Sha256Hash.wrap(batchGet(getKey(KeyType.VERIFIED_CHAIN_HEAD_SETTING))); this.verifiedChainHeadBlock = get(hash); this.verifiedChainHeadHash = hash; if (this.verifiedChainHeadBlock == null) { throw new BlockStoreException("corrupt databse block store - verified head block not found"); } }
byte[] inbytes = batchGet(key); if (inbytes == null) { if (instrument)
byte[] inbytes = batchGet(key); if (inbytes == null) { if (instrument)
byte[] inbytes = batchGet(key); if (inbytes == null) { if (instrument)
beginMethod("getUndoBlock"); byte[] result = batchGet(getKey(KeyType.UNDOABLEBLOCKS_ALL, hash));
byte[] inbytes = batchGet(key); if (inbytes == null) { if (instrument)
beginMethod("getUndoBlock"); byte[] result = batchGet(getKey(KeyType.UNDOABLEBLOCKS_ALL, hash));
beginMethod("getUndoBlock"); byte[] result = batchGet(getKey(KeyType.UNDOABLEBLOCKS_ALL, hash));
beginMethod("getUndoBlock"); byte[] result = batchGet(getKey(KeyType.UNDOABLEBLOCKS_ALL, hash));
private void openDB() { Options options = new Options(); options.createIfMissing(true); // options.compressionType(CompressionType.NONE); options.cacheSize(leveldbReadCache); options.writeBufferSize(leveldbWriteCache); options.maxOpenFiles(10000); // options.blockSize(1024*1024*50); try { db = factory.open(new File(filename), options); } catch (IOException e) { throw new RuntimeException("Can not open DB", e); } utxoCache = new LRUCache(openOutCache, 0.75f); try { if (batchGet(getKey(KeyType.CREATED)) == null) { createNewStore(params); } else { initFromDb(); } } catch (BlockStoreException e) { throw new RuntimeException("Can not init/load db", e); } }
private void openDB() { Options options = new Options(); options.createIfMissing(true); // options.compressionType(CompressionType.NONE); options.cacheSize(leveldbReadCache); options.writeBufferSize(leveldbWriteCache); options.maxOpenFiles(10000); // options.blockSize(1024*1024*50); try { db = factory.open(new File(filename), options); } catch (IOException e) { throw new RuntimeException("Can not open DB", e); } utxoCache = new LRUCache(openOutCache, 0.75f); try { if (batchGet(getKey(KeyType.CREATED)) == null) { createNewStore(params); } else { initFromDb(); } } catch (BlockStoreException e) { throw new RuntimeException("Can not init/load db", e); } }
private void openDB() { Options options = new Options(); options.createIfMissing(true); // options.compressionType(CompressionType.NONE); options.cacheSize(leveldbReadCache); options.writeBufferSize(leveldbWriteCache); options.maxOpenFiles(10000); // options.blockSize(1024*1024*50); try { db = factory.open(new File(filename), options); } catch (IOException e) { throw new RuntimeException("Can not open DB", e); } utxoCache = new LRUCache(openOutCache, 0.75f); try { if (batchGet(getKey(KeyType.CREATED)) == null) { createNewStore(params); } else { initFromDb(); } } catch (BlockStoreException e) { throw new RuntimeException("Can not init/load db", e); } }
private void openDB() { Options options = new Options(); options.createIfMissing(true); // options.compressionType(CompressionType.NONE); options.cacheSize(leveldbReadCache); options.writeBufferSize(leveldbWriteCache); options.maxOpenFiles(10000); // options.blockSize(1024*1024*50); try { db = factory.open(new File(filename), options); } catch (IOException e) { throw new RuntimeException("Can not open DB", e); } utxoCache = new LRUCache(openOutCache, 0.75f); try { if (batchGet(getKey(KeyType.CREATED)) == null) { createNewStore(params); } else { initFromDb(); } } catch (BlockStoreException e) { throw new RuntimeException("Can not init/load db", e); } }
public StoredBlock get(Sha256Hash hash, boolean wasUndoableOnly) throws BlockStoreException { // Optimize for chain head if (chainHeadHash != null && chainHeadHash.equals(hash)) return chainHeadBlock; if (verifiedChainHeadHash != null && verifiedChainHeadHash.equals(hash)) return verifiedChainHeadBlock; if (instrument) beginMethod("get");// ignore optimised case as not interesting for // tuning. boolean undoableResult; byte[] result = batchGet(getKey(KeyType.HEADERS_ALL, hash)); if (result == null) { if (instrument) endMethod("get"); return null; } undoableResult = (result[96] == 1 ? true : false); if (wasUndoableOnly && !undoableResult) { if (instrument) endMethod("get"); return null; } // TODO Should I chop the last byte off? Seems to work with it left // there... StoredBlock stored = StoredBlock.deserializeCompact(params, ByteBuffer.wrap(result)); stored.getHeader().verifyHeader(); if (instrument) endMethod("get"); return stored; }
public StoredBlock get(Sha256Hash hash, boolean wasUndoableOnly) throws BlockStoreException { // Optimize for chain head if (chainHeadHash != null && chainHeadHash.equals(hash)) return chainHeadBlock; if (verifiedChainHeadHash != null && verifiedChainHeadHash.equals(hash)) return verifiedChainHeadBlock; if (instrument) beginMethod("get");// ignore optimised case as not interesting for // tuning. boolean undoableResult; byte[] result = batchGet(getKey(KeyType.HEADERS_ALL, hash)); if (result == null) { if (instrument) endMethod("get"); return null; } undoableResult = (result[96] == 1 ? true : false); if (wasUndoableOnly && !undoableResult) { if (instrument) endMethod("get"); return null; } // TODO Should I chop the last byte off? Seems to work with it left // there... StoredBlock stored = StoredBlock.deserializeCompact(params, ByteBuffer.wrap(result)); stored.getHeader().verifyHeader(); if (instrument) endMethod("get"); return stored; }
public StoredBlock get(Sha256Hash hash, boolean wasUndoableOnly) throws BlockStoreException { // Optimize for chain head if (chainHeadHash != null && chainHeadHash.equals(hash)) return chainHeadBlock; if (verifiedChainHeadHash != null && verifiedChainHeadHash.equals(hash)) return verifiedChainHeadBlock; if (instrument) beginMethod("get");// ignore optimised case as not interesting for // tuning. boolean undoableResult; byte[] result = batchGet(getKey(KeyType.HEADERS_ALL, hash)); if (result == null) { if (instrument) endMethod("get"); return null; } undoableResult = (result[96] == 1 ? true : false); if (wasUndoableOnly && !undoableResult) { if (instrument) endMethod("get"); return null; } // TODO Should I chop the last byte off? Seems to work with it left // there... StoredBlock stored = StoredBlock.deserializeCompact(params, ByteBuffer.wrap(result)); stored.getHeader().verifyHeader(); if (instrument) endMethod("get"); return stored; }
public StoredBlock get(Sha256Hash hash, boolean wasUndoableOnly) throws BlockStoreException { // Optimize for chain head if (chainHeadHash != null && chainHeadHash.equals(hash)) return chainHeadBlock; if (verifiedChainHeadHash != null && verifiedChainHeadHash.equals(hash)) return verifiedChainHeadBlock; if (instrument) beginMethod("get");// ignore optimised case as not interesting for // tuning. boolean undoableResult; byte[] result = batchGet(getKey(KeyType.HEADERS_ALL, hash)); if (result == null) { if (instrument) endMethod("get"); return null; } undoableResult = (result[96] == 1 ? true : false); if (wasUndoableOnly && !undoableResult) { if (instrument) endMethod("get"); return null; } // TODO Should I chop the last byte off? Seems to work with it left // there... StoredBlock stored = StoredBlock.deserializeCompact(params, ByteBuffer.wrap(result)); stored.getHeader().verifyHeader(); if (instrument) endMethod("get"); return stored; }