Browse Source

Replace traditional for with ranged for in primitives

0.15
Dag Robole 8 years ago
parent
commit
72f00608d0
  1. 5
      src/primitives/block.cpp
  2. 19
      src/primitives/transaction.cpp

5
src/primitives/block.cpp

@ -25,9 +25,8 @@ std::string CBlock::ToString() const @@ -25,9 +25,8 @@ std::string CBlock::ToString() const
hashMerkleRoot.ToString(),
nTime, nBits, nNonce,
vtx.size());
for (unsigned int i = 0; i < vtx.size(); i++)
{
s << " " << vtx[i]->ToString() << "\n";
for (const auto& tx : vtx) {
s << " " << tx->ToString() << "\n";
}
return s.str();
}

19
src/primitives/transaction.cpp

@ -83,10 +83,9 @@ CTransaction::CTransaction(CMutableTransaction &&tx) : nVersion(tx.nVersion), vi @@ -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 @@ -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;
}

Loading…
Cancel
Save