Documentation ¶
Index ¶
- Constants
- Variables
- func Connect(host, port, user, pass, dbname string) (*sql.DB, error)
- func CreateTable(db *sql.DB, tableName string) error
- func CreateTables(db *sql.DB) error
- func CreateTypes(db *sql.DB) error
- func DeindexAddressTableOnAddress(db *sql.DB) (err error)
- func DeindexAddressTableOnTxHash(db *sql.DB) (err error)
- func DeindexAddressTableOnVoutID(db *sql.DB) (err error)
- func DeindexAgendasTableOnAgendaID(db *sql.DB) (err error)
- func DeindexAgendasTableOnBlockTime(db *sql.DB) (err error)
- func DeindexBlockTableOnHash(db *sql.DB) (err error)
- func DeindexBlockTableOnHeight(db *sql.DB) (err error)
- func DeindexBlockTimeOnTableAddress(db *sql.DB) (err error)
- func DeindexMatchingTxHashOnTableAddress(db *sql.DB) (err error)
- func DeindexMissesTableOnHash(db *sql.DB) (err error)
- func DeindexTicketsTableOnHash(db *sql.DB) (err error)
- func DeindexTicketsTableOnPoolStatus(db *sql.DB) (err error)
- func DeindexTicketsTableOnTxDbID(db *sql.DB) (err error)
- func DeindexTransactionTableOnBlockIn(db *sql.DB) (err error)
- func DeindexTransactionTableOnHashes(db *sql.DB) (err error)
- func DeindexVinTableOnPrevOuts(db *sql.DB) (err error)
- func DeindexVinTableOnVins(db *sql.DB) (err error)
- func DeindexVotesTableOnBlockHash(db *sql.DB) (err error)
- func DeindexVotesTableOnCandidate(db *sql.DB) (err error)
- func DeindexVotesTableOnHash(db *sql.DB) (err error)
- func DeindexVotesTableOnVoteVersion(db *sql.DB) (err error)
- func DeindexVoutTableOnTxHashIdx(db *sql.DB) (err error)
- func DeleteDuplicateMisses(db *sql.DB) (int64, error)
- func DeleteDuplicateTickets(db *sql.DB) (int64, error)
- func DeleteDuplicateTxns(db *sql.DB) (int64, error)
- func DeleteDuplicateVins(db *sql.DB) (int64, error)
- func DeleteDuplicateVotes(db *sql.DB) (int64, error)
- func DeleteDuplicateVouts(db *sql.DB) (int64, error)
- func DisableLog()
- func DropTables(db *sql.DB)
- func ExistsIndex(db *sql.DB, indexName string) (exists bool, err error)
- func IndexAddressTableOnAddress(db *sql.DB) (err error)
- func IndexAddressTableOnTxHash(db *sql.DB) (err error)
- func IndexAddressTableOnVoutID(db *sql.DB) (err error)
- func IndexAgendasTableOnAgendaID(db *sql.DB) (err error)
- func IndexAgendasTableOnBlockTime(db *sql.DB) (err error)
- func IndexBlockTableOnHash(db *sql.DB) (err error)
- func IndexBlockTableOnHeight(db *sql.DB) (err error)
- func IndexBlockTimeOnTableAddress(db *sql.DB) (err error)
- func IndexMatchingTxHashOnTableAddress(db *sql.DB) (err error)
- func IndexMissesTableOnHashes(db *sql.DB) (err error)
- func IndexTicketsTableOnHashes(db *sql.DB) (err error)
- func IndexTicketsTableOnPoolStatus(db *sql.DB) (err error)
- func IndexTicketsTableOnTxDbID(db *sql.DB) (err error)
- func IndexTransactionTableOnBlockIn(db *sql.DB) (err error)
- func IndexTransactionTableOnHashes(db *sql.DB) (err error)
- func IndexVinTableOnPrevOuts(db *sql.DB) (err error)
- func IndexVinTableOnVins(db *sql.DB) (err error)
- func IndexVotesTableOnBlockHash(db *sql.DB) (err error)
- func IndexVotesTableOnCandidate(db *sql.DB) (err error)
- func IndexVotesTableOnHashes(db *sql.DB) (err error)
- func IndexVotesTableOnVoteVersion(db *sql.DB) (err error)
- func IndexVoutTableOnTxHashIdx(db *sql.DB) (err error)
- func InsertAddressRow(db *sql.DB, dbA *dbtypes.AddressRow, dupCheck, updateExistingRecords bool) (uint64, error)
- func InsertAddressRows(db *sql.DB, dbAs []*dbtypes.AddressRow, dupCheck, updateExistingRecords bool) ([]uint64, error)
- func InsertBlock(db *sql.DB, dbBlock *dbtypes.Block, isValid, isMainchain, checked bool) (uint64, error)
- func InsertBlockPrevNext(db *sql.DB, blockDbID uint64, hash, prev, next string) error
- func InsertSpendingAddressRow(db *sql.DB, fundingTxHash string, fundingTxVoutIndex uint32, ...) (int64, error)
- func InsertTickets(db *sql.DB, dbTxns []*dbtypes.Tx, txDbIDs []uint64, ...) ([]uint64, []*dbtypes.Tx, error)
- func InsertTx(db *sql.DB, dbTx *dbtypes.Tx, checked, updateExistingRecords bool) (uint64, error)
- func InsertTxns(db *sql.DB, dbTxns []*dbtypes.Tx, checked, updateExistingRecords bool) ([]uint64, error)
- func InsertVin(db *sql.DB, dbVin dbtypes.VinTxProperty, checked bool, ...) (id uint64, err error)
- func InsertVins(db *sql.DB, dbVins dbtypes.VinTxPropertyARRAY, checked bool, ...) ([]uint64, error)
- func InsertVotes(db *sql.DB, dbTxns []*dbtypes.Tx, _ []uint64, fTx *TicketTxnIDGetter, ...) ([]uint64, []*dbtypes.Tx, []string, []uint64, map[string]uint64, error)
- func InsertVout(db *sql.DB, dbVout *dbtypes.Vout, checked bool, updateOnConflict ...bool) (uint64, error)
- func InsertVouts(db *sql.DB, dbVouts []*dbtypes.Vout, checked bool, updateOnConflict ...bool) ([]uint64, []dbtypes.AddressRow, error)
- func IsUniqueIndex(db *sql.DB, indexName string) (isUnique bool, err error)
- func RetrieveAddressCreditTxns(db *sql.DB, address string, N, offset int64) ([]uint64, []*dbtypes.AddressRow, error)
- func RetrieveAddressDebitTxns(db *sql.DB, address string, N, offset int64) ([]uint64, []*dbtypes.AddressRow, error)
- func RetrieveAddressIDsByOutpoint(db *sql.DB, txHash string, voutIndex uint32) ([]uint64, []string, int64, error)
- func RetrieveAddressMergedDebitTxns(db *sql.DB, address string, N, offset int64) ([]uint64, []*dbtypes.AddressRow, error)
- func RetrieveAddressRecvCount(db *sql.DB, address string) (count int64, err error)
- func RetrieveAddressSpent(db *sql.DB, address string) (count, totalAmount int64, err error)
- func RetrieveAddressSpentUnspent(db *sql.DB, address string) (numSpent, numUnspent, amtSpent, amtUnspent, numMergedSpent int64, err error)
- func RetrieveAddressTxns(db *sql.DB, address string, N, offset int64) ([]uint64, []*dbtypes.AddressRow, error)
- func RetrieveAddressTxnsOrdered(db *sql.DB, addresses []string, recentBlockHeight int64) (txs []string, recenttxs []string)
- func RetrieveAddressUTXOs(db *sql.DB, address string, currentBlockHeight int64) ([]apitypes.AddressTxnOutput, error)
- func RetrieveAddressUnspent(db *sql.DB, address string) (count, totalAmount int64, err error)
- func RetrieveAllAddressTxns(db *sql.DB, address string) ([]uint64, []*dbtypes.AddressRow, error)
- func RetrieveAllRevokes(db *sql.DB) (ids []uint64, hashes []string, heights []int64, vinDbIDs []uint64, err error)
- func RetrieveAllVinDbIDs(db *sql.DB) (vinDbIDs []uint64, err error)
- func RetrieveAllVotesDbIDsHeightsTicketDbIDs(db *sql.DB) (ids []uint64, heights []int64, ticketDbIDs []uint64, err error)
- func RetrieveBestBlockHeight(db *sql.DB) (height uint64, hash string, id uint64, err error)
- func RetrieveBestBlockHeightAny(db *sql.DB) (height uint64, hash string, id uint64, err error)
- func RetrieveBlockChainDbID(db *sql.DB, hash string) (dbID uint64, err error)
- func RetrieveBlockFlags(db *sql.DB, hash string) (isValid bool, isMainchain bool, err error)
- func RetrieveBlockHash(db *sql.DB, idx int64) (hash string, err error)
- func RetrieveBlockHeight(db *sql.DB, hash string) (height int64, err error)
- func RetrieveBlockStatus(db *sql.DB, hash string) (bs dbtypes.BlockStatus, err error)
- func RetrieveBlockSummaryByTimeRange(db *sql.DB, minTime, maxTime int64, limit int) ([]dbtypes.BlockDataBasic, error)
- func RetrieveBlockVoteCount(db *sql.DB, hash string) (numVotes int16, err error)
- func RetrieveBlocksHashesAll(db *sql.DB) ([]string, error)
- func RetrieveDbTxByHash(db *sql.DB, txHash string) (id uint64, dbTx *dbtypes.Tx, err error)
- func RetrieveDbTxsByHash(db *sql.DB, txHash string) (ids []uint64, dbTxs []*dbtypes.Tx, err error)
- func RetrieveDisapprovedBlocks(db *sql.DB) (blocks []*dbtypes.BlockStatus, err error)
- func RetrieveFullTxByHash(db *sql.DB, txHash string) (id uint64, blockHash string, blockHeight int64, blockTime int64, time int64, ...)
- func RetrieveFundingOutpointByTxIn(db *sql.DB, txHash string, vinIndex uint32) (id uint64, tx string, index uint32, tree int8, err error)
- func RetrieveFundingOutpointByVinID(db *sql.DB, vinDbID uint64) (tx string, index uint32, tree int8, err error)
- func RetrieveFundingOutpointIndxByVinID(db *sql.DB, vinDbID uint64) (idx uint32, err error)
- func RetrieveFundingTxByTxIn(db *sql.DB, txHash string, vinIndex uint32) (id uint64, tx string, err error)
- func RetrieveFundingTxByVinDbID(db *sql.DB, vinDbID uint64) (tx string, err error)
- func RetrieveFundingTxsByTx(db *sql.DB, txHash string) ([]uint64, []*dbtypes.Tx, error)
- func RetrieveMissedVotesInBlock(db *sql.DB, blockHash string) (ticketHashes []string, err error)
- func RetrievePkScriptByID(db *sql.DB, id uint64) (pkScript []byte, ver uint16, err error)
- func RetrievePkScriptByOutpoint(db *sql.DB, txHash string, voutIndex uint32) (pkScript []byte, ver uint16, err error)
- func RetrievePreviousHashByBlockHash(db *sql.DB, hash string) (previousHash string, err error)
- func RetrieveSideChainBlocks(db *sql.DB) (blocks []*dbtypes.BlockStatus, err error)
- func RetrieveSideChainTips(db *sql.DB) (blocks []*dbtypes.BlockStatus, err error)
- func RetrieveSpendingTxByTxOut(db *sql.DB, txHash string, voutIndex uint32) (id uint64, tx string, vin uint32, tree int8, err error)
- func RetrieveSpendingTxByVinID(db *sql.DB, vinDbID uint64) (tx string, vinIndex uint32, tree int8, err error)
- func RetrieveSpendingTxsByFundingTx(db *sql.DB, fundingTxID string) (dbIDs []uint64, txns []string, vinInds []uint32, voutInds []uint32, err error)
- func RetrieveSpendingTxsByFundingTxWithBlockHeight(db *sql.DB, fundingTxID string) (aSpendByFunHash []*apitypes.SpendByFundingHash, err error)
- func RetrieveTicketIDByHash(db *sql.DB, ticketHash string) (id uint64, err error)
- func RetrieveTicketIDsByHashes(db *sql.DB, ticketHashes []string) (ids []uint64, err error)
- func RetrieveTicketStatusByHash(db *sql.DB, ticketHash string) (id uint64, spendStatus dbtypes.TicketSpendType, ...)
- func RetrieveTicketsPriceByHeight(db *sql.DB, val int64) (*dbtypes.ChartsData, error)
- func RetrieveTxBlockTimeByHash(db *sql.DB, txHash string) (blockTime uint64, err error)
- func RetrieveTxByHash(db *sql.DB, txHash string) (id uint64, blockHash string, blockInd uint32, tree int8, err error)
- func RetrieveTxnsBlocks(db *sql.DB, txHash string) (blockHashes []string, blockHeights, blockIndexes []uint32, ...)
- func RetrieveTxnsVinsByBlock(db *sql.DB, blockHash string) (vinDbIDs []dbtypes.UInt64Array, areValid []bool, areMainchain []bool, ...)
- func RetrieveTxnsVinsVoutsByBlock(db *sql.DB, blockHash string, onlyRegular bool) (vinDbIDs, voutDbIDs []dbtypes.UInt64Array, areMainchain []bool, err error)
- func RetrieveTxsByBlockHash(db *sql.DB, blockHash string) (ids []uint64, txs []string, blockInds []uint32, trees []int8, ...)
- func RetrieveUnspentTickets(db *sql.DB) (ids []uint64, hashes []string, err error)
- func RetrieveVinByID(db *sql.DB, vinDbID uint64) (prevOutHash string, prevOutVoutInd uint32, prevOutTree int8, txHash string, ...)
- func RetrieveVinsByIDs(db *sql.DB, vinDbIDs []uint64) ([]dbtypes.VinTxProperty, error)
- func RetrieveVoutIDByOutpoint(db *sql.DB, txHash string, voutIndex uint32) (id uint64, err error)
- func RetrieveVoutValue(db *sql.DB, txHash string, voutIndex uint32) (value uint64, err error)
- func RetrieveVoutValues(db *sql.DB, txHash string) (values []uint64, txInds []uint32, txTrees []int8, err error)
- func RetrieveVoutsByIDs(db *sql.DB, voutDbIDs []uint64) ([]dbtypes.Vout, error)
- func SetMainchainByBlockHash(db *sql.DB, hash string, isMainchain bool) (previousHash string, err error)
- func SetPoolStatusForTickets(db *sql.DB, ticketDbIDs []uint64, poolStatuses []dbtypes.TicketPoolStatus) (int64, error)
- func SetPoolStatusForTicketsByHash(db *sql.DB, tickets []string, poolStatuses []dbtypes.TicketPoolStatus) (int64, error)
- func SetSpendingForFundingOP(db *sql.DB, fundingTxHash string, fundingTxVoutIndex uint32, ...) (int64, error)
- func SetSpendingForTickets(db *sql.DB, ticketDbIDs, spendDbIDs []uint64, blockHeights []int64, ...) (int64, error)
- func SetSpendingForVinDbID(db *sql.DB, vinDbID uint64) (int64, error)
- func SetSpendingForVinDbIDs(db *sql.DB, vinDbIDs []uint64) ([]int64, int64, error)
- func TableExists(db *sql.DB, tableName string) (bool, error)
- func TableVersionCompatible(required, actual TableVersion) string
- func TableVersions(db *sql.DB) map[string]TableVersion
- func TicketPoolData(interval dbtypes.ChartGrouping, height uint64) (barGraphs []*dbtypes.PoolTicketsData, donutChart *dbtypes.PoolTicketsData, ...)
- func TypeExists(db *sql.DB, tableName string) (bool, error)
- func UpdateAddressesMainchainByIDs(db *sql.DB, vinsBlk, voutsBlk []dbtypes.UInt64Array, isValidMainchain bool) (numSpendingRows, numFundingRows int64, err error)
- func UpdateBlockNext(db *sql.DB, blockDbID uint64, next string) error
- func UpdateBlockNextByHash(db *sql.DB, this, next string) error
- func UpdateLastAddressesValid(db *sql.DB, blockHash string, isValid bool) error
- func UpdateLastBlockValid(db *sql.DB, blockDbID uint64, isValid bool) error
- func UpdateLastVins(db *sql.DB, blockHash string, isValid, isMainchain bool) error
- func UpdateTicketPoolData(interval dbtypes.ChartGrouping, barGraphs []*dbtypes.PoolTicketsData, ...)
- func UpdateTicketsMainchain(db *sql.DB, blockHash string, isMainchain bool) (int64, error)
- func UpdateTransactionsMainchain(db *sql.DB, blockHash string, isMainchain bool) (int64, []uint64, error)
- func UpdateTransactionsValid(db *sql.DB, blockHash string, isValid bool) (int64, []uint64, error)
- func UpdateVotesMainchain(db *sql.DB, blockHash string, isMainchain bool) (int64, error)
- func UseLogger(logger slog.Logger)
- type ChainDB
- func (pgb *ChainDB) AddressHistory(address string, N, offset int64, txnType dbtypes.AddrTxnType) ([]*dbtypes.AddressRow, *explorer.AddressBalance, error)
- func (pgb *ChainDB) AddressHistoryAll(address string, N, offset int64) ([]*dbtypes.AddressRow, *explorer.AddressBalance, error)
- func (pgb *ChainDB) AddressTotals(address string) (*apitypes.AddressTotals, error)
- func (pgb *ChainDB) AddressTransactionDetails(addr string, count, skip int64, txnType dbtypes.AddrTxnType) (*apitypes.Address, error)
- func (pgb *ChainDB) AddressTransactionRawDetails(addr string, count, skip int64, txnType dbtypes.AddrTxnType) ([]*apitypes.AddressTxRaw, error)
- func (pgb *ChainDB) AddressTransactions(address string, N, offset int64, txnType dbtypes.AddrTxnType) (addressRows []*dbtypes.AddressRow, err error)
- func (pgb *ChainDB) AgendaVotes(agendaID string, chartType int) (*dbtypes.AgendaVoteChoices, error)
- func (pgb *ChainDB) BlockFlags(hash string) (bool, bool, error)
- func (pgb *ChainDB) BlockHash(height int64) (string, error)
- func (pgb *ChainDB) BlockHeight(hash string) (int64, error)
- func (pgb *ChainDB) BlockMissedVotes(blockHash string) ([]string, error)
- func (pgb *ChainDB) BlockStatus(hash string) (dbtypes.BlockStatus, error)
- func (pgb *ChainDB) BlockTransactions(blockHash string) ([]string, []uint32, []int8, error)
- func (pgb *ChainDB) CheckForAuxDBUpgrade(pfcdClient *rpcclient.Client) (bool, error)
- func (pgb *ChainDB) Close() error
- func (pgb *ChainDB) CollectTicketSpendDBInfo(dbTxns []*dbtypes.Tx, txDbIDs []uint64, msgBlock *wire.MsgBlock, ...) (spendingTxDbIDs []uint64, spendTypes []dbtypes.TicketSpendType, ...)
- func (pgb *ChainDB) DeindexAddressTable() error
- func (pgb *ChainDB) DeindexAll() error
- func (pgb *ChainDB) DeindexTicketsTable() error
- func (pgb *ChainDB) DeleteDuplicateMisses() (int64, error)
- func (pgb *ChainDB) DeleteDuplicateTickets() (int64, error)
- func (pgb *ChainDB) DeleteDuplicateTxns() (int64, error)
- func (pgb *ChainDB) DeleteDuplicateVins() (int64, error)
- func (pgb *ChainDB) DeleteDuplicateVotes() (int64, error)
- func (pgb *ChainDB) DeleteDuplicateVouts() (int64, error)
- func (pgb *ChainDB) DeleteDuplicates(barLoad chan *dbtypes.ProgressBarLoad) error
- func (pgb *ChainDB) DeleteDuplicatesRecovery(barLoad chan *dbtypes.ProgressBarLoad) error
- func (pgb *ChainDB) DevBalance() (*explorer.AddressBalance, error)
- func (pgb *ChainDB) DisapprovedBlocks() ([]*dbtypes.BlockStatus, error)
- func (pgb *ChainDB) DropTables()
- func (pgb *ChainDB) EnableDuplicateCheckOnInsert(dupCheck bool)
- func (pgb *ChainDB) ExistsIndexAddressesVoutIDAddress() (bool, error)
- func (pgb *ChainDB) ExistsIndexVinOnVins() (bool, error)
- func (pgb *ChainDB) ExistsIndexVoutOnTxHashIdx() (bool, error)
- func (pgb *ChainDB) FillAddressTransactions(addrInfo *explorer.AddressInfo) error
- func (pgb *ChainDB) FreshenAddressCaches(lazyProjectFund bool) error
- func (pgb *ChainDB) GetAddressBalance(address string, N, offset int64) *explorer.AddressBalance
- func (pgb *ChainDB) GetAddressUTXO(address string) []apitypes.AddressTxnOutput
- func (pgb *ChainDB) GetBlockHash(idx int64) (string, error)
- func (pgb *ChainDB) GetBlockHeight(hash string) (int64, error)
- func (pgb *ChainDB) GetBlockSummaryTimeRange(min, max int64, limit int) []dbtypes.BlockDataBasic
- func (pgb *ChainDB) GetHeight() int
- func (pgb *ChainDB) GetOldestTxBlockTime(addr string) (int64, error)
- func (pgb *ChainDB) GetPgChartsData() (map[string]*dbtypes.ChartsData, error)
- func (pgb *ChainDB) GetSpendDetailsByFundingHash(fundHash string) []*apitypes.SpendByFundingHash
- func (pgb *ChainDB) GetTicketPoolBlockMaturity() int64
- func (pgb *ChainDB) GetTicketPoolByDateAndInterval(maturityBlock int64, interval dbtypes.ChartGrouping) (*dbtypes.PoolTicketsData, error)
- func (pgb *ChainDB) GetTicketsPriceByHeight() (*dbtypes.ChartsData, error)
- func (pgb *ChainDB) GetTxHistoryData(address string, addrChart dbtypes.HistoryChart, ...) (*dbtypes.ChartsData, error)
- func (pgb *ChainDB) Hash() *chainhash.Hash
- func (pgb *ChainDB) HashDB() (string, error)
- func (pgb *ChainDB) HashStr() string
- func (pgb *ChainDB) Height() uint64
- func (pgb *ChainDB) HeightDB() (uint64, error)
- func (pgb *ChainDB) IndexAddressTable(barLoad chan *dbtypes.ProgressBarLoad) error
- func (pgb *ChainDB) IndexAll(barLoad chan *dbtypes.ProgressBarLoad) error
- func (pgb *ChainDB) IndexTicketsTable(barLoad chan *dbtypes.ProgressBarLoad) error
- func (pgb *ChainDB) InsightPgGetAddressTransactions(addr []string, recentBlockHeight int64) ([]string, []string)
- func (pgb *ChainDB) PoolStatusForTicket(txid string) (dbtypes.TicketSpendType, dbtypes.TicketPoolStatus, error)
- func (pgb *ChainDB) PosIntervals(limit, offset uint64) ([]*dbtypes.BlocksGroupedInfo, error)
- func (pgb *ChainDB) ReindexAddressesBlockTime() error
- func (pgb *ChainDB) RetrieveAddressIDsByOutpoint(txHash string, voutIndex uint32) ([]uint64, []string, int64, error)
- func (pgb *ChainDB) RetrieveAddressSpentUnspent(address string) (int64, int64, int64, int64, int64, error)
- func (pgb *ChainDB) SetVinsMainchainByBlock(blockHash string) (int64, []dbtypes.UInt64Array, []dbtypes.UInt64Array, error)
- func (pgb *ChainDB) SetupTables() error
- func (pgb *ChainDB) SideChainBlocks() ([]*dbtypes.BlockStatus, error)
- func (pgb *ChainDB) SideChainTips() ([]*dbtypes.BlockStatus, error)
- func (pgb *ChainDB) SpendingTransaction(fundingTxID string, fundingTxVout uint32) (string, uint32, int8, error)
- func (pgb *ChainDB) SpendingTransactions(fundingTxID string) ([]string, []uint32, []uint32, error)
- func (pgb *ChainDB) Store(blockData *blockdata.BlockData, msgBlock *wire.MsgBlock) error
- func (pgb *ChainDB) StoreBlock(msgBlock *wire.MsgBlock, winningTickets []string, ...) (numVins int64, numVouts int64, numAddresses int64, err error)
- func (db *ChainDB) SyncChainDB(ctx context.Context, client rpcutils.MasterBlockGetter, ...) (int64, error)
- func (db *ChainDB) SyncChainDBAsync(ctx context.Context, res chan dbtypes.SyncResult, ...)
- func (pgb *ChainDB) TicketPoolVisualization(interval dbtypes.ChartGrouping) ([]*dbtypes.PoolTicketsData, *dbtypes.PoolTicketsData, uint64, error)
- func (pgb *ChainDB) TipToSideChain(mainRoot string) (string, int64, error)
- func (pgb *ChainDB) Transaction(txHash string) ([]*dbtypes.Tx, error)
- func (pgb *ChainDB) TransactionBlock(txID string) (string, uint32, int8, error)
- func (pgb *ChainDB) TransactionBlocks(txHash string) ([]*dbtypes.BlockStatus, []uint32, error)
- func (pgb *ChainDB) UpdateDevBalance() (bool, error)
- func (pgb *ChainDB) UpdateLastBlock(msgBlock *wire.MsgBlock, isMainchain bool) error
- func (pgb *ChainDB) UpdateSpendingInfoInAllAddresses(barLoad chan *dbtypes.ProgressBarLoad) (int64, error)
- func (pgb *ChainDB) UpdateSpendingInfoInAllTickets() (int64, error)
- func (pgb *ChainDB) UseStakeDB(stakeDB *stakedb.StakeDatabase)
- func (pgb *ChainDB) VersionCheck(client *rpcclient.Client) error
- func (pgb *ChainDB) VinsForTx(dbTx *dbtypes.Tx) ([]dbtypes.VinTxProperty, []string, []uint16, error)
- func (pgb *ChainDB) VotesInBlock(hash string) (int16, error)
- func (pgb *ChainDB) VoutValue(txID string, vout uint32) (uint64, error)
- func (pgb *ChainDB) VoutValues(txID string) ([]uint64, []uint32, []int8, error)
- func (pgb *ChainDB) VoutsForTx(dbTx *dbtypes.Tx) ([]dbtypes.Vout, error)
- type ChainDBRPC
- func (pgb *ChainDBRPC) GetBlockVerboseByHash(hash string, verboseTx bool) *dcrjson.GetBlockVerboseResult
- func (pgb *ChainDBRPC) GetRawTransaction(txid string) (*dcrjson.TxRawResult, error)
- func (pgb *ChainDBRPC) GetTransactionHex(txid string) string
- func (pgb *ChainDBRPC) GetTransactionsForBlockByHash(hash string) *apitypes.BlockTransactions
- func (pgb *ChainDBRPC) InsightGetAddressTransactions(addr string, count, skip int) []*dcrjson.SearchRawTransactionsResult
- func (db *ChainDBRPC) MissingSideChainBlocks() ([]dbtypes.SideChain, int, error)
- func (db *ChainDBRPC) NewChainMonitor(ctx context.Context, wg *sync.WaitGroup, blockChan chan *chainhash.Hash, ...) *ChainMonitor
- func (pgb *ChainDBRPC) SendRawTransaction(txhex string) (string, error)
- func (db *ChainDBRPC) Store(blockData *blockdata.BlockData, msgBlock *wire.MsgBlock) error
- func (db *ChainDBRPC) SyncChainDBAsync(ctx context.Context, res chan dbtypes.SyncResult, ...)
- type ChainMonitor
- type DBInfo
- type DevFundBalance
- type MsgBlockPG
- type TableUpgrade
- type TableUpgradeType
- type TableVersion
- type TicketTxnIDGetter
- type UTXOData
- type VinVoutTypeUpdateData
Constants ¶
const ( InitialLoadSyncStatusMsg = "(Full Mode) Syncing stake, base and auxiliary DBs..." AddressesSyncStatusMsg = "Syncing addresses table with spending info..." )
Variables ¶
var VotingMilestones = map[string]dbtypes.MileStone{
"sdiffalgorithm": {
Activated: 149248,
HardForked: 149328,
LockedIn: 141184,
},
"lnsupport": {
Activated: 149248,
LockedIn: 141184,
},
"lnfeatures": {
Activated: 189568,
LockedIn: 181504,
},
}
VotingMilestones defines the various milestones phases have taken place when the agendas have been up for voting. Only sdiffalgorithm, lnsupport and lnfeatures agenda ids exist since appropriate voting mechanisms on the pfcd level are not yet fully implemented.
Functions ¶
func Connect ¶
Connect 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.
func CreateTable ¶
CreateTable creates one of the known tables by name
func CreateTables ¶
func CreateTypes ¶
func DeindexBlockTableOnHash ¶
func DeindexVinTableOnVins ¶
func DeindexVotesTableOnHash ¶
func DeleteDuplicateMisses ¶
DeleteDuplicateMisses deletes rows in misses with duplicate tx-block hashes, leaving the one row with the lowest id.
func DeleteDuplicateTickets ¶
DeleteDuplicateTickets deletes rows in tickets with duplicate tx-block hashes, leaving the one row with the lowest id.
func DeleteDuplicateTxns ¶
DeleteDuplicateTxns deletes rows in transactions with duplicate tx-block hashes, leaving the one row with the lowest id.
func DeleteDuplicateVins ¶
DeleteDuplicateVins deletes rows in vin with duplicate tx information, leaving the one row with the lowest id.
func DeleteDuplicateVotes ¶
DeleteDuplicateVotes deletes rows in votes with duplicate tx-block hashes, leaving the one row with the lowest id.
func DeleteDuplicateVouts ¶
DeleteDuplicateVouts deletes rows in vouts with duplicate tx information, leaving the one row with the lowest id.
func DisableLog ¶
func DisableLog()
DisableLog disables all library log output. Logging output is disabled by default until UseLogger is called.
func DropTables ¶
func ExistsIndex ¶
ExistsIndex checks if the specified index name exists.
func IndexAddressTableOnAddress ¶
IndexAddressTableOnAddress creates the index for the addresses table over address.
func IndexAddressTableOnTxHash ¶
IndexAddressTableOnTxHash creates the index for the addresses table over transaction hash.
func IndexAddressTableOnVoutID ¶
IndexAddressTableOnVoutID creates the index for the addresses table over vout row ID.
func IndexBlockTableOnHash ¶
func IndexBlockTableOnHeight ¶
func IndexBlockTimeOnTableAddress ¶
IndexBlockTimeOnTableAddress creates the index for the addresses table over block time.
func IndexMatchingTxHashOnTableAddress ¶
IndexMatchingTxHashOnTableAddress creates the index for the addresses table over matching transaction hash.
func IndexVinTableOnPrevOuts ¶
func IndexVinTableOnVins ¶
func IndexVotesTableOnHashes ¶
func IndexVoutTableOnTxHashIdx ¶
IndexVoutTableOnTxHashIdx creates the index for the addresses table over transaction hash and index.
func InsertAddressRow ¶
func InsertAddressRow(db *sql.DB, dbA *dbtypes.AddressRow, dupCheck, updateExistingRecords bool) (uint64, error)
InsertAddressRow inserts an AddressRow (input or output), returning the row ID in the addresses table of the inserted data.
func InsertAddressRows ¶
func InsertAddressRows(db *sql.DB, dbAs []*dbtypes.AddressRow, dupCheck, updateExistingRecords bool) ([]uint64, error)
InsertAddressRows inserts multiple transaction inputs or outputs for certain addresses ([]AddressRow). The row IDs of the inserted data are returned.
func InsertBlock ¶
func InsertBlockPrevNext ¶
InsertBlockPrevNext inserts a new row of the block_chain table.
func InsertSpendingAddressRow ¶
func InsertSpendingAddressRow(db *sql.DB, fundingTxHash string, fundingTxVoutIndex uint32, fundingTxTree int8, spendingTxHash string, spendingTxVinIndex uint32, vinDbID uint64, utxoData *UTXOData, checked, updateExisting, isValidMainchain bool, txType int16, updateFundingRow bool, spendingTXBlockTime uint64) (int64, error)
InsertSpendingAddressRow inserts a new spending tx row, and updates any corresponding funding tx row.
func InsertTickets ¶
func InsertTickets(db *sql.DB, dbTxns []*dbtypes.Tx, txDbIDs []uint64, checked, updateExistingRecords bool) ([]uint64, []*dbtypes.Tx, error)
InsertTickets 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.
func InsertTxns ¶
func InsertVin ¶
func InsertVin(db *sql.DB, dbVin dbtypes.VinTxProperty, checked bool, updateOnConflict ...bool) (id uint64, err error)
InsertVin either inserts, attempts to insert, or upserts the given vin data into the vins table. If checked=false, an unconditional insert as attempted, which may result in a violation of a unique index constraint (error). If checked=true, a constraint violation may be handled in one of two ways: update the conflicting row (upsert), or do nothing. In all cases, the id of the new/updated/conflicting row is returned. The updateOnConflict argumenet may be omitted, in which case an upsert will be favored over no nothing, but only if checked=true.
func InsertVins ¶
func InsertVins(db *sql.DB, dbVins dbtypes.VinTxPropertyARRAY, checked bool, updateOnConflict ...bool) ([]uint64, error)
InsertVins is like InsertVin, except that it operates on a slice of vin data.
func InsertVotes ¶
func InsertVotes(db *sql.DB, dbTxns []*dbtypes.Tx, _ []uint64, fTx *TicketTxnIDGetter, msgBlock *MsgBlockPG, checked, updateExistingRecords bool, params *chaincfg.Params) ([]uint64, []*dbtypes.Tx, []string, []uint64, map[string]uint64, error)
InsertVotes 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.
This 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).
The TicketTxnIDGetter is used to get the spent tickets' row IDs. The get function, TxnDbID, is called with the expire argument set to false, so that subsequent cache lookups by other consumers will succeed.
Outputs are slices of DB row IDs for the votes and misses, and an error.
func InsertVout ¶
func InsertVout(db *sql.DB, dbVout *dbtypes.Vout, checked bool, updateOnConflict ...bool) (uint64, error)
InsertVout either inserts, attempts to insert, or upserts the given vout data into the vouts table. If checked=false, an unconditional insert as attempted, which may result in a violation of a unique index constraint (error). If checked=true, a constraint violation may be handled in one of two ways: update the conflicting row (upsert), or do nothing. In all cases, the id of the new/updated/conflicting row is returned. The updateOnConflict argumenet may be omitted, in which case an upsert will be favored over no nothing, but only if checked=true.
func InsertVouts ¶
func InsertVouts(db *sql.DB, dbVouts []*dbtypes.Vout, checked bool, updateOnConflict ...bool) ([]uint64, []dbtypes.AddressRow, error)
InsertVouts is like InsertVout, except that it operates on a slice of vout data.
func IsUniqueIndex ¶
IsUniqueIndex checks if the given index name is defined as UNIQUE.
func RetrieveAddressIDsByOutpoint ¶
func RetrieveAddressIDsByOutpoint(db *sql.DB, txHash string, voutIndex uint32) ([]uint64, []string, int64, error)
RetrieveAddressIDsByOutpoint fetches all address row IDs for a given outpoint (hash:index). Update Vin due to PFCD AMOUNTIN - START - DO NOT MERGE CHANGES IF PFCD FIXED
func RetrieveAddressSpent ¶
func RetrieveAddressSpentUnspent ¶
func RetrieveAddressSpentUnspent(db *sql.DB, address string) (numSpent, numUnspent, amtSpent, amtUnspent, numMergedSpent int64, err error)
RetrieveAddressSpentUnspent gets the numbers of spent and unspent outpoints for the given address, the total amounts spent and unspent, and the the number of distinct spending transactions.
func RetrieveAddressTxns ¶
func RetrieveAddressTxnsOrdered ¶
func RetrieveAddressTxnsOrdered(db *sql.DB, addresses []string, recentBlockHeight int64) (txs []string, recenttxs []string)
RetrieveAddressTxnsOrdered 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.
func RetrieveAddressUTXOs ¶
func RetrieveAddressUTXOs(db *sql.DB, address string, currentBlockHeight int64) ([]apitypes.AddressTxnOutput, error)
RetrieveAddressUTXOs gets the unspent transaction outputs (UTXOs) paying to the specified address.
func RetrieveAddressUnspent ¶
func RetrieveAllAddressTxns ¶
func RetrieveAllRevokes ¶
func RetrieveAllRevokes(db *sql.DB) (ids []uint64, hashes []string, heights []int64, vinDbIDs []uint64, err error)
RetrieveAllRevokes gets for all ticket revocations the row IDs (primary keys), transaction hashes, block heights. It also gets the row ID in the vins table for the first input of the revocation transaction, which should correspond to the stakesubmission previous outpoint of the ticket purchase.
func RetrieveAllVinDbIDs ¶
RetrieveAllVinDbIDs gets every row ID (the primary keys) for the vins table.
func RetrieveAllVotesDbIDsHeightsTicketDbIDs ¶
func RetrieveAllVotesDbIDsHeightsTicketDbIDs(db *sql.DB) (ids []uint64, heights []int64, ticketDbIDs []uint64, err error)
RetrieveAllVotesDbIDsHeightsTicketDbIDs gets for all votes the row IDs (primary keys) in the votes table, the block heights, and the row IDs in the tickets table of the spent tickets.
func RetrieveBestBlockHeight ¶
RetrieveBestBlockHeight gets the best block height (main chain only).
func RetrieveBestBlockHeightAny ¶
RetrieveBestBlockHeightAny gets the best block height, including side chains.
func RetrieveBlockChainDbID ¶
RetrieveBlockChainDbID 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!).
func RetrieveBlockFlags ¶
RetrieveBlockFlags retrieves the block's is_valid and is_mainchain flags.
func RetrieveBlockHash ¶
RetrieveBlockHash 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.
func RetrieveBlockHeight ¶
RetrieveBlockHeight retrieves the height of the block with the given hash, if it exists (be sure to check error against sql.ErrNoRows!).
func RetrieveBlockStatus ¶
RetrieveBlockStatus retrieves the block chain status for the block with the specified hash.
func RetrieveBlockVoteCount ¶
RetrieveBlockVoteCount gets the number of votes mined in a block.
func RetrieveBlocksHashesAll ¶
RetrieveBlocksHashesAll retrieve the hash of every block in the blocks table, ordered by their row ID.
func RetrieveDbTxByHash ¶
func RetrieveDbTxsByHash ¶
RetrieveDbTxsByHash retrieves all the rows of the transactions table, including the primary keys/ids, for the given transaction hash.
func RetrieveDisapprovedBlocks ¶
func RetrieveDisapprovedBlocks(db *sql.DB) (blocks []*dbtypes.BlockStatus, err error)
RetrieveDisapprovedBlocks retrieves the block chain status for all blocks that had their regular transactions invalidated by stakeholder disapproval.
func RetrieveFullTxByHash ¶
func RetrieveFullTxByHash(db *sql.DB, txHash string) (id uint64, blockHash string, blockHeight int64, blockTime int64, time int64, txType int16, version int32, tree int8, blockInd uint32, lockTime, expiry int32, size uint32, spent, sent, fees int64, numVin int32, vinDbIDs []int64, numVout int32, voutDbIDs []int64, isValidBlock, isMainchainBlock bool, err error)
func RetrieveFundingOutpointByTxIn ¶
func RetrieveFundingOutpointByTxIn(db *sql.DB, txHash string, vinIndex uint32) (id uint64, tx string, index uint32, tree int8, err error)
RetrieveFundingOutpointByTxIn gets the previous outpoint for a transaction input specified by transaction hash and input index.
func RetrieveFundingOutpointByVinID ¶
func RetrieveFundingOutpointByVinID(db *sql.DB, vinDbID uint64) (tx string, index uint32, tree int8, err error)
RetrieveFundingOutpointByVinID gets the previous outpoint for a transaction input specified by row ID in the vins table.
func RetrieveFundingOutpointIndxByVinID ¶
RetrieveFundingOutpointIndxByVinID gets the transaction output index of the previous outpoint for a transaction input specified by row ID in the vins table.
func RetrieveFundingTxByTxIn ¶
func RetrieveFundingTxByTxIn(db *sql.DB, txHash string, vinIndex uint32) (id uint64, tx string, err error)
RetrieveFundingTxByTxIn gets the transaction hash of the previous outpoint for a transaction input specified by hash and input index.
func RetrieveFundingTxByVinDbID ¶
RetrieveFundingTxByVinDbID gets the transaction hash of the previous outpoint for a transaction input specified by row ID in the vins table.
func RetrieveFundingTxsByTx ¶
TODO: this does not appear correct.
func RetrieveMissedVotesInBlock ¶
RetrieveMissedVotesInBlock gets a list of ticket hashes that were called to vote in the given block, but missed their vote.
func RetrievePkScriptByID ¶
func RetrieveSideChainBlocks ¶
func RetrieveSideChainBlocks(db *sql.DB) (blocks []*dbtypes.BlockStatus, err error)
RetrieveSideChainBlocks retrieves the block chain status for all known side chain blocks.
func RetrieveSideChainTips ¶
func RetrieveSideChainTips(db *sql.DB) (blocks []*dbtypes.BlockStatus, err error)
RetrieveSideChainTips retrieves the block chain status for all known side chain tip blocks.
func RetrieveSpendingTxByTxOut ¶
func RetrieveSpendingTxByTxOut(db *sql.DB, txHash string, voutIndex uint32) (id uint64, tx string, vin uint32, tree int8, err error)
RetrieveSpendingTxByTxOut gets any spending transaction input info for a previous outpoint specified by funding transaction hash and vout number.
func RetrieveSpendingTxByVinID ¶
func RetrieveSpendingTxByVinID(db *sql.DB, vinDbID uint64) (tx string, vinIndex uint32, tree int8, err error)
RetrieveSpendingTxByVinID gets the spending transaction input (hash, vin number, and tx tree) for the transaction input specified by row ID in the vins table.
func RetrieveSpendingTxsByFundingTx ¶
func RetrieveSpendingTxsByFundingTx(db *sql.DB, fundingTxID string) (dbIDs []uint64, txns []string, vinInds []uint32, voutInds []uint32, err error)
RetrieveSpendingTxsByFundingTx gets info on all spending transaction inputs for the given funding transaction specified by DB row ID.
func RetrieveSpendingTxsByFundingTxWithBlockHeight ¶
func RetrieveSpendingTxsByFundingTxWithBlockHeight(db *sql.DB, fundingTxID string) (aSpendByFunHash []*apitypes.SpendByFundingHash, err error)
RetrieveSpendingTxsByFundingTxWithBlockHeight will retrieve all transactions, indexes and block heights funded by a specific transaction.
func RetrieveTicketIDByHash ¶
RetrieveTicketIDByHash gets the db row ID (primary key) in the tickets table for the given ticket hash.
func RetrieveTicketIDsByHashes ¶
RetrieveTicketIDsByHashes gets the db row IDs (primary keys) in the tickets table for the given ticket purchase transaction hashes.
func RetrieveTicketStatusByHash ¶
func RetrieveTicketStatusByHash(db *sql.DB, ticketHash string) (id uint64, spendStatus dbtypes.TicketSpendType, poolStatus dbtypes.TicketPoolStatus, err error)
RetrieveTicketStatusByHash gets the spend status and ticket pool status for the given ticket hash.
func RetrieveTicketsPriceByHeight ¶
RetrieveTicketsPriceByHeight fetches the ticket price and its timestamp that are used to display the ticket price variation on ticket price chart. These data are fetched at an interval of chaincfg.Params.StakeDiffWindowSize.
func RetrieveTxByHash ¶
func RetrieveTxnsBlocks ¶
func RetrieveTxnsBlocks(db *sql.DB, txHash string) (blockHashes []string, blockHeights, blockIndexes []uint32, areValid, areMainchain []bool, err error)
RetrieveTxnsBlocks retrieves for the specified transaction hash the following data for each block containing the transactions: block_hash, block_index, is_valid, is_mainchain.
func RetrieveTxnsVinsByBlock ¶
func RetrieveTxnsVinsByBlock(db *sql.DB, blockHash string) (vinDbIDs []dbtypes.UInt64Array, areValid []bool, areMainchain []bool, err error)
RetrieveTxnsVinsByBlock retrieves for all the transactions in the specified block the vin_db_ids arrays, is_valid, and is_mainchain.
func RetrieveTxnsVinsVoutsByBlock ¶
func RetrieveTxnsVinsVoutsByBlock(db *sql.DB, blockHash string, onlyRegular bool) (vinDbIDs, voutDbIDs []dbtypes.UInt64Array, areMainchain []bool, err error)
RetrieveTxnsVinsVoutsByBlock retrieves for all the transactions in the specified block the vin_db_ids and vout_db_ids arrays.
func RetrieveTxsByBlockHash ¶
func RetrieveUnspentTickets ¶
RetrieveUnspentTickets gets all unspent tickets.
func RetrieveVinByID ¶
func RetrieveVinsByIDs ¶
func RetrieveVoutValue ¶
func RetrieveVoutValues ¶
func RetrieveVoutsByIDs ¶
func SetMainchainByBlockHash ¶
func SetPoolStatusForTickets ¶
func SetPoolStatusForTickets(db *sql.DB, ticketDbIDs []uint64, poolStatuses []dbtypes.TicketPoolStatus) (int64, error)
SetPoolStatusForTickets sets the ticket pool status for the tickets specified by db row ID.
func SetPoolStatusForTicketsByHash ¶
func SetPoolStatusForTicketsByHash(db *sql.DB, tickets []string, poolStatuses []dbtypes.TicketPoolStatus) (int64, error)
SetPoolStatusForTicketsByHash sets the ticket pool status for the tickets specified by ticket purchase transaction hash.
func SetSpendingForFundingOP ¶
func SetSpendingForFundingOP(db *sql.DB, fundingTxHash string, fundingTxVoutIndex uint32, spendingTxHash string, _ uint32) (int64, error)
SetSpendingForFundingOP updates funding rows of the addresses table with the provided spending transaction output info.
func SetSpendingForTickets ¶
func SetSpendingForTickets(db *sql.DB, ticketDbIDs, spendDbIDs []uint64, blockHeights []int64, spendTypes []dbtypes.TicketSpendType, poolStatuses []dbtypes.TicketPoolStatus) (int64, error)
SetSpendingForTickets sets the spend type, spend height, spending transaction row IDs (in the table relevant to the spend type), and ticket pool status for the given tickets specified by their db row IDs.
func SetSpendingForVinDbID ¶
SetSpendingForVinDbIDs updates rows of the addresses table with spending information from the row of the vins table specified by vinDbID. This does not insert the spending transaction into the addresses table.
func SetSpendingForVinDbIDs ¶
SetSpendingForVinDbIDs updates rows of the addresses table with spending information from the rows of the vins table specified by vinDbIDs. This does not insert the spending transaction into the addresses table.
func TableVersionCompatible ¶
func TableVersionCompatible(required, actual TableVersion) string
TableVersionCompatible indicates if the table versions are compatible (equal), and if not, what is the required action (rebuild, upgrade, or reindex).
func TableVersions ¶
func TableVersions(db *sql.DB) map[string]TableVersion
func TicketPoolData ¶
func TicketPoolData(interval dbtypes.ChartGrouping, height uint64) (barGraphs []*dbtypes.PoolTicketsData, donutChart *dbtypes.PoolTicketsData, actualHeight uint64, intervalFound, isStale bool)
TicketPoolData is a thread-safe way to access the ticketpool graphs data stored in the cache.
func UpdateAddressesMainchainByIDs ¶
func UpdateAddressesMainchainByIDs(db *sql.DB, vinsBlk, voutsBlk []dbtypes.UInt64Array, isValidMainchain bool) (numSpendingRows, numFundingRows int64, err error)
UpdateAddressesMainchainByIDs sets the valid_mainchain column for the addresses specified by their vin (spending) or vout (funding) row IDs.
func UpdateBlockNext ¶
UpdateBlockNext sets the next block's hash for the specified row of the block_chain table specified by DB row ID.
func UpdateBlockNextByHash ¶
UpdateBlockNextByHash sets the next block's hash for the block in the block_chain table specified by hash.
func UpdateLastAddressesValid ¶
UpdateLastAddressesValid sets valid_mainchain as specified by isValid for addresses table rows pertaining to regular (non-stake) transactions found in the given block.
func UpdateLastBlockValid ¶
UpdateLastBlockValid updates the is_valid column of the block specified by the row id for the blocks table.
func UpdateLastVins ¶
UpdateLastVins updates the is_valid and is_mainchain columns in the vins table for all of the transactions in the block specified by the given block hash.
func UpdateTicketPoolData ¶
func UpdateTicketPoolData(interval dbtypes.ChartGrouping, barGraphs []*dbtypes.PoolTicketsData, donutcharts *dbtypes.PoolTicketsData, height uint64)
UpdateTicketPoolData updates the ticket pool cache with the latest data fetched. This is a thread-safe way to update ticket pool cache data. TryLock helps avoid stacking calls to update the cache.
func UpdateTicketsMainchain ¶
UpdateTicketsMainchain sets the is_mainchain column for the tickets in the specified block.
func UpdateTransactionsMainchain ¶
func UpdateTransactionsMainchain(db *sql.DB, blockHash string, isMainchain bool) (int64, []uint64, error)
UpdateTransactionsMainchain sets the is_mainchain column for the transactions in the specified block.
func UpdateTransactionsValid ¶
UpdateTransactionsValid sets the is_valid column of the transactions table for the regular (non-stake) transactions in the specified block.
func UpdateVotesMainchain ¶
UpdateVotesMainchain sets the is_mainchain column for the votes in the specified block.
Types ¶
type ChainDB ¶
type ChainDB struct { DevFundBalance *DevFundBalance InBatchSync bool InReorg bool // contains filtered or unexported fields }
ChainDB provides an interface for storing and manipulating extracted blockchain data in a PostgreSQL database.
func NewChainDB ¶
func NewChainDB(dbi *DBInfo, params *chaincfg.Params, stakeDB *stakedb.StakeDatabase, devPrefetch bool) (*ChainDB, error)
NewChainDB constructs a ChainDB for the given connection and Decred network parameters. By default, duplicate row checks on insertion are enabled.
func NewChainDBWithCancel ¶
func NewChainDBWithCancel(ctx context.Context, dbi *DBInfo, params *chaincfg.Params, stakeDB *stakedb.StakeDatabase, devPrefetch bool) (*ChainDB, error)
NewChainDBWithCancel constructs a cancellation-capable ChainDB for the given connection and Decred network parameters. By default, duplicate row checks on insertion are enabled.
func (*ChainDB) AddressHistory ¶
func (pgb *ChainDB) AddressHistory(address string, N, offset int64, txnType dbtypes.AddrTxnType) ([]*dbtypes.AddressRow, *explorer.AddressBalance, error)
AddressHistory 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.
func (*ChainDB) AddressHistoryAll ¶
func (pgb *ChainDB) AddressHistoryAll(address string, N, offset int64) ([]*dbtypes.AddressRow, *explorer.AddressBalance, error)
AddressHistoryAll queries the database for all rows of the addresses table for the given address.
func (*ChainDB) AddressTotals ¶
func (pgb *ChainDB) AddressTotals(address string) (*apitypes.AddressTotals, error)
AddressTotals queries for the following totals: amount spent, amount unspent, number of unspent transaction outputs and number spent.
func (*ChainDB) AddressTransactionDetails ¶
func (pgb *ChainDB) AddressTransactionDetails(addr string, count, skip int64, txnType dbtypes.AddrTxnType) (*apitypes.Address, error)
AddressTransactionDetails 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.
func (*ChainDB) AddressTransactionRawDetails ¶
func (pgb *ChainDB) AddressTransactionRawDetails(addr string, count, skip int64, txnType dbtypes.AddrTxnType) ([]*apitypes.AddressTxRaw, error)
TODO: finish
func (*ChainDB) AddressTransactions ¶
func (pgb *ChainDB) AddressTransactions(address string, N, offset int64, txnType dbtypes.AddrTxnType) (addressRows []*dbtypes.AddressRow, err error)
AddressTransactions 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.
func (*ChainDB) AgendaVotes ¶
AgendaVotes fetches the data used to plot a graph of votes cast per day per choice for the provided agenda.
func (*ChainDB) BlockFlags ¶
BlockFlags retrieves the block's isValid and isMainchain flags.
func (*ChainDB) BlockHash ¶
BlockHash queries the DB for the hash of the mainchain block at the given height.
func (*ChainDB) BlockHeight ¶
BlockHeight queries the DB for the height of the specified hash.
func (*ChainDB) BlockMissedVotes ¶
BlockMissedVotes retrieves the ticket IDs for all missed votes in the specified block, and an error value.
func (*ChainDB) BlockStatus ¶
func (pgb *ChainDB) BlockStatus(hash string) (dbtypes.BlockStatus, error)
BlockStatus retrieves the block chain status of the specified block.
func (*ChainDB) BlockTransactions ¶
BlockTransactions retrieves all transactions in the specified block, their indexes in the block, their tree, and an error value.
func (*ChainDB) CheckForAuxDBUpgrade ¶
CheckForAuxDBUpgrade checks if an upgrade is required and currently supported. A boolean value is returned to indicate if the db upgrade was successfully completed.
func (*ChainDB) CollectTicketSpendDBInfo ¶
func (pgb *ChainDB) CollectTicketSpendDBInfo(dbTxns []*dbtypes.Tx, txDbIDs []uint64, msgBlock *wire.MsgBlock, isMainchain bool) (spendingTxDbIDs []uint64, spendTypes []dbtypes.TicketSpendType, ticketHashes []string, ticketDbIDs []uint64, err error)
CollectTicketSpendDBInfo processes the stake transactions in msgBlock, which correspond to the transaction data in dbTxns, and extracts data for votes and revokes, including the spent ticket hash and DB row ID.
func (*ChainDB) DeindexAddressTable ¶
DeindexAddressTable drops the vin ID, block_time, matching_tx_hash and address column indexes for the address table.
func (*ChainDB) DeindexAll ¶
DeindexAll drops indexes in most tables.
func (*ChainDB) DeindexTicketsTable ¶
DeindexTicketsTable drops indexes in the tickets table on ticket hash, ticket pool status and tx DB ID columns.
func (*ChainDB) DeleteDuplicateMisses ¶
func (*ChainDB) DeleteDuplicateTickets ¶
func (*ChainDB) DeleteDuplicateTxns ¶
func (*ChainDB) DeleteDuplicateVins ¶
func (*ChainDB) DeleteDuplicateVotes ¶
func (*ChainDB) DeleteDuplicateVouts ¶
func (*ChainDB) DeleteDuplicates ¶
func (pgb *ChainDB) DeleteDuplicates(barLoad chan *dbtypes.ProgressBarLoad) error
func (*ChainDB) DeleteDuplicatesRecovery ¶
func (pgb *ChainDB) DeleteDuplicatesRecovery(barLoad chan *dbtypes.ProgressBarLoad) error
func (*ChainDB) DevBalance ¶
func (pgb *ChainDB) DevBalance() (*explorer.AddressBalance, error)
DevBalance returns the current development/project fund balance, updating the cached balance if it is stale.
func (*ChainDB) DisapprovedBlocks ¶
func (pgb *ChainDB) DisapprovedBlocks() ([]*dbtypes.BlockStatus, error)
DisapprovedBlocks retrieves all blocks disapproved by stakeholder votes.
func (*ChainDB) DropTables ¶
func (pgb *ChainDB) DropTables()
DropTables drops (deletes) all of the known pfcdata tables.
func (*ChainDB) EnableDuplicateCheckOnInsert ¶
EnableDuplicateCheckOnInsert specifies whether SQL insertions should check for row conflicts (duplicates), and avoid adding or updating.
func (*ChainDB) ExistsIndexAddressesVoutIDAddress ¶
func (*ChainDB) ExistsIndexVinOnVins ¶
func (*ChainDB) ExistsIndexVoutOnTxHashIdx ¶
func (*ChainDB) FillAddressTransactions ¶
func (pgb *ChainDB) FillAddressTransactions(addrInfo *explorer.AddressInfo) error
FillAddressTransactions 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.
func (*ChainDB) FreshenAddressCaches ¶
FreshenAddressCaches resets the address balance cache, and prefetches the project fund balance if devPrefetch is enabled and not mid-reorg.
func (*ChainDB) GetAddressBalance ¶
func (pgb *ChainDB) GetAddressBalance(address string, N, offset int64) *explorer.AddressBalance
GetAddressBalance returns a *explorer.AddressBalance for the specified address, transaction count limit, and transaction number offset.
func (*ChainDB) GetAddressUTXO ¶
func (pgb *ChainDB) GetAddressUTXO(address string) []apitypes.AddressTxnOutput
GetAddressUTXO returns the unspent transaction outputs (UTXOs) paying to the specified address in a []apitypes.AddressTxnOutput.
func (*ChainDB) GetBlockHash ¶
GetBlockHash returns the hash of the block at the specified height. TODO: create GetBlockHashes to return all blocks at a given height.
func (*ChainDB) GetBlockHeight ¶
GetBlockHeight returns the height of the block with the specified hash.
func (*ChainDB) GetBlockSummaryTimeRange ¶
func (pgb *ChainDB) GetBlockSummaryTimeRange(min, max int64, limit int) []dbtypes.BlockDataBasic
GetBlockSummaryTimeRange returns the blocks created within a specified time range (min, max time), up to limit transactions.
func (*ChainDB) GetOldestTxBlockTime ¶
GetOldestTxBlockTime returns the block time of the oldest transaction made in relation to the provided address. This helps provide more meaningful graphs with the addresses history plotted.
func (*ChainDB) GetPgChartsData ¶
func (pgb *ChainDB) GetPgChartsData() (map[string]*dbtypes.ChartsData, error)
GetPgChartsData fetches the charts data that is stored in pg
func (*ChainDB) GetSpendDetailsByFundingHash ¶
func (pgb *ChainDB) GetSpendDetailsByFundingHash(fundHash string) []*apitypes.SpendByFundingHash
GetSpendDetailsByFundingHash will return the spending details (tx, index, block height) by funding transaction
func (*ChainDB) GetTicketPoolBlockMaturity ¶
GetTicketPoolBlockMaturity returns the block at which all tickets with height greater than it are immature.
func (*ChainDB) GetTicketPoolByDateAndInterval ¶
func (pgb *ChainDB) GetTicketPoolByDateAndInterval(maturityBlock int64, interval dbtypes.ChartGrouping) (*dbtypes.PoolTicketsData, error)
GetTicketPoolByDateAndInterval fetches the tickets ordered by the purchase date interval provided and an error value.
func (*ChainDB) GetTicketsPriceByHeight ¶
func (pgb *ChainDB) GetTicketsPriceByHeight() (*dbtypes.ChartsData, error)
GetTicketsPriceByHeight returns the ticket price by height chart data. This is the default chart that appears at charts page.
func (*ChainDB) GetTxHistoryData ¶
func (pgb *ChainDB) GetTxHistoryData(address string, addrChart dbtypes.HistoryChart, chartGroupings dbtypes.ChartGrouping) (*dbtypes.ChartsData, error)
GetTxHistoryData fetches the address history chart data for the provided parameters.
func (*ChainDB) IndexAddressTable ¶
func (pgb *ChainDB) IndexAddressTable(barLoad chan *dbtypes.ProgressBarLoad) error
IndexAddressTable creates the indexes on the address table on the vout ID, block_time, matching_tx_hash and address columns.
func (*ChainDB) IndexAll ¶
func (pgb *ChainDB) IndexAll(barLoad chan *dbtypes.ProgressBarLoad) error
IndexAll creates indexes in most tables.
func (*ChainDB) IndexTicketsTable ¶
func (pgb *ChainDB) IndexTicketsTable(barLoad chan *dbtypes.ProgressBarLoad) error
IndexTicketsTable creates indexes in the tickets table on ticket hash, ticket pool status and tx DB ID columns.
func (*ChainDB) InsightPgGetAddressTransactions ¶
func (pgb *ChainDB) InsightPgGetAddressTransactions(addr []string, recentBlockHeight int64) ([]string, []string)
InsightPgGetAddressTransactions performs a db query to pull all txids for the specified addresses ordered desc by time.
func (*ChainDB) PoolStatusForTicket ¶
func (pgb *ChainDB) PoolStatusForTicket(txid string) (dbtypes.TicketSpendType, dbtypes.TicketPoolStatus, error)
PoolStatusForTicket retrieves the specified ticket's spend status and ticket pool status, and an error value.
func (*ChainDB) PosIntervals ¶
func (pgb *ChainDB) PosIntervals(limit, offset uint64) ([]*dbtypes.BlocksGroupedInfo, error)
PosIntervals retrieves the blocks at the respective stakebase windows interval. The term "window" is used here to describe the group of blocks whose count is defined by chainParams.StakeDiffWindowSize. During this chainParams.StakeDiffWindowSize block interval the ticket price and the difficulty value is constant.
func (*ChainDB) ReindexAddressesBlockTime ¶
ReindexAddressesBlockTime rebuilds the addresses(block_time) index.
func (*ChainDB) RetrieveAddressIDsByOutpoint ¶
func (pgb *ChainDB) RetrieveAddressIDsByOutpoint(txHash string, voutIndex uint32) ([]uint64, []string, int64, error)
RetrieveAddressIDsByOutpoint fetches all address row IDs for a given outpoint (txHash:voutIndex). TODO: Update the vin due to the issue with amountin invalid for unconfirmed txns.
func (*ChainDB) RetrieveAddressSpentUnspent ¶
func (pgb *ChainDB) RetrieveAddressSpentUnspent(address string) (int64, int64, int64, int64, int64, error)
RetrieveAddressSpentUnspent retrieves balance information for a specific address.
func (*ChainDB) SetVinsMainchainByBlock ¶
func (pgb *ChainDB) SetVinsMainchainByBlock(blockHash string) (int64, []dbtypes.UInt64Array, []dbtypes.UInt64Array, error)
func (*ChainDB) SetupTables ¶
SetupTables creates the required tables and type, and prints table versions stored in the table comments when debug level logging is enabled.
func (*ChainDB) SideChainBlocks ¶
func (pgb *ChainDB) SideChainBlocks() ([]*dbtypes.BlockStatus, error)
SideChainBlocks retrieves all known side chain blocks.
func (*ChainDB) SideChainTips ¶
func (pgb *ChainDB) SideChainTips() ([]*dbtypes.BlockStatus, error)
SideChainTips retrieves the tip/head block for all known side chains.
func (*ChainDB) SpendingTransaction ¶
func (pgb *ChainDB) SpendingTransaction(fundingTxID string, fundingTxVout uint32) (string, uint32, int8, error)
SpendingTransaction 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.
func (*ChainDB) SpendingTransactions ¶
SpendingTransactions 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.
func (*ChainDB) Store ¶
Store satisfies BlockDataSaver. Blocks stored this way are considered valid and part of mainchain. Store should not be used for batch block processing; instead, use StoreBlock and specify appropriate flags.
func (*ChainDB) StoreBlock ¶
func (pgb *ChainDB) StoreBlock(msgBlock *wire.MsgBlock, winningTickets []string, isValid, isMainchain, updateExistingRecords, updateAddressesSpendingInfo, updateTicketsSpendingInfo bool) (numVins int64, numVouts int64, numAddresses int64, err error)
StoreBlock processes the input wire.MsgBlock, and saves to the data tables. The number of vins and vouts stored are returned.
func (*ChainDB) SyncChainDB ¶
func (db *ChainDB) SyncChainDB(ctx context.Context, client rpcutils.MasterBlockGetter, updateAllAddresses, updateAllVotes, newIndexes bool, updateExplorer chan *chainhash.Hash, barLoad chan *dbtypes.ProgressBarLoad) (int64, error)
SyncChainDB 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.
func (*ChainDB) SyncChainDBAsync ¶
func (db *ChainDB) SyncChainDBAsync(ctx context.Context, res chan dbtypes.SyncResult, client rpcutils.MasterBlockGetter, updateAllAddresses, updateAllVotes, newIndexes bool, updateExplorer chan *chainhash.Hash, barLoad chan *dbtypes.ProgressBarLoad)
SyncChainDBAsync 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.
func (*ChainDB) TicketPoolVisualization ¶
func (pgb *ChainDB) TicketPoolVisualization(interval dbtypes.ChartGrouping) ([]*dbtypes.PoolTicketsData, *dbtypes.PoolTicketsData, uint64, error)
TicketPoolVisualization helps block consecutive and duplicate DB queries for the requested ticket pool chart data. If the data for the given interval is cached and fresh, it is returned. If the cached data is stale and there are no queries running to update the cache for the given interval, this launches a query and updates the cache. If there is no cached data for the interval, this will launch a new query for the data if one is not already running, and if one is running, it will wait for the query to complete.
func (*ChainDB) TipToSideChain ¶
func (*ChainDB) Transaction ¶
Transaction retrieves all rows from the transactions table for the given transaction hash.
func (*ChainDB) TransactionBlock ¶
TransactionBlock 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.
func (*ChainDB) TransactionBlocks ¶
TransactionBlocks retrieves the blocks in which the specified transaction appears, along with the index of the transaction in each of the blocks. The next and previous block hashes are NOT SET in each BlockStatus.
func (*ChainDB) UpdateDevBalance ¶
UpdateDevBalance 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).
func (*ChainDB) UpdateLastBlock ¶
UpdateLastBlock set the previous block's next block hash in the block_chain table with this block's hash as it is next. If the current block's votes invalidated/disapproved the previous block, it also updates the is_valid columns for the previous block's entries in the following tables: blocks, vins, addresses, and transactions. If the previous block is not on the same chain as this block (as indicated by isMainchain), no updates are performed.
func (*ChainDB) UpdateSpendingInfoInAllAddresses ¶
func (pgb *ChainDB) UpdateSpendingInfoInAllAddresses(barLoad chan *dbtypes.ProgressBarLoad) (int64, error)
UpdateSpendingInfoInAllAddresses completely rebuilds the matching transaction columns for funding rows of the addresses 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!).
func (*ChainDB) UpdateSpendingInfoInAllTickets ¶
UpdateSpendingInfoInAllTickets reviews all votes and revokes and sets this spending info in the tickets table.
func (*ChainDB) UseStakeDB ¶
func (pgb *ChainDB) UseStakeDB(stakeDB *stakedb.StakeDatabase)
UseStakeDB 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.
func (*ChainDB) VersionCheck ¶
VersionCheck checks the current version of all known tables and notifies when an upgrade is required. If there is no automatic upgrade supported, an error is returned when any table is not of the correct version. A smart client is passed to implement the supported upgrades if need be.
func (*ChainDB) VinsForTx ¶
func (pgb *ChainDB) VinsForTx(dbTx *dbtypes.Tx) ([]dbtypes.VinTxProperty, []string, []uint16, error)
VinsForTx returns a slice of dbtypes.VinTxProperty values for each vin referenced by the transaction dbTx.
func (*ChainDB) VotesInBlock ¶
VotesInBlock returns the number of votes mined in the block with the specified hash.
func (*ChainDB) VoutValue ¶
VoutValue retrieves the value of the specified transaction outpoint in atoms.
func (*ChainDB) VoutValues ¶
VoutValues 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.
type ChainDBRPC ¶
ChainDBRPC provides an interface for storing and manipulating extracted and includes the RPC Client blockchain data in a PostgreSQL database.
func NewChainDBRPC ¶
func NewChainDBRPC(chaindb *ChainDB, cl *rpcclient.Client) (*ChainDBRPC, error)
NewChainDBRPC contains ChainDB and RPC client parameters. By default, duplicate row checks on insertion are enabled. also enables rpc client
func (*ChainDBRPC) GetBlockVerboseByHash ¶
func (pgb *ChainDBRPC) GetBlockVerboseByHash(hash string, verboseTx bool) *dcrjson.GetBlockVerboseResult
GetBlockVerboseByHash returns a *dcrjson.GetBlockVerboseResult for the specified block hash, optionally with transaction details.
func (*ChainDBRPC) GetRawTransaction ¶
func (pgb *ChainDBRPC) GetRawTransaction(txid string) (*dcrjson.TxRawResult, error)
GetRawTransaction gets a dcrjson.TxRawResult for the specified transaction hash.
func (*ChainDBRPC) GetTransactionHex ¶
func (pgb *ChainDBRPC) GetTransactionHex(txid string) string
GetTransactionHex returns the full serialized transaction for the specified transaction hash as a hex encode string.
func (*ChainDBRPC) GetTransactionsForBlockByHash ¶
func (pgb *ChainDBRPC) GetTransactionsForBlockByHash(hash string) *apitypes.BlockTransactions
GetTransactionsForBlockByHash returns a *apitypes.BlockTransactions for the block with the specified hash.
func (*ChainDBRPC) InsightGetAddressTransactions ¶
func (pgb *ChainDBRPC) InsightGetAddressTransactions(addr string, count, skip int) []*dcrjson.SearchRawTransactionsResult
InsightGetAddressTransactions 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?
func (*ChainDBRPC) MissingSideChainBlocks ¶
func (db *ChainDBRPC) MissingSideChainBlocks() ([]dbtypes.SideChain, int, error)
MissingSideChainBlocks identifies side chain blocks that are missing from the DB. Side chains known to pfcd are listed via the getchaintips RPC. Each block presence in the postgres DB is checked, and any missing block is returned in a SideChain along with a count of the total number of missing blocks.
func (*ChainDBRPC) NewChainMonitor ¶
func (db *ChainDBRPC) NewChainMonitor(ctx context.Context, wg *sync.WaitGroup, blockChan chan *chainhash.Hash, reorgChan chan *txhelpers.ReorgData) *ChainMonitor
NewChainMonitor creates a new ChainMonitor.
func (*ChainDBRPC) SendRawTransaction ¶
func (pgb *ChainDBRPC) SendRawTransaction(txhex string) (string, error)
SendRawTransaction attempts to decode the input serialized transaction, passed as hex encoded string, and broadcast it, returning the tx hash.
func (*ChainDBRPC) Store ¶
Store satisfies BlockDataSaver. Blocks stored this way are considered valid and part of mainchain. This calls (*ChainDB).Store after a nil pointer check on the ChainDBRPC receiver
func (*ChainDBRPC) SyncChainDBAsync ¶
func (db *ChainDBRPC) SyncChainDBAsync(ctx context.Context, res chan dbtypes.SyncResult, client rpcutils.MasterBlockGetter, updateAllAddresses, updateAllVotes, newIndexes bool, updateExplorer chan *chainhash.Hash, barLoad chan *dbtypes.ProgressBarLoad)
SyncChainDBAsync calls (*ChainDB).SyncChainDBAsync after a nil pointer check on the ChainDBRPC receiver.
type ChainMonitor ¶
type ChainMonitor struct { ConnectingLock chan struct{} DoneConnecting chan struct{} // contains filtered or unexported fields }
ChainMonitor responds to block connection and chain reorganization.
func (*ChainMonitor) ReorgHandler ¶
func (p *ChainMonitor) ReorgHandler()
ReorgHandler receives notification of a chain reorganization and initiates a corresponding reorganization of the ChainDB.
type DBInfo ¶
type DBInfo struct {
Host, Port, User, Pass, DBName string
}
DBInfo holds the PostgreSQL database connection information.
type DevFundBalance ¶
type DevFundBalance struct { sync.RWMutex *explorer.AddressBalance Height int64 Hash chainhash.Hash // contains filtered or unexported fields }
DevFundBalance is a block-stamped wrapper for explorer.AddressBalance. It is intended to be used for the project address.
func (*DevFundBalance) Balance ¶
func (d *DevFundBalance) Balance() *explorer.AddressBalance
Balance is a thread-safe accessor for the explorer.AddressBalance.
func (*DevFundBalance) BlockHash ¶
func (d *DevFundBalance) BlockHash() chainhash.Hash
BlockHash is a thread-safe accessor for the block hash.
func (*DevFundBalance) BlockHeight ¶
func (d *DevFundBalance) BlockHeight() int64
BlockHeight is a thread-safe accessor for the block height.
type MsgBlockPG ¶
MsgBlockPG 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.
type TableUpgrade ¶
type TableUpgrade struct {
TableName, UpgradeType string
CurrentVer, RequiredVer TableVersion
}
TableUpgrade is used to define a required upgrade for a table
func TableUpgradesRequired ¶
func TableUpgradesRequired(versions map[string]TableVersion) []TableUpgrade
func (TableUpgrade) String ¶
func (s TableUpgrade) String() string
type TableUpgradeType ¶
type TableUpgradeType struct { TableName string // contains filtered or unexported fields }
type TableVersion ¶
type TableVersion struct {
// contains filtered or unexported fields
}
TableVersion models a table version by major.minor.patch
func NewTableVersion ¶
func NewTableVersion(major, minor, patch uint32) TableVersion
NewTableVersion returns a new TableVersion with the version major.minor.patch
func (TableVersion) String ¶
func (s TableVersion) String() string
type TicketTxnIDGetter ¶
TicketTxnIDGetter provides a cache for DB row IDs of tickets.
func NewTicketTxnIDGetter ¶
func NewTicketTxnIDGetter(db *sql.DB) *TicketTxnIDGetter
NewTicketTxnIDGetter constructs a new TicketTxnIDGetter with an empty cache.
func (*TicketTxnIDGetter) Set ¶
func (t *TicketTxnIDGetter) Set(txid string, txDbID uint64)
Set stores the (transaction hash, DB row ID) pair a map for future access.
func (*TicketTxnIDGetter) SetN ¶
func (t *TicketTxnIDGetter) SetN(txid []string, txDbID []uint64)
SetN stores several (transaction hash, DB row ID) pairs in the map.
func (*TicketTxnIDGetter) TxnDbID ¶
func (t *TicketTxnIDGetter) TxnDbID(txid string, expire bool) (uint64, error)
TxnDbID 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.
type VinVoutTypeUpdateData ¶
type VinVoutTypeUpdateData struct { VinsDbIDs dbtypes.UInt64Array VoutsDbIDs dbtypes.UInt64Array TxType stake.TxType }
VinVoutTypeUpdateData defines the fetched details from the transactions table that are needed to undertake the histogram upgrade.