mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-01-31 23:32:16 +00:00
Throw BlockStoreException not NullPointerException when chain head cannot be found in SPVBlockStore. Resolves issue 374.
This commit is contained in:
parent
3c6f435fde
commit
4f1c7f4816
@ -239,7 +239,10 @@ public class SPVBlockStore implements BlockStore {
|
||||
buffer.position(8);
|
||||
buffer.get(headHash);
|
||||
Sha256Hash hash = new Sha256Hash(headHash);
|
||||
lastChainHead = checkNotNull(get(hash), "Corrupted block store: could not find chain head: " + hash);
|
||||
StoredBlock block = get(hash);
|
||||
if (block == null)
|
||||
throw new BlockStoreException("Corrupted block store: could not find chain head: " + hash);
|
||||
lastChainHead = block;
|
||||
}
|
||||
return lastChainHead;
|
||||
} finally { lock.unlock(); }
|
||||
@ -285,7 +288,7 @@ public class SPVBlockStore implements BlockStore {
|
||||
/** Returns the offset from the file start where the latest block should be written (end of prev block). */
|
||||
private int getRingCursor(ByteBuffer buffer) {
|
||||
int c = buffer.getInt(4);
|
||||
Preconditions.checkState(c >= FILE_PROLOGUE_BYTES, "Integer overflow");
|
||||
checkState(c >= FILE_PROLOGUE_BYTES, "Integer overflow");
|
||||
return c;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user