aboutsummaryrefslogtreecommitdiff
path: root/src/primitives/transaction.cpp
diff options
context:
space:
mode:
authorDag Robole <dag.robole@gmail.com>2017-07-21 12:27:23 +0200
committerDag Robole <dag.robole@gmail.com>2017-07-24 16:32:21 +0200
commit72f00608d0a130a1488dc49df1073abe01d49519 (patch)
tree623e61b6194ace946139a5ab0294b916a71a0931 /src/primitives/transaction.cpp
parent6adc3a37324caa07015368bfe8529e1964366eef (diff)
Replace traditional for with ranged for in primitives
Diffstat (limited to 'src/primitives/transaction.cpp')
-rw-r--r--src/primitives/transaction.cpp19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/primitives/transaction.cpp b/src/primitives/transaction.cpp
index f87934d586..9b6a814e1f 100644
--- a/src/primitives/transaction.cpp
+++ b/src/primitives/transaction.cpp
@@ -83,10 +83,9 @@ CTransaction::CTransaction(CMutableTransaction &&tx) : nVersion(tx.nVersion), vi
CAmount CTransaction::GetValueOut() const
{
CAmount nValueOut = 0;
- for (std::vector<CTxOut>::const_iterator it(vout.begin()); it != vout.end(); ++it)
- {
- nValueOut += it->nValue;
- if (!MoneyRange(it->nValue) || !MoneyRange(nValueOut))
+ for (const auto& tx_out : vout) {
+ nValueOut += tx_out.nValue;
+ if (!MoneyRange(tx_out.nValue) || !MoneyRange(nValueOut))
throw std::runtime_error(std::string(__func__) + ": value out of range");
}
return nValueOut;
@@ -106,11 +105,11 @@ std::string CTransaction::ToString() const
vin.size(),
vout.size(),
nLockTime);
- for (unsigned int i = 0; i < vin.size(); i++)
- str += " " + vin[i].ToString() + "\n";
- for (unsigned int i = 0; i < vin.size(); i++)
- str += " " + vin[i].scriptWitness.ToString() + "\n";
- for (unsigned int i = 0; i < vout.size(); i++)
- str += " " + vout[i].ToString() + "\n";
+ for (const auto& tx_in : vin)
+ str += " " + tx_in.ToString() + "\n";
+ for (const auto& tx_in : vin)
+ str += " " + tx_in.scriptWitness.ToString() + "\n";
+ for (const auto& tx_out : vout)
+ str += " " + tx_out.ToString() + "\n";
return str;
}