From a18f883c1fdff7ecedd571ec54ff9d0ae1007631 Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Thu, 27 Oct 2016 11:18:39 -0500 Subject: [PATCH] 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. --- mempool/mempool.go | 8 ++------ mining.go | 7 +++---- mining/mining.go | 6 ++++++ 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/mempool/mempool.go b/mempool/mempool.go index d3f8b75b1..f70d6447b 100644 --- a/mempool/mempool.go +++ b/mempool/mempool.go @@ -30,10 +30,6 @@ const ( // inclusion when generating block templates. 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 // stay in the orphan pool before it expires and is evicted during the // next scan. @@ -797,10 +793,10 @@ func (mp *TxPool) maybeAcceptTransaction(tx *btcutil.Tx, isNew, rateLimit, rejec if isNew && !mp.cfg.Policy.DisableRelayPriority && txFee < minFee { currentPriority := mining.CalcPriority(tx.MsgTx(), utxoView, nextBlockHeight) - if currentPriority <= MinHighPriority { + if currentPriority <= mining.MinHighPriority { str := fmt.Sprintf("transaction %v has insufficient "+ "priority (%g <= %g)", txHash, - currentPriority, MinHighPriority) + currentPriority, mining.MinHighPriority) return nil, txRuleError(wire.RejectInsufficientFee, str) } } diff --git a/mining.go b/mining.go index b11fa2a1e..f253610d4 100644 --- a/mining.go +++ b/mining.go @@ -12,7 +12,6 @@ import ( "github.com/btcsuite/btcd/blockchain" "github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/mempool" "github.com/btcsuite/btcd/mining" "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/wire" @@ -638,13 +637,13 @@ mempoolLoop: // the priority size or there are no more high-priority // transactions. if !sortedByFee && (blockPlusTxSize >= policy.BlockPrioritySize || - prioItem.priority <= mempool.MinHighPriority) { + prioItem.priority <= mining.MinHighPriority) { minrLog.Tracef("Switching to sort by fees per "+ "kilobyte blockSize %d >= BlockPrioritySize "+ "%d || priority %.2f <= minHighPriority %.2f", blockPlusTxSize, policy.BlockPrioritySize, - prioItem.priority, mempool.MinHighPriority) + prioItem.priority, mining.MinHighPriority) sortedByFee = true priorityQueue.SetLessFunc(txPQByFee) @@ -656,7 +655,7 @@ mempoolLoop: // final one in the high-priority section, so just fall // though to the code below so it is added now. if blockPlusTxSize > policy.BlockPrioritySize || - prioItem.priority < mempool.MinHighPriority { + prioItem.priority < mining.MinHighPriority { heap.Push(priorityQueue, prioItem) continue diff --git a/mining/mining.go b/mining/mining.go index cf6f14ba7..87c50598c 100644 --- a/mining/mining.go +++ b/mining/mining.go @@ -11,6 +11,12 @@ import ( "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 // additional metadata. type TxDesc struct {