diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2014-09-15 07:24:05 +0200 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2014-09-15 07:29:04 +0200 |
commit | 2ec82e94e6b49a0e74243559b96ee736c0c54de7 (patch) | |
tree | de499243eaa1d1563ba9c342299f5018cc5fa43d /src/core.cpp | |
parent | a0a8700bc84cf10d99d9d3699e7b0fdfc323cf1c (diff) | |
parent | c26649f9ed03fa9505e44aaf7f8cfdaa81f734cc (diff) |
Merge pull request #4817
c26649f Track modified size in TxMemPoolEntry so that we can correctly compute priority. (Alex Morcos)
Diffstat (limited to 'src/core.cpp')
-rw-r--r-- | src/core.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/core.cpp b/src/core.cpp index 8dcda0126a..491e4fa68b 100644 --- a/src/core.cpp +++ b/src/core.cpp @@ -124,6 +124,14 @@ int64_t CTransaction::GetValueOut() const double CTransaction::ComputePriority(double dPriorityInputs, unsigned int nTxSize) const { + nTxSize = CalculateModifiedSize(nTxSize); + if (nTxSize == 0) return 0.0; + + return dPriorityInputs / nTxSize; +} + +unsigned int CTransaction::CalculateModifiedSize(unsigned int nTxSize) const +{ // 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. @@ -131,14 +139,14 @@ double CTransaction::ComputePriority(double dPriorityInputs, unsigned int nTxSiz // risk encouraging people to create junk outputs to redeem later. if (nTxSize == 0) nTxSize = ::GetSerializeSize(*this, SER_NETWORK, PROTOCOL_VERSION); + BOOST_FOREACH(const CTxIn& txin, vin) { unsigned int offset = 41U + std::min(110U, (unsigned int)txin.scriptSig.size()); if (nTxSize > offset) nTxSize -= offset; } - if (nTxSize == 0) return 0.0; - return dPriorityInputs / nTxSize; + return nTxSize; } std::string CTransaction::ToString() const |