{"modulePath":"github.com/parallelcointeam/exploder","version":"v2.1.3+incompatible","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package dcrpg\n\n## Functions\n\n```go\nfunc Connect(host, port, user, pass, dbname string) (*sql.DB, error)\n```\nConnect opens a connection to a PostgreSQL database. The caller is responsible for calling Close() on the returned db when finished using it. The input host may be an IP address for TCP connection, or an absolute path to a UNIX domain socket. An empty string should be provided for UNIX sockets.\n\n```go\nfunc CreateTable(db *sql.DB, tableName string) error\n```\nCreateTable creates one of the known tables by name\n\n```go\nfunc CreateTables(db *sql.DB) error\n```\n\n```go\nfunc CreateTypes(db *sql.DB) error\n```\n\n```go\nfunc DeindexAddressTableOnAddress(db *sql.DB) (err error)\n```\n\n```go\nfunc DeindexAddressTableOnTxHash(db *sql.DB) (err error)\n```\n\n```go\nfunc DeindexAddressTableOnVoutID(db *sql.DB) (err error)\n```\n\n```go\nfunc DeindexBlockTableOnHash(db *sql.DB) (err error)\n```\n\n```go\nfunc DeindexMissesTableOnHash(db *sql.DB) (err error)\n```\n\n```go\nfunc DeindexTicketsTableOnHash(db *sql.DB) (err error)\n```\n\n```go\nfunc DeindexTicketsTableOnTxDbID(db *sql.DB) (err error)\n```\n\n```go\nfunc DeindexTransactionTableOnBlockIn(db *sql.DB) (err error)\n```\n\n```go\nfunc DeindexTransactionTableOnHashes(db *sql.DB) (err error)\n```\n\n```go\nfunc DeindexVinTableOnPrevOuts(db *sql.DB) (err error)\n```\n\n```go\nfunc DeindexVinTableOnVins(db *sql.DB) (err error)\n```\n\n```go\nfunc DeindexVotesTableOnCandidate(db *sql.DB) (err error)\n```\n\n```go\nfunc DeindexVotesTableOnHash(db *sql.DB) (err error)\n```\n\n```go\nfunc DeindexVotesTableOnVoteVersion(db *sql.DB) (err error)\n```\n\n```go\nfunc DeindexVoutTableOnTxHashIdx(db *sql.DB) (err error)\n```\n\n```go\nfunc DeleteDuplicateMisses(db *sql.DB) (int64, error)\n```\nDeleteDuplicateMisses deletes rows in misses with duplicate tx-block hashes, leaving the one row with the lowest id.\n\n```go\nfunc DeleteDuplicateTickets(db *sql.DB) (int64, error)\n```\nDeleteDuplicateTickets deletes rows in tickets with duplicate tx-block hashes, leaving the one row with the lowest id.\n\n```go\nfunc DeleteDuplicateTxns(db *sql.DB) (int64, error)\n```\nDeleteDuplicateTxns deletes rows in transactions with duplicate tx-block hashes, leaving the one row with the lowest id.\n\n```go\nfunc DeleteDuplicateVins(db *sql.DB) (int64, error)\n```\nDeleteDuplicateVins deletes rows in vin with duplicate tx information, leaving the one row with the lowest id.\n\n```go\nfunc DeleteDuplicateVotes(db *sql.DB) (int64, error)\n```\nDeleteDuplicateVotes deletes rows in votes with duplicate tx-block hashes, leaving the one row with the lowest id.\n\n```go\nfunc DeleteDuplicateVouts(db *sql.DB) (int64, error)\n```\nDeleteDuplicateVouts deletes rows in vouts with duplicate tx information, leaving the one row with the lowest id.\n\n```go\nfunc DisableLog()\n```\nDisableLog disables all library log output.  Logging output is disabled by default until UseLogger is called.\n\n```go\nfunc DropTables(db *sql.DB)\n```\n\n```go\nfunc ExistsIndex(db *sql.DB, indexName string) (exists bool, err error)\n```\n\n```go\nfunc IndexAddressTableOnAddress(db *sql.DB) (err error)\n```\n\n```go\nfunc IndexAddressTableOnTxHash(db *sql.DB) (err error)\n```\n\n```go\nfunc IndexAddressTableOnVoutID(db *sql.DB) (err error)\n```\n\n```go\nfunc IndexBlockTableOnHash(db *sql.DB) (err error)\n```\n\n```go\nfunc IndexMissesTableOnHashes(db *sql.DB) (err error)\n```\n\n```go\nfunc IndexTicketsTableOnHashes(db *sql.DB) (err error)\n```\n\n```go\nfunc IndexTicketsTableOnTxDbID(db *sql.DB) (err error)\n```\n\n```go\nfunc IndexTransactionTableOnBlockIn(db *sql.DB) (err error)\n```\n\n```go\nfunc IndexTransactionTableOnHashes(db *sql.DB) (err error)\n```\n\n```go\nfunc IndexVinTableOnPrevOuts(db *sql.DB) (err error)\n```\n\n```go\nfunc IndexVinTableOnVins(db *sql.DB) (err error)\n```\n\n```go\nfunc IndexVotesTableOnCandidate(db *sql.DB) (err error)\n```\n\n```go\nfunc IndexVotesTableOnHashes(db *sql.DB) (err error)\n```\n\n```go\nfunc IndexVotesTableOnVoteVersion(db *sql.DB) (err error)\n```\n\n```go\nfunc IndexVoutTableOnTxHashIdx(db *sql.DB) (err error)\n```\n\n```go\nfunc InsertAddressOut(db *sql.DB, dbA *dbtypes.AddressRow, dupCheck bool) (uint64, error)\n```\nInsertAddressOut inserts an AddressRow (input or output), returning the row ID in the addresses table of the inserted data.\n\n```go\nfunc InsertAddressOuts(db *sql.DB, dbAs []*dbtypes.AddressRow, dupCheck bool) ([]uint64, error)\n```\n\n```go\nfunc InsertBlock(db *sql.DB, dbBlock *dbtypes.Block, isValid, checked bool) (uint64, error)\n```\n\n```go\nfunc InsertBlockPrevNext(db *sql.DB, blockDbID uint64,\n\thash, prev, next string) error\n```\n\n```go\nfunc InsertTickets(db *sql.DB, dbTxns []*dbtypes.Tx, txDbIDs []uint64, checked bool) ([]uint64, []*dbtypes.Tx, error)\n```\nInsertTickets takes a slice of \\*dbtypes.Tx and corresponding DB row IDs for transactions, extracts the tickets, and inserts the tickets into the database. Outputs are a slice of DB row IDs of the inserted tickets, and an error.\n\n```go\nfunc InsertTx(db *sql.DB, dbTx *dbtypes.Tx, checked bool) (uint64, error)\n```\n\n```go\nfunc InsertTxns(db *sql.DB, dbTxns []*dbtypes.Tx, checked bool) ([]uint64, error)\n```\n\n```go\nfunc InsertVin(db *sql.DB, dbVin dbtypes.VinTxProperty, checked bool) (id uint64, err error)\n```\n\n```go\nfunc InsertVins(db *sql.DB, dbVins dbtypes.VinTxPropertyARRAY, checked bool) ([]uint64, error)\n```\n\n```go\nfunc InsertVotes(db *sql.DB, dbTxns []*dbtypes.Tx, _ []uint64,\n\tfTx *TicketTxnIDGetter, msgBlock *MsgBlockPG, checked bool) ([]uint64,\n\t[]*dbtypes.Tx, []string, []uint64, map[string]uint64, error)\n```\nInsertVotes takes a slice of \\*dbtypes.Tx, which must contain all the stake transactions in a block, extracts the votes, and inserts the votes into the database. The input MsgBlockPG contains each stake transaction's MsgTx in STransactions, and they must be in the same order as the dbtypes.Tx slice.\n\nThis function also identifies and stores missed votes using msgBlock.Validators, which lists the ticket hashes called to vote on the previous block (msgBlock.WinningTickets are the lottery winners to be mined in the next block).\n\nOutputs are slices of DB row IDs for the votes and misses, and an error.\n\n```go\nfunc InsertVout(db *sql.DB, dbVout *dbtypes.Vout, checked bool) (uint64, error)\n```\n\n```go\nfunc InsertVouts(db *sql.DB, dbVouts []*dbtypes.Vout, checked bool) ([]uint64, []dbtypes.AddressRow, error)\n```\n\n```go\nfunc IsUniqueIndex(db *sql.DB, indexName string) (isUnique bool, err error)\n```\n\n```go\nfunc RetrieveAddressCreditTxns(db *sql.DB, address string, N, offset int64) (ids []uint64, addressRows []*dbtypes.AddressRow, err error)\n```\n\n```go\nfunc RetrieveAddressDebitTxns(db *sql.DB, address string, N, offset int64) ([]uint64, []*dbtypes.AddressRow, error)\n```\n\n```go\nfunc RetrieveAddressIDsByOutpoint(db *sql.DB, txHash string,\n\tvoutIndex uint32) ([]uint64, []string, int64, error)\n```\nRetrieveAddressIDsByOutpoint fetches all address row IDs for a given outpoint (hash:index). Update Vin due to DCRD AMOUNTIN - START - DO NOT MERGE CHANGES IF DCRD FIXED\n\n```go\nfunc RetrieveAddressRecvCount(db *sql.DB, address string) (count int64, err error)\n```\n\n```go\nfunc RetrieveAddressSpent(db *sql.DB, address string) (count, totalAmount int64, err error)\n```\n\n```go\nfunc RetrieveAddressSpentUnspent(db *sql.DB, address string) (numSpent, numUnspent,\n\ttotalSpent, totalUnspent int64, err error)\n```\n\n```go\nfunc RetrieveAddressTxnOutputWithTransaction(db *sql.DB, address string, currentBlockHeight int64) ([]apitypes.AddressTxnOutput, error)\n```\n\n```go\nfunc RetrieveAddressTxns(db *sql.DB, address string, N, offset int64) ([]uint64, []*dbtypes.AddressRow, error)\n```\n\n```go\nfunc RetrieveAddressTxnsAlt(db *sql.DB, address string, N, offset int64) ([]uint64, []*dbtypes.AddressRow, error)\n```\n\n```go\nfunc RetrieveAddressTxnsByFundingTx(db *sql.DB, fundTxHash string,\n\taddresses []string) (aSpendByFunHash []*apitypes.AddressSpendByFunHash, err error)\n```\nRetrieve all Transactions related to a set of addresses and funded by a specific transaction\n\n```go\nfunc RetrieveAddressTxnsOrdered(db *sql.DB, addresses []string, recentBlockHeight int64) (txs []string, recenttxs []string)\n```\nRetrieveAddressTxnsOrdered will get all transactions for addresses provided and return them sorted by time in descending order. It will also return a short list of recently (defined as greater than recentBlockHeight) confirmed transactions that can be used to validate mempool status.\n\n```go\nfunc RetrieveAddressUnspent(db *sql.DB, address string) (count, totalAmount int64, err error)\n```\n\n```go\nfunc RetrieveAllAddressTxns(db *sql.DB, address string) ([]uint64, []*dbtypes.AddressRow, error)\n```\n\n```go\nfunc RetrieveAllRevokesDbIDHashHeight(db *sql.DB) (ids []uint64,\n\thashes []string, heights []int64, vinDbIDs []uint64, err error)\n```\n\n```go\nfunc RetrieveAllVinDbIDs(db *sql.DB) (vinDbIDs []uint64, err error)\n```\n\n```go\nfunc RetrieveAllVotesDbIDsHeightsTicketDbIDs(db *sql.DB) (ids []uint64, heights []int64,\n\tticketDbIDs []uint64, err error)\n```\n\n```go\nfunc RetrieveBestBlockHeight(db *sql.DB) (height uint64, hash string, id uint64, err error)\n```\n\n```go\nfunc RetrieveBlockChainDbID(db *sql.DB, hash string) (dbID uint64, err error)\n```\nRetrieveBlockChainDbID retrieves the row id in the block\\_chain table of the block with the given hash, if it exists (be sure to check error against sql.ErrNoRows!).\n\n```go\nfunc RetrieveBlockHash(db *sql.DB, idx int64) (hash string, err error)\n```\nRetrieveBlockHash retrieves the hash of the block at the given height, if it exists (be sure to check error against sql.ErrNoRows!). WARNING: this returns the most recently added block at this height, but there may be others.\n\n```go\nfunc RetrieveBlockHeight(db *sql.DB, hash string) (height int64, err error)\n```\nRetrieveBlockHeight retrieves the height of the block with the given hash, if it exists (be sure to check error against sql.ErrNoRows!).\n\n```go\nfunc RetrieveBlockSummaryByTimeRange(db *sql.DB, minTime, maxTime int64, limit int) ([]dbtypes.BlockDataBasic, error)\n```\n\n```go\nfunc RetrieveBlockVoteCount(db *sql.DB, hash string) (numVotes int16, err error)\n```\nRetrieveBlockVoteCount gets the number of votes mined in a block.\n\n```go\nfunc RetrieveDbTxByHash(db *sql.DB, txHash string) (id uint64, dbTx *dbtypes.Tx, err error)\n```\n\n```go\nfunc RetrieveFullTxByHash(db *sql.DB, txHash string) (id uint64,\n\tblockHash string, blockHeight int64, blockTime int64, time int64,\n\ttxType int16, version int32, tree int8, blockInd uint32,\n\tlockTime, expiry int32, size uint32, spent, sent, fees int64,\n\tnumVin int32, vinDbIDs []int64, numVout int32, voutDbIDs []int64,\n\terr error)\n```\n\n```go\nfunc RetrieveFundingOutpointByTxIn(db *sql.DB, txHash string,\n\tvinIndex uint32) (id uint64, tx string, index uint32, tree int8, err error)\n```\n\n```go\nfunc RetrieveFundingOutpointByVinID(db *sql.DB, vinDbID uint64) (tx string, index uint32, tree int8, err error)\n```\n\n```go\nfunc RetrieveFundingTxByTxIn(db *sql.DB, txHash string, vinIndex uint32) (id uint64, tx string, err error)\n```\n\n```go\nfunc RetrieveFundingTxByVinDbID(db *sql.DB, vinDbID uint64) (tx string, err error)\n```\n\n```go\nfunc RetrieveFundingTxsByTx(db *sql.DB, txHash string) ([]uint64, []*dbtypes.Tx, error)\n```\n\n```go\nfunc RetrieveMissedVotesInBlock(db *sql.DB, blockHash string) (ticketHashes []string, err error)\n```\n\n```go\nfunc RetrievePkScriptByID(db *sql.DB, id uint64) (pkScript []byte, err error)\n```\n\n```go\nfunc RetrieveRegularTxByHash(db *sql.DB, txHash string) (id uint64, blockHash string, blockInd uint32, err error)\n```\n\n```go\nfunc RetrieveSpendingTxByTxOut(db *sql.DB, txHash string,\n\tvoutIndex uint32) (id uint64, tx string, vin uint32, tree int8, err error)\n```\n\n```go\nfunc RetrieveSpendingTxByVinID(db *sql.DB, vinDbID uint64) (tx string,\n\tvoutIndex uint32, tree int8, err error)\n```\n\n```go\nfunc RetrieveSpendingTxsByFundingTx(db *sql.DB, fundingTxID string) (dbIDs []uint64,\n\ttxns []string, vinInds []uint32, voutInds []uint32, err error)\n```\n\n```go\nfunc RetrieveStakeTxByHash(db *sql.DB, txHash string) (id uint64, blockHash string, blockInd uint32, err error)\n```\n\n```go\nfunc RetrieveTicketIDByHash(db *sql.DB, ticketHash string) (id uint64, err error)\n```\n\n```go\nfunc RetrieveTicketIDHeightByHash(db *sql.DB, ticketHash string) (id uint64, blockHeight int64, err error)\n```\n\n```go\nfunc RetrieveTicketIDsByHashes(db *sql.DB, ticketHashes []string) (ids []uint64, err error)\n```\n\n```go\nfunc RetrieveTicketStatusByHash(db *sql.DB, ticketHash string) (id uint64, spend_status dbtypes.TicketSpendType,\n\tpool_status dbtypes.TicketPoolStatus, err error)\n```\n\n```go\nfunc RetrieveTxByHash(db *sql.DB, txHash string) (id uint64, blockHash string, blockInd uint32, tree int8, err error)\n```\n\n```go\nfunc RetrieveTxIDHeightByHash(db *sql.DB, txHash string) (id uint64, blockHeight int64, err error)\n```\n\n```go\nfunc RetrieveTxsByBlockHash(db *sql.DB, blockHash string) (ids []uint64, txs []string, blockInds []uint32, trees []int8, err error)\n```\n\n```go\nfunc RetrieveUnspentTickets(db *sql.DB) (ids []uint64, hashes []string, err error)\n```\n\n```go\nfunc RetrieveVinByID(db *sql.DB, vinDbID uint64) (prevOutHash string, prevOutVoutInd uint32,\n\tprevOutTree int8, txHash string, txVinInd uint32, txTree int8, err error)\n```\n\n```go\nfunc RetrieveVoutIDByOutpoint(db *sql.DB, txHash string, voutIndex uint32) (id uint64, err error)\n```\n\n```go\nfunc RetrieveVoutValue(db *sql.DB, txHash string, voutIndex uint32) (value uint64, err error)\n```\n\n```go\nfunc RetrieveVoutValues(db *sql.DB, txHash string) (values []uint64, txInds []uint32, txTrees []int8, err error)\n```\n\n```go\nfunc SetPoolStatusForTickets(db *sql.DB, ticketDbIDs []uint64,\n\tpoolStatuses []dbtypes.TicketPoolStatus) (int64, error)\n```\n\n```go\nfunc SetPoolStatusForTicketsByHash(db *sql.DB, tickets []string,\n\tpoolStatuses []dbtypes.TicketPoolStatus) (int64, error)\n```\n\n```go\nfunc SetSpendingByVinID(db *sql.DB, vinDbID uint64, spendingTxDbID uint64,\n\tspendingTxHash string, spendingTxVinIndex uint32, checked bool) (int64, error)\n```\nSetSpendingByVinID is for when you got a new spending tx (vin entry) and you need to get the funding (previous output) tx info, and then update the corresponding row in the addresses table with the spending tx info.\n\n```go\nfunc SetSpendingForAddressDbID(db *sql.DB, addrDbID uint64, spendingTxDbID uint64,\n\tspendingTxHash string, spendingTxVinIndex uint32, vinDbID uint64) error\n```\n\n```go\nfunc SetSpendingForFundingOP(db *sql.DB,\n\tfundingTxHash string, fundingTxVoutIndex uint32,\n\tspendingTxDbID uint64, spendingTxHash string, spendingTxVinIndex uint32,\n\tvinDbID uint64) (int64, error)\n```\n\n```go\nfunc SetSpendingForTickets(db *sql.DB, ticketDbIDs, spendDbIDs []uint64,\n\tblockHeights []int64, spendTypes []dbtypes.TicketSpendType,\n\tpoolStatuses []dbtypes.TicketPoolStatus) (int64, error)\n```\n\n```go\nfunc SetSpendingForVinDbID(db *sql.DB, vinDbID uint64) (int64, error)\n```\n\n```go\nfunc SetSpendingForVinDbIDs(db *sql.DB, vinDbIDs []uint64) ([]int64, int64, error)\n```\n\n```go\nfunc TableExists(db *sql.DB, tableName string) (bool, error)\n```\n\n```go\nfunc TableVersionCompatible(required, actual TableVersion) string\n```\nTableVersionCompatible indicates if the table versions are compatible (equal), and if not, what is the required action (rebuild, upgrade, or reindex).\n\n```go\nfunc TableVersions(db *sql.DB) map[string]TableVersion\n```\n\n```go\nfunc TypeExists(db *sql.DB, tableName string) (bool, error)\n```\n\n```go\nfunc UpdateBlockNext(db *sql.DB, blockDbID uint64, next string) error\n```\n\n```go\nfunc UpdateLastBlock(db *sql.DB, blockDbID uint64, isValid bool) error\n```\nUpdateLastBlock updates the is\\_valid column of the block specified by the row id for the blocks table.\n\n```go\nfunc UseLogger(logger slog.Logger)\n```\nUseLogger uses a specified Logger to output package logging info.\n\n## Types\n\n```go\ntype ChainDB struct {\n\tDevFundBalance *DevFundBalance\n\n\tInBatchSync bool\n\t// contains filtered or unexported fields\n}\n```\nChainDB provides an interface for storing and manipulating extracted blockchain data in a PostgreSQL database.\n\n```go\nfunc NewChainDB(dbi *DBInfo, params *chaincfg.Params, stakeDB *stakedb.StakeDatabase,\n\tdevPrefetch bool) (*ChainDB, error)\n```\nNewChainDB constructs a ChainDB for the given connection and Decred network parameters. By default, duplicate row checks on insertion are enabled.\n\n```go\nfunc (pgb *ChainDB) AddressHistory(address string, N, offset int64,\n\ttxnType dbtypes.AddrTxnType) ([]*dbtypes.AddressRow, *explorer.AddressBalance, error)\n```\nAddressHistory queries the database for rows of the addresses table containing values for a certain type of transaction (all, credits, or debits) for the given address.\n\n```go\nfunc (pgb *ChainDB) AddressHistoryAll(address string, N, offset int64) ([]*dbtypes.AddressRow, *explorer.AddressBalance, error)\n```\nAddressHistoryAll queries the database for all rows of the addresses table for the given address.\n\n```go\nfunc (pgb *ChainDB) AddressTotals(address string) (*apitypes.AddressTotals, error)\n```\nAddressTotals queries for the following totals: amount spent, amount unspent, number of unspent transaction outputs and number spent.\n\n```go\nfunc (pgb *ChainDB) AddressTransactionDetails(addr string, count, skip int64,\n\ttxnType dbtypes.AddrTxnType) (*apitypes.Address, error)\n```\nAddressTransactionDetails returns an apitypes.Address with at most the last count transactions of type txnType in which the address was involved, starting after skip transactions. This does NOT include unconfirmed transactions.\n\n```go\nfunc (pgb *ChainDB) AddressTransactionRawDetails(addr string, count, skip int64,\n\ttxnType dbtypes.AddrTxnType) ([]*apitypes.AddressTxRaw, error)\n```\nTODO: finish\n\n```go\nfunc (pgb *ChainDB) AddressTransactions(address string, N, offset int64,\n\ttxnType dbtypes.AddrTxnType) (addressRows []*dbtypes.AddressRow, err error)\n```\nAddressTransactions retrieves a slice of \\*dbtypes.AddressRow for a given address and transaction type (i.e. all, credit, or debit) from the DB. Only the first N transactions starting from the offset element in the set of all txnType transactions.\n\n```go\nfunc (pgb *ChainDB) BlockMissedVotes(blockHash string) ([]string, error)\n```\nBlockMissedVotes retrieves the ticket IDs for all missed votes in the specified block, and an error value.\n\n```go\nfunc (pgb *ChainDB) BlockTransactions(blockHash string) ([]string, []uint32, []int8, error)\n```\nBlockTransactions retrieves all transactions in the specified block, their indexes in the block, their tree, and an error value.\n\n```go\nfunc (pgb *ChainDB) Close() error\n```\nClose closes the underlying sql.DB connection to the database.\n\n```go\nfunc (pgb *ChainDB) CollectTicketSpendDBInfo(dbTxns []*dbtypes.Tx, txDbIDs []uint64,\n\tmsgBlock *wire.MsgBlock) (spendingTxDbIDs []uint64, spendTypes []dbtypes.TicketSpendType,\n\tticketHashes []string, ticketDbIDs []uint64, err error)\n```\n\n```go\nfunc (pgb *ChainDB) DeindexAddressTable() error\n```\nDeindexAddressTable drops the vin ID and address column indexes for the address table.\n\n```go\nfunc (pgb *ChainDB) DeindexAll() error\n```\nDeindexAll drops all of the indexes in all tables\n\n```go\nfunc (pgb *ChainDB) DeindexTicketsTable() error\n```\nDeindexTicketsTable drops the ticket hash and tx DB ID column indexes for the tickets table.\n\n```go\nfunc (pgb *ChainDB) DeleteDuplicateMisses() (int64, error)\n```\n\n```go\nfunc (pgb *ChainDB) DeleteDuplicateTickets() (int64, error)\n```\n\n```go\nfunc (pgb *ChainDB) DeleteDuplicateTxns() (int64, error)\n```\n\n```go\nfunc (pgb *ChainDB) DeleteDuplicateVins() (int64, error)\n```\n\n```go\nfunc (pgb *ChainDB) DeleteDuplicateVotes() (int64, error)\n```\n\n```go\nfunc (pgb *ChainDB) DeleteDuplicateVouts() (int64, error)\n```\n\n```go\nfunc (pgb *ChainDB) DeleteDuplicates() error\n```\n\n```go\nfunc (pgb *ChainDB) DeleteDuplicatesRecovery() error\n```\n\n```go\nfunc (pgb *ChainDB) DevBalance() (*explorer.AddressBalance, error)\n```\nDevBalance returns the current development/project fund balance, updating the cached balance if it is stale.\n\n```go\nfunc (pgb *ChainDB) DropTables()\n```\nDropTables drops (deletes) all of the known dcrdata tables.\n\n```go\nfunc (pgb *ChainDB) EnableDuplicateCheckOnInsert(dupCheck bool)\n```\nEnableDuplicateCheckOnInsert specifies whether SQL insertions should check for row conflicts (duplicates), and avoid adding or updating.\n\n```go\nfunc (pgb *ChainDB) ExistsIndexAddressesVoutIDAddress() (bool, error)\n```\n\n```go\nfunc (pgb *ChainDB) ExistsIndexVinOnVins() (bool, error)\n```\n\n```go\nfunc (pgb *ChainDB) ExistsIndexVoutOnTxHashIdx() (bool, error)\n```\n\n```go\nfunc (pgb *ChainDB) FillAddressTransactions(addrInfo *explorer.AddressInfo) error\n```\nFillAddressTransactions is used to fill out the transaction details in an explorer.AddressInfo generated by explorer.ReduceAddressHistory, usually from the output of AddressHistory. This function also sets the number of unconfirmed transactions for the current best block in the database.\n\n```go\nfunc (pgb *ChainDB) GetAddressBalance(address string, N, offset int64) *explorer.AddressBalance\n```\nGetAddressBalance returns a \\*explorer.AddressBalance for the specified address, transaction count limit, and transaction number offset.\n\n```go\nfunc (pgb *ChainDB) GetAddressSpendByFunHash(addresses []string, fundHash string) []*apitypes.AddressSpendByFunHash\n```\nGetAddressSpendByFunHash will return the address that fundex a tx\n\n```go\nfunc (pgb *ChainDB) GetAddressUTXO(address string) []apitypes.AddressTxnOutput\n```\nGetAddressUTXO returns the unspent transaction outputs (UTXOs) paying to the specified address in a \\[]apitypes.AddressTxnOutput.\n\n```go\nfunc (pgb *ChainDB) GetBlockHash(idx int64) (string, error)\n```\nGetBlockHash returns the hash of the block at the specified height. TODO: create GetBlockHashes to return all blocks at a given height.\n\n```go\nfunc (pgb *ChainDB) GetBlockHeight(hash string) (int64, error)\n```\nGetBlockHeight returns the height of the block with the specified hash.\n\n```go\nfunc (pgb *ChainDB) GetBlockSummaryTimeRange(min, max int64, limit int) []dbtypes.BlockDataBasic\n```\nGetBlockSummaryTimeRange returns the blocks created within a specified time range (min, max time), up to limit transactions.\n\n```go\nfunc (pgb *ChainDB) GetHeight() int\n```\nGetHeight returns the current best block height.\n\n```go\nfunc (pgb *ChainDB) HashDB() (string, error)\n```\nHashDB queries the DB for the best block's hash.\n\n```go\nfunc (pgb *ChainDB) Height() uint64\n```\nHeight uses the last stored height.\n\n```go\nfunc (pgb *ChainDB) HeightDB() (uint64, error)\n```\nHeightDB queries the DB for the best block height.\n\n```go\nfunc (pgb *ChainDB) IndexAddressTable() error\n```\nIndexAddressTable creates the indexes on the address table on the vout ID and address columns, separately.\n\n```go\nfunc (pgb *ChainDB) IndexAll() error\n```\nIndexAll creates all of the indexes in all tables\n\n```go\nfunc (pgb *ChainDB) IndexTicketsTable() error\n```\nIndexTicketsTable creates the indexes on the tickets table on ticket hash and tx DB ID columns, separately.\n\n```go\nfunc (pgb *ChainDB) InsightPgGetAddressTransactions(addr []string,\n\trecentBlockHeight int64) ([]string, []string)\n```\nInsightPgGetAddressTransactions performs a db query to pull all txids for the specified addresses ordered desc by time.\n\n```go\nfunc (pgb *ChainDB) PoolStatusForTicket(txid string) (dbtypes.TicketSpendType, dbtypes.TicketPoolStatus, error)\n```\nPoolStatusForTicket retrieves the specified ticket's spend status and ticket pool status, and an error value.\n\n```go\nfunc (pgb *ChainDB) RetrieveAddressIDsByOutpoint(txHash string,\n\tvoutIndex uint32) ([]uint64, []string, int64, error)\n```\nUpdate Vin due to DCRD AMOUNTIN - START\n\n```go\nfunc (pgb *ChainDB) RetrieveAddressSpentUnspent(address string) (int64, int64, int64, int64, error)\n```\nRetrieveAddressSpentUnspent retrieves balance information for a specific address.\n\n```go\nfunc (pgb *ChainDB) SetupTables() error\n```\nSetupTables creates the required tables and type, and prints table versions stored in the table comments when debug level logging is enabled.\n\n```go\nfunc (pgb *ChainDB) SpendingTransaction(fundingTxID string,\n\tfundingTxVout uint32) (string, uint32, int8, error)\n```\nSpendingTransaction returns the transaction that spends the specified transaction outpoint, if it is spent. The spending transaction hash, input index, tx tree, and an error value are returned.\n\n```go\nfunc (pgb *ChainDB) SpendingTransactions(fundingTxID string) ([]string, []uint32, []uint32, error)\n```\nSpendingTransactions retrieves all transactions spending outpoints from the specified funding transaction. The spending transaction hashes, the spending tx input indexes, and the corresponding funding tx output indexes, and an error value are returned.\n\n```go\nfunc (pgb *ChainDB) Store(blockData *blockdata.BlockData, msgBlock *wire.MsgBlock) error\n```\nStore satisfies BlockDataSaver\n\n```go\nfunc (pgb *ChainDB) StoreBlock(msgBlock *wire.MsgBlock, winningTickets []string,\n\tisValid, updateAddressesSpendingInfo, updateTicketsSpendingInfo bool) (numVins int64, numVouts int64, err error)\n```\nStoreBlock processes the input wire.MsgBlock, and saves to the data tables. The number of vins, and vouts stored are also returned.\n\n```go\nfunc (db *ChainDB) SyncChainDB(client rpcutils.MasterBlockGetter, quit chan struct{},\n\tupdateAllAddresses, updateAllVotes, newIndexes bool) (int64, error)\n```\nSyncChainDB stores in the DB all blocks on the main chain available from the RPC client. The table indexes may be force-dropped and recreated by setting newIndexes to true. The quit channel is used to break the sync loop. For example, closing the channel on SIGINT.\n\n```go\nfunc (db *ChainDB) SyncChainDBAsync(res chan dbtypes.SyncResult,\n\tclient rpcutils.MasterBlockGetter, quit chan struct{}, updateAllAddresses,\n\tupdateAllVotes, newIndexes bool)\n```\nSyncChainDBAsync is like SyncChainDB except it also takes a result channel on which the caller should wait to receive the result. As such, this method should be called as a goroutine or it will hang on send if the channel is unbuffered.\n\n```go\nfunc (pgb *ChainDB) TransactionBlock(txID string) (string, uint32, int8, error)\n```\nTransactionBlock retrieves the hash of the block containing the specified transaction. The index of the transaction within the block, the transaction index, and an error value are also returned.\n\n```go\nfunc (pgb *ChainDB) UpdateDevBalance() (bool, error)\n```\nUpdateDevBalance forcibly updates the cached development/project fund balance via DB queries. The bool output inidcates if the cached balance was updated (if it was stale).\n\n```go\nfunc (pgb *ChainDB) UpdateSpendingInfoInAllAddresses() (int64, error)\n```\nUpdateSpendingInfoInAllAddresses completely rebuilds the spending transaction info columns of the address table. This is intended to be use after syncing all other tables and creating their indexes, particularly the indexes on the vins table, and the addresses table index on the funding tx columns. This can be used instead of using updateAddressesSpendingInfo=true with storeTxns, which will update these addresses table columns too, but much more slowly for a number of reasons (that are well worth investigating BTW!).\n\n```go\nfunc (pgb *ChainDB) UpdateSpendingInfoInAllTickets() (int64, error)\n```\nUpdateSpendingInfoInAllTickets reviews all votes and revokes and sets this spending info in the tickets table.\n\n```go\nfunc (pgb *ChainDB) UseStakeDB(stakeDB *stakedb.StakeDatabase)\n```\nUseStakeDB is used to assign a stakedb.StakeDatabase for ticket tracking. This may be useful when it is necessary to construct a ChainDB prior to creating or loading a StakeDatabase, such as when dropping tables.\n\n```go\nfunc (pgb *ChainDB) VersionCheck() error\n```\nVersionCheck checks the current version of all known tables and notifies when an upgrade is required. Since there is presently no automatic upgrade, an error is returned when any table is not of the correct version.\n\n```go\nfunc (pgb *ChainDB) VotesInBlock(hash string) (int16, error)\n```\nVotesInBlock returns the number of votes mined in the block with the specified hash.\n\n```go\nfunc (pgb *ChainDB) VoutValue(txID string, vout uint32) (uint64, error)\n```\nVoutValue retrieves the value of the specified transaction outpoint in atoms.\n\n```go\nfunc (pgb *ChainDB) VoutValues(txID string) ([]uint64, []uint32, []int8, error)\n```\nVoutValues retrieves the values of each outpoint of the specified transaction. The corresponding indexes in the block and tx trees of the outpoints, and an error value are also returned.\n\n```go\ntype ChainDBRPC struct {\n\tChainDB *ChainDB\n\tClient  *rpcclient.Client\n}\n```\nChainDBRPC provides an interface for storing and manipulating extracted and includes the RPC Client blockchain data in a PostgreSQL database.\n\n```go\nfunc NewChainDBRPC(chaindb *ChainDB, cl *rpcclient.Client) (*ChainDBRPC, error)\n```\nNewChainDBRPC contains ChainDB and RPC client parameters. By default, duplicate row checks on insertion are enabled. also enables rpc client\n\n```go\nfunc (pgb *ChainDBRPC) GetBlockVerboseByHash(hash string, verboseTx bool) *dcrjson.GetBlockVerboseResult\n```\nGetBlockVerboseByHash returns a \\*dcrjson.GetBlockVerboseResult for the specified block hash, optionally with transaction details.\n\n```go\nfunc (pgb *ChainDBRPC) GetRawTransaction(txid string) (*dcrjson.TxRawResult, error)\n```\nGetRawTransaction gets a dcrjson.TxRawResult for the specified transaction hash.\n\n```go\nfunc (pgb *ChainDBRPC) GetTransactionHex(txid string) string\n```\nGetTransactionHex returns the full serialized transaction for the specified transaction hash as a hex encode string.\n\n```go\nfunc (pgb *ChainDBRPC) GetTransactionsForBlockByHash(hash string) *apitypes.BlockTransactions\n```\nGetTransactionsForBlockByHash returns a \\*apitypes.BlockTransactions for the block with the specified hash.\n\n```go\nfunc (pgb *ChainDBRPC) InsightGetAddressTransactions(addr string, count,\n\tskip int) []*dcrjson.SearchRawTransactionsResult\n```\nInsightGetAddressTransactions performs a searchrawtransactions for the specfied address, max number of transactions, and offset into the transaction list. The search results are in reverse temporal order. TODO: Does this really need all the prev vout extra data?\n\n```go\nfunc (db *ChainDBRPC) SendRawTransaction(txhex string) (string, error)\n```\nSendRawTransaction attempts to decode the input serialized transaction, passed as hex encoded string, and broadcast it, returning the tx hash.\n\n```go\ntype DBInfo struct {\n\tHost, Port, User, Pass, DBName string\n}\n```\nDBInfo holds the PostgreSQL database connection information.\n\n```go\ntype DevFundBalance struct {\n\tsync.RWMutex\n\t*explorer.AddressBalance\n\n\tHeight int64\n\tHash   chainhash.Hash\n\t// contains filtered or unexported fields\n}\n```\nDevFundBalance is a block-stamped wrapper for explorer.AddressBalance. It is intended to be used for the project address.\n\n```go\nfunc (d *DevFundBalance) Balance() *explorer.AddressBalance\n```\nBalance is a thread-safe accessor for the explorer.AddressBalance.\n\n```go\nfunc (d *DevFundBalance) BlockHash() chainhash.Hash\n```\nBlockHash is a thread-safe accessor for the block hash.\n\n```go\nfunc (d *DevFundBalance) BlockHeight() int64\n```\nBlockHeight is a thread-safe accessor for the block height.\n\n```go\ntype MsgBlockPG struct {\n\t*wire.MsgBlock\n\tWinningTickets []string\n\tValidators     []string\n}\n```\nMsgBlockPG extends wire.MsgBlock with the winning tickets from the block, WinningTickets, and the tickets from the previous block that may vote on this block's validity, Validators.\n\n```go\ntype TableUpgrade struct {\n\tTableName, UpgradeType  string\n\tCurrentVer, RequiredVer TableVersion\n}\n```\nTableUpgrade is used to define a required upgrade for a table\n\n```go\nfunc TableUpgradesRequired(versions map[string]TableVersion) []TableUpgrade\n```\n\n```go\nfunc (s TableUpgrade) String() string\n```\n\n```go\ntype TableVersion struct {\n\t// contains filtered or unexported fields\n}\n```\nTableVersion models a table version by major.minor.patch\n\n```go\nfunc NewTableVersion(major, minor, patch uint32) TableVersion\n```\nNewTableVersion returns a new TableVersion with the version major.minor.patch\n\n```go\nfunc (s TableVersion) String() string\n```\n\n```go\ntype TicketTxnIDGetter struct {\n\tsync.RWMutex\n\t// contains filtered or unexported fields\n}\n```\nTicketTxnIDGetter provides a cache for DB row IDs of tickets.\n\n```go\nfunc NewTicketTxnIDGetter(db *sql.DB) *TicketTxnIDGetter\n```\nNewTicketTxnIDGetter constructs a new TicketTxnIDGetter with an empty cache.\n\n```go\nfunc (t *TicketTxnIDGetter) Set(txid string, txDbID uint64)\n```\nSet stores the (transaction hash, DB row ID) pair a map for future access.\n\n```go\nfunc (t *TicketTxnIDGetter) SetN(txid []string, txDbID []uint64)\n```\nSetN stores several (transaction hash, DB row ID) pairs in the map.\n\n```go\nfunc (t *TicketTxnIDGetter) TxnDbID(txid string, expire bool) (uint64, error)\n```\nTxnDbID fetches DB row ID for the ticket specified by the input transaction hash. A cache is checked first. In the event of a cache hit, the DB ID is returned and deleted from the internal cache. In the event of a cache miss, the database is queried. If the database query fails, the error is non-nil.\n\n","path":"github.com/parallelcointeam/exploder/db/dcrpg","name":"dcrpg","synopsis":"","isRedistributable":true}
