From e1c946776652a177e3b46db02391263cc24bfd5a Mon Sep 17 00:00:00 2001 From: Cory Fields Date: Fri, 10 Oct 2014 00:42:03 -0400 Subject: [PATCH] boost: drop boost dependency in core.cpp --- src/core.cpp | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/core.cpp b/src/core.cpp index 380b1c38e..6a7a9ff37 100644 --- a/src/core.cpp +++ b/src/core.cpp @@ -7,8 +7,6 @@ #include "tinyformat.h" -#include - std::string COutPoint::ToString() const { return strprintf("COutPoint(%s, %u)", hash.ToString().substr(0,10), n); @@ -113,10 +111,10 @@ CTransaction& CTransaction::operator=(const CTransaction &tx) { CAmount CTransaction::GetValueOut() const { CAmount nValueOut = 0; - BOOST_FOREACH(const CTxOut& txout, vout) + for (std::vector::const_iterator it(vout.begin()); it != vout.end(); ++it) { - nValueOut += txout.nValue; - if (!MoneyRange(txout.nValue) || !MoneyRange(nValueOut)) + nValueOut += it->nValue; + if (!MoneyRange(it->nValue) || !MoneyRange(nValueOut)) throw std::runtime_error("CTransaction::GetValueOut() : value out of range"); } return nValueOut; @@ -139,10 +137,9 @@ unsigned int CTransaction::CalculateModifiedSize(unsigned int nTxSize) const // 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) + for (std::vector::const_iterator it(vin.begin()); it != vin.end(); ++it) { - unsigned int offset = 41U + std::min(110U, (unsigned int)txin.scriptSig.size()); + unsigned int offset = 41U + std::min(110U, (unsigned int)it->scriptSig.size()); if (nTxSize > offset) nTxSize -= offset; } @@ -263,8 +260,8 @@ uint256 CBlock::BuildMerkleTree(bool* fMutated) const */ vMerkleTree.clear(); vMerkleTree.reserve(vtx.size() * 2 + 16); // Safe upper bound for the number of total nodes. - BOOST_FOREACH(const CTransaction& tx, vtx) - vMerkleTree.push_back(tx.GetHash()); + for (std::vector::const_iterator it(vtx.begin()); it != vtx.end(); ++it) + vMerkleTree.push_back(it->GetHash()); int j = 0; bool mutated = false; for (int nSize = vtx.size(); nSize > 1; nSize = (nSize + 1) / 2) @@ -307,12 +304,12 @@ uint256 CBlock::CheckMerkleBranch(uint256 hash, const std::vector& vMer { if (nIndex == -1) return 0; - BOOST_FOREACH(const uint256& otherside, vMerkleBranch) + for (std::vector::const_iterator it(vMerkleBranch.begin()); it != vMerkleBranch.end(); ++it) { if (nIndex & 1) - hash = Hash(BEGIN(otherside), END(otherside), BEGIN(hash), END(hash)); + hash = Hash(BEGIN(*it), END(*it), BEGIN(hash), END(hash)); else - hash = Hash(BEGIN(hash), END(hash), BEGIN(otherside), END(otherside)); + hash = Hash(BEGIN(hash), END(hash), BEGIN(*it), END(*it)); nIndex >>= 1; } return hash;