3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-01-30 14:52:16 +00:00

Remove redundant query in H2FullPrunedBlockStore.

Patch from Eric W Dickerson. Resolves issue 441.
This commit is contained in:
Mike Hearn 2013-10-23 14:22:44 +02:00
parent f315125bf5
commit 5a3aa5d6e1
2 changed files with 4 additions and 3 deletions

View File

@ -18,3 +18,4 @@ Mark van Cuijk <phedny@gmail.com>
Matt Corallo <git@bluematt.me>
Alexander Lolis <alexander.lolis@gmail.com>
Matija Mazi <matija.mazi@gmail.com>
Eric William Dickerson <eric.w.dickerson@gmail.com>

View File

@ -686,9 +686,6 @@ public class H2FullPrunedBlockStore implements FullPrunedBlockStore {
public void removeUnspentTransactionOutput(StoredTransactionOutput out) throws BlockStoreException {
maybeConnect();
// TODO: This should only need one query (maybe a stored procedure)
if (getTransactionOutput(out.getHash(), out.getIndex()) == null)
throw new BlockStoreException("Tried to remove a StoredTransactionOutput from H2FullPrunedBlockStore that it didn't have!");
try {
PreparedStatement s = conn.get()
.prepareStatement("DELETE FROM openOutputs WHERE hash = ? AND index = ?");
@ -696,7 +693,10 @@ public class H2FullPrunedBlockStore implements FullPrunedBlockStore {
// index is actually an unsigned int
s.setInt(2, (int)out.getIndex());
s.executeUpdate();
int updateCount = s.getUpdateCount();
s.close();
if (updateCount == 0)
throw new BlockStoreException("Tried to remove a StoredTransactionOutput from H2FullPrunedBlockStore that it didn't have!");
} catch (SQLException e) {
throw new BlockStoreException(e);
}