Documentation ¶
Index ¶
- Constants
- func DisableLog()
- func UseLogger(logger slog.Logger)
- type BlockSummaryDatabaser
- type ChainMonitor
- type DB
- func (db *DB) DeleteBlock(blockhash string) (NSummaryRows, NStakeInfoRows int64, err error)
- func (db *DB) DeleteBlocksAboveHeight(height int64) (NSummaryRows, NStakeInfoRows int64, err error)
- func (db *DB) GetBestBlockHash() string
- func (db *DB) GetBestBlockHeight() int64
- func (db *DB) GetBlockSummaryHeight() (int64, error)
- func (db *DB) GetStakeInfoHeight() (int64, error)
- func (db *DB) JustifyTableStructures(dbInfo *DBInfo) error
- func (db *DB) RetrieveBestBlockHash() (string, error)
- func (db *DB) RetrieveBestBlockHeight() (int64, error)
- func (db *DB) RetrieveBestStakeHeight() (int64, error)
- func (db *DB) RetrieveBlockFeeInfo(height []uint64, fee []float64) ([]uint64, []float64, error)
- func (db *DB) RetrieveBlockHash(ind int64) (string, error)
- func (db *DB) RetrieveBlockHeight(hash string) (int64, error)
- func (db *DB) RetrieveBlockSize(ind int64) (int32, error)
- func (db *DB) RetrieveBlockSizeRange(ind0, ind1 int64) ([]int32, error)
- func (db *DB) RetrieveBlockSummary(ind int64) (*apitypes.BlockDataBasic, error)
- func (db *DB) RetrieveBlockSummaryByHash(hash string) (*apitypes.BlockDataBasic, error)
- func (db *DB) RetrieveBlockSummaryByTimeRange(minTime, maxTime int64, limit int) ([]apitypes.BlockDataBasic, error)
- func (db *DB) RetrieveDiff(timestamp int64) (float64, error)
- func (db *DB) RetrieveHighestBlockHash() (string, error)
- func (db *DB) RetrieveHighestBlockHeight() (int64, error)
- func (db *DB) RetrieveHighestStakeHeight() (int64, error)
- func (db *DB) RetrieveLatestBlockSummary() (*apitypes.BlockDataBasic, error)
- func (db *DB) RetrieveLatestStakeInfoExtended() (*apitypes.StakeInfoExtended, error)
- func (db *DB) RetrievePoolAllValueAndSize(timeArr []dbtypes.TimeDef, poolSizeArr, poolValArr []float64) ([]dbtypes.TimeDef, []float64, []float64, error)
- func (db *DB) RetrievePoolInfo(ind int64) (*apitypes.TicketPoolInfo, error)
- func (db *DB) RetrievePoolInfoByHash(hash string) (*apitypes.TicketPoolInfo, error)
- func (db *DB) RetrievePoolInfoRange(ind0, ind1 int64) ([]apitypes.TicketPoolInfo, []string, error)
- func (db *DB) RetrievePoolValAndSizeRange(ind0, ind1 int64) ([]float64, []float64, error)
- func (db *DB) RetrieveSDiff(ind int64) (float64, error)
- func (db *DB) RetrieveSDiffRange(ind0, ind1 int64) ([]float64, error)
- func (db *DB) RetrieveStakeInfoExtended(ind int64) (*apitypes.StakeInfoExtended, error)
- func (db *DB) RetrieveStakeInfoExtendedByHash(blockhash string) (*apitypes.StakeInfoExtended, error)
- func (db *DB) RetrieveWinners(ind int64) ([]string, string, error)
- func (db *DB) RetrieveWinnersByHash(hash string) ([]string, uint32, error)
- func (db *DB) StoreBlock(bd *apitypes.BlockDataBasic, isMainchain bool, isValid bool) error
- func (db *DB) StoreBlockSummary(bd *apitypes.BlockDataBasic) error
- func (db *DB) StoreSideBlockSummary(bd *apitypes.BlockDataBasic) error
- func (db *DB) StoreStakeInfoExtended(si *apitypes.StakeInfoExtended) error
- type DBDataSaver
- type DBInfo
- type StakeInfoDatabaser
- type WiredDB
- func (db *WiredDB) BlockSubsidy(height int64, voters uint16) *dcrjson.GetBlockSubsidyResult
- func (db *WiredDB) BlockchainInfo() (*dcrjson.GetBlockChainInfoResult, error)
- func (db *WiredDB) ChargePoolInfoCache(startHeight int64) error
- func (db *WiredDB) CheckConnectivity() error
- func (db *WiredDB) CoinSupply() (supply *apitypes.CoinSupply)
- func (db *WiredDB) DBHeights() (lowest int64, summaryHeight int64, stakeInfoHeight int64, ...)
- func (db *WiredDB) DecodeRawTransaction(txhex string) (*dcrjson.TxRawResult, error)
- func (db *WiredDB) Difficulty() (float64, error)
- func (db *WiredDB) DisableCache()
- func (db *WiredDB) EnableCache()
- func (db *WiredDB) GetAddressTransactions(addr string, count int) *apitypes.Address
- func (db *WiredDB) GetAddressTransactionsRaw(addr string, count int) []*apitypes.AddressTxRaw
- func (db *WiredDB) GetAddressTransactionsRawWithSkip(addr string, count int, skip int) []*apitypes.AddressTxRaw
- func (db *WiredDB) GetAddressTransactionsWithSkip(addr string, count, skip int) *apitypes.Address
- func (db *WiredDB) GetAllTxIn(txid *chainhash.Hash) []*apitypes.TxIn
- func (db *WiredDB) GetAllTxOut(txid *chainhash.Hash) []*apitypes.TxOut
- func (db *WiredDB) GetBestBlockHash() (string, error)
- func (db *WiredDB) GetBestBlockHeightHash() (chainhash.Hash, int64, error)
- func (db *WiredDB) GetBestBlockSummary() *apitypes.BlockDataBasic
- func (db *WiredDB) GetBlockByHash(hash string) (*wire.MsgBlock, error)
- func (db *WiredDB) GetBlockHash(idx int64) (string, error)
- func (db *WiredDB) GetBlockHeaderByHash(hash string) (*wire.BlockHeader, error)
- func (db *WiredDB) GetBlockHeight(hash string) (int64, error)
- func (db *WiredDB) GetBlockSize(idx int) (int32, error)
- func (db *WiredDB) GetBlockSizeRange(idx0, idx1 int) ([]int32, error)
- func (db *WiredDB) GetBlockSummaryTimeRange(min, max int64, limit int) []apitypes.BlockDataBasic
- func (db *WiredDB) GetBlockVerbose(idx int, verboseTx bool) *dcrjson.GetBlockVerboseResult
- func (db *WiredDB) GetBlockVerboseByHash(hash string, verboseTx bool) *dcrjson.GetBlockVerboseResult
- func (db *WiredDB) GetChainParams() *chaincfg.Params
- func (db *WiredDB) GetExplorerAddress(address string, count, offset int64) (*dbtypes.AddressInfo, txhelpers.AddressType, txhelpers.AddressError)
- func (db *WiredDB) GetExplorerBlock(hash string) *exptypes.BlockInfo
- func (db *WiredDB) GetExplorerBlocks(start int, end int) []*exptypes.BlockBasic
- func (db *WiredDB) GetExplorerFullBlocks(start int, end int) []*exptypes.BlockInfo
- func (db *WiredDB) GetExplorerTx(txid string) *exptypes.TxInfo
- func (db *WiredDB) GetFeeInfo(idx int) *dcrjson.FeeInfoBlock
- func (db *WiredDB) GetHeader(idx int) *dcrjson.GetBlockHeaderVerboseResult
- func (db *WiredDB) GetHeight() (int64, error)
- func (db *WiredDB) GetMempool() []exptypes.MempoolTx
- func (db *WiredDB) GetMempoolPriceCountTime() *apitypes.PriceCountTime
- func (db *WiredDB) GetMempoolSSTxDetails(N int) *apitypes.MempoolTicketDetails
- func (db *WiredDB) GetMempoolSSTxFeeRates(N int) *apitypes.MempoolTicketFees
- func (db *WiredDB) GetMempoolSSTxSummary() *apitypes.MempoolTicketFeeInfo
- func (db *WiredDB) GetPool(idx int64) ([]string, error)
- func (db *WiredDB) GetPoolByHash(hash string) ([]string, error)
- func (db *WiredDB) GetPoolInfo(idx int) *apitypes.TicketPoolInfo
- func (db *WiredDB) GetPoolInfoByHash(hash string) *apitypes.TicketPoolInfo
- func (db *WiredDB) GetPoolInfoRange(idx0, idx1 int) []apitypes.TicketPoolInfo
- func (db *WiredDB) GetPoolValAndSizeRange(idx0, idx1 int) ([]float64, []float64)
- func (db *WiredDB) GetRawTransaction(txid *chainhash.Hash) *apitypes.Tx
- func (db *WiredDB) GetRawTransactionWithPrevOutAddresses(txid *chainhash.Hash) (*apitypes.Tx, [][]string)
- func (db *WiredDB) GetSDiff(idx int) float64
- func (db *WiredDB) GetSDiffRange(idx0, idx1 int) []float64
- func (db *WiredDB) GetStakeDB() *stakedb.StakeDatabase
- func (db *WiredDB) GetStakeDiffEstimates() *apitypes.StakeDiff
- func (db *WiredDB) GetStakeInfoExtendedByHash(blockhash string) *apitypes.StakeInfoExtended
- func (db *WiredDB) GetStakeInfoExtendedByHeight(idx int) *apitypes.StakeInfoExtended
- func (db *WiredDB) GetStakeVersions(blockHash string, count int32) (*dcrjson.GetStakeVersionsResult, error)
- func (db *WiredDB) GetStakeVersionsLatest() (*dcrjson.StakeVersions, error)
- func (db *WiredDB) GetSummary(idx int) *apitypes.BlockDataBasic
- func (db *WiredDB) GetSummaryByHash(hash string, withTxTotals bool) *apitypes.BlockDataBasic
- func (db *WiredDB) GetTip() (*exptypes.WebBasicBlock, error)
- func (db *WiredDB) GetTransactionHex(txid *chainhash.Hash) string
- func (db *WiredDB) GetTransactionsForBlock(idx int64) *apitypes.BlockTransactions
- func (db *WiredDB) GetTransactionsForBlockByHash(hash string) *apitypes.BlockTransactions
- func (db *WiredDB) GetTrimmedTransaction(txid *chainhash.Hash) *apitypes.TrimmedTx
- func (db *WiredDB) GetVoteInfo(txhash *chainhash.Hash) (*apitypes.VoteInfo, error)
- func (db *WiredDB) GetVoteVersionInfo(ver uint32) (*dcrjson.GetVoteInfoResult, error)
- func (db *WiredDB) ImportSideChains(collector *blockdata.Collector) error
- func (db *WiredDB) NewChainMonitor(ctx context.Context, collector *blockdata.Collector, wg *sync.WaitGroup, ...) *ChainMonitor
- func (db *WiredDB) NewStakeDBChainMonitor(ctx context.Context, wg *sync.WaitGroup, reorgChan chan *txhelpers.ReorgData) *stakedb.ChainMonitor
- func (db *WiredDB) PurgeBestBlock() (NSummaryRows, NStakeInfoRows, height int64, hash string, err error)
- func (db *WiredDB) PurgeBestBlocks(N int64) (NSummaryRows, NStakeInfoRows, height int64, hash string, err error)
- func (db *WiredDB) PurgeBlock(hash string) (NSummaryRows, NStakeInfoRows int64, err error)
- func (db *WiredDB) PurgeBlocksAboveHeight(height int64) (NSummaryRows, NStakeInfoRows int64, err error)
- func (db *WiredDB) ReportHeights() error
- func (db *WiredDB) RetreiveDifficulty(timestamp int64) float64
- func (db *WiredDB) RewindStakeDB(ctx context.Context, toHeight int64, quiet ...bool) (stakeDBHeight int64, err error)
- func (db *WiredDB) SendRawTransaction(txhex string) (string, error)
- func (db *WiredDB) SqliteChartsData(data map[string]*dbtypes.ChartsData) (err error)
- func (db *WiredDB) SyncDB(ctx context.Context, blockGetter rpcutils.BlockGetter, fetchToHeight int64) (int64, error)
- func (db *WiredDB) SyncDBAsync(ctx context.Context, res chan dbtypes.SyncResult, ...)
- func (db *WiredDB) TxHeight(txid *chainhash.Hash) (height int64)
Constants ¶
const ( // TableNameSummaries is name of the table used to store block summary data TableNameSummaries = "dcrdata_block_summary" // TableNameStakeInfo is name of the table used to store extended stake info TableNameStakeInfo = "dcrdata_stakeinfo_extended" // A couple database queries that are called before NewWiredDB SetCacheSizeSQL = "PRAGMA cache_size = 32768;" SetSynchrounousOffSQL = "pragma synchronous = OFF;" // DBBusyTimeout is the length of time in milliseconds for sqlite to retry // DB access when the SQLITE_BUSY error would otherwise be returned. DBBusyTimeout = "30000" )
const (
MaxAddressRows int64 = 1000
)
Variables ¶
This section is empty.
Functions ¶
func DisableLog ¶
func DisableLog()
DisableLog disables all library log output. Logging output is disabled by default until UseLogger is called.
Types ¶
type BlockSummaryDatabaser ¶
type BlockSummaryDatabaser interface { StoreBlockSummary(bd *apitypes.BlockDataBasic) error RetrieveBlockSummary(ind int64) (*apitypes.BlockDataBasic, error) }
BlockSummaryDatabaser is the interface for a block data saving database
type ChainMonitor ¶
type ChainMonitor struct { ConnectingLock chan struct{} DoneConnecting chan struct{} // contains filtered or unexported fields }
ChainMonitor handles change notifications from the node client
func (*ChainMonitor) ReorgHandler ¶
func (p *ChainMonitor) ReorgHandler()
ReorgHandler receives notification of a chain reorganization and initiates a corresponding update of the SQL db keeping the main chain data.
type DB ¶
type DB struct { *sql.DB // BlockCache stores apitypes.BlockDataBasic and apitypes.StakeInfoExtended // in StoreBlock for quick retrieval without a DB query. BlockCache *apitypes.APICache // contains filtered or unexported fields }
DB is a wrapper around sql.DB that adds methods for storing and retrieving chain data. Use InitDB to get a new instance.
func InitDB ¶
InitDB creates a new DB instance from a DBInfo containing the name of the file used to back the underlying sql database.
func NewDB ¶
NewDB creates a new DB instance with pre-generated sql statements from an existing sql.DB. Use InitDB to create a new DB without having a sql.DB.
func (*DB) DeleteBlock ¶
DeleteBlock purges the summary data and stake info for the block with the given hash. The number of rows deleted is returned.
func (*DB) DeleteBlocksAboveHeight ¶
DeleteBlocksAboveHeight purges the summary data and stake info for the blocks above the given height, including side chain blocks.
func (*DB) GetBestBlockHash ¶
GetBestBlockHash returns the hash of the best block.
func (*DB) GetBestBlockHeight ¶
GetBestBlockHeight returns the height of the best block
func (*DB) GetBlockSummaryHeight ¶
GetBlockSummaryHeight returns the largest block height for which the database can provide a block summary. A cached best block summary height will be returned when available to avoid unnecessary DB queries.
func (*DB) GetStakeInfoHeight ¶
GetStakeInfoHeight returns the cached stake info height if a height is set, otherwise it queries the database for the best (mainchain) block height in the stake info table and updates the cache.
func (*DB) JustifyTableStructures ¶
JustifyTableStructures updates an old structure that wasn't indexing sidechains. It could and should be removed in a future version. The block summary table got two new boolean columns, `is_mainchain` and `is_valid`, and the Primary key was changed from height to hash. The stake info table got a `hash` column and the primary key was switched from height to hash.
func (*DB) RetrieveBestBlockHash ¶
RetrieveBestBlockHash returns the block hash for the best (mainchain) block.
func (*DB) RetrieveBestBlockHeight ¶
RetrieveBestBlockHeight returns the block height for the best block
func (*DB) RetrieveBestStakeHeight ¶
RetrieveBestStakeHeight retreives the height of the best (mainchain) block in the stake table.
func (*DB) RetrieveBlockFeeInfo ¶
RetrieveBlockFeeInfo retrieves the block fee chart data over time. This data is used to plot block-fee-chart on the /charts page.
func (*DB) RetrieveBlockHash ¶
RetrieveBlockHash returns the block hash for block ind
func (*DB) RetrieveBlockHeight ¶
RetrieveBlockHeight returns the block height for blockhash hash
func (*DB) RetrieveBlockSize ¶
RetrieveBlockSize return the size of block at height ind.
func (*DB) RetrieveBlockSizeRange ¶
RetrieveBlockSizeRange returns an array of block sizes for block range ind0 to ind1
func (*DB) RetrieveBlockSummary ¶
func (db *DB) RetrieveBlockSummary(ind int64) (*apitypes.BlockDataBasic, error)
RetrieveBlockSummary returns basic block data for block ind.
func (*DB) RetrieveBlockSummaryByHash ¶
func (db *DB) RetrieveBlockSummaryByHash(hash string) (*apitypes.BlockDataBasic, error)
RetrieveBlockSummaryByHash returns basic block data for a block given its hash
func (*DB) RetrieveBlockSummaryByTimeRange ¶
func (*DB) RetrieveDiff ¶
RetrieveDiff returns the difficulty in the last 24hrs or immediately after 24hrs.
func (*DB) RetrieveHighestBlockHash ¶
RetrieveHighestBlockHash returns the block hash for the highest block, regardless of mainchain status.
func (*DB) RetrieveHighestBlockHeight ¶
RetrieveHighestBlockHeight returns the block height for the highest block, regardless of mainchain status.
func (*DB) RetrieveHighestStakeHeight ¶
RetrieveHighestStakeHeight retrieves the height of the highest block in the stake table without regard to mainchain status.
func (*DB) RetrieveLatestBlockSummary ¶
func (db *DB) RetrieveLatestBlockSummary() (*apitypes.BlockDataBasic, error)
RetrieveLatestBlockSummary returns the block summary for the best block.
func (*DB) RetrieveLatestStakeInfoExtended ¶
func (db *DB) RetrieveLatestStakeInfoExtended() (*apitypes.StakeInfoExtended, error)
RetrieveLatestStakeInfoExtended returns the extended stake info for the best block.
func (*DB) RetrievePoolAllValueAndSize ¶
func (db *DB) RetrievePoolAllValueAndSize(timeArr []dbtypes.TimeDef, poolSizeArr, poolValArr []float64) ([]dbtypes.TimeDef, []float64, []float64, error)
RetrievePoolAllValueAndSize returns all the pool value and the pool size charts data needed to plot ticket-pool-size and ticket-pool value charts on charts page.
func (*DB) RetrievePoolInfo ¶
func (db *DB) RetrievePoolInfo(ind int64) (*apitypes.TicketPoolInfo, error)
RetrievePoolInfo returns ticket pool info for block height ind
func (*DB) RetrievePoolInfoByHash ¶
func (db *DB) RetrievePoolInfoByHash(hash string) (*apitypes.TicketPoolInfo, error)
RetrievePoolInfoByHash returns ticket pool info for blockhash hash.
func (*DB) RetrievePoolInfoRange ¶
RetrievePoolInfoRange returns an array of apitypes.TicketPoolInfo for block range ind0 to ind1 and a non-nil error on success
func (*DB) RetrievePoolValAndSizeRange ¶
RetrievePoolValAndSizeRange returns an array each of the pool values and sizes for block range ind0 to ind1.
func (*DB) RetrieveSDiff ¶
RetrieveSDiff returns the stake difficulty for block at the specified chain height.
func (*DB) RetrieveSDiffRange ¶
RetrieveSDiffRange returns an array of stake difficulties for block range ind0 to ind1
func (*DB) RetrieveStakeInfoExtended ¶
func (db *DB) RetrieveStakeInfoExtended(ind int64) (*apitypes.StakeInfoExtended, error)
RetrieveStakeInfoExtended returns the extended stake info for the block at height ind.
func (*DB) RetrieveStakeInfoExtendedByHash ¶
func (db *DB) RetrieveStakeInfoExtendedByHash(blockhash string) (*apitypes.StakeInfoExtended, error)
func (*DB) RetrieveWinners ¶
RetrieveWinners returns the winning ticket tx IDs drawn after connecting the given block height (called to validate the block). The block hash corresponding to the input block height is also returned.
func (*DB) RetrieveWinnersByHash ¶
RetrieveWinnersByHash returns the winning ticket tx IDs drawn after connecting the block with the given hash. The block height corresponding to the input block hash is also returned.
func (*DB) StoreBlock ¶
StoreBlock attempts to store the block data in the database, and returns an error on failure.
func (*DB) StoreBlockSummary ¶
func (db *DB) StoreBlockSummary(bd *apitypes.BlockDataBasic) error
StoreBlockSummary is called with new mainchain blocks.
func (*DB) StoreSideBlockSummary ¶
func (db *DB) StoreSideBlockSummary(bd *apitypes.BlockDataBasic) error
StoreSideBlockSummary is for storing side chain.
func (*DB) StoreStakeInfoExtended ¶
func (db *DB) StoreStakeInfoExtended(si *apitypes.StakeInfoExtended) error
StoreStakeInfoExtended stores the extended stake info in the database.
type DBDataSaver ¶
type DBDataSaver struct { *DB // contains filtered or unexported fields }
DBDataSaver models a DB with a channel to communicate new block height to the web interface.
type StakeInfoDatabaser ¶
type StakeInfoDatabaser interface { StoreStakeInfoExtended(bd *apitypes.StakeInfoExtended) error RetrieveStakeInfoExtended(ind int64) (*apitypes.StakeInfoExtended, error) }
StakeInfoDatabaser is the interface for an extended stake info saving database
type WiredDB ¶
type WiredDB struct { *DBDataSaver MPC *mempool.MempoolDataCache // contains filtered or unexported fields }
WiredDB is intended to satisfy DataSourceLite interface. The block header is not stored in the DB, so the RPC client is used to get it on demand.
func InitWiredDB ¶
func InitWiredDB(dbInfo *DBInfo, statusC chan uint32, cl *rpcclient.Client, p *chaincfg.Params, datadir string, shutdown func()) (*WiredDB, func() error, error)
InitWiredDB creates a new WiredDB from a file containing the data for a sql.DB. The other parameters are same as those for NewWiredDB.
func NewWiredDB ¶
func NewWiredDB(db *sql.DB, statusC chan uint32, cl *rpcclient.Client, p *chaincfg.Params, datadir string, shutdown func()) (*WiredDB, func() error, error)
NewWiredDB creates a new WiredDB from a *sql.DB, a node client, network parameters, and a status update channel. It calls dcrsqlite.NewDB to create a new DB that wrapps the sql.DB.
func (*WiredDB) BlockSubsidy ¶
func (*WiredDB) BlockchainInfo ¶
BlockchainInfo retrieves the result of the getblockchaininfo node RPC.
func (*WiredDB) ChargePoolInfoCache ¶
func (*WiredDB) CheckConnectivity ¶
CheckConnectivity ensures the db and RPC client are working.
func (*WiredDB) CoinSupply ¶
func (db *WiredDB) CoinSupply() (supply *apitypes.CoinSupply)
func (*WiredDB) DBHeights ¶
func (db *WiredDB) DBHeights() (lowest int64, summaryHeight int64, stakeInfoHeight int64, stakeDatabaseHeight int64, err error)
DBHeights returns the best block heights of: SQLite database tables (block summary and stake info tables), the stake database (ffldb_stake), and the lowest of these. An error value is returned if any database is inaccessible.
func (*WiredDB) DecodeRawTransaction ¶
func (*WiredDB) Difficulty ¶
Difficulty returns the difficulty.
func (*WiredDB) DisableCache ¶
func (db *WiredDB) DisableCache()
func (*WiredDB) EnableCache ¶
func (db *WiredDB) EnableCache()
func (*WiredDB) GetAddressTransactions ¶
GetAddressTransactions returns an apitypes.Address Object with at most the last count transactions the address was in
func (*WiredDB) GetAddressTransactionsRaw ¶
func (db *WiredDB) GetAddressTransactionsRaw(addr string, count int) []*apitypes.AddressTxRaw
GetAddressTransactionsRaw returns an array of apitypes.AddressTxRaw objects representing the raw result of SearchRawTransactionsverbose
func (*WiredDB) GetAddressTransactionsRawWithSkip ¶
func (db *WiredDB) GetAddressTransactionsRawWithSkip(addr string, count int, skip int) []*apitypes.AddressTxRaw
GetAddressTransactionsRawWithSkip returns an array of apitypes.AddressTxRaw objects representing the raw result of SearchRawTransactionsverbose
func (*WiredDB) GetAddressTransactionsWithSkip ¶
GetAddressTransactionsWithSkip returns an apitypes.Address Object with at most the last count transactions the address was in
func (*WiredDB) GetAllTxOut ¶
func (*WiredDB) GetBestBlockHash ¶
func (*WiredDB) GetBestBlockHeightHash ¶
GetBestBlockHeightHash retrieves the DB's best block hash and height.
func (*WiredDB) GetBestBlockSummary ¶
func (db *WiredDB) GetBestBlockSummary() *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 (*WiredDB) GetBlockByHash ¶
func (*WiredDB) GetBlockHeaderByHash ¶
func (db *WiredDB) GetBlockHeaderByHash(hash string) (*wire.BlockHeader, error)
func (*WiredDB) GetBlockSizeRange ¶
func (*WiredDB) GetBlockSummaryTimeRange ¶
func (db *WiredDB) GetBlockSummaryTimeRange(min, max int64, limit int) []apitypes.BlockDataBasic
GetBlockSummaryTimeRange returns the blocks created within a specified time range min, max time
func (*WiredDB) GetBlockVerbose ¶
func (*WiredDB) GetBlockVerboseByHash ¶
func (*WiredDB) GetChainParams ¶
func (*WiredDB) GetExplorerAddress ¶
func (db *WiredDB) GetExplorerAddress(address string, count, offset int64) (*dbtypes.AddressInfo, txhelpers.AddressType, txhelpers.AddressError)
func (*WiredDB) GetExplorerBlock ¶
func (*WiredDB) GetExplorerBlocks ¶
func (db *WiredDB) GetExplorerBlocks(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 (*WiredDB) GetExplorerFullBlocks ¶
func (*WiredDB) GetFeeInfo ¶
func (*WiredDB) GetMempool ¶
GetMempool gets all transactions from the mempool for explorer and adds the total out for all the txs and vote info for the votes. The returned slice will be nil if the GetRawMempoolVerbose RPC fails. A zero-length non-nil slice is returned if there are no transactions in mempool.
func (*WiredDB) GetMempoolPriceCountTime ¶
func (db *WiredDB) GetMempoolPriceCountTime() *apitypes.PriceCountTime
GetMempoolPriceCountTime retreives from mempool: the ticket price, the number of tickets in mempool, the time of the first ticket.
func (*WiredDB) GetMempoolSSTxDetails ¶
func (db *WiredDB) GetMempoolSSTxDetails(N int) *apitypes.MempoolTicketDetails
func (*WiredDB) GetMempoolSSTxFeeRates ¶
func (db *WiredDB) GetMempoolSSTxFeeRates(N int) *apitypes.MempoolTicketFees
func (*WiredDB) GetMempoolSSTxSummary ¶
func (db *WiredDB) GetMempoolSSTxSummary() *apitypes.MempoolTicketFeeInfo
func (*WiredDB) GetPoolInfo ¶
func (db *WiredDB) GetPoolInfo(idx int) *apitypes.TicketPoolInfo
func (*WiredDB) GetPoolInfoByHash ¶
func (db *WiredDB) GetPoolInfoByHash(hash string) *apitypes.TicketPoolInfo
func (*WiredDB) GetPoolInfoRange ¶
func (db *WiredDB) GetPoolInfoRange(idx0, idx1 int) []apitypes.TicketPoolInfo
func (*WiredDB) GetPoolValAndSizeRange ¶
func (*WiredDB) GetRawTransaction ¶
func (*WiredDB) GetRawTransactionWithPrevOutAddresses ¶
func (db *WiredDB) GetRawTransactionWithPrevOutAddresses(txid *chainhash.Hash) (*apitypes.Tx, [][]string)
GetRawTransactionWithPrevOutAddresses looks up the previous outpoints for a transaction and extracts a slice of addresses encoded by the pkScript for each previous outpoint consumed by the transaction.
func (*WiredDB) GetSDiffRange ¶
func (*WiredDB) GetStakeDB ¶
func (db *WiredDB) GetStakeDB() *stakedb.StakeDatabase
func (*WiredDB) GetStakeDiffEstimates ¶
func (*WiredDB) GetStakeInfoExtendedByHash ¶
func (db *WiredDB) GetStakeInfoExtendedByHash(blockhash string) *apitypes.StakeInfoExtended
func (*WiredDB) GetStakeInfoExtendedByHeight ¶
func (db *WiredDB) GetStakeInfoExtendedByHeight(idx int) *apitypes.StakeInfoExtended
func (*WiredDB) GetStakeVersions ¶
func (db *WiredDB) GetStakeVersions(blockHash string, count int32) (*dcrjson.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 (*WiredDB) GetStakeVersionsLatest ¶
GetStakeVersionsLatest requests the output of the getstakeversions RPC for just the current best block.
func (*WiredDB) GetSummary ¶
func (db *WiredDB) GetSummary(idx int) *apitypes.BlockDataBasic
func (*WiredDB) GetSummaryByHash ¶
func (db *WiredDB) GetSummaryByHash(hash string, withTxTotals bool) *apitypes.BlockDataBasic
func (*WiredDB) GetTip ¶
func (db *WiredDB) GetTip() (*exptypes.WebBasicBlock, error)
GetTip grabs the highest block stored in the database.
func (*WiredDB) GetTransactionHex ¶
func (*WiredDB) GetTransactionsForBlock ¶
func (db *WiredDB) GetTransactionsForBlock(idx int64) *apitypes.BlockTransactions
func (*WiredDB) GetTransactionsForBlockByHash ¶
func (db *WiredDB) GetTransactionsForBlockByHash(hash string) *apitypes.BlockTransactions
func (*WiredDB) GetTrimmedTransaction ¶
func (*WiredDB) GetVoteInfo ¶
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 (*WiredDB) GetVoteVersionInfo ¶
GetVoteVersionInfo requests stake version info from the dcrd RPC server
func (*WiredDB) ImportSideChains ¶
ImportSideChains imports all side chains. Similar to pgblockchain.MissingSideChainBlocks plus the rest from main.go
func (*WiredDB) NewChainMonitor ¶
func (db *WiredDB) NewChainMonitor(ctx context.Context, collector *blockdata.Collector, wg *sync.WaitGroup, blockChan chan *chainhash.Hash, reorgChan chan *txhelpers.ReorgData) *ChainMonitor
NewChainMonitor creates a new ChainMonitor
func (*WiredDB) NewStakeDBChainMonitor ¶
func (*WiredDB) PurgeBestBlock ¶
func (db *WiredDB) PurgeBestBlock() (NSummaryRows, NStakeInfoRows, height int64, hash string, err error)
PurgeBestBlock deletes all data across all tables for the best block in the block summary table. The numbers of blocks removed from the block summary table and stake info table are returned. PurgeBestBlock will not return sql.ErrNoRows, but it will return without removing a block if the tables are empty. The returned height and hash values represent the best block after successful data removal, or before a failed removal attempt.
func (*WiredDB) PurgeBestBlocks ¶
func (db *WiredDB) PurgeBestBlocks(N int64) (NSummaryRows, NStakeInfoRows, height int64, hash string, err error)
PurgeBestBlocks deletes all data across all tables for the N best blocks in the block summary table. The number of blocks removed is returned. PurgeBestBlocks will not return sql.ErrNoRows, but it will return without removing the requested number of blocks if the tables are empty or become empty. The returned height and hash values represent the best block after successful data removal, or before a failed removal attempt.
func (*WiredDB) PurgeBlock ¶
PurgeBlock deletes all data across all tables for the block with the specified hash. The numbers of blocks removed from the block summary table and stake info table are returned. PurgeBlock will not return sql.ErrNoRows, but it may return without removing a block.
func (*WiredDB) PurgeBlocksAboveHeight ¶
func (db *WiredDB) PurgeBlocksAboveHeight(height int64) (NSummaryRows, NStakeInfoRows int64, err error)
PurgeBlocksAboveHeight deletes all data across all tables for the blocks above the given height, including side chain blocks. The numbers of blocks removed from the block summary table and stake info table are returned. PurgeBlocksAboveHeight will not return sql.ErrNoRows, but it will return without removing a block if the tables are empty.
func (*WiredDB) ReportHeights ¶
ReportHeights logs the SQLite table heights, and the stake database height, returning a non-nil error only when the SQLite tables are not at the same height.
func (*WiredDB) RetreiveDifficulty ¶
RetreiveDifficulty fetches the difficulty value in the last 24hrs or immediately after 24hrs.
func (*WiredDB) RewindStakeDB ¶
func (db *WiredDB) 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 channel must be provided for signaling if the rewind should abort. 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 (*WiredDB) SendRawTransaction ¶
func (*WiredDB) SqliteChartsData ¶
func (db *WiredDB) SqliteChartsData(data map[string]*dbtypes.ChartsData) (err error)
SqliteChartsData takes the old sqlite charts' data that requires an update. If any of the chart's data has no entries, records from the oldest to the most recent are queried from the db and updated. If some entries were found, only the change since the last update is queried and pushed to the charts' data.
func (*WiredDB) SyncDB ¶
func (db *WiredDB) SyncDB(ctx context.Context, blockGetter rpcutils.BlockGetter, fetchToHeight int64) (int64, error)
SyncDB is like SyncDBAsync, except it uses synchronous execution (the call to resyncDB is a blocking call).
func (*WiredDB) SyncDBAsync ¶
func (db *WiredDB) SyncDBAsync(ctx context.Context, res chan dbtypes.SyncResult, blockGetter rpcutils.BlockGetter, fetchToHeight int64, updateExplorer chan *chainhash.Hash, barLoad chan *dbtypes.ProgressBarLoad)
SyncDBAsync is like SyncDB except it also takes a result channel where the caller should wait to receive the result. When a slave BlockGetter is in use, fetchToHeight is used to indicate at what height the MasterBlockGetter will start sending blocks for processing. e.g. When an auxiliary DB owns the MasterBlockGetter, fetchToHeight should be one past the best block in the aux DB, thus putting WiredDB sync into "catch up" mode where it just pulls blocks from RPC until it matches the auxDB height and coordination begins.