Documentation ¶
Index ¶
- Constants
- func DisableLog()
- func InitWiredDB(dbInfo *DBInfo, statusC chan uint32, cl *rpcclient.Client, p *chaincfg.Params, ...) (wiredDB, func() error, error)
- func NewWiredDB(db *sql.DB, statusC chan uint32, cl *rpcclient.Client, p *chaincfg.Params, ...) (wiredDB, func() error, error)
- func UseLogger(logger slog.Logger)
- type BlockSummaryDatabaser
- type ChainMonitor
- type DB
- 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) RetrieveAllPoolValAndSize() (*dbtypes.ChartsData, error)
- func (db *DB) RetrieveBestBlockHash() (string, error)
- func (db *DB) RetrieveBestBlockHeight() (int64, error)
- func (db *DB) RetrieveBlockFeeInfo() (*dbtypes.ChartsData, error)
- func (db *DB) RetrieveBlockHash(ind int64) (string, error)
- func (db *DB) RetrieveBlockHeight(hash string) (int64, 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) RetrieveLatestBlockSummary() (*apitypes.BlockDataBasic, error)
- func (db *DB) RetrieveLatestStakeInfoExtended() (*apitypes.StakeInfoExtended, 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) RetrieveWinners(ind int64) ([]string, string, error)
- func (db *DB) RetrieveWinnersByHash(hash string) ([]string, uint32, error)
- func (db *DB) StoreBlockSummary(bd *apitypes.BlockDataBasic) error
- func (db *DB) StoreStakeInfoExtended(si *apitypes.StakeInfoExtended) error
- type DBDataSaver
- type DBInfo
- type StakeInfoDatabaser
Constants ¶
const ( // TableNameSummaries is name of the table used to store block summary data TableNameSummaries = "pfcdata_block_summary" // TableNameStakeInfo is name of the table used to store extended stake info TableNameStakeInfo = "pfcdata_stakeinfo_extended" // 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 (
InitialLoadSyncStatusMsg = "(Lite Mode) Syncing stake and base DBs..."
)
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.
func InitWiredDB ¶
func InitWiredDB(dbInfo *DBInfo, statusC chan uint32, cl *rpcclient.Client, p *chaincfg.Params, datadir string, updateStatusSync bool) (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, updateStatusSync bool) (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.
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 ¶
DB is a wrapper around sql.DB that adds methods for storing and retrieving chain data. Use InitDB to get a new instance. This may be unexported in the future.
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. TODO: if this db exists, figure out best heights
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
func (*DB) GetStakeInfoHeight ¶
GetStakeInfoHeight returns the largest block height for which the database can provide a stake info
func (*DB) RetrieveAllPoolValAndSize ¶
func (db *DB) RetrieveAllPoolValAndSize() (*dbtypes.ChartsData, error)
RetrieveAllPoolValAndSize returns all the pool values and sizes stored since the first value was recorded up current height.
func (*DB) RetrieveBestBlockHash ¶
RetrieveBestBlockHash returns the block hash for the best block
func (*DB) RetrieveBestBlockHeight ¶
RetrieveBestBlockHeight returns the block height for the best block
func (*DB) RetrieveBlockFeeInfo ¶
func (db *DB) RetrieveBlockFeeInfo() (*dbtypes.ChartsData, error)
RetrieveBlockFeeInfo fetches the block median fee chart data.
func (*DB) RetrieveBlockHash ¶
RetrieveBlockHash returns the block hash for block ind
func (*DB) RetrieveBlockHeight ¶
RetrieveBlockHeight returns the block height for blockhash hash
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) 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) 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) 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) StoreBlockSummary ¶
func (db *DB) StoreBlockSummary(bd *apitypes.BlockDataBasic) error
StoreBlockSummary attempts to store the block data in the database, and returns an error on failure.
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