Package org.bitcoinj.store
Class H2FullPrunedBlockStore
- java.lang.Object
-
- org.bitcoinj.store.DatabaseFullPrunedBlockStore
-
- org.bitcoinj.store.H2FullPrunedBlockStore
-
- All Implemented Interfaces:
UTXOProvider
,BlockStore
,FullPrunedBlockStore
public class H2FullPrunedBlockStore extends DatabaseFullPrunedBlockStore
A full pruned block store using the H2 pure-java embedded database. Note that because of the heavy delete load on the database, during IBD, you may see the database files grow quite large (around 1.5G). H2 automatically frees some space at shutdown, so close()ing the database decreases the space usage somewhat (to only around 1.3G).
-
-
Field Summary
-
Fields inherited from class org.bitcoinj.store.DatabaseFullPrunedBlockStore
allConnections, chainHeadBlock, chainHeadHash, conn, connectionURL, fullStoreDepth, params, password, schemaName, username, verifiedChainHeadBlock, verifiedChainHeadHash
-
-
Constructor Summary
Constructors Constructor Description H2FullPrunedBlockStore(NetworkParameters params, java.lang.String dbName, int fullStoreDepth)
Creates a new H2FullPrunedBlockStoreH2FullPrunedBlockStore(NetworkParameters params, java.lang.String dbName, int fullStoreDepth, int cacheSize)
Creates a new H2FullPrunedBlockStore with the given cache sizeH2FullPrunedBlockStore(NetworkParameters params, java.lang.String dbName, java.lang.String username, java.lang.String password, int fullStoreDepth)
Creates a new H2FullPrunedBlockStore, with given credentials for H2 database
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.util.List<java.lang.String>
getCreateIndexesSQL()
Get the SQL statements that create the indexes (DDL).protected java.util.List<java.lang.String>
getCreateSchemeSQL()
Get the SQL statements that create the schema (DDL).protected java.util.List<java.lang.String>
getCreateTablesSQL()
Get the SQL statements that create the tables (DDL).protected java.lang.String
getDatabaseDriverClass()
Get the database driver class,protected java.lang.String
getDuplicateKeyErrorCode()
Get the database specific error code that indicated a duplicate key error when inserting a record.-
Methods inherited from class org.bitcoinj.store.DatabaseFullPrunedBlockStore
abortDatabaseBatchWrite, addUnspentTransactionOutput, beginDatabaseBatchWrite, calculateBalanceForAddress, close, commitDatabaseBatchWrite, deleteStore, dumpSizes, get, get, getBalanceSelectSQL, getChainHead, getChainHeadHeight, getCompatibilitySQL, getDeleteOpenoutputsSQL, getDeleteUndoableBlocksSQL, getDropTablesSQL, getInsertHeadersSQL, getInsertOpenoutputsSQL, getInsertSettingsSQL, getInsertUndoableBlocksSQL, getOnceUndoableStoredBlock, getOpenTransactionOutputs, getParams, getSelectHeadersDumpSQL, getSelectHeadersSQL, getSelectOpenoutputsCountSQL, getSelectopenoutputsDumpSQL, getSelectOpenoutputsSQL, getSelectSettingsDumpSQL, getSelectSettingsSQL, getSelectUndoableblocksDumpSQL, getSelectUndoableBlocksSQL, getTablesExistSQL, getTransactionOutput, getTransactionOutputSelectSQL, getUndoBlock, getUpdateHeadersSQL, getUpdateSettingsSLQ, getUpdateUndoableBlocksSQL, getVerifiedChainHead, hasUnspentOutputs, maybeConnect, put, put, putUpdateStoredBlock, removeUnspentTransactionOutput, resetStore, setChainHead, setVerifiedChainHead
-
-
-
-
Constructor Detail
-
H2FullPrunedBlockStore
public H2FullPrunedBlockStore(NetworkParameters params, java.lang.String dbName, java.lang.String username, java.lang.String password, int fullStoreDepth) throws BlockStoreException
Creates a new H2FullPrunedBlockStore, with given credentials for H2 database- Parameters:
params
- A copy of the NetworkParameters useddbName
- The path to the database on diskusername
- The username to use in the databasepassword
- The username's password to use in the databasefullStoreDepth
- 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
-
H2FullPrunedBlockStore
public H2FullPrunedBlockStore(NetworkParameters params, java.lang.String dbName, int fullStoreDepth) throws BlockStoreException
Creates a new H2FullPrunedBlockStore- Parameters:
params
- A copy of the NetworkParameters useddbName
- The path to the database on diskfullStoreDepth
- 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
-
H2FullPrunedBlockStore
public H2FullPrunedBlockStore(NetworkParameters params, java.lang.String dbName, int fullStoreDepth, int cacheSize) throws BlockStoreException
Creates a new H2FullPrunedBlockStore with the given cache size- Parameters:
params
- A copy of the NetworkParameters useddbName
- The path to the database on diskfullStoreDepth
- The number of blocks of history stored in full (something like 1000 is pretty safe)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
-
-
Method Detail
-
getDuplicateKeyErrorCode
protected java.lang.String getDuplicateKeyErrorCode()
Description copied from class:DatabaseFullPrunedBlockStore
Get the database specific error code that indicated a duplicate key error when inserting a record.This is the code returned by
SQLException.getSQLState()
- Specified by:
getDuplicateKeyErrorCode
in classDatabaseFullPrunedBlockStore
- Returns:
- The database duplicate error code.
-
getCreateTablesSQL
protected java.util.List<java.lang.String> getCreateTablesSQL()
Description copied from class:DatabaseFullPrunedBlockStore
Get the SQL statements that create the tables (DDL).- Specified by:
getCreateTablesSQL
in classDatabaseFullPrunedBlockStore
- Returns:
- The list of SQL statements.
-
getCreateIndexesSQL
protected java.util.List<java.lang.String> getCreateIndexesSQL()
Description copied from class:DatabaseFullPrunedBlockStore
Get the SQL statements that create the indexes (DDL).- Specified by:
getCreateIndexesSQL
in classDatabaseFullPrunedBlockStore
- Returns:
- The list of SQL statements.
-
getCreateSchemeSQL
protected java.util.List<java.lang.String> getCreateSchemeSQL()
Description copied from class:DatabaseFullPrunedBlockStore
Get the SQL statements that create the schema (DDL).- Specified by:
getCreateSchemeSQL
in classDatabaseFullPrunedBlockStore
- Returns:
- The list of SQL statements.
-
getDatabaseDriverClass
protected java.lang.String getDatabaseDriverClass()
Description copied from class:DatabaseFullPrunedBlockStore
Get the database driver class,i.e org.postgresql.Driver.
- Specified by:
getDatabaseDriverClass
in classDatabaseFullPrunedBlockStore
- Returns:
- The fully qualified database driver class.
-
-