Documentation ¶
Overview ¶
Package mining includes all mining and policy types, and will house all mining code in the future.
Overview ¶
This package currently contains the 3 struct types for mining and policy. In the future it will contain all of the pieces of code pertaining to block template creation, CPU mining and other various mining code.
Index ¶
Constants ¶
const ( // MinHighPriority is the minimum priority value that allows a // transaction to be considered high priority. MinHighPriority = dcrutil.AtomsPerCoin * 144.0 / 250 )
const ( // UnminedHeight is the height used for the "block" height field of the // contextual transaction information provided in a transaction store // when it has not yet been mined into a block. UnminedHeight = 0x7fffffff )
Variables ¶
This section is empty.
Functions ¶
func CalcPriority ¶
func CalcPriority(tx *wire.MsgTx, utxoView *blockchain.UtxoViewpoint, nextBlockHeight int64) float64
CalcPriority returns a transaction priority given a transaction and the sum of each of its input values multiplied by their age (# of confirmations). Thus, the final formula for the priority is: sum(inputValue * inputAge) / adjustedTxSize
Types ¶
type Policy ¶
type Policy struct { // BlockMinSize is the minimum block size in bytes to be used when // generating a block template. BlockMinSize uint32 // BlockMaxSize is the maximum block size in bytes to be used when // generating a block template. BlockMaxSize uint32 // BlockPrioritySize is the size in bytes for high-priority / low-fee // transactions to be used when generating a block template. BlockPrioritySize uint32 // TxMinFreeFee is the minimum fee in Atoms/1000 bytes that is // required for a transaction to be treated as free for mining purposes // (block template generation). TxMinFreeFee dcrutil.Amount }
Policy houses the policy (configuration parameters) which is used to control the generation of block templates. See the documentation for NewBlockTemplate for more details on each of these parameters are used.
type TxDesc ¶
type TxDesc struct { // Tx is the transaction associated with the entry. Tx *dcrutil.Tx // Type is the type of the transaction associated with the entry. Type stake.TxType // Added is the time when the entry was added to the source pool. Added time.Time // Height is the block height when the entry was added to the source // pool. Height int64 // Fee is the total fee the transaction associated with the entry pays. Fee int64 }
TxDesc is a descriptor about a transaction in a transaction source along with additional metadata.
type TxSource ¶
type TxSource interface { // LastUpdated returns the last time a transaction was added to or // removed from the source pool. LastUpdated() time.Time // MiningDescs returns a slice of mining descriptors for all the // transactions in the source pool. MiningDescs() []*TxDesc // HaveTransaction returns whether or not the passed transaction hash // exists in the source pool. HaveTransaction(hash *chainhash.Hash) bool // HaveAllTransactions returns whether or not all of the passed // transaction hashes exist in the source pool. HaveAllTransactions(hashes []chainhash.Hash) bool // VoteHashesForBlock returns the hashes for all votes on the provided // block hash that are currently available in the source pool. VoteHashesForBlock(hash *chainhash.Hash) []chainhash.Hash // VotesForBlocks returns a slice of vote descriptors for all votes on // the provided block hashes that are currently available in the source // pool. VotesForBlocks(hashes []chainhash.Hash) [][]VoteDesc // IsRegTxTreeKnownDisapproved returns whether or not the regular // transaction tree of the block represented by the provided hash is // known to be disapproved according to the votes currently in the // source pool. IsRegTxTreeKnownDisapproved(hash *chainhash.Hash) bool }
TxSource represents a source of transactions to consider for inclusion in new blocks.
The interface contract requires that all of these methods are safe for concurrent access with respect to the source.