bitumsqlite

package module
v0.0.0-...-1112063 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 16, 2019 License: ISC Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TableNameSummaries is name of the table used to store block summary data
	TableNameSummaries = "bitumdata_block_summary"
	// TableNameStakeInfo is name of the table used to store extended stake info
	TableNameStakeInfo = "bitumdata_stakeinfo_extended"

	// SetCacheSizeSQL sets the maximum number of database disk pages that
	// SQLite will hold in memory at once per open database file" before
	// calling. It is called by InitDB when creating a fresh database.
	SetCacheSizeSQL = "PRAGMA cache_size = 32768;"

	// SetSynchronousOffSQL lets SQLite continue without syncing to disk as soon
	// as it has handed data off to the operating system. Although data loss may
	// occur if the machine crashes or losses power, "commits can be orders of
	// magnitude faster" with synchronous OFF. It is called by InitDB when
	// creating a fresh database.
	SetSynchronousOffSQL = "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"
)
View Source
const (
	// MaxAddressRows is an upper limit on the number of rows that may be
	// requested with the searchrawtransactions RPC.
	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.

func UseLogger

func UseLogger(logger slog.Logger)

UseLogger uses a specified Logger to output package logging info.

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(reorg *txhelpers.ReorgData) (err error)

ReorgHandler processes a chain reorganization and initiates a corresponding update of the SQL db keeping the main chain data. ReorgHandler satisfies notification.ReorgHandler, and is registered as a handler in main.go.

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

func InitDB(dbInfo *DBInfo, shutdown func()) (*DB, error)

InitDB creates a new DB instance from a DBInfo containing the name of the file used to back the underlying sql database.

func NewDB

func NewDB(db *sql.DB, shutdown func()) (*DB, error)

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) AppendBlockFeeRows

func (db *DB) AppendBlockFeeRows(charts *cache.ChartData, rows *sql.Rows) error

Append the result from RetrieveBlockFeeRows to the provided ChartData. This is the Appender half of a pair that make up a cache.ChartUpdater.

func (*DB) AppendPoolAllValueAndSize

func (db *DB) AppendPoolAllValueAndSize(charts *cache.ChartData, rows *sql.Rows) error

Append the result from RetrievePoolAllValueAndSize to the provided ChartData. This is the Appender half of a pair that make up a cache.ChartUpdater.

func (*DB) DeleteBlock

func (db *DB) DeleteBlock(blockhash string) (NSummaryRows, NStakeInfoRows int64, err error)

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

func (db *DB) DeleteBlocksAboveHeight(height int64) (NSummaryRows, NStakeInfoRows int64, err error)

DeleteBlocksAboveHeight purges the summary data and stake info for the blocks above the given height, including side chain blocks.

func (*DB) GetBestBlockHash

func (db *DB) GetBestBlockHash() string

GetBestBlockHash returns the hash of the best block.

func (*DB) GetBestBlockHeight

func (db *DB) GetBestBlockHeight() int64

GetBestBlockHeight returns the height of the best block

func (*DB) GetBlockSummaryHeight

func (db *DB) GetBlockSummaryHeight() (int64, error)

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

func (db *DB) GetStakeInfoHeight() (int64, error)

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

func (db *DB) JustifyTableStructures(dbInfo *DBInfo) error

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

func (db *DB) RetrieveBestBlockHash() (string, error)

RetrieveBestBlockHash returns the block hash for the best (mainchain) block.

func (*DB) RetrieveBestBlockHeight

func (db *DB) RetrieveBestBlockHeight() (int64, error)

RetrieveBestBlockHeight returns the block height for the best block

func (*DB) RetrieveBestStakeHeight

func (db *DB) RetrieveBestStakeHeight() (int64, error)

RetrieveBestStakeHeight retrieves the height of the best (mainchain) block in the stake table.

func (*DB) RetrieveBlockFeeRows

func (db *DB) RetrieveBlockFeeRows(charts *cache.ChartData) (*sql.Rows, func(), error)

RetrieveBlockFeeRows retrieves any block fee data that is newer than the data in the provided ChartData. This data is used to plot fees on the /charts page. This is the Fetcher half of a pair that make up a cache.ChartUpdater.

func (*DB) RetrieveBlockHash

func (db *DB) RetrieveBlockHash(ind int64) (string, error)

RetrieveBlockHash returns the block hash for block ind

func (*DB) RetrieveBlockHeight

func (db *DB) RetrieveBlockHeight(hash string) (int64, error)

RetrieveBlockHeight returns the block height for blockhash hash

func (*DB) RetrieveBlockSize

func (db *DB) RetrieveBlockSize(ind int64) (int32, error)

RetrieveBlockSize return the size of block at height ind.

func (*DB) RetrieveBlockSizeRange

func (db *DB) RetrieveBlockSizeRange(ind0, ind1 int64) ([]int32, error)

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 *DB) RetrieveBlockSummaryByTimeRange(minTime, maxTime int64, limit int) ([]apitypes.BlockDataBasic, error)

func (*DB) RetrieveDiff

func (db *DB) RetrieveDiff(timestamp int64) (float64, error)

