aboutsummaryrefslogtreecommitdiff
path: root/src/miner.cpp
diff options
context:
space:
mode:
authorGavin Andresen <gavinandresen@gmail.com>2013-10-19 23:05:04 -0700
committerGavin Andresen <gavinandresen@gmail.com>2013-10-19 23:05:04 -0700
commitbd48a4fe492b46708a0397c6330f06fcc80aee0b (patch)
tree1bac0297ba887a4b65499ca1d92f388687de2e4c /src/miner.cpp
parentf90b690a0d5fb147080da4ecdab1a99ce0b72042 (diff)
parentd6eb259953699f5bea208ff41a0967d8ea513a70 (diff)
Merge pull request #2945 from gmaxwell/fee-logic_encourage_sweeping
[Fee logic] Don't count txins for priority to encourage sweeping.
Diffstat (limited to 'src/miner.cpp')
-rw-r--r--src/miner.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/miner.cpp b/src/miner.cpp
index e9c1d9aff9..83684fa349 100644
--- a/src/miner.cpp
+++ b/src/miner.cpp
@@ -238,9 +238,21 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
}
if (fMissingInputs) continue;
- // Priority is sum(valuein * age) / txsize
+ // Priority is sum(valuein * age) / modified_txsize
unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION);
- dPriority /= nTxSize;
+ unsigned int nTxSizeMod = nTxSize;
+ // In order to avoid disincentivizing cleaning up the UTXO set we don't count
+ // the constant overhead for each txin and up to 110 bytes of scriptSig (which
+ // is enough to cover a compressed pubkey p2sh redemption) for priority.
+ // Providing any more cleanup incentive than making additional inputs free would
+ // risk encouraging people to create junk outputs to redeem later.
+ BOOST_FOREACH(const CTxIn& txin, tx.vin)
+ {
+ unsigned int offset = 41U + min(110U, (unsigned int)txin.scriptSig.size());
+ if (nTxSizeMod > offset)
+ nTxSizeMod -= offset;
+ }
+ dPriority /= nTxSizeMod;
// This is a more accurate fee-per-kilobyte than is used by the client code, because the
// client code rounds up the size to the nearest 1K. That's good, because it gives an