Small cleanup and optimization for Derby store

This commit is contained in:
Miron Cuperman 2011-12-16 14:04:06 -08:00 committed by Miron Cuperman
parent cf824dfbce
commit 826f2d2c51
2 changed files with 6 additions and 8 deletions

View file

@ -212,7 +212,7 @@ public class DerbyBlockStore implements BlockStore {
s.setBytes(1, stored.getHeader().getHash().getBytes());
s.setBytes(2, stored.getChainWork().toByteArray());
s.setLong(3, stored.getHeight());
s.setBytes(4, stored.getHeader().bitcoinSerialize());
s.setBytes(4, stored.getHeader().unsafeBitcoinSerialize());
s.executeUpdate();
s.close();
startCommitter();
@ -239,13 +239,8 @@ public class DerbyBlockStore implements BlockStore {
int height = results.getInt(2);
Block b = new Block(params, results.getBytes(3));
StoredBlock stored;
if (b.equals(params.genesisBlock)) {
stored = new StoredBlock(params.genesisBlock.cloneAsHeader(),
params.genesisBlock.getWork(), 0);
} else {
b.verifyHeader();
stored = new StoredBlock(b, chainWork, height);
}
return stored;
} catch (SQLException ex) {
throw new BlockStoreException(ex);

View file

@ -57,6 +57,9 @@ public class DerbyBlockStoreTest {
assertEquals(b1, b2);
// Check the chain head was stored correctly also.
assertEquals(b1, store.getChainHead());
StoredBlock g1 = store.get(params.genesisBlock.getHash());
assertEquals(params.genesisBlock, g1.getHeader());
store.dump();
}