aboutsummaryrefslogtreecommitdiff
path: root/src/coins.cpp
diff options
context:
space:
mode:
authorAlex Morcos <morcos@chaincode.com>2015-11-13 10:05:21 -0500
committerAlex Morcos <morcos@chaincode.com>2015-11-19 21:44:35 -0500
commitc0353064ddf71ad103bd19f6e7c10ff8e240ac46 (patch)
tree9fec6d8c6ddb79925d90b2d12582e2dee3380de6 /src/coins.cpp
parent71f1d9fd4ae2c2fc90d5487bdf2096f9eb5898d9 (diff)
Change GetPriority calculation.
Compute the value of inputs that already are in the chain at time of mempool entry and only increase priority due to aging for those inputs. This effectively changes the CTxMemPoolEntry's GetPriority calculation from an upper bound to a lower bound.
Diffstat (limited to 'src/coins.cpp')
-rw-r--r--src/coins.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/coins.cpp b/src/coins.cpp
index f0ea5c0459..723e114708 100644
--- a/src/coins.cpp
+++ b/src/coins.cpp
@@ -243,8 +243,9 @@ bool CCoinsViewCache::HaveInputs(const CTransaction& tx) const
return true;
}
-double CCoinsViewCache::GetPriority(const CTransaction &tx, int nHeight) const
+double CCoinsViewCache::GetPriority(const CTransaction &tx, int nHeight, CAmount &inChainInputValue) const
{
+ inChainInputValue = 0;
if (tx.IsCoinBase())
return 0.0;
double dResult = 0.0;
@@ -253,8 +254,9 @@ double CCoinsViewCache::GetPriority(const CTransaction &tx, int nHeight) const
const CCoins* coins = AccessCoins(txin.prevout.hash);
assert(coins);
if (!coins->IsAvailable(txin.prevout.n)) continue;
- if (coins->nHeight < nHeight) {
+ if (coins->nHeight <= nHeight) {
dResult += coins->vout[txin.prevout.n].nValue * (nHeight-coins->nHeight);
+ inChainInputValue += coins->vout[txin.prevout.n].nValue;
}
}
return tx.ComputePriority(dResult);