From 0733c1bde69c6ccfe593d2eec775d0ae32fe7140 Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Mon, 11 Nov 2013 16:03:51 +1000 Subject: Refactor: move GetValueIn(tx) to tx.GetValueIn() GetValueIn makes more sense as a CTransaction member. --- src/core.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/core.cpp') diff --git a/src/core.cpp b/src/core.cpp index 7a1c90e58..5da6f11b5 100644 --- a/src/core.cpp +++ b/src/core.cpp @@ -106,6 +106,18 @@ bool CTransaction::IsNewerThan(const CTransaction& old) const return fNewer; } +int64_t CTransaction::GetValueOut() const +{ + int64_t nValueOut = 0; + BOOST_FOREACH(const CTxOut& txout, vout) + { + nValueOut += txout.nValue; + if (!MoneyRange(txout.nValue) || !MoneyRange(nValueOut)) + throw std::runtime_error("CTransaction::GetValueOut() : value out of range"); + } + return nValueOut; +} + std::string CTransaction::ToString() const { std::string str; -- cgit v1.2.3 From 4d707d512070ed88c888fdf625c0ae0f85f68d9b Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Mon, 11 Nov 2013 17:35:14 +1000 Subject: Add verbose boolean to getrawmempool Also changes mempool to store CTxMemPoolEntries to keep track of when they enter/exit the pool. --- src/core.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/core.cpp') diff --git a/src/core.cpp b/src/core.cpp index 5da6f11b5..f41ea87fe 100644 --- a/src/core.cpp +++ b/src/core.cpp @@ -118,6 +118,25 @@ int64_t CTransaction::GetValueOut() const return nValueOut; } +double CTransaction::ComputePriority(double dPriorityInputs, 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. + // Providing any more cleanup incentive than making additional inputs free would + // 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; +} + std::string CTransaction::ToString() const { std::string str; -- cgit v1.2.3