Documentation
¶
Index ¶
- func AnalyzeAllTables(db *sql.DB, statisticsTarget int) error
- func AnalyzeTable(db *sql.DB, table string, statisticsTarget int) error
- func CheckBadBlockApproval(ctx context.Context, db *sql.DB) (hashes []string, approvals, disapprovals, totals []int16, ...)
- func CheckBadExpiredVotedTickets(ctx context.Context, db *sql.DB) (ids []uint64, txHashes []string, spendTypes []int16, err error)
- func CheckBadMissedVotedTickets(ctx context.Context, db *sql.DB) (ids []uint64, txHashes []string, spendTypes []int16, err error)
- func CheckBadSpentLiveTickets(ctx context.Context, db *sql.DB) (ids []uint64, txHashes []string, spendTypes []int16, err error)
- func CheckBadVotedTickets(ctx context.Context, db *sql.DB) (ids []uint64, txHashes []string, spendTypes []int16, err error)
- func CheckColumnDataType(db *sql.DB, table, column string) (dataType string, err error)
- func CheckCurrentTimeZone(db *sql.DB) (currentTZ string, err error)
- func CheckDefaultTimeZone(db *sql.DB) (defaultTZ, currentTZ string, err error)
- func CheckExtraMainchainBlocks(ctx context.Context, db *sql.DB) (ids, heights []uint64, hashes []string, err error)
- func CheckMislabeledInvalidBlocks(ctx context.Context, db *sql.DB) (ids []uint64, hashes []string, err error)
- func CheckMislabeledTicketTransactions(ctx context.Context, db *sql.DB) (ids []uint64, txTypes []int16, txHashes []string, err error)
- func CheckMissingTicketTransactions(ctx context.Context, db *sql.DB) (ids []uint64, txHashes []string, err error)
- func CheckMissingTickets(ctx context.Context, db *sql.DB) (ids []uint64, txTypes []int16, txHashes []string, err error)
- func CheckSpentTicketsWithoutSpendInfo(ctx context.Context, db *sql.DB) (ids, spendHeights, spendTxDbIDs []uint64, err error)
- func CheckUnmatchedSpending(ctx context.Context, db *sql.DB) (ids []uint64, addresses []string, err error)
- func CheckUnspentTicketsWithSpendInfo(ctx context.Context, db *sql.DB) (ids, spendHeights, spendTxDbIDs []uint64, err error)
- func ClearTestingTable(db *sql.DB) error
- 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 DeindexAddressTableOnAddress(db *sql.DB) (err error)
- func DeindexAddressTableOnMatchingTxHash(db *sql.DB) (err error)
- func DeindexAddressTableOnTxHash(db *sql.DB) (err error)
- func DeindexAddressTableOnVoutID(db *sql.DB) (err error)
- func DeindexAgendaVotesTableOnAgendaID(db *sql.DB) (err error)
- func DeindexAgendasTableOnAgendaID(db *sql.DB) (err error)
- func DeindexBlockTableOnHash(db *sql.DB) (err error)
- func DeindexBlockTableOnHeight(db *sql.DB) (err error)
- func DeindexBlockTableOnTime(db *sql.DB) (err error)
- func DeindexBlockTimeOnTableAddress(db *sql.DB) (err error)
- func DeindexMissesTableOnHash(db *sql.DB) (err error)
- func DeindexStatsTableOnHeight(db *sql.DB) (err error)
- func DeindexSwapsTableOnHeight(db *sql.DB) (err error)
- func DeindexTicketsTableOnHashes(db *sql.DB) (err error)
- func DeindexTicketsTableOnPoolStatus(db *sql.DB) (err error)
- func DeindexTicketsTableOnTxDbID(db *sql.DB) (err error)
- func DeindexTransactionTableOnBlockHeight(db *sql.DB) (err error)
- func DeindexTransactionTableOnBlockIn(db *sql.DB) (err error)
- func DeindexTransactionTableOnHashes(db *sql.DB) (err error)
- func DeindexTreasuryTableOnHeight(db *sql.DB) (err error)
- func DeindexTreasuryTableOnTxHash(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 DeindexVotesTableOnBlockTime(db *sql.DB) (err error)
- func DeindexVotesTableOnCandidate(db *sql.DB) (err error)
- func DeindexVotesTableOnHash(db *sql.DB) (err error)
- func DeindexVotesTableOnHeight(db *sql.DB) (err error)
- func DeindexVotesTableOnVoteVersion(db *sql.DB) (err error)
- func DeindexVoutTableOnSpendTxID(db *sql.DB) (err error)
- func DeindexVoutTableOnTxHashIdx(db *sql.DB) (err error)
- func DisableLog()
- func DropTables(db *sql.DB)
- func DropTestingTable(db SqlExecutor) error
- func ExistsIndex(db *sql.DB, indexName string) (exists bool, err error)
- func IndexAddressTableOnAddress(db *sql.DB) (err error)
- func IndexAddressTableOnMatchingTxHash(db *sql.DB) (err error)
- func IndexAddressTableOnTxHash(db *sql.DB) (err error)
- func IndexAddressTableOnVoutID(db *sql.DB) (err error)
- func IndexAgendaVotesTableOnAgendaID(db *sql.DB) (err error)
- func IndexAgendasTableOnAgendaID(db *sql.DB) (err error)
- func IndexBlockTableOnHash(db *sql.DB) (err error)
- func IndexBlockTableOnHeight(db *sql.DB) (err error)
- func IndexBlockTableOnTime(db *sql.DB) (err error)
- func IndexBlockTimeOnTableAddress(db *sql.DB) (err error)
- func IndexMissesTableOnHashes(db *sql.DB) (err error)
- func IndexSwapsTableOnHeight(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 IndexTransactionTableOnBlockHeight(db *sql.DB) (err error)
- func IndexTransactionTableOnBlockIn(db *sql.DB) (err error)
- func IndexTransactionTableOnHashes(db *sql.DB) (err error)
- func IndexTreasuryTableOnHeight(db *sql.DB) (err error)
- func IndexTreasuryTableOnTxHash(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 IndexVotesTableOnBlockTime(db *sql.DB) (err error)
- func IndexVotesTableOnCandidate(db *sql.DB) (err error)
- func IndexVotesTableOnHashes(db *sql.DB) (err error)
- func IndexVotesTableOnHeight(db *sql.DB) (err error)
- func IndexVotesTableOnVoteVersion(db *sql.DB) (err error)
- func IndexVoutTableOnSpendTxID(db *sql.DB) (err error)
- func IndexVoutTableOnTxHashIdx(db *sql.DB) (err error)
- func IsRetryError(err error) bool
- func IsUniqueIndex(db *sql.DB, indexName string) (isUnique bool, err error)
- func SetSynchronousCommit(db SqlExecutor, syncCommit string) error
- func TableExists(db *sql.DB, tableName string) (bool, error)
- func TicketPoolData(interval dbtypes.TimeBasedGrouping, height int64) (timeGraph *dbtypes.PoolTicketsData, priceGraph *dbtypes.PoolTicketsData, ...)
- func UpdateTicketPoolData(interval dbtypes.TimeBasedGrouping, timeGraph *dbtypes.PoolTicketsData, ...)
- func UseLogger(logger slog.Logger)
- type BestBlock
- type BlockGetter
- type ChainDB
- func (pgb *ChainDB) AddressBalance(ctx context.Context, address string) (bal *dbtypes.AddressBalance, cacheUpdated bool, err error)
- func (pgb *ChainDB) AddressData(ctx context.Context, address string, limitN, offsetAddrOuts int64, ...) (addrData *dbtypes.AddressInfo, err error)
- func (pgb *ChainDB) AddressHistory(ctx context.Context, address string, N, offset int64, ...) ([]*dbtypes.AddressRow, *dbtypes.AddressBalance, error)
- func (pgb *ChainDB) AddressHistoryAll(ctx context.Context, address string, N, offset int64) ([]*dbtypes.AddressRow, *dbtypes.AddressBalance, error)
- func (pgb *ChainDB) AddressRowsCompact(ctx context.Context, address string) ([]*dbtypes.AddressRowCompact, error)
- func (pgb *ChainDB) AddressRowsMerged(ctx context.Context, address string) ([]*dbtypes.AddressRowMerged, error)
- func (pgb *ChainDB) AddressTotals(ctx context.Context, address string) (*apitypes.AddressTotals, error)
- func (pgb *ChainDB) AddressTransactionDetails(ctx context.Context, addr string, count, skip int64, ...) (*apitypes.Address, error)
- func (pgb *ChainDB) AddressTransactionsAll(ctx context.Context, address string) (addressRows []*dbtypes.AddressRow, err error)
- func (pgb *ChainDB) AddressTransactionsAllMerged(ctx context.Context, address string) (addressRows []*dbtypes.AddressRow, err error)
- func (pgb *ChainDB) AddressUTXO(ctx context.Context, address string) ([]*dbtypes.AddressTxnOutput, bool, error)
- func (pgb *ChainDB) AgendaVoteCounts(ctx context.Context, agendaID string) (yes, abstain, no uint32, err error)
- func (pgb *ChainDB) AgendaVotes(ctx context.Context, agendaID string, chartType int) (*dbtypes.AgendaVoteChoices, error)
- func (pgb *ChainDB) AgendasVotesSummary(ctx context.Context, agendaID string) (summary *dbtypes.AgendaSummary, err error)
- func (pgb *ChainDB) AllAgendas() (map[string]dbtypes.MileStone, error)
- func (pgb *ChainDB) BestBlock() (*chainhash.Hash, int64)
- func (pgb *ChainDB) BestBlockHash() *chainhash.Hash
- func (pgb *ChainDB) BestBlockHashStr() string
- func (pgb *ChainDB) BestBlockStr() (string, int64)
- func (pgb *ChainDB) BinnedTreasuryIO(ctx context.Context, chartGroupings dbtypes.TimeBasedGrouping) (*dbtypes.ChartsData, error)
- func (pgb *ChainDB) BlockChainDbID(ctx context.Context, hash string) (dbID uint64, err error)
- func (pgb *ChainDB) BlockChainDbIDNoCancel(hash string) (dbID uint64, err error)
- func (pgb *ChainDB) BlockFlags(ctx context.Context, hash string) (bool, bool, error)
- func (pgb *ChainDB) BlockFlagsNoCancel(hash string) (bool, bool, error)
- func (pgb *ChainDB) BlockHash(ctx context.Context, height int64) (string, error)
- func (pgb *ChainDB) BlockHeight(ctx context.Context, hash string) (int64, error)
- func (pgb *ChainDB) BlockMissedVotes(ctx context.Context, blockHash string) ([]string, error)
- func (pgb *ChainDB) BlockSize(ctx context.Context, ind int64) (int32, error)
- func (pgb *ChainDB) BlockSizeRange(ctx context.Context, ind0, ind1 int64) ([]int32, error)
- func (pgb *ChainDB) BlockStatus(ctx context.Context, hash string) (dbtypes.BlockStatus, error)
- func (pgb *ChainDB) BlockStatuses(ctx context.Context, height int64) ([]*dbtypes.BlockStatus, error)
- func (pgb *ChainDB) BlockSubsidy(_ context.Context, height int64, voters uint16) *chainjson.GetBlockSubsidyResult
- func (pgb *ChainDB) BlockSummary(ctx context.Context, ind int64) (*apitypes.BlockDataBasic, error)
- func (pgb *ChainDB) BlockSummaryByHash(ctx context.Context, hash string) (*apitypes.BlockDataBasic, error)
- func (pgb *ChainDB) BlockSummaryRange(ctx context.Context, idx0, idx1 int64) ([]*apitypes.BlockDataBasic, error)
- func (pgb *ChainDB) BlockSummaryRangeStepped(ctx context.Context, idx0, idx1, step int64) ([]*apitypes.BlockDataBasic, error)
- func (pgb *ChainDB) BlockSummaryTimeRange(ctx context.Context, min, max int64, limit int) ([]dbtypes.BlockDataBasic, error)
- func (pgb *ChainDB) BlockTimeByHeight(ctx context.Context, height int64) (int64, error)
- func (pgb *ChainDB) BlockTransactions(ctx context.Context, blockHash string) ([]string, []uint32, []int8, error)
- func (pgb *ChainDB) ChainInfo() *dbtypes.BlockChainData
- func (pgb *ChainDB) ChargePoolInfoCache(startHeight int64) error
- func (pgb *ChainDB) Close() error
- func (pgb *ChainDB) CountTransactions(ctx context.Context, addr string, txnView dbtypes.AddrTxnViewType) (int, error)
- func (pgb *ChainDB) CurrentCoinSupply(ctx context.Context) (supply *apitypes.CoinSupply)
- func (pgb *ChainDB) CurrentDifficulty(ctx context.Context) (float64, error)
- func (pgb *ChainDB) DCP0010ActivationHeight() int64
- func (pgb *ChainDB) DCP0011ActivationHeight() int64
- func (pgb *ChainDB) DCP0012ActivationHeight() int64
- func (pgb *ChainDB) DbTxByHash(ctx context.Context, txid string) (*dbtypes.Tx, error)
- func (pgb *ChainDB) DecodeRawTransaction(ctx context.Context, txhex string) (*chainjson.TxRawResult, error)
- func (pgb *ChainDB) DeindexAddressTable() error
- func (pgb *ChainDB) DeindexAll() error
- func (pgb *ChainDB) DeindexTicketsTable() error
- func (pgb *ChainDB) DevBalance(ctx context.Context) (*dbtypes.AddressBalance, error)
- func (pgb *ChainDB) Difficulty(ctx context.Context, timestamp int64) float64
- func (pgb *ChainDB) DisapprovedBlocks(ctx context.Context) ([]*dbtypes.BlockStatus, error)
- func (pgb *ChainDB) DropTables()
- func (pgb *ChainDB) EnableDuplicateCheckOnInsert(dupCheck bool)
- func (pgb *ChainDB) FillAddressTransactions(ctx context.Context, addrInfo *dbtypes.AddressInfo) error
- func (pgb *ChainDB) FreshenAddressCaches(lazyProjectFund bool, expireAddresses []string) error
- func (pgb *ChainDB) GetAPITransaction(ctx context.Context, txid *chainhash.Hash) *apitypes.Tx
- func (pgb *ChainDB) GetAddressTransactionsRawWithSkip(ctx context.Context, addr string, count, skip int) []*apitypes.AddressTxRaw
- func (pgb *ChainDB) GetAllTxIn(ctx context.Context, txid *chainhash.Hash) []*apitypes.TxIn
- func (pgb *ChainDB) GetAllTxOut(ctx context.Context, txid *chainhash.Hash) []*apitypes.TxOut
- func (pgb *ChainDB) GetBestBlockHash(_ context.Context) (string, error)
- func (pgb *ChainDB) GetBestBlockSummary(ctx context.Context) *apitypes.BlockDataBasic
- func (pgb *ChainDB) GetBlockByHash(ctx context.Context, hash string) (*wire.MsgBlock, error)
- func (pgb *ChainDB) GetBlockHash(ctx context.Context, idx int64) (string, error)
- func (pgb *ChainDB) GetBlockHeaderByHash(ctx context.Context, hash string) (*wire.BlockHeader, error)
- func (pgb *ChainDB) GetBlockHeight(ctx context.Context, hash string) (int64, error)
- func (pgb *ChainDB) GetBlockSize(ctx context.Context, idx int) (int32, error)
- func (pgb *ChainDB) GetBlockSizeRange(ctx context.Context, idx0, idx1 int) ([]int32, error)
- func (pgb *ChainDB) GetBlockVerboseByHash(ctx context.Context, hash string, verboseTx bool) *chainjson.GetBlockVerboseResult
- func (pgb *ChainDB) GetBurnedCoins(ctx context.Context) (map[uint8]*big.Int, error)
- func (pgb *ChainDB) GetChainParams() *chaincfg.Params
- func (pgb *ChainDB) GetChainWork(hash *chainhash.Hash) (string, error)
- func (pgb *ChainDB) GetExplorerBlock(ctx context.Context, hash string) *exptypes.BlockInfo
- func (pgb *ChainDB) GetExplorerBlocks(ctx context.Context, start int, end int) []*exptypes.BlockBasic
- func (pgb *ChainDB) GetExplorerFullBlocks(ctx context.Context, start int, end int) []*exptypes.BlockInfo
- func (pgb *ChainDB) GetExplorerTx(ctx context.Context, txid string) *exptypes.TxInfo
- func (pgb *ChainDB) GetHeader(idx int) *chainjson.GetBlockHeaderVerboseResult
- func (pgb *ChainDB) GetHeight(_ context.Context) (int64, error)
- func (pgb *ChainDB) GetMempoolPriceCountTime() *apitypes.PriceCountTime
- func (pgb *ChainDB) GetMempoolSSTxDetails(N int) *apitypes.MempoolTicketDetails
- func (pgb *ChainDB) GetMempoolSSTxFeeRates(N int) *apitypes.MempoolTicketFees
- func (pgb *ChainDB) GetMempoolSSTxSummary() *apitypes.MempoolTicketFeeInfo
- func (pgb *ChainDB) GetPool(idx int64) ([]string, error)
- func (pgb *ChainDB) GetPoolInfo(ctx context.Context, idx int) *apitypes.TicketPoolInfo
- func (pgb *ChainDB) GetPoolInfoRange(ctx context.Context, idx0, idx1 int) []apitypes.TicketPoolInfo
- func (pgb *ChainDB) GetPoolValAndSizeRange(ctx context.Context, idx0, idx1 int) ([]float64, []uint32)
- func (pgb *ChainDB) GetRawTransactionVerbose(ctx context.Context, txid *chainhash.Hash) (*chainjson.TxRawResult, error)
- func (pgb *ChainDB) GetSBitsByHash(ctx context.Context, hash string) int64
- func (pgb *ChainDB) GetSDiff(ctx context.Context, idx int) float64
- func (pgb *ChainDB) GetSDiffRange(ctx context.Context, idx0, idx1 int) []float64
- func (pgb *ChainDB) GetStakeDiffEstimates(ctx context.Context) *apitypes.StakeDiff
- func (pgb *ChainDB) GetStakeInfoExtendedByHash(ctx context.Context, hashStr string) *apitypes.StakeInfoExtended
- func (pgb *ChainDB) GetStakeInfoExtendedByHeight(ctx context.Context, height int) *apitypes.StakeInfoExtended
- func (pgb *ChainDB) GetStakeVersions(ctx context.Context, blockHash string, count int32) (*chainjson.GetStakeVersionsResult, error)
- func (pgb *ChainDB) GetStakeVersionsLatest(ctx context.Context) (*chainjson.StakeVersions, error)
- func (pgb *ChainDB) GetSummary(ctx context.Context, idx int) *apitypes.BlockDataBasic
- func (pgb *ChainDB) GetSummaryByHash(ctx context.Context, hash string, withTxTotals bool) *apitypes.BlockDataBasic
- func (pgb *ChainDB) GetSummaryRange(ctx context.Context, idx0, idx1 int) []*apitypes.BlockDataBasic
- func (pgb *ChainDB) GetSummaryRangeStepped(ctx context.Context, idx0, idx1, step int) []*apitypes.BlockDataBasic
- func (pgb *ChainDB) GetTicketInfo(ctx context.Context, txid string) (*apitypes.TicketInfo, error)
- func (pgb *ChainDB) GetTip(ctx context.Context) (*exptypes.WebBasicBlock, error)
- func (pgb *ChainDB) GetTransactionByHash(ctx context.Context, txid string) (*wire.MsgTx, error)
- func (pgb *ChainDB) GetTransactionHex(ctx context.Context, txid *chainhash.Hash) string
- func (pgb *ChainDB) GetTransactionsForBlockByHash(ctx context.Context, hash string) *apitypes.BlockTransactions
- func (pgb *ChainDB) GetTrimmedTransaction(ctx context.Context, txid *chainhash.Hash) *apitypes.TrimmedTx
- func (pgb *ChainDB) GetVoteInfo(ctx context.Context, txhash *chainhash.Hash) (*apitypes.VoteInfo, error)
- func (pgb *ChainDB) GetVoteVersionInfo(ctx context.Context, ver uint32) (*chainjson.GetVoteInfoResult, error)
- func (pgb *ChainDB) HashDB(ctx context.Context) (string, error)
- func (pgb *ChainDB) HashDBLegacy(ctx context.Context) (string, error)
- func (pgb *ChainDB) Height() int64
- func (pgb *ChainDB) HeightDB(ctx context.Context) (int64, error)
- func (pgb *ChainDB) HeightDBLegacy(ctx context.Context) (int64, error)
- func (pgb *ChainDB) HeightHashDB(ctx context.Context) (int64, string, error)
- func (pgb *ChainDB) HeightHashDBLegacy(ctx context.Context) (uint64, string, 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) InitUtxoCache(utxos []dbtypes.UTXO)
- func (pgb *ChainDB) InsightAddressTransactions(ctx context.Context, addr []string, recentBlockHeight int64) (txs, recentTxs []chainhash.Hash, err error)
- func (pgb *ChainDB) IsDCP0010Active(height int64) bool
- func (pgb *ChainDB) IsDCP0011Active(height int64) bool
- func (pgb *ChainDB) IsDCP0012Active(height int64) bool
- func (pgb *ChainDB) MissingAddressIndexes() (missing []string, descs []string, err error)
- func (pgb *ChainDB) MissingIndexes() (missing, descs []string, err error)
- func (pgb *ChainDB) MissingSideChainBlocks(ctx context.Context) ([]dbtypes.SideChain, int, error)
- func (pgb *ChainDB) NewChainMonitor(ctx context.Context) *ChainMonitor
- func (pgb *ChainDB) OutpointAddresses(ctx context.Context, txHash string, voutIndex uint32) ([]string, int64, error)
- func (pgb *ChainDB) PoolStatusForTicket(ctx context.Context, txid string) (dbtypes.TicketSpendType, dbtypes.TicketPoolStatus, error)
- func (pgb *ChainDB) PosIntervals(ctx context.Context, limit, offset uint64) ([]*dbtypes.BlocksGroupedInfo, error)
- func (pgb *ChainDB) PowerlessTickets(ctx context.Context) (*apitypes.PowerlessTickets, error)
- func (pgb *ChainDB) PurgeBestBlocks(N int64) (*dbtypes.DeletionSummary, int64, error)
- func (pgb *ChainDB) RegisterCharts(charts *cache.ChartData)
- func (pgb *ChainDB) ReindexAddressesBlockTime() error
- func (pgb *ChainDB) RewindStakeDB(ctx context.Context, toHeight int64, quiet ...bool) (stakeDBHeight int64, err error)
- func (pgb *ChainDB) SDiffRange(ctx context.Context, ind0, ind1 int64) ([]float64, error)
- func (pgb *ChainDB) SKACoinSupply(ctx context.Context) ([]*exptypes.SKACoinSupplyEntry, error)
- func (pgb *ChainDB) SendRawTransaction(ctx context.Context, txhex string) (string, error)
- func (pgb *ChainDB) SideChainBlocks(ctx context.Context) ([]*dbtypes.BlockStatus, error)
- func (pgb *ChainDB) SignalHeight(height uint32)
- func (pgb *ChainDB) SpendDetailsForFundingTx(ctx context.Context, fundHash string) ([]*apitypes.SpendByFundingHash, error)
- func (pgb *ChainDB) SpendingTransaction(ctx context.Context, fundingTxID string, fundingTxVout uint32) (string, uint32, error)
- func (pgb *ChainDB) SpendingTransactions(ctx context.Context, fundingTxID string) ([]string, []uint32, []uint32, error)
- func (pgb *ChainDB) SqlDB() *sql.DB
- func (pgb *ChainDB) Store(blockData *blockdata.BlockData, msgBlock *wire.MsgBlock) error
- func (pgb *ChainDB) StoreBlock(msgBlock *wire.MsgBlock, ...) (numVins int64, numVouts int64, numAddresses int64, err error)
- func (pgb *ChainDB) SyncChainDB(ctx context.Context, client rpcutils.BlockFetcher, ...) (int64, error)
- func (pgb *ChainDB) TSpendVotes(ctx context.Context, tspendID *chainhash.Hash) (*dbtypes.TreasurySpendVotes, error)
- func (pgb *ChainDB) TicketMiss(ctx context.Context, ticketHash string) (string, int64, error)
- func (pgb *ChainDB) TicketPoolBlockMaturity() int64
- func (pgb *ChainDB) TicketPoolByDateAndInterval(ctx context.Context, maturityBlock int64, interval dbtypes.TimeBasedGrouping) (*dbtypes.PoolTicketsData, error)
- func (pgb *ChainDB) TicketPoolVisualization(ctx context.Context, interval dbtypes.TimeBasedGrouping) (*dbtypes.PoolTicketsData, *dbtypes.PoolTicketsData, *dbtypes.PoolTicketsData, ...)
- func (pgb *ChainDB) TicketsByInputCount(ctx context.Context) (*dbtypes.PoolTicketsData, error)
- func (pgb *ChainDB) TicketsByPrice(ctx context.Context, maturityBlock int64) (*dbtypes.PoolTicketsData, error)
- func (pgb *ChainDB) TimeBasedIntervals(ctx context.Context, timeGrouping dbtypes.TimeBasedGrouping, ...) ([]*dbtypes.BlocksGroupedInfo, error)
- func (pgb *ChainDB) TipToSideChain(mainRoot string) (tipHashStr string, blocksMoved int64)
- func (pgb *ChainDB) Transaction(ctx context.Context, txHash string) ([]*dbtypes.Tx, error)
- func (pgb *ChainDB) TransactionBlock(ctx context.Context, txID string) (string, uint32, int8, error)
- func (pgb *ChainDB) TransactionBlocks(ctx context.Context, txHash string) ([]*dbtypes.BlockStatus, []uint32, error)
- func (pgb *ChainDB) TreasuryBalance(ctx context.Context) (*dbtypes.TreasuryBalance, error)
- func (pgb *ChainDB) TreasuryTxns(ctx context.Context, n, offset int64, txType stake.TxType) ([]*dbtypes.TreasuryTx, error)
- func (pgb *ChainDB) TxHeight(ctx context.Context, txid *chainhash.Hash) (height int64)
- func (pgb *ChainDB) TxHistoryData(ctx context.Context, address string, addrChart dbtypes.HistoryChart, ...) (cd *dbtypes.ChartsData, err error)
- func (pgb *ChainDB) UpdateChainState(blockChainInfo *chainjson.GetBlockChainInfoResult)
- func (pgb *ChainDB) UpdateChan() chan uint32
- func (pgb *ChainDB) UseMempoolChecker(mp rpcutils.MempoolAddressChecker)
- func (pgb *ChainDB) UseStakeDB(stakeDB *stakedb.StakeDatabase)
- func (pgb *ChainDB) VARCoinSupply(ctx context.Context) (*exptypes.VARCoinSupply, error)
- func (pgb *ChainDB) VinsForTx(ctx context.Context, dbTx *dbtypes.Tx) ([]dbtypes.VinTxProperty, error)
- func (pgb *ChainDB) VotesInBlock(ctx context.Context, hash string) (int16, error)
- func (pgb *ChainDB) VoutValue(ctx context.Context, txID string, vout uint32) (uint64, error)
- func (pgb *ChainDB) VoutValues(ctx context.Context, txID string) ([]uint64, []uint32, []int8, error)
- func (pgb *ChainDB) VoutsForTx(ctx context.Context, dbTx *dbtypes.Tx) ([]dbtypes.Vout, error)
- type ChainDBCfg
- type ChainDeployments
- type ChainMonitor
- type CompatAction
- type DBInfo
- type DatabaseUpgrade
- type DatabaseVersion
- type MsgBlockPG
- type PGSetting
- type PGSettings
- type SqlExecQueryer
- type SqlExecutor
- type SqlQueryer
- type TicketTxnIDGetter
- type Upgrader
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AnalyzeAllTables ¶
AnalyzeAllTables performs an ANALYZE on all tables after setting default_statistics_target for the transaction.
func AnalyzeTable ¶
AnalyzeTable performs an ANALYZE on the specified table after setting default_statistics_target for the transaction.
func CheckBadBlockApproval ¶
func CheckBadBlockApproval(ctx context.Context, db *sql.DB) (hashes []string, approvals, disapprovals, totals []int16, approvedActual, approvedSet []bool, err error)
CheckBadBlockApproval checks the blocks table for blocks with an incorrect approval flag as determined by computing (approvals/total_votes > 0.5).
func CheckBadExpiredVotedTickets ¶
func CheckBadExpiredVotedTickets(ctx context.Context, db *sql.DB) (ids []uint64, txHashes []string, spendTypes []int16, err error)
CheckBadExpiredVotedTickets checks the tickets table for tickets with expired pool status but with voted status. This indicates likely database corruption.
func CheckBadMissedVotedTickets ¶
func CheckBadMissedVotedTickets(ctx context.Context, db *sql.DB) (ids []uint64, txHashes []string, spendTypes []int16, err error)
CheckBadMissedVotedTickets checks the tickets table for tickets with missed pool status but with voted status. This indicates likely database corruption.
func CheckBadSpentLiveTickets ¶
func CheckBadSpentLiveTickets(ctx context.Context, db *sql.DB) (ids []uint64, txHashes []string, spendTypes []int16, err error)
CheckBadSpentLiveTickets checks the tickets table for tickets with live pool status but not unspent status. This indicates likely database corruption.
func CheckBadVotedTickets ¶
func CheckBadVotedTickets(ctx context.Context, db *sql.DB) (ids []uint64, txHashes []string, spendTypes []int16, err error)
CheckBadVotedTickets checks the tickets table for tickets with voted pool status but not voted status. This indicates likely database corruption.
func CheckColumnDataType ¶
CheckColumnDataType gets the data type of specified table column .
func CheckCurrentTimeZone ¶
CheckCurrentTimeZone queries for the currently set postgres time zone.
func CheckDefaultTimeZone ¶
CheckDefaultTimeZone queries for the default postgres time zone. This is the value that would be observed if postgres were restarted using its current configuration. The currently set time zone is also returned.
func CheckExtraMainchainBlocks ¶
func CheckExtraMainchainBlocks(ctx context.Context, db *sql.DB) (ids, heights []uint64, hashes []string, err error)
CheckExtraMainchainBlocks checks the blocks table for multiple main chain blocks at a given height, which is not possible. The row IDs, block heights, and block hashes are returned. Non-zero length sizes is an indication of database corruption.
func CheckMislabeledInvalidBlocks ¶
func CheckMislabeledInvalidBlocks(ctx context.Context, db *sql.DB) (ids []uint64, hashes []string, err error)
CheckMislabeledInvalidBlocks checks the blocks table for blocks labeled as approved, but for which the following block has specified vote bits that invalidate it. This indicates likely database corruption.
func CheckMislabeledTicketTransactions ¶
func CheckMislabeledTicketTransactions(ctx context.Context, db *sql.DB) (ids []uint64, txTypes []int16, txHashes []string, err error)
CheckMislabeledTicketTransactions checks the transactions table for ticket transactions that also appear in the tickets table, but which do not have the proper tx_type (1) set. This indicates likely database corruption.
func CheckMissingTicketTransactions ¶
func CheckMissingTicketTransactions(ctx context.Context, db *sql.DB) (ids []uint64, txHashes []string, err error)
CheckMissingTicketTransactions checks the tickets table for tickets that do NOT appear in the transactions table at all. This indicates likely database corruption.
func CheckMissingTickets ¶
func CheckMissingTickets(ctx context.Context, db *sql.DB) (ids []uint64, txTypes []int16, txHashes []string, err error)
CheckMissingTickets checks the transactions table for ticket transactions (with tx_type=1) that do NOT appear in the tickets table. This indicates likely database corruption.
func CheckSpentTicketsWithoutSpendInfo ¶
func CheckSpentTicketsWithoutSpendInfo(ctx context.Context, db *sql.DB) (ids, spendHeights, spendTxDbIDs []uint64, err error)
CheckSpentTicketsWithoutSpendInfo checks the tickets table for tickets that are flagged as spent, but which do not have set either a spend height or spending transaction row id. This indicates likely database corruption.
func CheckUnmatchedSpending ¶
func CheckUnmatchedSpending(ctx context.Context, db *sql.DB) (ids []uint64, addresses []string, err error)
CheckUnmatchedSpending checks the addresses table for spending rows where the matching (funding) txhash has not been set. The row IDs and addresses are returned. Non-zero length sizes is an indication of database corruption.
func CheckUnspentTicketsWithSpendInfo ¶
func CheckUnspentTicketsWithSpendInfo(ctx context.Context, db *sql.DB) (ids, spendHeights, spendTxDbIDs []uint64, err error)
CheckUnspentTicketsWithSpendInfo checks the tickets table for tickets that are flagged as unspent, but which have set either a spend height or spending transaction row id. This indicates likely database corruption.
func ClearTestingTable ¶
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 ¶
CreateTables creates all tables required by dcrdata if they do not already exist.
func DeindexBlockTableOnHash ¶
func DeindexBlockTableOnTime ¶
func DeindexStatsTableOnHeight ¶
DeindexStatsTableOnHeight drops the index for the stats table over height.
func DeindexSwapsTableOnHeight ¶
DeindexSwapsTableOnHeight drops the index for the swaps table over spend block height.
func DeindexTreasuryTableOnHeight ¶
DeindexTreasuryTableOnHeight drops the index for the treasury table over block height.
func DeindexTreasuryTableOnTxHash ¶
DeindexTreasuryTableOnTxHash drops the index for the treasury table over tx hash.
func DeindexVinTableOnVins ¶
func DeindexVotesTableOnHash ¶
func DisableLog ¶
func DisableLog()
DisableLog disables all library log output. Logging output is disabled by default until UseLogger is called.
func DropTables ¶
DropTables drops all of the tables internally recognized tables.
func DropTestingTable ¶
func DropTestingTable(db SqlExecutor) error
DropTestingTable drops only the "testing" table.
func ExistsIndex ¶
ExistsIndex checks if the specified index name exists.
func IndexAddressTableOnAddress ¶
IndexAddressTableOnAddress creates the index for the addresses table over address.
func IndexAddressTableOnMatchingTxHash ¶
IndexAddressTableOnMatchingTxHash creates the index for the addresses table over matching transaction hash.
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 IndexBlockTableOnTime ¶
func IndexBlockTimeOnTableAddress ¶
IndexBlockTimeOnTableAddress creates the index for the addresses table over block time.
func IndexSwapsTableOnHeight ¶
IndexSwapsTableOnHeight creates the index for the swaps table over spend block height.
func IndexTreasuryTableOnHeight ¶
IndexTreasuryTableOnHeight creates the index for the treasury table over block height.
func IndexTreasuryTableOnTxHash ¶
IndexTreasuryTableOnTxHash creates the index for the treasury table over tx_hash.
func IndexVinTableOnPrevOuts ¶
func IndexVinTableOnVins ¶
func IndexVotesTableOnBlockTime ¶
IndexVotesTableOnBlockTime improves the speed of "Vote Choices By Block" agendas chart query.
func IndexVotesTableOnHashes ¶
func IndexVotesTableOnHeight ¶
IndexVotesTableOnHeight improves the speed of "Cumulative Vote Choices" agendas chart query.
func IndexVoutTableOnTxHashIdx ¶
IndexVoutTableOnTxHashIdx creates the index for the addresses table over transaction hash and index.
func IsRetryError ¶
IsRetryError checks if an error is a retryError type.
func IsUniqueIndex ¶
IsUniqueIndex checks if the given index name is defined as UNIQUE.
func SetSynchronousCommit ¶
func SetSynchronousCommit(db SqlExecutor, syncCommit string) error
SetSynchronousCommit sets the synchronous_commit setting.
func TableExists ¶
TableExists checks if the specified table exists.
func TicketPoolData ¶
func TicketPoolData(interval dbtypes.TimeBasedGrouping, height int64) (timeGraph *dbtypes.PoolTicketsData, priceGraph *dbtypes.PoolTicketsData, donutChart *dbtypes.PoolTicketsData, actualHeight int64, intervalFound, isStale bool)
TicketPoolData is a thread-safe way to access the ticketpool graphs data stored in the cache.
func UpdateTicketPoolData ¶
func UpdateTicketPoolData(interval dbtypes.TimeBasedGrouping, timeGraph *dbtypes.PoolTicketsData, priceGraph *dbtypes.PoolTicketsData, donutcharts *dbtypes.PoolTicketsData, height int64)
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.
Types ¶
type BestBlock ¶
type BestBlock struct {
// contains filtered or unexported fields
}
BestBlock is mutex-protected block hash and height.
type BlockGetter ¶
type BlockGetter interface {
// rpcutils.BlockFetcher implements GetBestBlock, GetBlock, GetBlockHash,
// and GetBlockHeaderVerbose.
rpcutils.BlockFetcher
// GetBlockChainInfo is required for a legacy upgrade involving agendas.
GetBlockChainInfo(ctx context.Context) (*chainjson.GetBlockChainInfoResult, error)
}
BlockGetter implements a few basic blockchain data retrieval functions. It is like rpcutils.BlockFetcher except that it must also implement GetBlockChainInfo.
type ChainDB ¶
type ChainDB struct {
AddressCache *cache.AddressCache
CacheLocks cacheLocks
InBatchSync bool
InReorg bool
MPC *mempool.DataCache
// BlockCache stores apitypes.BlockDataBasic and apitypes.StakeInfoExtended
// in StoreBlock for quick retrieval without a DB query.
BlockCache *apitypes.APICache
Client *rpcclient.Client
// contains filtered or unexported fields
}
ChainDB provides an interface for storing and manipulating extracted blockchain data in a PostgreSQL database.
func NewChainDB ¶
func NewChainDB(ctx context.Context, cfg *ChainDBCfg, stakeDB *stakedb.StakeDatabase, mp rpcutils.MempoolAddressChecker, client *rpcclient.Client, shutdown func()) (*ChainDB, error)
NewChainDB constructs a cancellation-capable ChainDB for the given connection and Decred network parameters. By default, duplicate row checks on insertion are enabled. See EnableDuplicateCheckOnInsert to change this behavior.
func (*ChainDB) AddressBalance ¶
func (pgb *ChainDB) AddressBalance(ctx context.Context, address string) (bal *dbtypes.AddressBalance, cacheUpdated bool, err error)
AddressBalance attempts to retrieve balance information for a specific address from cache, and if cache is stale or missing data for the address, a DB query is used. A successful DB query will freshen the cache.
func (*ChainDB) AddressData ¶
func (pgb *ChainDB) AddressData(ctx context.Context, address string, limitN, offsetAddrOuts int64, txnType dbtypes.AddrTxnViewType) (addrData *dbtypes.AddressInfo, err error)
AddressData returns comprehensive, paginated information for an address.
func (*ChainDB) AddressHistory ¶
func (pgb *ChainDB) AddressHistory(ctx context.Context, address string, N, offset int64, txnView dbtypes.AddrTxnViewType) ([]*dbtypes.AddressRow, *dbtypes.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(ctx context.Context, address string, N, offset int64) ([]*dbtypes.AddressRow, *dbtypes.AddressBalance, error)
AddressHistoryAll retrieves N address rows of type AddrTxnAll, skipping over offset rows first, in order of block time.
func (*ChainDB) AddressRowsCompact ¶
func (pgb *ChainDB) AddressRowsCompact(ctx context.Context, address string) ([]*dbtypes.AddressRowCompact, error)
AddressRowsCompact gets non-merged address rows either from cache or via DB query.
func (*ChainDB) AddressRowsMerged ¶
func (pgb *ChainDB) AddressRowsMerged(ctx context.Context, address string) ([]*dbtypes.AddressRowMerged, error)
AddressRowsMerged gets the merged address rows either from cache or via DB query.
func (*ChainDB) AddressTotals ¶
func (pgb *ChainDB) AddressTotals(ctx context.Context, 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(ctx context.Context, addr string, count, skip int64, txnType dbtypes.AddrTxnViewType) (*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) AddressTransactionsAll ¶
func (pgb *ChainDB) AddressTransactionsAll(ctx context.Context, address string) (addressRows []*dbtypes.AddressRow, err error)
AddressTransactionsAll retrieves all non-merged main chain addresses table rows for the given address. There is presently a hard limit of 3 million rows that may be returned, which is more than 4x the count for the treasury address as of mainnet block 521900.
func (*ChainDB) AddressTransactionsAllMerged ¶
func (pgb *ChainDB) AddressTransactionsAllMerged(ctx context.Context, address string) (addressRows []*dbtypes.AddressRow, err error)
AddressTransactionsAllMerged retrieves all merged (stakeholder-approved and mainchain only) addresses table rows for the given address. There is presently a hard limit of 3 million rows that may be returned, which is more than 4x the count for the treasury address as of mainnet block 521900.
func (*ChainDB) AddressUTXO ¶
func (pgb *ChainDB) AddressUTXO(ctx context.Context, address string) ([]*dbtypes.AddressTxnOutput, bool, error)
AddressUTXO returns the unspent transaction outputs (UTXOs) paying to the specified address in a []*dbtypes.AddressTxnOutput.
func (*ChainDB) AgendaVoteCounts ¶
func (pgb *ChainDB) AgendaVoteCounts(ctx context.Context, agendaID string) (yes, abstain, no uint32, err error)
AgendaVoteCounts returns the vote counts for the agenda as builtin types.
func (*ChainDB) AgendaVotes ¶
func (pgb *ChainDB) AgendaVotes(ctx context.Context, agendaID string, chartType int) (*dbtypes.AgendaVoteChoices, error)
AgendaVotes fetches the data used to plot a graph of votes cast per day per choice for the provided agenda.
func (*ChainDB) AgendasVotesSummary ¶
func (pgb *ChainDB) AgendasVotesSummary(ctx context.Context, agendaID string) (summary *dbtypes.AgendaSummary, err error)
AgendasVotesSummary fetches the total vote choices count for the provided agenda.
func (*ChainDB) AllAgendas ¶
AllAgendas returns all the agendas stored currently.
func (*ChainDB) BestBlockHash ¶
BestBlockHash is a getter for ChainDB.bestBlock.hash.
func (*ChainDB) BestBlockHashStr ¶
BestBlockHashStr is a getter for ChainDB.bestBlock.hash.
func (*ChainDB) BestBlockStr ¶
func (*ChainDB) BinnedTreasuryIO ¶
func (pgb *ChainDB) BinnedTreasuryIO(ctx context.Context, chartGroupings dbtypes.TimeBasedGrouping) (*dbtypes.ChartsData, error)
func (*ChainDB) BlockChainDbID ¶
BlockChainDbID gets the row ID of the given block hash in the block_chain table. The cancellation context is used without timeout.
func (*ChainDB) BlockChainDbIDNoCancel ¶
BlockChainDbIDNoCancel gets the row ID of the given block hash in the block_chain table. The cancellation context is used without timeout.
func (*ChainDB) BlockFlags ¶
BlockFlags retrieves the block's isValid and isMainchain flags.
func (*ChainDB) BlockFlagsNoCancel ¶
BlockFlagsNoCancel 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) BlockSizeRange ¶
BlockSizeRange returns an array of block sizes for block range ind0 to ind1
func (*ChainDB) BlockStatus ¶
BlockStatus retrieves the block chain status of the specified block.
func (*ChainDB) BlockStatuses ¶
func (pgb *ChainDB) BlockStatuses(ctx context.Context, height int64) ([]*dbtypes.BlockStatus, error)
BlockStatuses retrieves the block chain statuses of all blocks at the given height.
func (*ChainDB) BlockSubsidy ¶
func (pgb *ChainDB) BlockSubsidy(_ context.Context, height int64, voters uint16) *chainjson.GetBlockSubsidyResult
BlockSubsidy gets the *chainjson.GetBlockSubsidyResult for the given height and number of voters, which can be fewer than the network parameter allows.
func (*ChainDB) BlockSummary ¶
BlockSummary returns basic block data for block ind.
func (*ChainDB) BlockSummaryByHash ¶
func (pgb *ChainDB) BlockSummaryByHash(ctx context.Context, hash string) (*apitypes.BlockDataBasic, error)
BlockSummaryByHash makes a *apitypes.BlockDataBasic, checking the BlockCache first before querying the database.
func (*ChainDB) BlockSummaryRange ¶
func (pgb *ChainDB) BlockSummaryRange(ctx context.Context, idx0, idx1 int64) ([]*apitypes.BlockDataBasic, error)
BlockSummaryRange returns the *apitypes.BlockDataBasic for a range of block height.
func (*ChainDB) BlockSummaryRangeStepped ¶
func (pgb *ChainDB) BlockSummaryRangeStepped(ctx context.Context, idx0, idx1, step int64) ([]*apitypes.BlockDataBasic, error)
BlockSummaryRangeStepped returns the []*apitypes.BlockDataBasic for every step'th block in a specified range.
func (*ChainDB) BlockSummaryTimeRange ¶
func (pgb *ChainDB) BlockSummaryTimeRange(ctx context.Context, min, max int64, limit int) ([]dbtypes.BlockDataBasic, error)
BlockSummaryTimeRange returns the blocks created within a specified time range (min, max time), up to limit transactions.
func (*ChainDB) BlockTimeByHeight ¶
BlockTimeByHeight queries the DB for the time of the mainchain block at the given height.
func (*ChainDB) BlockTransactions ¶
func (pgb *ChainDB) BlockTransactions(ctx context.Context, blockHash string) ([]string, []uint32, []int8, error)
BlockTransactions retrieves all transactions in the specified block, their indexes in the block, their tree, and an error value.
func (*ChainDB) ChainInfo ¶
func (pgb *ChainDB) ChainInfo() *dbtypes.BlockChainData
ChainInfo guarantees thread-safe access of the deployment data.
func (*ChainDB) ChargePoolInfoCache ¶
ChargePoolInfoCache prepares the stakeDB by querying the database for block info.
func (*ChainDB) CountTransactions ¶
func (pgb *ChainDB) CountTransactions(ctx context.Context, addr string, txnView dbtypes.AddrTxnViewType) (int, error)
CountTransactions gets the total row count for the given address and address transaction view.
func (*ChainDB) CurrentCoinSupply ¶
func (pgb *ChainDB) CurrentCoinSupply(ctx context.Context) (supply *apitypes.CoinSupply)
CurrentCoinSupply gets the current coin supply as an *apitypes.CoinSupply, which additionally contains block info and max supply.
func (*ChainDB) CurrentDifficulty ¶
CurrentDifficulty returns the current difficulty from dcrd.
func (*ChainDB) DCP0010ActivationHeight ¶
DCP0010ActivationHeight indicates the height at which the changesubsidysplit agenda will activate, or -1 if it is not determined yet.
func (*ChainDB) DCP0011ActivationHeight ¶
DCP0011ActivationHeight indicates the height at which the blake3pow agenda will activate, or -1 if it is not determined yet.
func (*ChainDB) DCP0012ActivationHeight ¶
DCP0012ActivationHeight indicates the height at which the changesubsidysplitr2 agenda will activate, or -1 if it is not determined yet.
func (*ChainDB) DbTxByHash ¶
DbTxByHash retrieves a row of the transactions table corresponding to the given transaction hash. Transactions in valid and mainchain blocks are chosen first.
func (*ChainDB) DecodeRawTransaction ¶
func (pgb *ChainDB) DecodeRawTransaction(ctx context.Context, txhex string) (*chainjson.TxRawResult, error)
DecodeRawTransaction creates a *chainjson.TxRawResult from a hex-encoded transaction.
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) DevBalance ¶
DevBalance returns the current development/project fund balance, updating the cached balance if it is stale. DevBalance differs slightly from addressBalance(devAddress) in that it will not initiate a DB query if a chain reorganization is in progress.
func (*ChainDB) Difficulty ¶
Difficulty returns the difficulty for the first block mined after the provided UNIX timestamp.
func (*ChainDB) DisapprovedBlocks ¶
DisapprovedBlocks retrieves all blocks disapproved by stakeholder votes.
func (*ChainDB) DropTables ¶
func (pgb *ChainDB) DropTables()
DropTables drops (deletes) all of the known dcrdata tables.
func (*ChainDB) EnableDuplicateCheckOnInsert ¶
EnableDuplicateCheckOnInsert specifies whether SQL insertions should check for row conflicts (duplicates), and avoid adding or updating.
func (*ChainDB) FillAddressTransactions ¶
func (pgb *ChainDB) FillAddressTransactions(ctx context.Context, addrInfo *dbtypes.AddressInfo) error
FillAddressTransactions is used to fill out the transaction details in an explorer.AddressInfo generated by dbtypes.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 by purging data for the addresses listed in expireAddresses, and prefetches the project fund balance if devPrefetch is enabled and not mid-reorg. The project fund update is run asynchronously if lazyProjectFund is true.
func (*ChainDB) GetAPITransaction ¶
GetAPITransaction gets an *apitypes.Tx for a given transaction ID.
func (*ChainDB) GetAddressTransactionsRawWithSkip ¶
func (pgb *ChainDB) GetAddressTransactionsRawWithSkip(ctx context.Context, addr string, count, skip int) []*apitypes.AddressTxRaw
GetAddressTransactionsRawWithSkip returns a slice of apitypes.AddressTxRaw objects similar to the raw result of SearchRawTransactionsVerbose, but with fewer Vin details, namely the SigScript and Sequence. This powers the /address/{addr}/.../raw API endpoints.
func (*ChainDB) GetAllTxIn ¶
GetAllTxIn gets all transaction inputs, as a slice of *apitypes.TxIn, for a given transaction ID.
func (*ChainDB) GetAllTxOut ¶
GetAllTxOut gets all transaction outputs, as a slice of *apitypes.TxOut, for a given transaction ID.
func (*ChainDB) GetBestBlockHash ¶
GetBestBlockHash is for middleware DataSource compatibility. No DB query is performed; the last stored height is used.
func (*ChainDB) GetBestBlockSummary ¶
func (pgb *ChainDB) GetBestBlockSummary(ctx context.Context) *apitypes.BlockDataBasic
GetBestBlockSummary retrieves data for the best block in the DB. If there are no blocks in the table (yet), a nil pointer is returned.
func (*ChainDB) GetBlockByHash ¶
GetBlockByHash gets a *wire.MsgBlock for the supplied hex-encoded hash string.
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) GetBlockHeaderByHash ¶
func (pgb *ChainDB) GetBlockHeaderByHash(ctx context.Context, hash string) (*wire.BlockHeader, error)
GetBlockHeaderByHash fetches the *chainjson.GetBlockHeaderVerboseResult for a given block hash.
func (*ChainDB) GetBlockHeight ¶
GetBlockHeight returns the height of the block with the specified hash.
func (*ChainDB) GetBlockSize ¶
GetBlockSize returns the block size in bytes for the block at a given block height.
func (*ChainDB) GetBlockSizeRange ¶
GetBlockSizeRange gets the block sizes in bytes for an inclusive range of block heights.
func (*ChainDB) GetBlockVerboseByHash ¶
func (pgb *ChainDB) GetBlockVerboseByHash(ctx context.Context, hash string, verboseTx bool) *chainjson.GetBlockVerboseResult
GetBlockVerboseByHash returns a *chainjson.GetBlockVerboseResult for the specified block hash, optionally with transaction details.
func (*ChainDB) GetBurnedCoins ¶
GetBurnedCoins retrieves the total burned amount for all SKA coin types.
func (*ChainDB) GetChainParams ¶
GetChainParams is a getter for the current network parameters.
func (*ChainDB) GetChainWork ¶
GetChainWork fetches the chainjson.BlockHeaderVerbose and returns only the ChainWork attribute as a hex-encoded string, without 0x prefix.
func (*ChainDB) GetExplorerBlock ¶
GetExplorerBlock gets a *exptypes.Blockinfo for the specified block.
func (*ChainDB) GetExplorerBlocks ¶
func (pgb *ChainDB) GetExplorerBlocks(ctx context.Context, start int, end int) []*exptypes.BlockBasic
GetExplorerBlocks creates an slice of exptypes.BlockBasic beginning at start and decreasing in block height to end, not including end.
func (*ChainDB) GetExplorerFullBlocks ¶
func (pgb *ChainDB) GetExplorerFullBlocks(ctx context.Context, start int, end int) []*exptypes.BlockInfo
GetExplorerFullBlocks gets the *exptypes.BlockInfo's for a range of block heights.
func (*ChainDB) GetExplorerTx ¶
GetExplorerTx creates a *exptypes.TxInfo for the transaction with the given ID.
func (*ChainDB) GetHeader ¶
func (pgb *ChainDB) GetHeader(idx int) *chainjson.GetBlockHeaderVerboseResult
GetHeader fetches the *chainjson.GetBlockHeaderVerboseResult for a given block height.
func (*ChainDB) GetHeight ¶
GetHeight is for middleware DataSource compatibility. No DB query is performed; the last stored height is used.
func (*ChainDB) GetMempoolPriceCountTime ¶
func (pgb *ChainDB) GetMempoolPriceCountTime() *apitypes.PriceCountTime
GetMempoolPriceCountTime retrieves from mempool: the ticket price, the number of tickets in mempool, the time of the first ticket.
func (*ChainDB) GetMempoolSSTxDetails ¶
func (pgb *ChainDB) GetMempoolSSTxDetails(N int) *apitypes.MempoolTicketDetails
GetMempoolSSTxDetails returns the current mempool ticket info for tickets above height N in the mempool cache.
func (*ChainDB) GetMempoolSSTxFeeRates ¶
func (pgb *ChainDB) GetMempoolSSTxFeeRates(N int) *apitypes.MempoolTicketFees
GetMempoolSSTxFeeRates returns the current mempool stake fee info for tickets above height N in the mempool cache.
func (*ChainDB) GetMempoolSSTxSummary ¶
func (pgb *ChainDB) GetMempoolSSTxSummary() *apitypes.MempoolTicketFeeInfo
GetMempoolSSTxSummary returns the current *apitypes.MempoolTicketFeeInfo.
func (*ChainDB) GetPoolInfo ¶
GetPoolInfo retrieves the ticket pool statistics at the specified height.
func (*ChainDB) GetPoolInfoRange ¶
GetPoolInfoRange retrieves the ticket pool statistics for a range of block heights, as a slice.
func (*ChainDB) GetPoolValAndSizeRange ¶
func (pgb *ChainDB) GetPoolValAndSizeRange(ctx context.Context, idx0, idx1 int) ([]float64, []uint32)
GetPoolValAndSizeRange returns the ticket pool size at each block height within a given range.
func (*ChainDB) GetRawTransactionVerbose ¶
func (pgb *ChainDB) GetRawTransactionVerbose(ctx context.Context, txid *chainhash.Hash) (*chainjson.TxRawResult, error)
GetRawTransactionVerbose gets a chainjson.TxRawResult for the specified transaction hash.
func (*ChainDB) GetSBitsByHash ¶
GetSBitsByHash gets the stake difficulty in DCR for a given block height.
func (*ChainDB) GetSDiffRange ¶
GetSDiffRange gets the stake difficulties in DCR for a range of block heights.
func (*ChainDB) GetStakeDiffEstimates ¶
GetStakeDiffEstimates gets an *apitypes.StakeDiff, which is a combo of chainjson.EstimateStakeDiffResult and chainjson.GetStakeDifficultyResult
func (*ChainDB) GetStakeInfoExtendedByHash ¶
func (pgb *ChainDB) GetStakeInfoExtendedByHash(ctx context.Context, hashStr string) *apitypes.StakeInfoExtended
GetStakeInfoExtendedByHash fetches a apitypes.StakeInfoExtended, containing comprehensive data for the state of staking at a given block.
func (*ChainDB) GetStakeInfoExtendedByHeight ¶
func (pgb *ChainDB) GetStakeInfoExtendedByHeight(ctx context.Context, height int) *apitypes.StakeInfoExtended
GetStakeInfoExtendedByHeight gets extended stake information for the mainchain block at the specified height.
func (*ChainDB) GetStakeVersions ¶
func (pgb *ChainDB) GetStakeVersions(ctx context.Context, blockHash string, count int32) (*chainjson.GetStakeVersionsResult, error)
GetStakeVersions requests the output of the getstakeversions RPC, which gets stake version information and individual vote version information starting at the given block and for count-1 blocks prior.
func (*ChainDB) GetStakeVersionsLatest ¶
GetStakeVersionsLatest requests the output of the getstakeversions RPC for just the current best block.
func (*ChainDB) GetSummary ¶
GetSummary returns the *apitypes.BlockDataBasic for a given block height.
func (*ChainDB) GetSummaryByHash ¶
func (pgb *ChainDB) GetSummaryByHash(ctx context.Context, hash string, withTxTotals bool) *apitypes.BlockDataBasic
GetSummaryByHash returns a *apitypes.BlockDataBasic for a given hex-encoded block hash. If withTxTotals is true, the TotalSent and MiningFee fields will be set, but it's costly because it requires a GetBlockVerboseByHash RPC call.
func (*ChainDB) GetSummaryRange ¶
GetSummaryRange returns the *apitypes.BlockDataBasic for a range of block heights.
func (*ChainDB) GetSummaryRangeStepped ¶
func (pgb *ChainDB) GetSummaryRangeStepped(ctx context.Context, idx0, idx1, step int) []*apitypes.BlockDataBasic
GetSummaryRangeStepped returns the []*apitypes.BlockDataBasic for a given block height.
func (*ChainDB) GetTicketInfo ¶
GetTicketInfo retrieves information about the pool and spend statuses, the purchase block, the lottery block, and the spending transaction.
func (*ChainDB) GetTransactionByHash ¶
GetTransactionByHash gets a wire.MsgTx for the specified transaction hash.
func (*ChainDB) GetTransactionHex ¶
GetTransactionHex returns the full serialized transaction for the specified transaction hash as a hex encode string.
func (*ChainDB) GetTransactionsForBlockByHash ¶
func (pgb *ChainDB) GetTransactionsForBlockByHash(ctx context.Context, hash string) *apitypes.BlockTransactions
GetTransactionsForBlockByHash returns a *apitypes.BlockTransactions for the block with the specified hash.
func (*ChainDB) GetTrimmedTransaction ¶
func (pgb *ChainDB) GetTrimmedTransaction(ctx context.Context, txid *chainhash.Hash) *apitypes.TrimmedTx
GetTrimmedTransaction gets a *apitypes.TrimmedTx for a given transaction ID.
func (*ChainDB) GetVoteInfo ¶
func (pgb *ChainDB) GetVoteInfo(ctx context.Context, txhash *chainhash.Hash) (*apitypes.VoteInfo, error)
GetVoteInfo attempts to decode the vote bits of a SSGen transaction. If the transaction is not a valid SSGen, the VoteInfo output will be nil. Depending on the stake version with which dcrdata is compiled with (chaincfg.Params), the Choices field of VoteInfo may be a nil slice even if the votebits were set for a previously-valid agenda.
func (*ChainDB) GetVoteVersionInfo ¶
func (pgb *ChainDB) GetVoteVersionInfo(ctx context.Context, ver uint32) (*chainjson.GetVoteInfoResult, error)
GetVoteVersionInfo requests stake version info from the dcrd RPC server
func (*ChainDB) HashDBLegacy ¶
HashDBLegacy queries the blocks table for the best block's hash.
func (*ChainDB) HeightDBLegacy ¶
HeightDBLegacy queries the blocks table for the best block height. When the tables are empty, the returned height will be -1.
func (*ChainDB) HeightHashDB ¶
HeightHashDB retrieves the best block height and hash according to the meta table.
func (*ChainDB) HeightHashDBLegacy ¶
HeightHashDBLegacy queries the blocks table for the best block's height and hash.
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 most indexes in the tables. Exceptions: (1) addresses on matching_tx_hash (use IndexAddressTable or do it individually) and (2) all tickets table indexes (use IndexTicketsTable).
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) InitUtxoCache ¶
InitUtxoCache resets the UTXO cache with the given slice of UTXO data.
func (*ChainDB) InsightAddressTransactions ¶
func (pgb *ChainDB) InsightAddressTransactions(ctx context.Context, addr []string, recentBlockHeight int64) (txs, recentTxs []chainhash.Hash, err error)
InsightAddressTransactions performs DB queries to get all transaction hashes for the specified addresses in descending order by time, then ascending order by hash. It also returns a list of recently (defined as greater than recentBlockHeight) confirmed transactions that can be used to validate mempool status.
func (*ChainDB) IsDCP0010Active ¶
IsDCP0010Active indicates if the "changesubsidysplit" consensus deployment is active at the given height according to the current status of the agendas.
func (*ChainDB) IsDCP0011Active ¶
IsDCP0011Active indicates if the "blake3pow" consensus deployment is active at the given height according to the current status of the agendas.
func (*ChainDB) IsDCP0012Active ¶
IsDCP0012Active indicates if the "blake3pow" consensus deployment is active at the given height according to the current status of the agendas.
func (*ChainDB) MissingAddressIndexes ¶
MissingAddressIndexes list missing addresses table indexes and their descriptions.
func (*ChainDB) MissingIndexes ¶
MissingIndexes lists missing table indexes and their descriptions.
func (*ChainDB) MissingSideChainBlocks ¶
MissingSideChainBlocks identifies side chain blocks that are missing from the DB. Side chains known to dcrd 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 (*ChainDB) NewChainMonitor ¶
func (pgb *ChainDB) NewChainMonitor(ctx context.Context) *ChainMonitor
NewChainMonitor creates a new ChainMonitor.
func (*ChainDB) OutpointAddresses ¶
func (pgb *ChainDB) OutpointAddresses(ctx context.Context, txHash string, voutIndex uint32) ([]string, int64, error)
OutpointAddresses fetches all addresses and the value of a given outpoint (txHash:voutIndex).
func (*ChainDB) PoolStatusForTicket ¶
func (pgb *ChainDB) PoolStatusForTicket(ctx context.Context, 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(ctx context.Context, 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) PowerlessTickets ¶
PowerlessTickets fetches all missed and expired tickets, sorted by revocation status.
func (*ChainDB) PurgeBestBlocks ¶
PurgeBestBlocks deletes all data for the N best blocks in the DB.
func (*ChainDB) RegisterCharts ¶
RegisterCharts registers chart data fetchers and appenders with the provided ChartData.
func (*ChainDB) ReindexAddressesBlockTime ¶
ReindexAddressesBlockTime rebuilds the addresses(block_time) index.
func (*ChainDB) RewindStakeDB ¶
func (pgb *ChainDB) RewindStakeDB(ctx context.Context, toHeight int64, quiet ...bool) (stakeDBHeight int64, err error)
RewindStakeDB attempts to disconnect blocks from the stake database to reach the specified height. A Context may be provided to allow cancellation of the rewind process. If the specified height is greater than the current stake DB height, RewindStakeDB will exit without error, returning the current stake DB height and a nil error.
func (*ChainDB) SDiffRange ¶
SDiffRange returns an array of stake difficulties for block range ind0 to ind1.
func (*ChainDB) SKACoinSupply ¶
SKACoinSupply retrieves the supply info for all SKA coin types. TotalIssued = sum of vouts by coin_type (mainchain). TotalBurned = retrieved from RPC getburnedcoins. InCirculation = TotalIssued - TotalBurned.
func (*ChainDB) SendRawTransaction ¶
SendRawTransaction attempts to decode the input serialized transaction, passed as hex encoded string, and broadcast it, returning the tx hash.
func (*ChainDB) SideChainBlocks ¶
SideChainBlocks retrieves all known side chain blocks.
func (*ChainDB) SignalHeight ¶
SignalHeight signals the database height to any registered receivers. This function is exported so that it can be called once externally after all update channel clients have subscribed.
func (*ChainDB) SpendDetailsForFundingTx ¶
func (pgb *ChainDB) SpendDetailsForFundingTx(ctx context.Context, fundHash string) ([]*apitypes.SpendByFundingHash, error)
SpendDetailsForFundingTx will return the details of any spending transactions (tx, index, block height) for a given funding transaction.
func (*ChainDB) SpendingTransaction ¶
func (pgb *ChainDB) SpendingTransaction(ctx context.Context, fundingTxID string, fundingTxVout uint32) (string, uint32, 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 ¶
func (pgb *ChainDB) SpendingTransactions(ctx context.Context, fundingTxID string) ([]string, []uint32, []uint32, error)
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) SqlDB ¶
SqlDB returns the underlying sql.DB, which should not be used directly unless you know what you are doing (if you have to ask...).
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, isValid, isMainchain, updateExistingRecords, updateAddressesSpendingInfo bool, chainWork string) (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 (pgb *ChainDB) SyncChainDB(ctx context.Context, client rpcutils.BlockFetcher, updateAllAddresses, 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) TSpendVotes ¶
func (*ChainDB) TicketMiss ¶
TicketMiss retrieves the mainchain block in which the specified ticket was called to vote but failed to do so (miss). If the ticket never missed a vote, the returned error will be dbtypes.ErrNoResult.
func (*ChainDB) TicketPoolBlockMaturity ¶
TicketPoolBlockMaturity returns the block at which all tickets with height greater than it are immature.
func (*ChainDB) TicketPoolByDateAndInterval ¶
func (pgb *ChainDB) TicketPoolByDateAndInterval(ctx context.Context, maturityBlock int64, interval dbtypes.TimeBasedGrouping) (*dbtypes.PoolTicketsData, error)
TicketPoolByDateAndInterval fetches the tickets ordered by the purchase date interval provided and an error value.
func (*ChainDB) TicketPoolVisualization ¶
func (pgb *ChainDB) TicketPoolVisualization(ctx context.Context, interval dbtypes.TimeBasedGrouping) (*dbtypes.PoolTicketsData, *dbtypes.PoolTicketsData, *dbtypes.PoolTicketsData, int64, 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) TicketsByInputCount ¶
TicketsByInputCount returns chart data for tickets grouped by number of inputs.
func (*ChainDB) TicketsByPrice ¶
func (pgb *ChainDB) TicketsByPrice(ctx context.Context, maturityBlock int64) (*dbtypes.PoolTicketsData, error)
TicketsByPrice returns chart data for tickets grouped by price. maturityBlock is used to define when tickets are considered live.
func (*ChainDB) TimeBasedIntervals ¶
func (pgb *ChainDB) TimeBasedIntervals(ctx context.Context, timeGrouping dbtypes.TimeBasedGrouping, limit, offset uint64) ([]*dbtypes.BlocksGroupedInfo, error)
TimeBasedIntervals retrieves blocks groups by the selected time-based interval. For the consecutive groups the number of blocks grouped together is not uniform.
func (*ChainDB) TipToSideChain ¶
func (*ChainDB) Transaction ¶
Transaction retrieves all rows from the transactions table for the given transaction hash.
func (*ChainDB) TransactionBlock ¶
func (pgb *ChainDB) TransactionBlock(ctx context.Context, txID string) (string, uint32, int8, error)
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 ¶
func (pgb *ChainDB) TransactionBlocks(ctx context.Context, txHash string) ([]*dbtypes.BlockStatus, []uint32, error)
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) TreasuryBalance ¶
TreasuryBalance calculates the *dbtypes.TreasuryBalance.
func (*ChainDB) TreasuryTxns ¶
func (pgb *ChainDB) TreasuryTxns(ctx context.Context, n, offset int64, txType stake.TxType) ([]*dbtypes.TreasuryTx, error)
TreasuryTxns fetches filtered treasury transactions.
func (*ChainDB) TxHistoryData ¶
func (pgb *ChainDB) TxHistoryData(ctx context.Context, address string, addrChart dbtypes.HistoryChart, chartGroupings dbtypes.TimeBasedGrouping) (cd *dbtypes.ChartsData, err error)
TxHistoryData fetches the address history chart data for specified chart type and time grouping.
func (*ChainDB) UpdateChainState ¶
func (pgb *ChainDB) UpdateChainState(blockChainInfo *chainjson.GetBlockChainInfoResult)
UpdateChainState updates the blockchain's state, which includes each of the agenda's VotingDone and Activated heights. If the agenda passed (i.e. status is "lockedIn" or "activated"), Activated is set to the height at which the rule change will take(or took) place.
func (*ChainDB) UpdateChan ¶
UpdateChan creates a channel that will receive height updates. All calls to UpdateChan should be completed before blocks start being connected.
func (*ChainDB) UseMempoolChecker ¶
func (pgb *ChainDB) UseMempoolChecker(mp rpcutils.MempoolAddressChecker)
UseMempoolChecker assigns a MempoolAddressChecker for searching mempool for transactions involving a certain address.
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) VARCoinSupply ¶
VARCoinSupply retrieves the VAR circulating supply and target cap.
func (*ChainDB) VinsForTx ¶
func (pgb *ChainDB) VinsForTx(ctx context.Context, dbTx *dbtypes.Tx) ([]dbtypes.VinTxProperty, 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. TEST ONLY REMOVE
func (*ChainDB) VoutValues ¶
func (pgb *ChainDB) VoutValues(ctx context.Context, txID string) ([]uint64, []uint32, []int8, error)
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. TEST ONLY REMOVE
type ChainDBCfg ¶
type ChainDeployments ¶
type ChainDeployments struct {
// contains filtered or unexported fields
}
ChainDeployments is mutex-protected blockchain deployment data.
type ChainMonitor ¶
type ChainMonitor struct {
// contains filtered or unexported fields
}
ChainMonitor responds to block connection and chain reorganization.
func (*ChainMonitor) ReorgHandler ¶
func (p *ChainMonitor) ReorgHandler(reorg *txhelpers.ReorgData) error
ReorgHandler processes a blockchain reorganization and initiates a corresponding reorganization of the ChainDB. ReorgHandler satisfies notification.ReorgHandler, and is registered as a handler in main.go.
type CompatAction ¶
type CompatAction int8
CompatAction defines the action to be taken once the current and the required pg table versions are compared.
const ( Rebuild CompatAction = iota Upgrade Maintenance OK TimeTravel Unknown )
These are the recognized CompatActions for upgrading a database from one version to another.
func (CompatAction) String ¶
func (v CompatAction) String() string
String implements Stringer for CompatAction.
type DatabaseUpgrade ¶
type DatabaseUpgrade struct {
TableName string
UpgradeType CompatAction
CurrentVer, RequiredVer DatabaseVersion
}
DatabaseUpgrade is used to define a required DB upgrade.
func (DatabaseUpgrade) String ¶
func (s DatabaseUpgrade) String() string
String implements Stringer for DatabaseUpgrade.
type DatabaseVersion ¶
type DatabaseVersion struct {
// contains filtered or unexported fields
}
DatabaseVersion models a database version.
func DBVersion ¶
func DBVersion(db *sql.DB) (ver DatabaseVersion, err error)
DBVersion retrieves the database version from the meta table. See (*DatabaseVersion).NeededToReach for version comparison.
func NewDatabaseVersion ¶
func NewDatabaseVersion(major, minor, patch uint32) DatabaseVersion
NewDatabaseVersion returns a new DatabaseVersion with the version major.minor.patch
func (*DatabaseVersion) NeededToReach ¶
func (v *DatabaseVersion) NeededToReach(other *DatabaseVersion) CompatAction
NeededToReach describes what action is required for the DatabaseVersion to reach another version provided in the input argument.
func (DatabaseVersion) String ¶
func (v DatabaseVersion) String() string
String implements Stringer for DatabaseVersion.
type MsgBlockPG ¶
type MsgBlockPG struct {
*wire.MsgBlock
WinningTickets []dbtypes.ChainHash
Validators []dbtypes.ChainHash
}
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 PGSetting ¶
type PGSetting struct {
Name, Setting, Unit, ShortDesc, Source, SourceFile, SourceLine string
}
PGSetting describes a PostgreSQL setting scanned from pg_settings.
type PGSettings ¶
PGSettings facilitates looking up a PGSetting based on a setting's Name.
func (PGSettings) String ¶
func (pgs PGSettings) String() string
String implements the Stringer interface, generating a table of the settings where the Setting and Unit fields are merged into a single column. The rows of the table are sorted by the PGSettings string key (the setting's Name). This function is not thread-safe, so do not modify PGSettings concurrently.
type SqlExecQueryer ¶
type SqlExecQueryer interface {
SqlExecutor
SqlQueryer
}
SqlExecQueryer is implemented by both sql.DB and sql.Tx.
type SqlExecutor ¶
SqlExecutor is implemented by both sql.DB and sql.Tx.
type SqlQueryer ¶
type SqlQueryer interface {
Query(query string, args ...interface{}) (*sql.Rows, error)
QueryRow(query string, args ...interface{}) *sql.Row
}
SqlQueryer is implemented by both sql.DB and sql.Tx.
type TicketTxnIDGetter ¶
type TicketTxnIDGetter struct {
// contains filtered or unexported fields
}
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 dbtypes.ChainHash, txDbID uint64)
Set stores the (transaction hash, DB row ID) pair a map for future access.
func (*TicketTxnIDGetter) SetN ¶
func (t *TicketTxnIDGetter) SetN(txid []dbtypes.ChainHash, txDbID []uint64)
SetN stores several (transaction hash, DB row ID) pairs in the map.
func (*TicketTxnIDGetter) TxnDbID ¶
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 Upgrader ¶
type Upgrader struct {
// contains filtered or unexported fields
}
Upgrader contains a number of elements necessary to perform a database upgrade.
func NewUpgrader ¶
func NewUpgrader(ctx context.Context, params *chaincfg.Params, db *sql.DB, bg BlockGetter, stakeDB *stakedb.StakeDatabase) *Upgrader
NewUpgrader is a contructor for an Upgrader.
func (*Upgrader) UpgradeDatabase ¶
UpgradeDatabase attempts to upgrade the given sql.DB with help from the BlockGetter. The DB version will be compared against the target version to decide what upgrade type to initiate.