From 2799ddf538cddc5721f58761d7f60ddb7e766a6b Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Sun, 22 Nov 2015 00:45:42 -0600 Subject: [PATCH] mining: Remove comment and change fee calc to int. Now that the memory pool minimum fee calculation code is also calculating a more precise value instead of rounding up to the nearest kilobyte boundary, the comment in NewBlockTemplate regarding this behavior is no longer accurate. Thus, this removes the comment. Also, while here, change the calculation to use an int64 instead of float since it matches the precision of the new calculation code used by the memory pool and can also avoid the need for the slower floating point math. --- mining.go | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/mining.go b/mining.go index 76dcaa80..c06b8772 100644 --- a/mining.go +++ b/mining.go @@ -47,7 +47,7 @@ type txPrioItem struct { tx *btcutil.Tx fee int64 priority float64 - feePerKB float64 + feePerKB int64 // dependsOn holds a map of transaction hashes which this one depends // on. It will only be set when the transaction references other @@ -519,13 +519,9 @@ mempoolLoop: // formula is: sum(inputValue * inputAge) / adjustedTxSize prioItem.priority = txDesc.CurrentPriority(txStore, nextBlockHeight) - // Calculate the fee in Satoshi/KB. - // NOTE: This is a more precise value than the one calculated - // during calcMinRelayFee which rounds up to the nearest full - // kilobyte boundary. This is beneficial since it provides an - // incentive to create smaller transactions. + // Calculate the fee in Satoshi/kB. txSize := tx.MsgTx().SerializeSize() - prioItem.feePerKB = float64(txDesc.Fee) / (float64(txSize) / 1000) + prioItem.feePerKB = (txDesc.Fee * 1000) / int64(txSize) prioItem.fee = txDesc.Fee // Add the transaction to the priority queue to mark it ready @@ -605,7 +601,7 @@ mempoolLoop: // Skip free transactions once the block is larger than the // minimum block size. if sortedByFee && - prioItem.feePerKB < float64(cfg.minRelayTxFee) && + prioItem.feePerKB < int64(cfg.minRelayTxFee) && blockPlusTxSize >= cfg.BlockMinSize { minrLog.Tracef("Skipping tx %s with feePerKB %.2f "+