aboutsummaryrefslogtreecommitdiff
path: root/src/core.cpp
diff options
context:
space:
mode:
authorGavin Andresen <[email protected]>2013-11-29 22:04:18 -0800
committerGavin Andresen <[email protected]>2013-11-29 22:04:18 -0800
commitb78d1cdf82fb12cc0c8eb9049074b359b9589b7c (patch)
tree2fe293e6b06acff639d8c1361fe1c0725313dd30 /src/core.cpp
parentMerge pull request #3309 (diff)
parentAdd verbose boolean to getrawmempool (diff)
downloaddiscoin-b78d1cdf82fb12cc0c8eb9049074b359b9589b7c.tar.xz
discoin-b78d1cdf82fb12cc0c8eb9049074b359b9589b7c.zip
Merge pull request #3239 from gavinandresen/mempool_verbose
Add verbose flag to getrawmempool
Diffstat (limited to 'src/core.cpp')
-rw-r--r--src/core.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/core.cpp b/src/core.cpp
index 7a1c90e58..f41ea87fe 100644
--- a/src/core.cpp
+++ b/src/core.cpp
@@ -106,6 +106,37 @@ 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;
+}
+
+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;