H2FullPrunedBlockStore: Constructor with H2 database credentials.

This commit is contained in:
kushti
2016-03-15 22:39:52 +03:00
committed by Andreas Schildbach
parent a97f4923b4
commit 645f2d2572
2 changed files with 20 additions and 4 deletions

View File

@@ -78,6 +78,20 @@ public class H2FullPrunedBlockStore extends DatabaseFullPrunedBlockStore {
private static final String CREATE_OUTPUTS_HASH_INDEX = "CREATE INDEX openoutputs_hash_idx ON openoutputs (hash)";
private static final String CREATE_UNDOABLE_TABLE_INDEX = "CREATE INDEX undoableblocks_height_idx ON undoableblocks (height)";
/**
* Creates a new H2FullPrunedBlockStore, with given credentials for H2 database
* @param params A copy of the NetworkParameters used
* @param dbName The path to the database on disk
* @param username The username to use in the database
* @param password The username's password to use in the database
* @param fullStoreDepth The number of blocks of history stored in full (something like 1000 is pretty safe)
* @throws BlockStoreException if the database fails to open for any reason
*/
public H2FullPrunedBlockStore(NetworkParameters params, String dbName, String username, String password,
int fullStoreDepth) throws BlockStoreException {
super(params, DATABASE_CONNECTION_URL_PREFIX + dbName + ";create=true;LOCK_TIMEOUT=60000;DB_CLOSE_ON_EXIT=FALSE", fullStoreDepth, username, password, null);
}
/**
* Creates a new H2FullPrunedBlockStore
* @param params A copy of the NetworkParameters used
@@ -85,8 +99,9 @@ public class H2FullPrunedBlockStore extends DatabaseFullPrunedBlockStore {
* @param fullStoreDepth The number of blocks of history stored in full (something like 1000 is pretty safe)
* @throws BlockStoreException if the database fails to open for any reason
*/
public H2FullPrunedBlockStore(NetworkParameters params, String dbName, int fullStoreDepth) throws BlockStoreException {
super(params, DATABASE_CONNECTION_URL_PREFIX + dbName + ";create=true;LOCK_TIMEOUT=60000;DB_CLOSE_ON_EXIT=FALSE", fullStoreDepth, null, null, null);
public H2FullPrunedBlockStore(NetworkParameters params, String dbName, int fullStoreDepth)
throws BlockStoreException {
this(params, DATABASE_CONNECTION_URL_PREFIX + dbName + ";create=true;LOCK_TIMEOUT=60000;DB_CLOSE_ON_EXIT=FALSE", null, null, fullStoreDepth);
}
/**
@@ -99,7 +114,8 @@ public class H2FullPrunedBlockStore extends DatabaseFullPrunedBlockStore {
* and below 4MB sees a sharp drop in performance)
* @throws BlockStoreException if the database fails to open for any reason
*/
public H2FullPrunedBlockStore(NetworkParameters params, String dbName, int fullStoreDepth, int cacheSize) throws BlockStoreException {
public H2FullPrunedBlockStore(NetworkParameters params, String dbName, int fullStoreDepth, int cacheSize)
throws BlockStoreException {
this(params, dbName, fullStoreDepth);
try {
Statement s = conn.get().createStatement();

View File

@@ -19,7 +19,7 @@ public class H2FullPrunedBlockChainTest extends AbstractFullPrunedBlockChainTest
@Override
public FullPrunedBlockStore createStore(NetworkParameters params, int blockCount) throws BlockStoreException {
deleteFiles();
return new H2FullPrunedBlockStore(params, "test", blockCount);
return new H2FullPrunedBlockStore(params, "test", "sa", "sa", blockCount);
}
private void deleteFiles() {