Merge #10347: Use range-based for loops (C++11) when looping over vector elements
211adc0
Use range-based for loops (C++11) when looping over vector elements (practicalswift)
Tree-SHA512: 0e007f20dcef99d3c7a1036265e00f689d69f42e02fd82dd8389f45b52d31947e5f9388de2610d3d9bd9f554915ce0d35ebce561e5ae3a9013956d0ee4937145
This commit is contained in:
commit
f2f7e97e8c
5 changed files with 22 additions and 25 deletions
|
@ -754,8 +754,8 @@ void PeerLogicValidation::BlockConnected(const std::shared_ptr<const CBlock>& pb
|
||||||
const CTransaction& tx = *ptx;
|
const CTransaction& tx = *ptx;
|
||||||
|
|
||||||
// Which orphan pool entries must we evict?
|
// Which orphan pool entries must we evict?
|
||||||
for (size_t j = 0; j < tx.vin.size(); j++) {
|
for (const auto& txin : tx.vin) {
|
||||||
auto itByPrev = mapOrphanTransactionsByPrev.find(tx.vin[j].prevout);
|
auto itByPrev = mapOrphanTransactionsByPrev.find(txin.prevout);
|
||||||
if (itByPrev == mapOrphanTransactionsByPrev.end()) continue;
|
if (itByPrev == mapOrphanTransactionsByPrev.end()) continue;
|
||||||
for (auto mi = itByPrev->second.begin(); mi != itByPrev->second.end(); ++mi) {
|
for (auto mi = itByPrev->second.begin(); mi != itByPrev->second.end(); ++mi) {
|
||||||
const CTransaction& orphanTx = *(*mi)->second.tx;
|
const CTransaction& orphanTx = *(*mi)->second.tx;
|
||||||
|
@ -1553,10 +1553,8 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
|
||||||
|
|
||||||
uint32_t nFetchFlags = GetFetchFlags(pfrom);
|
uint32_t nFetchFlags = GetFetchFlags(pfrom);
|
||||||
|
|
||||||
for (unsigned int nInv = 0; nInv < vInv.size(); nInv++)
|
for (CInv &inv : vInv)
|
||||||
{
|
{
|
||||||
CInv &inv = vInv[nInv];
|
|
||||||
|
|
||||||
if (interruptMsgProc)
|
if (interruptMsgProc)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
|
@ -604,8 +604,8 @@ void CBlockPolicyEstimator::processBlock(unsigned int nBlockHeight,
|
||||||
|
|
||||||
unsigned int countedTxs = 0;
|
unsigned int countedTxs = 0;
|
||||||
// Update averages with data points from current block
|
// Update averages with data points from current block
|
||||||
for (unsigned int i = 0; i < entries.size(); i++) {
|
for (const auto& entry : entries) {
|
||||||
if (processBlockTx(nBlockHeight, entries[i]))
|
if (processBlockTx(nBlockHeight, entry))
|
||||||
countedTxs++;
|
countedTxs++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1142,24 +1142,24 @@ public:
|
||||||
|
|
||||||
uint256 GetPrevoutHash(const CTransaction& txTo) {
|
uint256 GetPrevoutHash(const CTransaction& txTo) {
|
||||||
CHashWriter ss(SER_GETHASH, 0);
|
CHashWriter ss(SER_GETHASH, 0);
|
||||||
for (unsigned int n = 0; n < txTo.vin.size(); n++) {
|
for (const auto& txin : txTo.vin) {
|
||||||
ss << txTo.vin[n].prevout;
|
ss << txin.prevout;
|
||||||
}
|
}
|
||||||
return ss.GetHash();
|
return ss.GetHash();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint256 GetSequenceHash(const CTransaction& txTo) {
|
uint256 GetSequenceHash(const CTransaction& txTo) {
|
||||||
CHashWriter ss(SER_GETHASH, 0);
|
CHashWriter ss(SER_GETHASH, 0);
|
||||||
for (unsigned int n = 0; n < txTo.vin.size(); n++) {
|
for (const auto& txin : txTo.vin) {
|
||||||
ss << txTo.vin[n].nSequence;
|
ss << txin.nSequence;
|
||||||
}
|
}
|
||||||
return ss.GetHash();
|
return ss.GetHash();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint256 GetOutputsHash(const CTransaction& txTo) {
|
uint256 GetOutputsHash(const CTransaction& txTo) {
|
||||||
CHashWriter ss(SER_GETHASH, 0);
|
CHashWriter ss(SER_GETHASH, 0);
|
||||||
for (unsigned int n = 0; n < txTo.vout.size(); n++) {
|
for (const auto& txout : txTo.vout) {
|
||||||
ss << txTo.vout[n];
|
ss << txout;
|
||||||
}
|
}
|
||||||
return ss.GetHash();
|
return ss.GetHash();
|
||||||
}
|
}
|
||||||
|
|
|
@ -309,7 +309,6 @@ bool CheckSequenceLocks(const CTransaction &tx, int flags, LockPoints* lp, bool
|
||||||
return EvaluateSequenceLocks(index, lockPair);
|
return EvaluateSequenceLocks(index, lockPair);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LimitMempoolSize(CTxMemPool& pool, size_t limit, unsigned long age) {
|
void LimitMempoolSize(CTxMemPool& pool, size_t limit, unsigned long age) {
|
||||||
int expired = pool.Expire(GetTime() - age);
|
int expired = pool.Expire(GetTime() - age);
|
||||||
if (expired != 0) {
|
if (expired != 0) {
|
||||||
|
@ -2817,8 +2816,8 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, const Co
|
||||||
|
|
||||||
// No witness data is allowed in blocks that don't commit to witness data, as this would otherwise leave room for spam
|
// No witness data is allowed in blocks that don't commit to witness data, as this would otherwise leave room for spam
|
||||||
if (!fHaveWitness) {
|
if (!fHaveWitness) {
|
||||||
for (size_t i = 0; i < block.vtx.size(); i++) {
|
for (const auto& tx : block.vtx) {
|
||||||
if (block.vtx[i]->HasWitness()) {
|
if (tx->HasWitness()) {
|
||||||
return state.DoS(100, false, REJECT_INVALID, "unexpected-witness", true, strprintf("%s : unexpected witness data found", __func__));
|
return state.DoS(100, false, REJECT_INVALID, "unexpected-witness", true, strprintf("%s : unexpected witness data found", __func__));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1788,8 +1788,8 @@ bool CWalletTx::IsEquivalentTo(const CWalletTx& _tx) const
|
||||||
{
|
{
|
||||||
CMutableTransaction tx1 = *this->tx;
|
CMutableTransaction tx1 = *this->tx;
|
||||||
CMutableTransaction tx2 = *_tx.tx;
|
CMutableTransaction tx2 = *_tx.tx;
|
||||||
for (unsigned int i = 0; i < tx1.vin.size(); i++) tx1.vin[i].scriptSig = CScript();
|
for (auto& txin : tx1.vin) txin.scriptSig = CScript();
|
||||||
for (unsigned int i = 0; i < tx2.vin.size(); i++) tx2.vin[i].scriptSig = CScript();
|
for (auto& txin : tx2.vin) txin.scriptSig = CScript();
|
||||||
return CTransaction(tx1) == CTransaction(tx2);
|
return CTransaction(tx1) == CTransaction(tx2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2268,10 +2268,10 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, const int nConfMin
|
||||||
|
|
||||||
if (nTotalLower == nTargetValue)
|
if (nTotalLower == nTargetValue)
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < vValue.size(); ++i)
|
for (const auto& input : vValue)
|
||||||
{
|
{
|
||||||
setCoinsRet.insert(vValue[i]);
|
setCoinsRet.insert(input);
|
||||||
nValueRet += vValue[i].txout.nValue;
|
nValueRet += input.txout.nValue;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -2401,7 +2401,7 @@ bool CWallet::SignTransaction(CMutableTransaction &tx)
|
||||||
// sign the new tx
|
// sign the new tx
|
||||||
CTransaction txNewConst(tx);
|
CTransaction txNewConst(tx);
|
||||||
int nIn = 0;
|
int nIn = 0;
|
||||||
for (auto& input : tx.vin) {
|
for (const auto& input : tx.vin) {
|
||||||
std::map<uint256, CWalletTx>::const_iterator mi = mapWallet.find(input.prevout.hash);
|
std::map<uint256, CWalletTx>::const_iterator mi = mapWallet.find(input.prevout.hash);
|
||||||
if(mi == mapWallet.end() || input.prevout.n >= mi->second.tx->vout.size()) {
|
if(mi == mapWallet.end() || input.prevout.n >= mi->second.tx->vout.size()) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -3340,11 +3340,11 @@ std::set< std::set<CTxDestination> > CWallet::GetAddressGroupings()
|
||||||
}
|
}
|
||||||
|
|
||||||
// group lone addrs by themselves
|
// group lone addrs by themselves
|
||||||
for (unsigned int i = 0; i < pcoin->tx->vout.size(); i++)
|
for (const auto& txout : pcoin->tx->vout)
|
||||||
if (IsMine(pcoin->tx->vout[i]))
|
if (IsMine(txout))
|
||||||
{
|
{
|
||||||
CTxDestination address;
|
CTxDestination address;
|
||||||
if(!ExtractDestination(pcoin->tx->vout[i].scriptPubKey, address))
|
if(!ExtractDestination(txout.scriptPubKey, address))
|
||||||
continue;
|
continue;
|
||||||
grouping.insert(address);
|
grouping.insert(address);
|
||||||
groupings.insert(grouping);
|
groupings.insert(grouping);
|
||||||
|
|
Loading…
Reference in a new issue