RetrieveDiff returns the difficulty in the last 24hrs or immediately after 24hrs.

func (*DB) RetrieveHighestBlockHash

func (db *DB) RetrieveHighestBlockHash() (string, error)

RetrieveHighestBlockHash returns the block hash for the highest block, regardless of mainchain status.

func (*DB) RetrieveHighestBlockHeight

func (db *DB) RetrieveHighestBlockHeight() (int64, error)

RetrieveHighestBlockHeight returns the block height for the highest block, regardless of mainchain status.

func (*DB) RetrieveHighestStakeHeight

func (db *DB) RetrieveHighestStakeHeight() (int64, error)

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(charts *cache.ChartData) (*sql.Rows, func(), 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 the charts page. This is the Fetcher half of a pair that make up a cache.ChartUpdater.

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

func (db *DB) RetrievePoolInfoRange(ind0, ind1 int64) ([]apitypes.TicketPoolInfo, []string, error)

RetrievePoolInfoRange returns an array of apitypes.TicketPoolInfo for block range ind0 to ind1 and a non-nil error on success

func (*DB) RetrievePoolValAndSizeRange

func (db *DB) RetrievePoolValAndSizeRange(ind0, ind1 int64) ([]float64, []float64, error)

RetrievePoolValAndSizeRange returns an array each of the pool values and sizes for block range ind0 to ind1.

func (*DB) RetrieveSDiff

func (db *DB) RetrieveSDiff(ind int64) (float64, error)

RetrieveSDiff returns the stake difficulty for block at the specified chain height.

func (*DB) RetrieveSDiffRange

func (db *DB) RetrieveSDiffRange(ind0, ind1 int64) ([]float64, error)

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

func (db *DB) RetrieveWinners(ind int64) ([]string, string, error)

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

func (db *DB) RetrieveWinnersByHash(hash string) ([]string, uint32, error)

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

func (db *DB) StoreBlock(bd *apitypes.BlockDataBasic, isMainchain bool, isValid bool) error

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.

func NewDBDataSaver

func NewDBDataSaver(db *DB) *DBDataSaver

func (*DBDataSaver) SignalHeight

func (db *DBDataSaver) SignalHeight(height uint32)

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 (*DBDataSaver) Store

func (db *DBDataSaver) Store(data *blockdata.BlockData, msgBlock *wire.MsgBlock) error

Store satisfies the blockdata.BlockDataSaver interface. This function is only to be used for storing main chain block data. Use StoreSideBlock or StoreBlock directly to store side chain block data.

func (*DBDataSaver) UpdateChan

func (db *DBDataSaver) UpdateChan() chan uint32

UpdateChan creates a channel that will receive height updates. All calls to UpdateChan should be completed before blocks start being connected.

type DBInfo

type DBInfo struct {
	FileName string
}

DBInfo contains db configuration

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, stakeDB *stakedb.StakeDatabase, cl *rpcclient.Client,
	p *chaincfg.Params, shutdown func()) (*WiredDB, 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, stakeDB *stakedb.StakeDatabase, cl *rpcclient.Client,
	p *chaincfg.Params, shutdown func()) (*WiredDB, error)

NewWiredDB creates a new WiredDB from a *sql.DB, a node client, network parameters, and a status update channel. It calls bitumsqlite.NewDB to create a new DB that wrapps the sql.DB.

func (*WiredDB) BlockSubsidy

func (db *WiredDB) BlockSubsidy(height int64, voters uint16) *bitumjson.GetBlockSubsidyResult

func (*WiredDB) BlockchainInfo

func (db *WiredDB) BlockchainInfo() (*bitumjson.GetBlockChainInfoResult, error)

BlockchainInfo retrieves the result of the getblockchaininfo node RPC.

func (*WiredDB) ChargePoolInfoCache

func (db *WiredDB) ChargePoolInfoCache(startHeight int64) error

func (*WiredDB) CheckConnectivity

func (db *WiredDB) CheckConnectivity() error

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 (db *WiredDB) DecodeRawTransaction(txhex string) (*bitumjson.TxRawResult, error)

func (*WiredDB) Difficulty

func (db *WiredDB) Difficulty() (float64, error)

Difficulty returns the difficulty.

func (*WiredDB) DisableCache

func (db *WiredDB) DisableCache()

func (*WiredDB) EnableCache

func (db *WiredDB) EnableCache()

func (*WiredDB) GetAddressTransactions

func (db *WiredDB) GetAddressTransactions(addr string, count int) *apitypes.Address

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

func (db *WiredDB) GetAddressTransactionsWithSkip(addr string, count, skip int) *apitypes.Address

GetAddressTransactionsWithSkip returns an apitypes.Address Object with at most the last count transactions the address was in

func (*WiredDB) GetAllTxIn

func (db *WiredDB) GetAllTxIn(txid *chainhash.Hash) []*apitypes.TxIn

func (*WiredDB) GetAllTxOut

func (db *WiredDB) GetAllTxOut(txid *chainhash.Hash) []*apitypes.TxOut

func (*WiredDB) GetBestBlockHash

func (db *WiredDB) GetBestBlockHash() (string, error)

