Documentation ¶
Index ¶
- Constants
- func DisableLog()
- func ParseTxns(txs []exptypes.MempoolTx, params *chaincfg.Params, lastBlock *BlockID) *exptypes.MempoolInfo
- func UseLogger(logger slog.Logger)
- type BlockID
- type ByAbsoluteFee
- type ByFeeRate
- type MempoolDataCache
- func (c *MempoolDataCache) GetFeeInfo() (uint32, dcrjson.FeeInfoMempool)
- func (c *MempoolDataCache) GetFeeInfoExtra() (uint32, *apitypes.MempoolTicketFeeInfo)
- func (c *MempoolDataCache) GetFeeRates(N int) (uint32, int64, int, []float64)
- func (c *MempoolDataCache) GetFees(N int) (uint32, int, []float64)
- func (c *MempoolDataCache) GetHeight() uint32
- func (c *MempoolDataCache) GetNumTickets() (uint32, uint32)
- func (c *MempoolDataCache) GetTicketPriceCountTime(feeAvgLength int) *apitypes.PriceCountTime
- func (c *MempoolDataCache) GetTicketsDetails(N int) (uint32, int64, int, TicketsDetails)
- func (c *MempoolDataCache) StoreMPData(stakeData *StakeData, txsCopy []exptypes.MempoolTx, _ *exptypes.MempoolInfo)
- type MempoolDataCollector
- type MempoolDataSaver
- type MempoolInfo
- type MempoolMonitor
- func (p *MempoolMonitor) CollectAndStore() error
- func (p *MempoolMonitor) LastBlockHash() chainhash.Hash
- func (p *MempoolMonitor) LastBlockHeight() int64
- func (p *MempoolMonitor) LastBlockTime() int64
- func (p *MempoolMonitor) Refresh() (*StakeData, []exptypes.MempoolTx, *exptypes.MempoolInfo, error)
- func (p *MempoolMonitor) TxHandler(client *rpcclient.Client)
- type MinableFeeInfo
- type NewTx
- type ScriptPubKeyResult
- type ScriptSig
- type StakeData
- type TicketsDetails
- type Tx
- type Vin
- type Vout
Constants ¶
const NumLatestMempoolTxns = 5
NumLatestMempoolTxns is the maximum number of mempool transactions that will be stored in the LatestTransactions field of the MempoolInfo generated by ParseTxns.
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 ByAbsoluteFee ¶
type ByAbsoluteFee struct {
TicketsDetails
}
ByAbsoluteFee models TicketDetails sorted by fee
func (ByAbsoluteFee) Less ¶
func (tix ByAbsoluteFee) Less(i, j int) bool
Less compares fee rates by fee_i < fee_j
type ByFeeRate ¶
type ByFeeRate struct {
TicketsDetails
}
ByFeeRate models TicketsDetails sorted by fee rates
type MempoolDataCache ¶
type MempoolDataCache struct {
// contains filtered or unexported fields
}
MempoolDataCache models the basic data for the mempool cache.
func (*MempoolDataCache) GetFeeInfo ¶
func (c *MempoolDataCache) GetFeeInfo() (uint32, dcrjson.FeeInfoMempool)
GetFeeInfo returns the mempool height and basic fee info
func (*MempoolDataCache) GetFeeInfoExtra ¶
func (c *MempoolDataCache) GetFeeInfoExtra() (uint32, *apitypes.MempoolTicketFeeInfo)
GetFeeInfoExtra returns the mempool height and detailed fee info
func (*MempoolDataCache) GetFeeRates ¶
GetFeeRates returns the mempool height, time, number of fees and an array of fee rates
func (*MempoolDataCache) GetFees ¶
func (c *MempoolDataCache) GetFees(N int) (uint32, int, []float64)
GetFees returns the mempool height number of fees and an array of the fields
func (*MempoolDataCache) GetHeight ¶
func (c *MempoolDataCache) GetHeight() uint32
GetHeight returns the mempool height
func (*MempoolDataCache) GetNumTickets ¶
func (c *MempoolDataCache) GetNumTickets() (uint32, uint32)
GetNumTickets returns the mempool height and number of tickets
func (*MempoolDataCache) GetTicketPriceCountTime ¶
func (c *MempoolDataCache) GetTicketPriceCountTime(feeAvgLength int) *apitypes.PriceCountTime
GetTicketPriceCountTime gathers the nominal info for mempool tickets.
func (*MempoolDataCache) GetTicketsDetails ¶
func (c *MempoolDataCache) GetTicketsDetails(N int) (uint32, int64, int, TicketsDetails)
GetTicketsDetails returns the mempool height, time, number of tickets and the ticket details
func (*MempoolDataCache) StoreMPData ¶
func (c *MempoolDataCache) StoreMPData(stakeData *StakeData, txsCopy []exptypes.MempoolTx, _ *exptypes.MempoolInfo)
StoreMPData stores info from data in the mempool cache. It is advisable to pass a copy of the []types.MempoolTx so that it may be modified (e.g. sorted) without affecting other MempoolDataSavers.
type MempoolDataCollector ¶
type MempoolDataCollector struct {
// contains filtered or unexported fields
}
MempoolDataCollector is used for retrieving and processing data from a chain server's mempool.
func NewMempoolDataCollector ¶
func NewMempoolDataCollector(dcrdChainSvr *rpcclient.Client, params *chaincfg.Params) *MempoolDataCollector
NewMempoolDataCollector creates a new MempoolDataCollector.
func (*MempoolDataCollector) Collect ¶
func (t *MempoolDataCollector) Collect() (*StakeData, []exptypes.MempoolTx, error)
Collect is the main handler for collecting mempool data. Data collection is focused on stake-related information, including vote and ticket transactions, and fee info. Transactions of all types in mempool are returned as a []exptypes.MempoolTx, corresponding to the same data provided by the unexported mempoolTxns method.
type MempoolDataSaver ¶
type MempoolDataSaver interface {
StoreMPData(*StakeData, []exptypes.MempoolTx, *exptypes.MempoolInfo)
}
MempoolDataSaver is an interface for storing mempool data.
type MempoolInfo ¶
type MempoolInfo struct { CurrentHeight uint32 NumTicketPurchasesInMempool uint32 NumTicketsSinceStatsReport int32 LastCollectTime time.Time }
MempoolInfo models basic data about the node's mempool
type MempoolMonitor ¶
type MempoolMonitor struct {
// contains filtered or unexported fields
}
MempoolMonitor processes new transactions as they are added to mempool, and forwards the processed data on channels assigned during construction. An inventory of transactions in the current mempool is maintained to prevent repetative data processing and signaling. Periodically, such as after a new block is mined, the mempool info and the transaction inventory are rebuilt fresh via the CollectAndStore method. A MempoolDataCollector is required to perform the collection and parsing, and an optional []MempoolDataSaver is used to to forward the data to arbitrary destinations. The last block's height, hash, and time are kept in memory in order to properly process votes in mempool.
func NewMempoolMonitor ¶
func NewMempoolMonitor(ctx context.Context, collector *MempoolDataCollector, savers []MempoolDataSaver, params *chaincfg.Params, wg *sync.WaitGroup, newTxInChan <-chan *dcrjson.TxRawResult, signalOuts []chan<- pstypes.HubSignal, newTxOutChans []chan<- *exptypes.MempoolTx) *MempoolMonitor
NewMempoolMonitor creates a new MempoolMonitor. The MempoolMonitor receives notifications of new transactions on newTxInChan, and of new blocks on the same channel using a nil transaction message. Once TxHandler is started, the MempoolMonitor will process incoming transactions, and forward new ones on via the newTxOutChan following an appropriate signal on hubRelay.
func (*MempoolMonitor) CollectAndStore ¶
func (p *MempoolMonitor) CollectAndStore() error
CollectAndStore collects mempool data, resets counters ticket counters and the timer, and dispatches the storers.
func (*MempoolMonitor) LastBlockHash ¶
func (p *MempoolMonitor) LastBlockHash() chainhash.Hash
LastBlockHash returns the hash of the most recently stored block.
func (*MempoolMonitor) LastBlockHeight ¶
func (p *MempoolMonitor) LastBlockHeight() int64
LastBlockHeight returns the height of the most recently stored block.
func (*MempoolMonitor) LastBlockTime ¶
func (p *MempoolMonitor) LastBlockTime() int64
LastBlockTime returns the time of the most recently stored block.
func (*MempoolMonitor) Refresh ¶
func (p *MempoolMonitor) Refresh() (*StakeData, []exptypes.MempoolTx, *exptypes.MempoolInfo, error)
Refresh collects mempool data, resets counters ticket counters and the timer, but does not dispatch the MempoolDataSavers.
func (*MempoolMonitor) TxHandler ¶
func (p *MempoolMonitor) TxHandler(client *rpcclient.Client)
TxHandler receives signals from OnTxAccepted via the newTxIn, indicating that a new transaction has entered mempool. This function should be launched as a goroutine, and stopped by closing the quit channel, the broadcasting mechanism used by main. The newTxIn contains a chain hash for the transaction from the notificiation, or a zero value hash indicating it was from a Ticker or manually triggered.
type MinableFeeInfo ¶
type MinableFeeInfo struct {
// contains filtered or unexported fields
}
MinableFeeInfo describes the ticket fees
type ScriptPubKeyResult ¶
type StakeData ¶
type StakeData struct { LatestBlock BlockID Time time.Time NumTickets uint32 NumVotes uint32 NewTickets uint32 Ticketfees *dcrjson.TicketFeeInfoResult MinableFees *MinableFeeInfo AllTicketsDetails TicketsDetails StakeDiff float64 }
StakeData models info about ticket purchases in mempool
type TicketsDetails ¶
type TicketsDetails apitypes.TicketsDetails
TicketsDetails localizes apitypes.TicketsDetails
func (TicketsDetails) Len ¶
func (tix TicketsDetails) Len() int
Len returns the length of TicketsDetails
func (TicketsDetails) Swap ¶
func (tix TicketsDetails) Swap(i, j int)
Swap swaps TicketsDetails elements at i and j
type Vin ¶
type Vin struct { Coinbase string `json:"coinbase"` Stakebase string `json:"stakebase"` Txid string `json:"txid"` Vout uint32 `json:"vout"` Tree int8 `json:"tree"` Sequence uint32 `json:"sequence"` AmountIn float64 `json:"amountin"` BlockHeight uint32 `json:"blockheight"` BlockIndex uint32 `json:"blockindex"` ScriptSig *ScriptSig `json:"scriptSig"` }
type Vout ¶
type Vout struct { Value float64 `json:"value"` N uint32 `json:"n"` Version uint16 `json:"version"` ScriptPubKey ScriptPubKeyResult `json:"scriptPubKey"` }
Vout models parts of the tx data. It is defined separately since both getrawtransaction and decoderawtransaction use the same structure.