InMemoryBlockStore implements BlockStore { @Override public Block getBlockByNumber(long blockNumber) { Block block = numberIndex.get(blockNumber); if (block == null) return dbGetBlockByNumber(blockNumber); else return block; } InMemoryBlockStore(); @Override byte[] getBlockHashByNumber(long blockNumber); @Override Block getBlockByNumber(long blockNumber); @Override Block getBlockByHash(byte[] hash); @Override List<byte[]> getListHashesEndWith(byte[] hash, long qty); @Override void saveBlock(Block block, List<TransactionReceipt> receipts); @Override BigInteger getTotalDifficulty(); @Override Block getBestBlock(); byte[] dbGetBlockHashByNumber(long blockNumber); Block dbGetBlockByNumber(long blockNumber); Block dbGetBlockByHash(byte[] hash); @Override void flush(); void load(); @Override void setSessionFactory(SessionFactory sessionFactory);  }
@Test public void testGetBlockByNumber() { BlockStore blockStore = new InMemoryBlockStore(); SessionFactory sessionFactory = sessionFactory(); blockStore.setSessionFactory(sessionFactory); for( Block block : blocks ){ blockStore.saveBlock(block, null); } assertEquals("4312750101", blockStore.getTotalDifficulty().toString()); blockStore.flush(); assertEquals("4312750101", blockStore.getTotalDifficulty().toString()); }