diff options
author | Alex Morcos <morcos@chaincode.com> | 2015-11-13 10:05:21 -0500 |
---|---|---|
committer | Alex Morcos <morcos@chaincode.com> | 2015-11-19 21:44:35 -0500 |
commit | c0353064ddf71ad103bd19f6e7c10ff8e240ac46 (patch) | |
tree | 9fec6d8c6ddb79925d90b2d12582e2dee3380de6 /src/txmempool.cpp | |
parent | 71f1d9fd4ae2c2fc90d5487bdf2096f9eb5898d9 (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/txmempool.cpp')
-rw-r--r-- | src/txmempool.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/txmempool.cpp b/src/txmempool.cpp index ea3aad34a3..6d1df0b3d1 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -19,10 +19,10 @@ using namespace std; CTxMemPoolEntry::CTxMemPoolEntry(const CTransaction& _tx, const CAmount& _nFee, - int64_t _nTime, double _entryPriority, - unsigned int _entryHeight, bool poolHasNoInputsOf): + int64_t _nTime, double _entryPriority, unsigned int _entryHeight, + bool poolHasNoInputsOf, CAmount _inChainInputValue): tx(_tx), nFee(_nFee), nTime(_nTime), entryPriority(_entryPriority), entryHeight(_entryHeight), - hadNoDependencies(poolHasNoInputsOf) + hadNoDependencies(poolHasNoInputsOf), inChainInputValue(_inChainInputValue) { nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); nModSize = tx.CalculateModifiedSize(nTxSize); @@ -31,6 +31,8 @@ CTxMemPoolEntry::CTxMemPoolEntry(const CTransaction& _tx, const CAmount& _nFee, nCountWithDescendants = 1; nSizeWithDescendants = nTxSize; nFeesWithDescendants = nFee; + CAmount nValueIn = tx.GetValueOut()+nFee; + assert(inChainInputValue <= nValueIn); } CTxMemPoolEntry::CTxMemPoolEntry(const CTxMemPoolEntry& other) @@ -41,9 +43,10 @@ CTxMemPoolEntry::CTxMemPoolEntry(const CTxMemPoolEntry& other) double CTxMemPoolEntry::GetPriority(unsigned int currentHeight) const { - CAmount nValueIn = tx.GetValueOut()+nFee; - double deltaPriority = ((double)(currentHeight-entryHeight)*nValueIn)/nModSize; + double deltaPriority = ((double)(currentHeight-entryHeight)*inChainInputValue)/nModSize; double dResult = entryPriority + deltaPriority; + if (dResult < 0) // This should only happen if it was called with a height below entry height + dResult = 0; return dResult; } |