Tighten the exception SPVBlockStore throws when the chain file is locked.

This commit is contained in:
Mike Hearn
2015-07-30 17:30:57 +02:00
parent 041b51f8e6
commit 09f13f7956
2 changed files with 15 additions and 1 deletions

View File

@@ -0,0 +1,14 @@
package org.bitcoinj.store;
/**
* Thrown by {@link SPVBlockStore} when the process cannot gain exclusive access to the chain file.
*/
public class ChainFileLockedException extends BlockStoreException {
public ChainFileLockedException(String message) {
super(message);
}
public ChainFileLockedException(Throwable t) {
super(t);
}
}

View File

@@ -103,7 +103,7 @@ public class SPVBlockStore implements BlockStore {
FileChannel channel = randomAccessFile.getChannel();
fileLock = channel.tryLock();
if (fileLock == null)
throw new BlockStoreException("Store file is already locked by another process");
throw new ChainFileLockedException("Store file is already locked by another process");
// Map it into memory read/write. The kernel will take care of flushing writes to disk at the most
// efficient times, which may mean that until the map is deallocated the data on disk is randomly