func (*WiredDB) GetBestBlockHeightHash

func (db *WiredDB) GetBestBlockHeightHash() (chainhash.Hash, int64, error)

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 (db *WiredDB) GetBlockByHash(hash string) (*wire.MsgBlock, error)

func (*WiredDB) GetBlockHash

func (db *WiredDB) GetBlockHash(idx int64) (string, error)

func (*WiredDB) GetBlockHeaderByHash

func (db *WiredDB) GetBlockHeaderByHash(hash string) (*wire.BlockHeader, error)

func (*WiredDB) GetBlockHeight

func (db *WiredDB) GetBlockHeight(hash string) (int64, error)

func (*WiredDB) GetBlockSize

func (db *WiredDB) GetBlockSize(idx int) (int32, error)

func (*WiredDB) GetBlockSizeRange

func (db *WiredDB) GetBlockSizeRange(idx0, idx1 int) ([]int32, error)

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 (db *WiredDB) GetBlockVerbose(idx int, verboseTx bool) *bitumjson.GetBlockVerboseResult

func (*WiredDB) GetBlockVerboseByHash

func (db *WiredDB) GetBlockVerboseByHash(hash string, verboseTx bool) *bitumjson.GetBlockVerboseResult

func (*WiredDB) GetChainParams

func (db *WiredDB) GetChainParams() *chaincfg.Params

func (*WiredDB) GetExplorerAddress

func (db *WiredDB) GetExplorerAddress(address string, count, offset int64) (*dbtypes.AddressInfo, txhelpers.AddressType, txhelpers.AddressError)

func (*WiredDB) GetExplorerBlock

func (db *WiredDB) GetExplorerBlock(hash string) *exptypes.BlockInfo

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 (db *WiredDB) GetExplorerFullBlocks(start int, end int) []*exptypes.BlockInfo

func (*WiredDB) GetExplorerTx

func (db *WiredDB) GetExplorerTx(txid string) *exptypes.TxInfo

func (*WiredDB) GetFeeInfo

func (db *WiredDB) GetFeeInfo(idx int) *bitumjson.FeeInfoBlock

func (*WiredDB) GetHeader

func (db *WiredDB) GetHeader(idx int) *bitumjson.GetBlockHeaderVerboseResult

func (*WiredDB) GetHeight

func (db *WiredDB) GetHeight() (int64, error)

func (*WiredDB) GetMempool

func (db *WiredDB) GetMempool() []exptypes.MempoolTx

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 retrieves 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) GetPool

func (db *WiredDB) GetPool(idx int64) ([]string, error)

func (*WiredDB) GetPoolByHash

func (db *WiredDB) GetPoolByHash(hash string) ([]string, error)

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 (db *WiredDB) GetPoolValAndSizeRange(idx0, idx1 int) ([]float64, []float64)

func (*WiredDB) GetRawTransaction

func (db *WiredDB) GetRawTransaction(txid *chainhash.Hash) *apitypes.Tx

func (*WiredDB) GetRawTransactionWithPrevOutAddresses

func (db *WiredDB) GetRawTransactionWithPrevOutAddresses(txid *chainhash.Hash) (*apitypes.Tx, [][]string, []int64)

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) GetSDiff

func (db *WiredDB) GetSDiff(idx int) float64

func (*WiredDB) GetSDiffRange

func (db *WiredDB) GetSDiffRange(idx0, idx1 int) []float64

func (*WiredDB) GetStakeDiffEstimates

func (db *WiredDB) GetStakeDiffEstimates() *apitypes.StakeDiff

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) (*bitumjson.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

func (db *WiredDB) GetStakeVersionsLatest() (*bitumjson.StakeVersions, error)

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 (db *WiredDB) GetTransactionHex(txid *chainhash.Hash) string

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 (db *WiredDB) GetTrimmedTransaction(txid *chainhash.Hash) *apitypes.TrimmedTx

func (*WiredDB) GetVoteInfo

func (db *WiredDB) GetVoteInfo(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 bitumdata 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

func (db *WiredDB) GetVoteVersionInfo(ver uint32) (*bitumjson.GetVoteInfoResult, error)

GetVoteVersionInfo requests stake version info from the bitumd RPC server

func (*WiredDB) ImportSideChains

func (db *WiredDB) ImportSideChains(collector *blockdata.Collector) error

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) *ChainMonitor

NewChainMonitor creates a new ChainMonitor

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

func (db *WiredDB) PurgeBlock(hash string) (NSummaryRows, NStakeInfoRows int64, err error)

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) RegisterCharts

func (db *WiredDB) RegisterCharts(charts *cache.ChartData)

RegisterCharts registers chart data fetchers and appenders with the provided ChartData.

func (*WiredDB) ReportHeights

func (db *WiredDB) ReportHeights() error

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

func (db *WiredDB) RetreiveDifficulty(timestamp int64) float64

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 (db *WiredDB) SendRawTransaction(txhex string) (string, error)

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)

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.

func (*WiredDB) TxHeight

func (db *WiredDB) TxHeight(txid *chainhash.Hash) (height int64)

TxHeight gives the block height of the transaction id specified

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL