1919using namespace std ;
2020
2121CTxMemPoolEntry::CTxMemPoolEntry (const CTransaction& _tx, const CAmount& _nFee,
22- int64_t _nTime, double _dPriority ,
23- unsigned int _nHeight, bool poolHasNoInputsOf ):
24- tx(_tx), nFee(_nFee), nTime(_nTime), dPriority(_dPriority ), nHeight(_nHeight ),
25- hadNoDependencies(poolHasNoInputsOf)
22+ int64_t _nTime, double _entryPriority, unsigned int _entryHeight ,
23+ bool poolHasNoInputsOf, CAmount _inChainInputValue ):
24+ tx(_tx), nFee(_nFee), nTime(_nTime), entryPriority(_entryPriority ), entryHeight(_entryHeight ),
25+ hadNoDependencies(poolHasNoInputsOf), inChainInputValue(_inChainInputValue)
2626{
2727 nTxSize = ::GetSerializeSize (tx, SER_NETWORK, PROTOCOL_VERSION);
2828 nModSize = tx.CalculateModifiedSize (nTxSize);
@@ -31,6 +31,8 @@ CTxMemPoolEntry::CTxMemPoolEntry(const CTransaction& _tx, const CAmount& _nFee,
3131 nCountWithDescendants = 1 ;
3232 nSizeWithDescendants = nTxSize;
3333 nFeesWithDescendants = nFee;
34+ CAmount nValueIn = tx.GetValueOut ()+nFee;
35+ assert (inChainInputValue <= nValueIn);
3436}
3537
3638CTxMemPoolEntry::CTxMemPoolEntry (const CTxMemPoolEntry& other)
@@ -41,9 +43,10 @@ CTxMemPoolEntry::CTxMemPoolEntry(const CTxMemPoolEntry& other)
4143double
4244CTxMemPoolEntry::GetPriority (unsigned int currentHeight) const
4345{
44- CAmount nValueIn = tx.GetValueOut ()+nFee;
45- double deltaPriority = ((double )(currentHeight-nHeight)*nValueIn)/nModSize;
46- double dResult = dPriority + deltaPriority;
46+ double deltaPriority = ((double )(currentHeight-entryHeight)*inChainInputValue)/nModSize;
47+ double dResult = entryPriority + deltaPriority;
48+ if (dResult < 0 ) // This should only happen if it was called with a height below entry height
49+ dResult = 0 ;
4750 return dResult;
4851}
4952
0 commit comments