mining/mempool: Export MinHighPriority from mining.

This move the export for MinHighPriority from the mempool package to the
mining package.  This should have been done when the priority
calculation code was moved to the mining package.
This commit is contained in:
Dave Collins 2016-10-27 11:18:39 -05:00
parent 660467259e
commit a18f883c1f
No known key found for this signature in database
GPG key ID: B8904D9D9C93D1F2
3 changed files with 11 additions and 10 deletions

View file

@ -30,10 +30,6 @@ const (
// inclusion when generating block templates. // inclusion when generating block templates.
DefaultBlockPrioritySize = 50000 DefaultBlockPrioritySize = 50000
// MinHighPriority is the minimum priority value that allows a
// transaction to be considered high priority.
MinHighPriority = btcutil.SatoshiPerBitcoin * 144.0 / 250
// orphanTTL is the maximum amount of time an orphan is allowed to // orphanTTL is the maximum amount of time an orphan is allowed to
// stay in the orphan pool before it expires and is evicted during the // stay in the orphan pool before it expires and is evicted during the
// next scan. // next scan.
@ -797,10 +793,10 @@ func (mp *TxPool) maybeAcceptTransaction(tx *btcutil.Tx, isNew, rateLimit, rejec
if isNew && !mp.cfg.Policy.DisableRelayPriority && txFee < minFee { if isNew && !mp.cfg.Policy.DisableRelayPriority && txFee < minFee {
currentPriority := mining.CalcPriority(tx.MsgTx(), utxoView, currentPriority := mining.CalcPriority(tx.MsgTx(), utxoView,
nextBlockHeight) nextBlockHeight)
if currentPriority <= MinHighPriority { if currentPriority <= mining.MinHighPriority {
str := fmt.Sprintf("transaction %v has insufficient "+ str := fmt.Sprintf("transaction %v has insufficient "+
"priority (%g <= %g)", txHash, "priority (%g <= %g)", txHash,
currentPriority, MinHighPriority) currentPriority, mining.MinHighPriority)
return nil, txRuleError(wire.RejectInsufficientFee, str) return nil, txRuleError(wire.RejectInsufficientFee, str)
} }
} }

View file

@ -12,7 +12,6 @@ import (
"github.com/btcsuite/btcd/blockchain" "github.com/btcsuite/btcd/blockchain"
"github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/mempool"
"github.com/btcsuite/btcd/mining" "github.com/btcsuite/btcd/mining"
"github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
@ -638,13 +637,13 @@ mempoolLoop:
// the priority size or there are no more high-priority // the priority size or there are no more high-priority
// transactions. // transactions.
if !sortedByFee && (blockPlusTxSize >= policy.BlockPrioritySize || if !sortedByFee && (blockPlusTxSize >= policy.BlockPrioritySize ||
prioItem.priority <= mempool.MinHighPriority) { prioItem.priority <= mining.MinHighPriority) {
minrLog.Tracef("Switching to sort by fees per "+ minrLog.Tracef("Switching to sort by fees per "+
"kilobyte blockSize %d >= BlockPrioritySize "+ "kilobyte blockSize %d >= BlockPrioritySize "+
"%d || priority %.2f <= minHighPriority %.2f", "%d || priority %.2f <= minHighPriority %.2f",
blockPlusTxSize, policy.BlockPrioritySize, blockPlusTxSize, policy.BlockPrioritySize,
prioItem.priority, mempool.MinHighPriority) prioItem.priority, mining.MinHighPriority)
sortedByFee = true sortedByFee = true
priorityQueue.SetLessFunc(txPQByFee) priorityQueue.SetLessFunc(txPQByFee)
@ -656,7 +655,7 @@ mempoolLoop:
// final one in the high-priority section, so just fall // final one in the high-priority section, so just fall
// though to the code below so it is added now. // though to the code below so it is added now.
if blockPlusTxSize > policy.BlockPrioritySize || if blockPlusTxSize > policy.BlockPrioritySize ||
prioItem.priority < mempool.MinHighPriority { prioItem.priority < mining.MinHighPriority {
heap.Push(priorityQueue, prioItem) heap.Push(priorityQueue, prioItem)
continue continue

View file

@ -11,6 +11,12 @@ import (
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcutil"
) )
const (
// MinHighPriority is the minimum priority value that allows a
// transaction to be considered high priority.
MinHighPriority = btcutil.SatoshiPerBitcoin * 144.0 / 250
)
// TxDesc is a descriptor about a transaction in a transaction source along with // TxDesc is a descriptor about a transaction in a transaction source along with
// additional metadata. // additional metadata.
type TxDesc struct { type TxDesc struct {