Fix: Block headers received (save to fullstore) that are >80 in length i.e includes tx. Tx are removed when saving the header.

This commit is contained in:
Kalpesh Parmar
2015-06-15 11:55:52 +01:00
committed by Mike Hearn
parent 1d96e1ad1d
commit b11c17a5f6
2 changed files with 4 additions and 3 deletions

View File

@@ -664,14 +664,15 @@ public abstract class AbstractBlockChain {
// Walk in ascending chronological order.
for (Iterator<StoredBlock> it = newBlocks.descendingIterator(); it.hasNext();) {
cursor = it.next();
if (expensiveChecks && cursor.getHeader().getTimeSeconds() <= getMedianTimestampOfRecentBlocks(cursor.getPrev(blockStore), blockStore))
Block cursorBlock = cursor.getHeader();
if (expensiveChecks && cursorBlock.getTimeSeconds() <= getMedianTimestampOfRecentBlocks(cursor.getPrev(blockStore), blockStore))
throw new VerificationException("Block's timestamp is too early during reorg");
TransactionOutputChanges txOutChanges;
if (cursor != newChainHead || block == null)
txOutChanges = connectTransactions(cursor);
else
txOutChanges = connectTransactions(newChainHead.getHeight(), block);
storedNewHead = addToBlockStore(storedNewHead, cursor.getHeader(), txOutChanges);
storedNewHead = addToBlockStore(storedNewHead, cursorBlock.cloneAsHeader(), txOutChanges);
}
} else {
// (Finally) write block to block store

View File

@@ -619,7 +619,7 @@ public abstract class DatabaseFullPrunedBlockStore implements FullPrunedBlockSto
s.setBytes(1, hashBytes);
s.setBytes(2, storedBlock.getChainWork().toByteArray());
s.setInt(3, storedBlock.getHeight());
s.setBytes(4, storedBlock.getHeader().unsafeBitcoinSerialize());
s.setBytes(4, storedBlock.getHeader().cloneAsHeader().unsafeBitcoinSerialize());
s.setBoolean(5, wasUndoable);
s.executeUpdate();
s.close();