public class PostgresFullPrunedBlockStore extends DatabaseFullPrunedBlockStore
A full pruned block store using the Postgres database engine. As an added bonus an address index is calculated,
so you can use DatabaseFullPrunedBlockStore.calculateBalanceForAddress(org.bitcoinj.core.Address) to quickly look up
the quantity of bitcoins controlled by that address.
allConnections, chainHeadBlock, chainHeadHash, conn, connectionURL, fullStoreDepth, params, password, schemaName, username, verifiedChainHeadBlock, verifiedChainHeadHash| Constructor and Description |
|---|
PostgresFullPrunedBlockStore(NetworkParameters params,
int fullStoreDepth,
String hostname,
String dbName,
String username,
String password)
Creates a new PostgresFullPrunedBlockStore.
|
PostgresFullPrunedBlockStore(NetworkParameters params,
int fullStoreDepth,
String hostname,
String dbName,
String username,
String password,
String schemaName)
Create a new PostgresFullPrunedBlockStore, storing the tables in the schema specified.
|
| Modifier and Type | Method and Description |
|---|---|
protected List<String> |
getCreateIndexesSQL()
Get the SQL statements that create the indexes (DDL).
|
protected List<String> |
getCreateSchemeSQL()
Get the SQL statements that create the schema (DDL).
|
protected List<String> |
getCreateTablesSQL()
Get the SQL statements that create the tables (DDL).
|
protected String |
getDatabaseDriverClass()
Get the database driver class,
|
protected String |
getDuplicateKeyErrorCode()
Get the database specific error code that indicated a duplicate key error when inserting a record.
|
void |
put(StoredBlock storedBlock,
StoredUndoableBlock undoableBlock)
Saves the given
StoredUndoableBlock and StoredBlock. |
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, getTrasactionOutputSelectSQL, getUndoBlock, getUpdateHeadersSQL, getUpdateSettingsSLQ, getUpdateUndoableBlocksSQL, getVerifiedChainHead, hasUnspentOutputs, maybeConnect, put, putUpdateStoredBlock, removeUnspentTransactionOutput, resetStore, setChainHead, setVerifiedChainHeadpublic PostgresFullPrunedBlockStore(NetworkParameters params, int fullStoreDepth, String hostname, String dbName, String username, String password) throws BlockStoreException
params - A copy of the NetworkParameters usedfullStoreDepth - The number of blocks of history stored in full (something like 1000 is pretty safe)hostname - The hostname of the database to connect todbName - The database to connect tousername - The database usernamepassword - The password to the databaseBlockStoreException - if the database fails to open for any reasonpublic PostgresFullPrunedBlockStore(NetworkParameters params, int fullStoreDepth, String hostname, String dbName, String username, String password, @Nullable String schemaName) throws BlockStoreException
Create a new PostgresFullPrunedBlockStore, storing the tables in the schema specified. You may want to specify a schema to avoid name collisions, or just to keep the database better organized. The schema is not required, and if one is not provided than the default schema for the username will be used. See the postgres schema docs for more on schemas.
params - A copy of the NetworkParameters used.fullStoreDepth - The number of blocks of history stored in full (something like 1000 is pretty safe).hostname - The hostname of the database to connect to.dbName - The database to connect to.username - The database username.password - The password to the database.schemaName - The name of the schema to put the tables in. May be null if no schema is being used.BlockStoreException - If the database fails to open for any reason.protected String getDuplicateKeyErrorCode()
DatabaseFullPrunedBlockStoreThis is the code returned by SQLException.getSQLState()
getDuplicateKeyErrorCode in class DatabaseFullPrunedBlockStoreprotected List<String> getCreateTablesSQL()
DatabaseFullPrunedBlockStoregetCreateTablesSQL in class DatabaseFullPrunedBlockStoreprotected List<String> getCreateIndexesSQL()
DatabaseFullPrunedBlockStoregetCreateIndexesSQL in class DatabaseFullPrunedBlockStoreprotected List<String> getCreateSchemeSQL()
DatabaseFullPrunedBlockStoregetCreateSchemeSQL in class DatabaseFullPrunedBlockStoreprotected String getDatabaseDriverClass()
DatabaseFullPrunedBlockStorei.e org.postgresql.Driver.
getDatabaseDriverClass in class DatabaseFullPrunedBlockStorepublic void put(StoredBlock storedBlock, StoredUndoableBlock undoableBlock) throws BlockStoreException
FullPrunedBlockStoreSaves the given StoredUndoableBlock and StoredBlock. Calculates keys from the StoredBlock
Though not required for proper function of a FullPrunedBlockStore, any user of a FullPrunedBlockStore should ensure that a StoredUndoableBlock for each block up to the fully verified chain head has been added to this block store using this function (not put(StoredBlock)), so that the ability to perform reorgs is maintained.
put in interface FullPrunedBlockStoreput in class DatabaseFullPrunedBlockStoreBlockStoreException - if there is a problem with the underlying storage layer, such as running out of disk space.Copyright © 2015. All rights reserved.