diff --git a/core/src/main/java/org/bitcoinj/store/H2FullPrunedBlockStore.java b/core/src/main/java/org/bitcoinj/store/H2FullPrunedBlockStore.java index 13a7af4f..efa1e79f 100644 --- a/core/src/main/java/org/bitcoinj/store/H2FullPrunedBlockStore.java +++ b/core/src/main/java/org/bitcoinj/store/H2FullPrunedBlockStore.java @@ -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(); diff --git a/core/src/test/java/org/bitcoinj/core/H2FullPrunedBlockChainTest.java b/core/src/test/java/org/bitcoinj/core/H2FullPrunedBlockChainTest.java index 2ff7dc4c..d47ad4af 100644 --- a/core/src/test/java/org/bitcoinj/core/H2FullPrunedBlockChainTest.java +++ b/core/src/test/java/org/bitcoinj/core/H2FullPrunedBlockChainTest.java @@ -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() {