diff --git a/src/primitives/block.cpp b/src/primitives/block.cpp --- a/src/primitives/block.cpp +++ b/src/primitives/block.cpp @@ -21,8 +21,8 @@ "vtx=%u)\n", GetHash().ToString(), nVersion, hashPrevBlock.ToString(), 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(); } diff --git a/src/primitives/transaction.cpp b/src/primitives/transaction.cpp --- a/src/primitives/transaction.cpp +++ b/src/primitives/transaction.cpp @@ -73,10 +73,9 @@ Amount CTransaction::GetValueOut() const { Amount nValueOut = Amount::zero(); - for (std::vector::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"); }