mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-02-24 22:58:32 +01:00
Small cleanup and optimization for Derby store
This commit is contained in:
parent
cf824dfbce
commit
826f2d2c51
2 changed files with 6 additions and 8 deletions
|
@ -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);
|
||||
}
|
||||
b.verifyHeader();
|
||||
stored = new StoredBlock(b, chainWork, height);
|
||||
return stored;
|
||||
} catch (SQLException ex) {
|
||||
throw new BlockStoreException(ex);
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue