mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-15 11:45:51 +00:00
Add constructor to H2FullPrunedBlockStore to specify cache size.
This commit is contained in:
parent
a011948139
commit
739b2c6183
@ -86,6 +86,13 @@ public class H2FullPrunedBlockStore implements FullPrunedBlockStore {
|
|||||||
+ "CONSTRAINT openOutputs_fk FOREIGN KEY (id) REFERENCES openOutputsIndex(id)"
|
+ "CONSTRAINT openOutputs_fk FOREIGN KEY (id) REFERENCES openOutputsIndex(id)"
|
||||||
+ ")";
|
+ ")";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new H2FullPrunedBlockStore
|
||||||
|
* @param params A copy of the NetworkParameters used
|
||||||
|
* @param dbName The path to the database on disk
|
||||||
|
* @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 {
|
public H2FullPrunedBlockStore(NetworkParameters params, String dbName, int fullStoreDepth) throws BlockStoreException {
|
||||||
this.params = params;
|
this.params = params;
|
||||||
this.fullStoreDepth = fullStoreDepth;
|
this.fullStoreDepth = fullStoreDepth;
|
||||||
@ -113,6 +120,28 @@ public class H2FullPrunedBlockStore implements FullPrunedBlockStore {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new H2FullPrunedBlockStore with the given cache size
|
||||||
|
* @param params A copy of the NetworkParameters used
|
||||||
|
* @param dbName The path to the database on disk
|
||||||
|
* @param fullStoreDepth The number of blocks of history stored in full (something like 1000 is pretty safe)
|
||||||
|
* @param cacheSize The number of kilobytes to dedicate to H2 Cache (the default value of 16MB (16384) is a safe bet
|
||||||
|
* to achieve good performance/cost when importing blocks from disk, past 32MB makes little sense,
|
||||||
|
* 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 {
|
||||||
|
this(params, dbName, fullStoreDepth);
|
||||||
|
|
||||||
|
try {
|
||||||
|
Statement s = conn.get().createStatement();
|
||||||
|
s.executeUpdate("SET CACHE_SIZE " + cacheSize);
|
||||||
|
s.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new BlockStoreException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private synchronized void maybeConnect() throws BlockStoreException {
|
private synchronized void maybeConnect() throws BlockStoreException {
|
||||||
try {
|
try {
|
||||||
if (conn.get() != null)
|
if (conn.get() != null)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user