scripted-diff: Fully remove BOOST_FOREACH
-BEGIN VERIFY SCRIPT- sed -i 's/BOOST_FOREACH *(\(.*\),/for (\1 :/' ./src/*.h ./src/*.cpp ./src/*/*.h ./src/*/*.cpp ./src/*/*/*.h ./src/*/*/*.cpp ; -END VERIFY SCRIPT-
This commit is contained in:
parent
a5410ac5ec
commit
7c00c26726
49 changed files with 266 additions and 266 deletions
|
@ -39,7 +39,7 @@ static void CoinSelection(benchmark::State& state)
|
||||||
|
|
||||||
while (state.KeepRunning()) {
|
while (state.KeepRunning()) {
|
||||||
// Empty wallet.
|
// Empty wallet.
|
||||||
BOOST_FOREACH (COutput output, vCoins)
|
for (COutput output : vCoins)
|
||||||
delete output.tx;
|
delete output.tx;
|
||||||
vCoins.clear();
|
vCoins.clear();
|
||||||
|
|
||||||
|
|
|
@ -611,7 +611,7 @@ static void MutateTxSign(CMutableTransaction& tx, const std::string& flagStr)
|
||||||
ProduceSignature(MutableTransactionSignatureCreator(&keystore, &mergedTx, i, amount, nHashType), prevPubKey, sigdata);
|
ProduceSignature(MutableTransactionSignatureCreator(&keystore, &mergedTx, i, amount, nHashType), prevPubKey, sigdata);
|
||||||
|
|
||||||
// ... and merge in other signatures:
|
// ... and merge in other signatures:
|
||||||
BOOST_FOREACH(const CTransaction& txv, txVariants)
|
for (const CTransaction& txv : txVariants)
|
||||||
sigdata = CombineSignatures(prevPubKey, MutableTransactionSignatureChecker(&mergedTx, i, amount), sigdata, DataFromTransaction(txv, i));
|
sigdata = CombineSignatures(prevPubKey, MutableTransactionSignatureChecker(&mergedTx, i, amount), sigdata, DataFromTransaction(txv, i));
|
||||||
UpdateTransaction(mergedTx, i, sigdata);
|
UpdateTransaction(mergedTx, i, sigdata);
|
||||||
|
|
||||||
|
|
|
@ -179,7 +179,7 @@ bool CBloomFilter::IsRelevantAndUpdate(const CTransaction& tx)
|
||||||
if (fFound)
|
if (fFound)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
BOOST_FOREACH(const CTxIn& txin, tx.vin)
|
for (const CTxIn& txin : tx.vin)
|
||||||
{
|
{
|
||||||
// Match if the filter contains an outpoint tx spends
|
// Match if the filter contains an outpoint tx spends
|
||||||
if (contains(txin.prevout))
|
if (contains(txin.prevout))
|
||||||
|
|
|
@ -121,7 +121,7 @@ private:
|
||||||
fOk = fAllOk;
|
fOk = fAllOk;
|
||||||
}
|
}
|
||||||
// execute work
|
// execute work
|
||||||
BOOST_FOREACH (T& check, vChecks)
|
for (T& check : vChecks)
|
||||||
if (fOk)
|
if (fOk)
|
||||||
fOk = check();
|
fOk = check();
|
||||||
vChecks.clear();
|
vChecks.clear();
|
||||||
|
@ -151,7 +151,7 @@ public:
|
||||||
void Add(std::vector<T>& vChecks)
|
void Add(std::vector<T>& vChecks)
|
||||||
{
|
{
|
||||||
boost::unique_lock<boost::mutex> lock(mutex);
|
boost::unique_lock<boost::mutex> lock(mutex);
|
||||||
BOOST_FOREACH (T& check, vChecks) {
|
for (T& check : vChecks) {
|
||||||
queue.push_back(T());
|
queue.push_back(T());
|
||||||
check.swap(queue.back());
|
check.swap(queue.back());
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,7 +141,7 @@ void ScriptPubKeyToUniv(const CScript& scriptPubKey,
|
||||||
out.pushKV("type", GetTxnOutputType(type));
|
out.pushKV("type", GetTxnOutputType(type));
|
||||||
|
|
||||||
UniValue a(UniValue::VARR);
|
UniValue a(UniValue::VARR);
|
||||||
BOOST_FOREACH(const CTxDestination& addr, addresses)
|
for (const CTxDestination& addr : addresses)
|
||||||
a.push_back(CBitcoinAddress(addr).ToString());
|
a.push_back(CBitcoinAddress(addr).ToString());
|
||||||
out.pushKV("addresses", a);
|
out.pushKV("addresses", a);
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,7 +95,7 @@ static bool multiUserAuthorized(std::string strUserPass)
|
||||||
|
|
||||||
if (gArgs.IsArgSet("-rpcauth")) {
|
if (gArgs.IsArgSet("-rpcauth")) {
|
||||||
//Search for multi-user login/pass "rpcauth" from config
|
//Search for multi-user login/pass "rpcauth" from config
|
||||||
BOOST_FOREACH(std::string strRPCAuth, gArgs.GetArgs("-rpcauth"))
|
for (std::string strRPCAuth : gArgs.GetArgs("-rpcauth"))
|
||||||
{
|
{
|
||||||
std::vector<std::string> vFields;
|
std::vector<std::string> vFields;
|
||||||
boost::split(vFields, strRPCAuth, boost::is_any_of(":$"));
|
boost::split(vFields, strRPCAuth, boost::is_any_of(":$"));
|
||||||
|
|
18
src/init.cpp
18
src/init.cpp
|
@ -611,7 +611,7 @@ void CleanupBlockRevFiles()
|
||||||
// keeping a separate counter. Once we hit a gap (or if 0 doesn't exist)
|
// keeping a separate counter. Once we hit a gap (or if 0 doesn't exist)
|
||||||
// start removing block files.
|
// start removing block files.
|
||||||
int nContigCounter = 0;
|
int nContigCounter = 0;
|
||||||
BOOST_FOREACH(const PAIRTYPE(std::string, fs::path)& item, mapBlockFiles) {
|
for (const PAIRTYPE(std::string, fs::path)& item : mapBlockFiles) {
|
||||||
if (atoi(item.first) == nContigCounter) {
|
if (atoi(item.first) == nContigCounter) {
|
||||||
nContigCounter++;
|
nContigCounter++;
|
||||||
continue;
|
continue;
|
||||||
|
@ -664,7 +664,7 @@ void ThreadImport(std::vector<fs::path> vImportFiles)
|
||||||
}
|
}
|
||||||
|
|
||||||
// -loadblock=
|
// -loadblock=
|
||||||
BOOST_FOREACH(const fs::path& path, vImportFiles) {
|
for (const fs::path& path : vImportFiles) {
|
||||||
FILE *file = fsbridge::fopen(path, "rb");
|
FILE *file = fsbridge::fopen(path, "rb");
|
||||||
if (file) {
|
if (file) {
|
||||||
LogPrintf("Importing blocks file %s...\n", path.string());
|
LogPrintf("Importing blocks file %s...\n", path.string());
|
||||||
|
@ -1258,7 +1258,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||||
// sanitize comments per BIP-0014, format user agent and check total size
|
// sanitize comments per BIP-0014, format user agent and check total size
|
||||||
std::vector<std::string> uacomments;
|
std::vector<std::string> uacomments;
|
||||||
if (gArgs.IsArgSet("-uacomment")) {
|
if (gArgs.IsArgSet("-uacomment")) {
|
||||||
BOOST_FOREACH(std::string cmt, gArgs.GetArgs("-uacomment"))
|
for (std::string cmt : gArgs.GetArgs("-uacomment"))
|
||||||
{
|
{
|
||||||
if (cmt != SanitizeString(cmt, SAFE_CHARS_UA_COMMENT))
|
if (cmt != SanitizeString(cmt, SAFE_CHARS_UA_COMMENT))
|
||||||
return InitError(strprintf(_("User Agent comment (%s) contains unsafe characters."), cmt));
|
return InitError(strprintf(_("User Agent comment (%s) contains unsafe characters."), cmt));
|
||||||
|
@ -1273,7 +1273,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||||
|
|
||||||
if (gArgs.IsArgSet("-onlynet")) {
|
if (gArgs.IsArgSet("-onlynet")) {
|
||||||
std::set<enum Network> nets;
|
std::set<enum Network> nets;
|
||||||
BOOST_FOREACH(const std::string& snet, gArgs.GetArgs("-onlynet")) {
|
for (const std::string& snet : gArgs.GetArgs("-onlynet")) {
|
||||||
enum Network net = ParseNetwork(snet);
|
enum Network net = ParseNetwork(snet);
|
||||||
if (net == NET_UNROUTABLE)
|
if (net == NET_UNROUTABLE)
|
||||||
return InitError(strprintf(_("Unknown network specified in -onlynet: '%s'"), snet));
|
return InitError(strprintf(_("Unknown network specified in -onlynet: '%s'"), snet));
|
||||||
|
@ -1287,7 +1287,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gArgs.IsArgSet("-whitelist")) {
|
if (gArgs.IsArgSet("-whitelist")) {
|
||||||
BOOST_FOREACH(const std::string& net, gArgs.GetArgs("-whitelist")) {
|
for (const std::string& net : gArgs.GetArgs("-whitelist")) {
|
||||||
CSubNet subnet;
|
CSubNet subnet;
|
||||||
LookupSubNet(net.c_str(), subnet);
|
LookupSubNet(net.c_str(), subnet);
|
||||||
if (!subnet.IsValid())
|
if (!subnet.IsValid())
|
||||||
|
@ -1349,7 +1349,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||||
if (fListen) {
|
if (fListen) {
|
||||||
bool fBound = false;
|
bool fBound = false;
|
||||||
if (gArgs.IsArgSet("-bind")) {
|
if (gArgs.IsArgSet("-bind")) {
|
||||||
BOOST_FOREACH(const std::string& strBind, gArgs.GetArgs("-bind")) {
|
for (const std::string& strBind : gArgs.GetArgs("-bind")) {
|
||||||
CService addrBind;
|
CService addrBind;
|
||||||
if (!Lookup(strBind.c_str(), addrBind, GetListenPort(), false))
|
if (!Lookup(strBind.c_str(), addrBind, GetListenPort(), false))
|
||||||
return InitError(ResolveErrMsg("bind", strBind));
|
return InitError(ResolveErrMsg("bind", strBind));
|
||||||
|
@ -1357,7 +1357,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gArgs.IsArgSet("-whitebind")) {
|
if (gArgs.IsArgSet("-whitebind")) {
|
||||||
BOOST_FOREACH(const std::string& strBind, gArgs.GetArgs("-whitebind")) {
|
for (const std::string& strBind : gArgs.GetArgs("-whitebind")) {
|
||||||
CService addrBind;
|
CService addrBind;
|
||||||
if (!Lookup(strBind.c_str(), addrBind, 0, false))
|
if (!Lookup(strBind.c_str(), addrBind, 0, false))
|
||||||
return InitError(ResolveErrMsg("whitebind", strBind));
|
return InitError(ResolveErrMsg("whitebind", strBind));
|
||||||
|
@ -1377,7 +1377,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gArgs.IsArgSet("-externalip")) {
|
if (gArgs.IsArgSet("-externalip")) {
|
||||||
BOOST_FOREACH(const std::string& strAddr, gArgs.GetArgs("-externalip")) {
|
for (const std::string& strAddr : gArgs.GetArgs("-externalip")) {
|
||||||
CService addrLocal;
|
CService addrLocal;
|
||||||
if (Lookup(strAddr.c_str(), addrLocal, GetListenPort(), fNameLookup) && addrLocal.IsValid())
|
if (Lookup(strAddr.c_str(), addrLocal, GetListenPort(), fNameLookup) && addrLocal.IsValid())
|
||||||
AddLocal(addrLocal, LOCAL_MANUAL);
|
AddLocal(addrLocal, LOCAL_MANUAL);
|
||||||
|
@ -1616,7 +1616,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||||
std::vector<fs::path> vImportFiles;
|
std::vector<fs::path> vImportFiles;
|
||||||
if (gArgs.IsArgSet("-loadblock"))
|
if (gArgs.IsArgSet("-loadblock"))
|
||||||
{
|
{
|
||||||
BOOST_FOREACH(const std::string& strFile, gArgs.GetArgs("-loadblock"))
|
for (const std::string& strFile : gArgs.GetArgs("-loadblock"))
|
||||||
vImportFiles.push_back(strFile);
|
vImportFiles.push_back(strFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -242,7 +242,7 @@ bool BlockAssembler::TestPackage(uint64_t packageSize, int64_t packageSigOpsCost
|
||||||
bool BlockAssembler::TestPackageTransactions(const CTxMemPool::setEntries& package)
|
bool BlockAssembler::TestPackageTransactions(const CTxMemPool::setEntries& package)
|
||||||
{
|
{
|
||||||
uint64_t nPotentialBlockSize = nBlockSize; // only used with fNeedSizeAccounting
|
uint64_t nPotentialBlockSize = nBlockSize; // only used with fNeedSizeAccounting
|
||||||
BOOST_FOREACH (const CTxMemPool::txiter it, package) {
|
for (const CTxMemPool::txiter it : package) {
|
||||||
if (!IsFinalTx(it->GetTx(), nHeight, nLockTimeCutoff))
|
if (!IsFinalTx(it->GetTx(), nHeight, nLockTimeCutoff))
|
||||||
return false;
|
return false;
|
||||||
if (!fIncludeWitness && it->GetTx().HasWitness())
|
if (!fIncludeWitness && it->GetTx().HasWitness())
|
||||||
|
@ -284,11 +284,11 @@ int BlockAssembler::UpdatePackagesForAdded(const CTxMemPool::setEntries& already
|
||||||
indexed_modified_transaction_set &mapModifiedTx)
|
indexed_modified_transaction_set &mapModifiedTx)
|
||||||
{
|
{
|
||||||
int nDescendantsUpdated = 0;
|
int nDescendantsUpdated = 0;
|
||||||
BOOST_FOREACH(const CTxMemPool::txiter it, alreadyAdded) {
|
for (const CTxMemPool::txiter it : alreadyAdded) {
|
||||||
CTxMemPool::setEntries descendants;
|
CTxMemPool::setEntries descendants;
|
||||||
mempool.CalculateDescendants(it, descendants);
|
mempool.CalculateDescendants(it, descendants);
|
||||||
// Insert all descendants (not yet in block) into the modified set
|
// Insert all descendants (not yet in block) into the modified set
|
||||||
BOOST_FOREACH(CTxMemPool::txiter desc, descendants) {
|
for (CTxMemPool::txiter desc : descendants) {
|
||||||
if (alreadyAdded.count(desc))
|
if (alreadyAdded.count(desc))
|
||||||
continue;
|
continue;
|
||||||
++nDescendantsUpdated;
|
++nDescendantsUpdated;
|
||||||
|
|
68
src/net.cpp
68
src/net.cpp
|
@ -295,7 +295,7 @@ bool IsReachable(const CNetAddr& addr)
|
||||||
CNode* CConnman::FindNode(const CNetAddr& ip)
|
CNode* CConnman::FindNode(const CNetAddr& ip)
|
||||||
{
|
{
|
||||||
LOCK(cs_vNodes);
|
LOCK(cs_vNodes);
|
||||||
BOOST_FOREACH(CNode* pnode, vNodes)
|
for (CNode* pnode : vNodes)
|
||||||
if ((CNetAddr)pnode->addr == ip)
|
if ((CNetAddr)pnode->addr == ip)
|
||||||
return (pnode);
|
return (pnode);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -304,7 +304,7 @@ CNode* CConnman::FindNode(const CNetAddr& ip)
|
||||||
CNode* CConnman::FindNode(const CSubNet& subNet)
|
CNode* CConnman::FindNode(const CSubNet& subNet)
|
||||||
{
|
{
|
||||||
LOCK(cs_vNodes);
|
LOCK(cs_vNodes);
|
||||||
BOOST_FOREACH(CNode* pnode, vNodes)
|
for (CNode* pnode : vNodes)
|
||||||
if (subNet.Match((CNetAddr)pnode->addr))
|
if (subNet.Match((CNetAddr)pnode->addr))
|
||||||
return (pnode);
|
return (pnode);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -313,7 +313,7 @@ CNode* CConnman::FindNode(const CSubNet& subNet)
|
||||||
CNode* CConnman::FindNode(const std::string& addrName)
|
CNode* CConnman::FindNode(const std::string& addrName)
|
||||||
{
|
{
|
||||||
LOCK(cs_vNodes);
|
LOCK(cs_vNodes);
|
||||||
BOOST_FOREACH(CNode* pnode, vNodes) {
|
for (CNode* pnode : vNodes) {
|
||||||
if (pnode->GetAddrName() == addrName) {
|
if (pnode->GetAddrName() == addrName) {
|
||||||
return (pnode);
|
return (pnode);
|
||||||
}
|
}
|
||||||
|
@ -324,7 +324,7 @@ CNode* CConnman::FindNode(const std::string& addrName)
|
||||||
CNode* CConnman::FindNode(const CService& addr)
|
CNode* CConnman::FindNode(const CService& addr)
|
||||||
{
|
{
|
||||||
LOCK(cs_vNodes);
|
LOCK(cs_vNodes);
|
||||||
BOOST_FOREACH(CNode* pnode, vNodes)
|
for (CNode* pnode : vNodes)
|
||||||
if ((CService)pnode->addr == addr)
|
if ((CService)pnode->addr == addr)
|
||||||
return (pnode);
|
return (pnode);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -333,7 +333,7 @@ CNode* CConnman::FindNode(const CService& addr)
|
||||||
bool CConnman::CheckIncomingNonce(uint64_t nonce)
|
bool CConnman::CheckIncomingNonce(uint64_t nonce)
|
||||||
{
|
{
|
||||||
LOCK(cs_vNodes);
|
LOCK(cs_vNodes);
|
||||||
BOOST_FOREACH(CNode* pnode, vNodes) {
|
for (CNode* pnode : vNodes) {
|
||||||
if (!pnode->fSuccessfullyConnected && !pnode->fInbound && pnode->GetLocalNonce() == nonce)
|
if (!pnode->fSuccessfullyConnected && !pnode->fInbound && pnode->GetLocalNonce() == nonce)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -528,7 +528,7 @@ void CConnman::Ban(const CSubNet& subNet, const BanReason &banReason, int64_t ba
|
||||||
clientInterface->BannedListChanged();
|
clientInterface->BannedListChanged();
|
||||||
{
|
{
|
||||||
LOCK(cs_vNodes);
|
LOCK(cs_vNodes);
|
||||||
BOOST_FOREACH(CNode* pnode, vNodes) {
|
for (CNode* pnode : vNodes) {
|
||||||
if (subNet.Match((CNetAddr)pnode->addr))
|
if (subNet.Match((CNetAddr)pnode->addr))
|
||||||
pnode->fDisconnect = true;
|
pnode->fDisconnect = true;
|
||||||
}
|
}
|
||||||
|
@ -606,7 +606,7 @@ void CConnman::SetBannedSetDirty(bool dirty)
|
||||||
|
|
||||||
bool CConnman::IsWhitelistedRange(const CNetAddr &addr) {
|
bool CConnman::IsWhitelistedRange(const CNetAddr &addr) {
|
||||||
LOCK(cs_vWhitelistedRange);
|
LOCK(cs_vWhitelistedRange);
|
||||||
BOOST_FOREACH(const CSubNet& subnet, vWhitelistedRange) {
|
for (const CSubNet& subnet : vWhitelistedRange) {
|
||||||
if (subnet.Match(addr))
|
if (subnet.Match(addr))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -959,7 +959,7 @@ bool CConnman::AttemptToEvictConnection()
|
||||||
{
|
{
|
||||||
LOCK(cs_vNodes);
|
LOCK(cs_vNodes);
|
||||||
|
|
||||||
BOOST_FOREACH(CNode *node, vNodes) {
|
for (CNode *node : vNodes) {
|
||||||
if (node->fWhitelisted)
|
if (node->fWhitelisted)
|
||||||
continue;
|
continue;
|
||||||
if (!node->fInbound)
|
if (!node->fInbound)
|
||||||
|
@ -1019,7 +1019,7 @@ bool CConnman::AttemptToEvictConnection()
|
||||||
unsigned int nMostConnections = 0;
|
unsigned int nMostConnections = 0;
|
||||||
int64_t nMostConnectionsTime = 0;
|
int64_t nMostConnectionsTime = 0;
|
||||||
std::map<uint64_t, std::vector<NodeEvictionCandidate> > mapNetGroupNodes;
|
std::map<uint64_t, std::vector<NodeEvictionCandidate> > mapNetGroupNodes;
|
||||||
BOOST_FOREACH(const NodeEvictionCandidate &node, vEvictionCandidates) {
|
for (const NodeEvictionCandidate &node : vEvictionCandidates) {
|
||||||
mapNetGroupNodes[node.nKeyedNetGroup].push_back(node);
|
mapNetGroupNodes[node.nKeyedNetGroup].push_back(node);
|
||||||
int64_t grouptime = mapNetGroupNodes[node.nKeyedNetGroup][0].nTimeConnected;
|
int64_t grouptime = mapNetGroupNodes[node.nKeyedNetGroup][0].nTimeConnected;
|
||||||
size_t groupsize = mapNetGroupNodes[node.nKeyedNetGroup].size();
|
size_t groupsize = mapNetGroupNodes[node.nKeyedNetGroup].size();
|
||||||
|
@ -1063,7 +1063,7 @@ void CConnman::AcceptConnection(const ListenSocket& hListenSocket) {
|
||||||
bool whitelisted = hListenSocket.whitelisted || IsWhitelistedRange(addr);
|
bool whitelisted = hListenSocket.whitelisted || IsWhitelistedRange(addr);
|
||||||
{
|
{
|
||||||
LOCK(cs_vNodes);
|
LOCK(cs_vNodes);
|
||||||
BOOST_FOREACH(CNode* pnode, vNodes)
|
for (CNode* pnode : vNodes)
|
||||||
if (pnode->fInbound)
|
if (pnode->fInbound)
|
||||||
nInbound++;
|
nInbound++;
|
||||||
}
|
}
|
||||||
|
@ -1139,7 +1139,7 @@ void CConnman::ThreadSocketHandler()
|
||||||
LOCK(cs_vNodes);
|
LOCK(cs_vNodes);
|
||||||
// Disconnect unused nodes
|
// Disconnect unused nodes
|
||||||
std::vector<CNode*> vNodesCopy = vNodes;
|
std::vector<CNode*> vNodesCopy = vNodes;
|
||||||
BOOST_FOREACH(CNode* pnode, vNodesCopy)
|
for (CNode* pnode : vNodesCopy)
|
||||||
{
|
{
|
||||||
if (pnode->fDisconnect)
|
if (pnode->fDisconnect)
|
||||||
{
|
{
|
||||||
|
@ -1161,7 +1161,7 @@ void CConnman::ThreadSocketHandler()
|
||||||
{
|
{
|
||||||
// Delete disconnected nodes
|
// Delete disconnected nodes
|
||||||
std::list<CNode*> vNodesDisconnectedCopy = vNodesDisconnected;
|
std::list<CNode*> vNodesDisconnectedCopy = vNodesDisconnected;
|
||||||
BOOST_FOREACH(CNode* pnode, vNodesDisconnectedCopy)
|
for (CNode* pnode : vNodesDisconnectedCopy)
|
||||||
{
|
{
|
||||||
// wait until threads are done using it
|
// wait until threads are done using it
|
||||||
if (pnode->GetRefCount() <= 0) {
|
if (pnode->GetRefCount() <= 0) {
|
||||||
|
@ -1209,7 +1209,7 @@ void CConnman::ThreadSocketHandler()
|
||||||
SOCKET hSocketMax = 0;
|
SOCKET hSocketMax = 0;
|
||||||
bool have_fds = false;
|
bool have_fds = false;
|
||||||
|
|
||||||
BOOST_FOREACH(const ListenSocket& hListenSocket, vhListenSocket) {
|
for (const ListenSocket& hListenSocket : vhListenSocket) {
|
||||||
FD_SET(hListenSocket.socket, &fdsetRecv);
|
FD_SET(hListenSocket.socket, &fdsetRecv);
|
||||||
hSocketMax = std::max(hSocketMax, hListenSocket.socket);
|
hSocketMax = std::max(hSocketMax, hListenSocket.socket);
|
||||||
have_fds = true;
|
have_fds = true;
|
||||||
|
@ -1217,7 +1217,7 @@ void CConnman::ThreadSocketHandler()
|
||||||
|
|
||||||
{
|
{
|
||||||
LOCK(cs_vNodes);
|
LOCK(cs_vNodes);
|
||||||
BOOST_FOREACH(CNode* pnode, vNodes)
|
for (CNode* pnode : vNodes)
|
||||||
{
|
{
|
||||||
// Implement the following logic:
|
// Implement the following logic:
|
||||||
// * If there is data to send, select() for sending data. As this only
|
// * If there is data to send, select() for sending data. As this only
|
||||||
|
@ -1278,7 +1278,7 @@ void CConnman::ThreadSocketHandler()
|
||||||
//
|
//
|
||||||
// Accept new connections
|
// Accept new connections
|
||||||
//
|
//
|
||||||
BOOST_FOREACH(const ListenSocket& hListenSocket, vhListenSocket)
|
for (const ListenSocket& hListenSocket : vhListenSocket)
|
||||||
{
|
{
|
||||||
if (hListenSocket.socket != INVALID_SOCKET && FD_ISSET(hListenSocket.socket, &fdsetRecv))
|
if (hListenSocket.socket != INVALID_SOCKET && FD_ISSET(hListenSocket.socket, &fdsetRecv))
|
||||||
{
|
{
|
||||||
|
@ -1293,10 +1293,10 @@ void CConnman::ThreadSocketHandler()
|
||||||
{
|
{
|
||||||
LOCK(cs_vNodes);
|
LOCK(cs_vNodes);
|
||||||
vNodesCopy = vNodes;
|
vNodesCopy = vNodes;
|
||||||
BOOST_FOREACH(CNode* pnode, vNodesCopy)
|
for (CNode* pnode : vNodesCopy)
|
||||||
pnode->AddRef();
|
pnode->AddRef();
|
||||||
}
|
}
|
||||||
BOOST_FOREACH(CNode* pnode, vNodesCopy)
|
for (CNode* pnode : vNodesCopy)
|
||||||
{
|
{
|
||||||
if (interruptNet)
|
if (interruptNet)
|
||||||
return;
|
return;
|
||||||
|
@ -1417,7 +1417,7 @@ void CConnman::ThreadSocketHandler()
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
LOCK(cs_vNodes);
|
LOCK(cs_vNodes);
|
||||||
BOOST_FOREACH(CNode* pnode, vNodesCopy)
|
for (CNode* pnode : vNodesCopy)
|
||||||
pnode->Release();
|
pnode->Release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1598,7 +1598,7 @@ void CConnman::ThreadDNSAddressSeed()
|
||||||
|
|
||||||
LogPrintf("Loading addresses from DNS seeds (could take a while)\n");
|
LogPrintf("Loading addresses from DNS seeds (could take a while)\n");
|
||||||
|
|
||||||
BOOST_FOREACH(const CDNSSeedData &seed, vSeeds) {
|
for (const CDNSSeedData &seed : vSeeds) {
|
||||||
if (interruptNet) {
|
if (interruptNet) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1610,7 +1610,7 @@ void CConnman::ThreadDNSAddressSeed()
|
||||||
ServiceFlags requiredServiceBits = nRelevantServices;
|
ServiceFlags requiredServiceBits = nRelevantServices;
|
||||||
if (LookupHost(GetDNSHost(seed, &requiredServiceBits).c_str(), vIPs, 0, true))
|
if (LookupHost(GetDNSHost(seed, &requiredServiceBits).c_str(), vIPs, 0, true))
|
||||||
{
|
{
|
||||||
BOOST_FOREACH(const CNetAddr& ip, vIPs)
|
for (const CNetAddr& ip : vIPs)
|
||||||
{
|
{
|
||||||
int nOneDay = 24*3600;
|
int nOneDay = 24*3600;
|
||||||
CAddress addr = CAddress(CService(ip, Params().GetDefaultPort()), requiredServiceBits);
|
CAddress addr = CAddress(CService(ip, Params().GetDefaultPort()), requiredServiceBits);
|
||||||
|
@ -1691,7 +1691,7 @@ void CConnman::ThreadOpenConnections()
|
||||||
for (int64_t nLoop = 0;; nLoop++)
|
for (int64_t nLoop = 0;; nLoop++)
|
||||||
{
|
{
|
||||||
ProcessOneShot();
|
ProcessOneShot();
|
||||||
BOOST_FOREACH(const std::string& strAddr, gArgs.GetArgs("-connect"))
|
for (const std::string& strAddr : gArgs.GetArgs("-connect"))
|
||||||
{
|
{
|
||||||
CAddress addr(CService(), NODE_NONE);
|
CAddress addr(CService(), NODE_NONE);
|
||||||
OpenNetworkConnection(addr, false, NULL, strAddr.c_str());
|
OpenNetworkConnection(addr, false, NULL, strAddr.c_str());
|
||||||
|
@ -1746,7 +1746,7 @@ void CConnman::ThreadOpenConnections()
|
||||||
std::set<std::vector<unsigned char> > setConnected;
|
std::set<std::vector<unsigned char> > setConnected;
|
||||||
{
|
{
|
||||||
LOCK(cs_vNodes);
|
LOCK(cs_vNodes);
|
||||||
BOOST_FOREACH(CNode* pnode, vNodes) {
|
for (CNode* pnode : vNodes) {
|
||||||
if (!pnode->fInbound && !pnode->fAddnode) {
|
if (!pnode->fInbound && !pnode->fAddnode) {
|
||||||
|
|
||||||
// Count the peers that have all relevant services
|
// Count the peers that have all relevant services
|
||||||
|
@ -1863,7 +1863,7 @@ std::vector<AddedNodeInfo> CConnman::GetAddedNodeInfo()
|
||||||
{
|
{
|
||||||
LOCK(cs_vAddedNodes);
|
LOCK(cs_vAddedNodes);
|
||||||
ret.reserve(vAddedNodes.size());
|
ret.reserve(vAddedNodes.size());
|
||||||
BOOST_FOREACH(const std::string& strAddNode, vAddedNodes)
|
for (const std::string& strAddNode : vAddedNodes)
|
||||||
lAddresses.push_back(strAddNode);
|
lAddresses.push_back(strAddNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1884,7 +1884,7 @@ std::vector<AddedNodeInfo> CConnman::GetAddedNodeInfo()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_FOREACH(const std::string& strAddNode, lAddresses) {
|
for (const std::string& strAddNode : lAddresses) {
|
||||||
CService service(LookupNumeric(strAddNode.c_str(), Params().GetDefaultPort()));
|
CService service(LookupNumeric(strAddNode.c_str(), Params().GetDefaultPort()));
|
||||||
if (service.IsValid()) {
|
if (service.IsValid()) {
|
||||||
// strAddNode is an IP:port
|
// strAddNode is an IP:port
|
||||||
|
@ -1993,14 +1993,14 @@ void CConnman::ThreadMessageHandler()
|
||||||
{
|
{
|
||||||
LOCK(cs_vNodes);
|
LOCK(cs_vNodes);
|
||||||
vNodesCopy = vNodes;
|
vNodesCopy = vNodes;
|
||||||
BOOST_FOREACH(CNode* pnode, vNodesCopy) {
|
for (CNode* pnode : vNodesCopy) {
|
||||||
pnode->AddRef();
|
pnode->AddRef();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool fMoreWork = false;
|
bool fMoreWork = false;
|
||||||
|
|
||||||
BOOST_FOREACH(CNode* pnode, vNodesCopy)
|
for (CNode* pnode : vNodesCopy)
|
||||||
{
|
{
|
||||||
if (pnode->fDisconnect)
|
if (pnode->fDisconnect)
|
||||||
continue;
|
continue;
|
||||||
|
@ -2022,7 +2022,7 @@ void CConnman::ThreadMessageHandler()
|
||||||
|
|
||||||
{
|
{
|
||||||
LOCK(cs_vNodes);
|
LOCK(cs_vNodes);
|
||||||
BOOST_FOREACH(CNode* pnode, vNodesCopy)
|
for (CNode* pnode : vNodesCopy)
|
||||||
pnode->Release();
|
pnode->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2150,7 +2150,7 @@ void Discover(boost::thread_group& threadGroup)
|
||||||
std::vector<CNetAddr> vaddr;
|
std::vector<CNetAddr> vaddr;
|
||||||
if (LookupHost(pszHostName, vaddr, 0, true))
|
if (LookupHost(pszHostName, vaddr, 0, true))
|
||||||
{
|
{
|
||||||
BOOST_FOREACH (const CNetAddr &addr, vaddr)
|
for (const CNetAddr &addr : vaddr)
|
||||||
{
|
{
|
||||||
if (AddLocal(addr, LOCAL_IF))
|
if (AddLocal(addr, LOCAL_IF))
|
||||||
LogPrintf("%s: %s - %s\n", __func__, pszHostName, addr.ToString());
|
LogPrintf("%s: %s - %s\n", __func__, pszHostName, addr.ToString());
|
||||||
|
@ -2197,7 +2197,7 @@ void CConnman::SetNetworkActive(bool active)
|
||||||
|
|
||||||
LOCK(cs_vNodes);
|
LOCK(cs_vNodes);
|
||||||
// Close sockets to all nodes
|
// Close sockets to all nodes
|
||||||
BOOST_FOREACH(CNode* pnode, vNodes) {
|
for (CNode* pnode : vNodes) {
|
||||||
pnode->CloseSocketDisconnect();
|
pnode->CloseSocketDisconnect();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -2399,18 +2399,18 @@ void CConnman::Stop()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close sockets
|
// Close sockets
|
||||||
BOOST_FOREACH(CNode* pnode, vNodes)
|
for (CNode* pnode : vNodes)
|
||||||
pnode->CloseSocketDisconnect();
|
pnode->CloseSocketDisconnect();
|
||||||
BOOST_FOREACH(ListenSocket& hListenSocket, vhListenSocket)
|
for (ListenSocket& hListenSocket : vhListenSocket)
|
||||||
if (hListenSocket.socket != INVALID_SOCKET)
|
if (hListenSocket.socket != INVALID_SOCKET)
|
||||||
if (!CloseSocket(hListenSocket.socket))
|
if (!CloseSocket(hListenSocket.socket))
|
||||||
LogPrintf("CloseSocket(hListenSocket) failed with error %s\n", NetworkErrorString(WSAGetLastError()));
|
LogPrintf("CloseSocket(hListenSocket) failed with error %s\n", NetworkErrorString(WSAGetLastError()));
|
||||||
|
|
||||||
// clean up some globals (to help leak detection)
|
// clean up some globals (to help leak detection)
|
||||||
BOOST_FOREACH(CNode *pnode, vNodes) {
|
for (CNode *pnode : vNodes) {
|
||||||
DeleteNode(pnode);
|
DeleteNode(pnode);
|
||||||
}
|
}
|
||||||
BOOST_FOREACH(CNode *pnode, vNodesDisconnected) {
|
for (CNode *pnode : vNodesDisconnected) {
|
||||||
DeleteNode(pnode);
|
DeleteNode(pnode);
|
||||||
}
|
}
|
||||||
vNodes.clear();
|
vNodes.clear();
|
||||||
|
@ -2722,7 +2722,7 @@ CNode::CNode(NodeId idIn, ServiceFlags nLocalServicesIn, int nMyStartingHeightIn
|
||||||
fPauseSend = false;
|
fPauseSend = false;
|
||||||
nProcessQueueSize = 0;
|
nProcessQueueSize = 0;
|
||||||
|
|
||||||
BOOST_FOREACH(const std::string &msg, getAllNetMessageTypes())
|
for (const std::string &msg : getAllNetMessageTypes())
|
||||||
mapRecvBytesPerMsgCmd[msg] = 0;
|
mapRecvBytesPerMsgCmd[msg] = 0;
|
||||||
mapRecvBytesPerMsgCmd[NET_MESSAGE_COMMAND_OTHER] = 0;
|
mapRecvBytesPerMsgCmd[NET_MESSAGE_COMMAND_OTHER] = 0;
|
||||||
|
|
||||||
|
|
|
@ -287,7 +287,7 @@ void FinalizeNode(NodeId nodeid, bool& fUpdateConnectionTime) {
|
||||||
fUpdateConnectionTime = true;
|
fUpdateConnectionTime = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_FOREACH(const QueuedBlock& entry, state->vBlocksInFlight) {
|
for (const QueuedBlock& entry : state->vBlocksInFlight) {
|
||||||
mapBlocksInFlight.erase(entry.hash);
|
mapBlocksInFlight.erase(entry.hash);
|
||||||
}
|
}
|
||||||
EraseOrphansFor(nodeid);
|
EraseOrphansFor(nodeid);
|
||||||
|
@ -522,7 +522,7 @@ void FindNextBlocksToDownload(NodeId nodeid, unsigned int count, std::vector<con
|
||||||
// are not yet downloaded and not in flight to vBlocks. In the mean time, update
|
// are not yet downloaded and not in flight to vBlocks. In the mean time, update
|
||||||
// pindexLastCommonBlock as long as all ancestors are already downloaded, or if it's
|
// pindexLastCommonBlock as long as all ancestors are already downloaded, or if it's
|
||||||
// already part of our chain (and therefore don't need it even if pruned).
|
// already part of our chain (and therefore don't need it even if pruned).
|
||||||
BOOST_FOREACH(const CBlockIndex* pindex, vToFetch) {
|
for (const CBlockIndex* pindex : vToFetch) {
|
||||||
if (!pindex->IsValid(BLOCK_VALID_TREE)) {
|
if (!pindex->IsValid(BLOCK_VALID_TREE)) {
|
||||||
// We consider the chain that this peer is on invalid.
|
// We consider the chain that this peer is on invalid.
|
||||||
return;
|
return;
|
||||||
|
@ -566,7 +566,7 @@ bool GetNodeStateStats(NodeId nodeid, CNodeStateStats &stats) {
|
||||||
stats.nMisbehavior = state->nMisbehavior;
|
stats.nMisbehavior = state->nMisbehavior;
|
||||||
stats.nSyncHeight = state->pindexBestKnownBlock ? state->pindexBestKnownBlock->nHeight : -1;
|
stats.nSyncHeight = state->pindexBestKnownBlock ? state->pindexBestKnownBlock->nHeight : -1;
|
||||||
stats.nCommonHeight = state->pindexLastCommonBlock ? state->pindexLastCommonBlock->nHeight : -1;
|
stats.nCommonHeight = state->pindexLastCommonBlock ? state->pindexLastCommonBlock->nHeight : -1;
|
||||||
BOOST_FOREACH(const QueuedBlock& queue, state->vBlocksInFlight) {
|
for (const QueuedBlock& queue : state->vBlocksInFlight) {
|
||||||
if (queue.pindex)
|
if (queue.pindex)
|
||||||
stats.vHeightInFlight.push_back(queue.pindex->nHeight);
|
stats.vHeightInFlight.push_back(queue.pindex->nHeight);
|
||||||
}
|
}
|
||||||
|
@ -627,7 +627,7 @@ bool AddOrphanTx(const CTransactionRef& tx, NodeId peer) EXCLUSIVE_LOCKS_REQUIRE
|
||||||
|
|
||||||
auto ret = mapOrphanTransactions.emplace(hash, COrphanTx{tx, peer, GetTime() + ORPHAN_TX_EXPIRE_TIME});
|
auto ret = mapOrphanTransactions.emplace(hash, COrphanTx{tx, peer, GetTime() + ORPHAN_TX_EXPIRE_TIME});
|
||||||
assert(ret.second);
|
assert(ret.second);
|
||||||
BOOST_FOREACH(const CTxIn& txin, tx->vin) {
|
for (const CTxIn& txin : tx->vin) {
|
||||||
mapOrphanTransactionsByPrev[txin.prevout].insert(ret.first);
|
mapOrphanTransactionsByPrev[txin.prevout].insert(ret.first);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -643,7 +643,7 @@ int static EraseOrphanTx(uint256 hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
|
||||||
std::map<uint256, COrphanTx>::iterator it = mapOrphanTransactions.find(hash);
|
std::map<uint256, COrphanTx>::iterator it = mapOrphanTransactions.find(hash);
|
||||||
if (it == mapOrphanTransactions.end())
|
if (it == mapOrphanTransactions.end())
|
||||||
return 0;
|
return 0;
|
||||||
BOOST_FOREACH(const CTxIn& txin, it->second.tx->vin)
|
for (const CTxIn& txin : it->second.tx->vin)
|
||||||
{
|
{
|
||||||
auto itPrev = mapOrphanTransactionsByPrev.find(txin.prevout);
|
auto itPrev = mapOrphanTransactionsByPrev.find(txin.prevout);
|
||||||
if (itPrev == mapOrphanTransactionsByPrev.end())
|
if (itPrev == mapOrphanTransactionsByPrev.end())
|
||||||
|
@ -768,7 +768,7 @@ void PeerLogicValidation::BlockConnected(const std::shared_ptr<const CBlock>& pb
|
||||||
// Erase orphan transactions include or precluded by this block
|
// Erase orphan transactions include or precluded by this block
|
||||||
if (vOrphanErase.size()) {
|
if (vOrphanErase.size()) {
|
||||||
int nErased = 0;
|
int nErased = 0;
|
||||||
BOOST_FOREACH(uint256 &orphanHash, vOrphanErase) {
|
for (uint256 &orphanHash : vOrphanErase) {
|
||||||
nErased += EraseOrphanTx(orphanHash);
|
nErased += EraseOrphanTx(orphanHash);
|
||||||
}
|
}
|
||||||
LogPrint(BCLog::MEMPOOL, "Erased %d orphan tx included or conflicted by block\n", nErased);
|
LogPrint(BCLog::MEMPOOL, "Erased %d orphan tx included or conflicted by block\n", nErased);
|
||||||
|
@ -1078,7 +1078,7 @@ void static ProcessGetData(CNode* pfrom, const Consensus::Params& consensusParam
|
||||||
// Thus, the protocol spec specified allows for us to provide duplicate txn here,
|
// Thus, the protocol spec specified allows for us to provide duplicate txn here,
|
||||||
// however we MUST always provide at least what the remote peer needs
|
// however we MUST always provide at least what the remote peer needs
|
||||||
typedef std::pair<unsigned int, uint256> PairType;
|
typedef std::pair<unsigned int, uint256> PairType;
|
||||||
BOOST_FOREACH(PairType& pair, merkleBlock.vMatchedTxn)
|
for (PairType& pair : merkleBlock.vMatchedTxn)
|
||||||
connman.PushMessage(pfrom, msgMaker.Make(SERIALIZE_TRANSACTION_NO_WITNESS, NetMsgType::TX, *pblock->vtx[pair.first]));
|
connman.PushMessage(pfrom, msgMaker.Make(SERIALIZE_TRANSACTION_NO_WITNESS, NetMsgType::TX, *pblock->vtx[pair.first]));
|
||||||
}
|
}
|
||||||
// else
|
// else
|
||||||
|
@ -1473,7 +1473,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
|
||||||
std::vector<CAddress> vAddrOk;
|
std::vector<CAddress> vAddrOk;
|
||||||
int64_t nNow = GetAdjustedTime();
|
int64_t nNow = GetAdjustedTime();
|
||||||
int64_t nSince = nNow - 10 * 60;
|
int64_t nSince = nNow - 10 * 60;
|
||||||
BOOST_FOREACH(CAddress& addr, vAddr)
|
for (CAddress& addr : vAddr)
|
||||||
{
|
{
|
||||||
if (interruptMsgProc)
|
if (interruptMsgProc)
|
||||||
return true;
|
return true;
|
||||||
|
@ -1883,13 +1883,13 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_FOREACH(uint256 hash, vEraseQueue)
|
for (uint256 hash : vEraseQueue)
|
||||||
EraseOrphanTx(hash);
|
EraseOrphanTx(hash);
|
||||||
}
|
}
|
||||||
else if (fMissingInputs)
|
else if (fMissingInputs)
|
||||||
{
|
{
|
||||||
bool fRejectedParents = false; // It may be the case that the orphans parents have all been rejected
|
bool fRejectedParents = false; // It may be the case that the orphans parents have all been rejected
|
||||||
BOOST_FOREACH(const CTxIn& txin, tx.vin) {
|
for (const CTxIn& txin : tx.vin) {
|
||||||
if (recentRejects->contains(txin.prevout.hash)) {
|
if (recentRejects->contains(txin.prevout.hash)) {
|
||||||
fRejectedParents = true;
|
fRejectedParents = true;
|
||||||
break;
|
break;
|
||||||
|
@ -1897,7 +1897,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
|
||||||
}
|
}
|
||||||
if (!fRejectedParents) {
|
if (!fRejectedParents) {
|
||||||
uint32_t nFetchFlags = GetFetchFlags(pfrom);
|
uint32_t nFetchFlags = GetFetchFlags(pfrom);
|
||||||
BOOST_FOREACH(const CTxIn& txin, tx.vin) {
|
for (const CTxIn& txin : tx.vin) {
|
||||||
CInv _inv(MSG_TX | nFetchFlags, txin.prevout.hash);
|
CInv _inv(MSG_TX | nFetchFlags, txin.prevout.hash);
|
||||||
pfrom->AddInventoryKnown(_inv);
|
pfrom->AddInventoryKnown(_inv);
|
||||||
if (!AlreadyHave(_inv)) pfrom->AskFor(_inv);
|
if (!AlreadyHave(_inv)) pfrom->AskFor(_inv);
|
||||||
|
@ -2433,7 +2433,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
|
||||||
pfrom->vAddrToSend.clear();
|
pfrom->vAddrToSend.clear();
|
||||||
std::vector<CAddress> vAddr = connman.GetAddresses();
|
std::vector<CAddress> vAddr = connman.GetAddresses();
|
||||||
FastRandomContext insecure_rand;
|
FastRandomContext insecure_rand;
|
||||||
BOOST_FOREACH(const CAddress &addr, vAddr)
|
for (const CAddress &addr : vAddr)
|
||||||
pfrom->PushAddress(addr, insecure_rand);
|
pfrom->PushAddress(addr, insecure_rand);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2627,7 +2627,7 @@ static bool SendRejectsAndCheckIfBanned(CNode* pnode, CConnman& connman)
|
||||||
AssertLockHeld(cs_main);
|
AssertLockHeld(cs_main);
|
||||||
CNodeState &state = *State(pnode->GetId());
|
CNodeState &state = *State(pnode->GetId());
|
||||||
|
|
||||||
BOOST_FOREACH(const CBlockReject& reject, state.rejects) {
|
for (const CBlockReject& reject : state.rejects) {
|
||||||
connman.PushMessage(pnode, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::REJECT, (std::string)NetMsgType::BLOCK, reject.chRejectCode, reject.strRejectReason, reject.hashBlock));
|
connman.PushMessage(pnode, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::REJECT, (std::string)NetMsgType::BLOCK, reject.chRejectCode, reject.strRejectReason, reject.hashBlock));
|
||||||
}
|
}
|
||||||
state.rejects.clear();
|
state.rejects.clear();
|
||||||
|
@ -2851,7 +2851,7 @@ bool SendMessages(CNode* pto, CConnman& connman, const std::atomic<bool>& interr
|
||||||
pto->nNextAddrSend = PoissonNextSend(nNow, AVG_ADDRESS_BROADCAST_INTERVAL);
|
pto->nNextAddrSend = PoissonNextSend(nNow, AVG_ADDRESS_BROADCAST_INTERVAL);
|
||||||
std::vector<CAddress> vAddr;
|
std::vector<CAddress> vAddr;
|
||||||
vAddr.reserve(pto->vAddrToSend.size());
|
vAddr.reserve(pto->vAddrToSend.size());
|
||||||
BOOST_FOREACH(const CAddress& addr, pto->vAddrToSend)
|
for (const CAddress& addr : pto->vAddrToSend)
|
||||||
{
|
{
|
||||||
if (!pto->addrKnown.contains(addr.GetKey()))
|
if (!pto->addrKnown.contains(addr.GetKey()))
|
||||||
{
|
{
|
||||||
|
@ -2929,7 +2929,7 @@ bool SendMessages(CNode* pto, CConnman& connman, const std::atomic<bool>& interr
|
||||||
// Try to find first header that our peer doesn't have, and
|
// Try to find first header that our peer doesn't have, and
|
||||||
// then send all headers past that one. If we come across any
|
// then send all headers past that one. If we come across any
|
||||||
// headers that aren't on chainActive, give up.
|
// headers that aren't on chainActive, give up.
|
||||||
BOOST_FOREACH(const uint256 &hash, pto->vBlockHashesToAnnounce) {
|
for (const uint256 &hash : pto->vBlockHashesToAnnounce) {
|
||||||
BlockMap::iterator mi = mapBlockIndex.find(hash);
|
BlockMap::iterator mi = mapBlockIndex.find(hash);
|
||||||
assert(mi != mapBlockIndex.end());
|
assert(mi != mapBlockIndex.end());
|
||||||
const CBlockIndex *pindex = mi->second;
|
const CBlockIndex *pindex = mi->second;
|
||||||
|
@ -3055,7 +3055,7 @@ bool SendMessages(CNode* pto, CConnman& connman, const std::atomic<bool>& interr
|
||||||
vInv.reserve(std::max<size_t>(pto->vInventoryBlockToSend.size(), INVENTORY_BROADCAST_MAX));
|
vInv.reserve(std::max<size_t>(pto->vInventoryBlockToSend.size(), INVENTORY_BROADCAST_MAX));
|
||||||
|
|
||||||
// Add blocks
|
// Add blocks
|
||||||
BOOST_FOREACH(const uint256& hash, pto->vInventoryBlockToSend) {
|
for (const uint256& hash : pto->vInventoryBlockToSend) {
|
||||||
vInv.push_back(CInv(MSG_BLOCK, hash));
|
vInv.push_back(CInv(MSG_BLOCK, hash));
|
||||||
if (vInv.size() == MAX_INV_SZ) {
|
if (vInv.size() == MAX_INV_SZ) {
|
||||||
connman.PushMessage(pto, msgMaker.Make(NetMsgType::INV, vInv));
|
connman.PushMessage(pto, msgMaker.Make(NetMsgType::INV, vInv));
|
||||||
|
@ -3213,7 +3213,7 @@ bool SendMessages(CNode* pto, CConnman& connman, const std::atomic<bool>& interr
|
||||||
std::vector<const CBlockIndex*> vToDownload;
|
std::vector<const CBlockIndex*> vToDownload;
|
||||||
NodeId staller = -1;
|
NodeId staller = -1;
|
||||||
FindNextBlocksToDownload(pto->GetId(), MAX_BLOCKS_IN_TRANSIT_PER_PEER - state.nBlocksInFlight, vToDownload, staller, consensusParams);
|
FindNextBlocksToDownload(pto->GetId(), MAX_BLOCKS_IN_TRANSIT_PER_PEER - state.nBlocksInFlight, vToDownload, staller, consensusParams);
|
||||||
BOOST_FOREACH(const CBlockIndex *pindex, vToDownload) {
|
for (const CBlockIndex *pindex : vToDownload) {
|
||||||
uint32_t nFetchFlags = GetFetchFlags(pto);
|
uint32_t nFetchFlags = GetFetchFlags(pto);
|
||||||
vGetData.push_back(CInv(MSG_BLOCK | nFetchFlags, pindex->GetBlockHash()));
|
vGetData.push_back(CInv(MSG_BLOCK | nFetchFlags, pindex->GetBlockHash()));
|
||||||
MarkBlockAsInFlight(pto->GetId(), pindex->GetBlockHash(), pindex);
|
MarkBlockAsInFlight(pto->GetId(), pindex->GetBlockHash(), pindex);
|
||||||
|
|
|
@ -111,7 +111,7 @@ bool IsStandardTx(const CTransaction& tx, std::string& reason, const bool witnes
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_FOREACH(const CTxIn& txin, tx.vin)
|
for (const CTxIn& txin : tx.vin)
|
||||||
{
|
{
|
||||||
// Biggest 'standard' txin is a 15-of-15 P2SH multisig with compressed
|
// Biggest 'standard' txin is a 15-of-15 P2SH multisig with compressed
|
||||||
// keys (remember the 520 byte limit on redeemScript size). That works
|
// keys (remember the 520 byte limit on redeemScript size). That works
|
||||||
|
@ -132,7 +132,7 @@ bool IsStandardTx(const CTransaction& tx, std::string& reason, const bool witnes
|
||||||
|
|
||||||
unsigned int nDataOut = 0;
|
unsigned int nDataOut = 0;
|
||||||
txnouttype whichType;
|
txnouttype whichType;
|
||||||
BOOST_FOREACH(const CTxOut& txout, tx.vout) {
|
for (const CTxOut& txout : tx.vout) {
|
||||||
if (!::IsStandard(txout.scriptPubKey, whichType, witnessEnabled)) {
|
if (!::IsStandard(txout.scriptPubKey, whichType, witnessEnabled)) {
|
||||||
reason = "scriptpubkey";
|
reason = "scriptpubkey";
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
bool SignalsOptInRBF(const CTransaction &tx)
|
bool SignalsOptInRBF(const CTransaction &tx)
|
||||||
{
|
{
|
||||||
BOOST_FOREACH(const CTxIn &txin, tx.vin) {
|
for (const CTxIn &txin : tx.vin) {
|
||||||
if (txin.nSequence < std::numeric_limits<unsigned int>::max()-1) {
|
if (txin.nSequence < std::numeric_limits<unsigned int>::max()-1) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ RBFTransactionState IsRBFOptIn(const CTransaction &tx, CTxMemPool &pool)
|
||||||
CTxMemPoolEntry entry = *pool.mapTx.find(tx.GetHash());
|
CTxMemPoolEntry entry = *pool.mapTx.find(tx.GetHash());
|
||||||
pool.CalculateMemPoolAncestors(entry, setAncestors, noLimit, noLimit, noLimit, noLimit, dummy, false);
|
pool.CalculateMemPoolAncestors(entry, setAncestors, noLimit, noLimit, noLimit, noLimit, dummy, false);
|
||||||
|
|
||||||
BOOST_FOREACH(CTxMemPool::txiter it, setAncestors) {
|
for (CTxMemPool::txiter it : setAncestors) {
|
||||||
if (SignalsOptInRBF(it->GetTx())) {
|
if (SignalsOptInRBF(it->GetTx())) {
|
||||||
return RBF_TRANSACTIONSTATE_REPLACEABLE_BIP125;
|
return RBF_TRANSACTIONSTATE_REPLACEABLE_BIP125;
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,7 @@ public:
|
||||||
cachedAddressTable.clear();
|
cachedAddressTable.clear();
|
||||||
{
|
{
|
||||||
LOCK(wallet->cs_wallet);
|
LOCK(wallet->cs_wallet);
|
||||||
BOOST_FOREACH(const PAIRTYPE(CTxDestination, CAddressBookData)& item, wallet->mapAddressBook)
|
for (const PAIRTYPE(CTxDestination, CAddressBookData)& item : wallet->mapAddressBook)
|
||||||
{
|
{
|
||||||
const CBitcoinAddress& address = item.first;
|
const CBitcoinAddress& address = item.first;
|
||||||
bool fMine = IsMine(*wallet, address.Get());
|
bool fMine = IsMine(*wallet, address.Get());
|
||||||
|
|
|
@ -452,7 +452,7 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
|
||||||
coinControl->ListSelected(vCoinControl);
|
coinControl->ListSelected(vCoinControl);
|
||||||
model->getOutputs(vCoinControl, vOutputs);
|
model->getOutputs(vCoinControl, vOutputs);
|
||||||
|
|
||||||
BOOST_FOREACH(const COutput& out, vOutputs) {
|
for (const COutput& out : vOutputs) {
|
||||||
// unselect already spent, very unlikely scenario, this could happen
|
// unselect already spent, very unlikely scenario, this could happen
|
||||||
// when selected are spent elsewhere, like rpc or another computer
|
// when selected are spent elsewhere, like rpc or another computer
|
||||||
uint256 txhash = out.tx->GetHash();
|
uint256 txhash = out.tx->GetHash();
|
||||||
|
@ -628,7 +628,7 @@ void CoinControlDialog::updateView()
|
||||||
std::map<QString, std::vector<COutput> > mapCoins;
|
std::map<QString, std::vector<COutput> > mapCoins;
|
||||||
model->listCoins(mapCoins);
|
model->listCoins(mapCoins);
|
||||||
|
|
||||||
BOOST_FOREACH(const PAIRTYPE(QString, std::vector<COutput>)& coins, mapCoins) {
|
for (const PAIRTYPE(QString, std::vector<COutput>)& coins : mapCoins) {
|
||||||
CCoinControlWidgetItem *itemWalletAddress = new CCoinControlWidgetItem();
|
CCoinControlWidgetItem *itemWalletAddress = new CCoinControlWidgetItem();
|
||||||
itemWalletAddress->setCheckState(COLUMN_CHECKBOX, Qt::Unchecked);
|
itemWalletAddress->setCheckState(COLUMN_CHECKBOX, Qt::Unchecked);
|
||||||
QString sWalletAddress = coins.first;
|
QString sWalletAddress = coins.first;
|
||||||
|
@ -653,7 +653,7 @@ void CoinControlDialog::updateView()
|
||||||
|
|
||||||
CAmount nSum = 0;
|
CAmount nSum = 0;
|
||||||
int nChildren = 0;
|
int nChildren = 0;
|
||||||
BOOST_FOREACH(const COutput& out, coins.second) {
|
for (const COutput& out : coins.second) {
|
||||||
nSum += out.tx->tx->vout[out.i].nValue;
|
nSum += out.tx->tx->vout[out.i].nValue;
|
||||||
nChildren++;
|
nChildren++;
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ public:
|
||||||
TRY_LOCK(cs_main, lockMain);
|
TRY_LOCK(cs_main, lockMain);
|
||||||
if (lockMain)
|
if (lockMain)
|
||||||
{
|
{
|
||||||
BOOST_FOREACH(CNodeCombinedStats &stats, cachedNodeStats)
|
for (CNodeCombinedStats &stats : cachedNodeStats)
|
||||||
stats.fNodeStateStatsAvailable = GetNodeStateStats(stats.nodeStats.nodeid, stats.nodeStateStats);
|
stats.fNodeStateStatsAvailable = GetNodeStateStats(stats.nodeStats.nodeid, stats.nodeStateStats);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ RecentRequestsTableModel::RecentRequestsTableModel(CWallet *wallet, WalletModel
|
||||||
// Load entries from wallet
|
// Load entries from wallet
|
||||||
std::vector<std::string> vReceiveRequests;
|
std::vector<std::string> vReceiveRequests;
|
||||||
parent->loadReceiveRequests(vReceiveRequests);
|
parent->loadReceiveRequests(vReceiveRequests);
|
||||||
BOOST_FOREACH(const std::string& request, vReceiveRequests)
|
for (const std::string& request : vReceiveRequests)
|
||||||
addNewRequest(request);
|
addNewRequest(request);
|
||||||
|
|
||||||
/* These columns must match the indices in the ColumnIndex enumeration */
|
/* These columns must match the indices in the ColumnIndex enumeration */
|
||||||
|
|
|
@ -133,7 +133,7 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco
|
||||||
// Coinbase
|
// Coinbase
|
||||||
//
|
//
|
||||||
CAmount nUnmatured = 0;
|
CAmount nUnmatured = 0;
|
||||||
BOOST_FOREACH(const CTxOut& txout, wtx.tx->vout)
|
for (const CTxOut& txout : wtx.tx->vout)
|
||||||
nUnmatured += wallet->GetCredit(txout, ISMINE_ALL);
|
nUnmatured += wallet->GetCredit(txout, ISMINE_ALL);
|
||||||
strHTML += "<b>" + tr("Credit") + ":</b> ";
|
strHTML += "<b>" + tr("Credit") + ":</b> ";
|
||||||
if (wtx.IsInMainChain())
|
if (wtx.IsInMainChain())
|
||||||
|
@ -152,14 +152,14 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
isminetype fAllFromMe = ISMINE_SPENDABLE;
|
isminetype fAllFromMe = ISMINE_SPENDABLE;
|
||||||
BOOST_FOREACH(const CTxIn& txin, wtx.tx->vin)
|
for (const CTxIn& txin : wtx.tx->vin)
|
||||||
{
|
{
|
||||||
isminetype mine = wallet->IsMine(txin);
|
isminetype mine = wallet->IsMine(txin);
|
||||||
if(fAllFromMe > mine) fAllFromMe = mine;
|
if(fAllFromMe > mine) fAllFromMe = mine;
|
||||||
}
|
}
|
||||||
|
|
||||||
isminetype fAllToMe = ISMINE_SPENDABLE;
|
isminetype fAllToMe = ISMINE_SPENDABLE;
|
||||||
BOOST_FOREACH(const CTxOut& txout, wtx.tx->vout)
|
for (const CTxOut& txout : wtx.tx->vout)
|
||||||
{
|
{
|
||||||
isminetype mine = wallet->IsMine(txout);
|
isminetype mine = wallet->IsMine(txout);
|
||||||
if(fAllToMe > mine) fAllToMe = mine;
|
if(fAllToMe > mine) fAllToMe = mine;
|
||||||
|
@ -173,7 +173,7 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco
|
||||||
//
|
//
|
||||||
// Debit
|
// Debit
|
||||||
//
|
//
|
||||||
BOOST_FOREACH(const CTxOut& txout, wtx.tx->vout)
|
for (const CTxOut& txout : wtx.tx->vout)
|
||||||
{
|
{
|
||||||
// Ignore change
|
// Ignore change
|
||||||
isminetype toSelf = wallet->IsMine(txout);
|
isminetype toSelf = wallet->IsMine(txout);
|
||||||
|
@ -221,10 +221,10 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco
|
||||||
//
|
//
|
||||||
// Mixed debit transaction
|
// Mixed debit transaction
|
||||||
//
|
//
|
||||||
BOOST_FOREACH(const CTxIn& txin, wtx.tx->vin)
|
for (const CTxIn& txin : wtx.tx->vin)
|
||||||
if (wallet->IsMine(txin))
|
if (wallet->IsMine(txin))
|
||||||
strHTML += "<b>" + tr("Debit") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, -wallet->GetDebit(txin, ISMINE_ALL)) + "<br>";
|
strHTML += "<b>" + tr("Debit") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, -wallet->GetDebit(txin, ISMINE_ALL)) + "<br>";
|
||||||
BOOST_FOREACH(const CTxOut& txout, wtx.tx->vout)
|
for (const CTxOut& txout : wtx.tx->vout)
|
||||||
if (wallet->IsMine(txout))
|
if (wallet->IsMine(txout))
|
||||||
strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, wallet->GetCredit(txout, ISMINE_ALL)) + "<br>";
|
strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, wallet->GetCredit(txout, ISMINE_ALL)) + "<br>";
|
||||||
}
|
}
|
||||||
|
@ -276,10 +276,10 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco
|
||||||
if (logCategories != BCLog::NONE)
|
if (logCategories != BCLog::NONE)
|
||||||
{
|
{
|
||||||
strHTML += "<hr><br>" + tr("Debug information") + "<br><br>";
|
strHTML += "<hr><br>" + tr("Debug information") + "<br><br>";
|
||||||
BOOST_FOREACH(const CTxIn& txin, wtx.tx->vin)
|
for (const CTxIn& txin : wtx.tx->vin)
|
||||||
if(wallet->IsMine(txin))
|
if(wallet->IsMine(txin))
|
||||||
strHTML += "<b>" + tr("Debit") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, -wallet->GetDebit(txin, ISMINE_ALL)) + "<br>";
|
strHTML += "<b>" + tr("Debit") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, -wallet->GetDebit(txin, ISMINE_ALL)) + "<br>";
|
||||||
BOOST_FOREACH(const CTxOut& txout, wtx.tx->vout)
|
for (const CTxOut& txout : wtx.tx->vout)
|
||||||
if(wallet->IsMine(txout))
|
if(wallet->IsMine(txout))
|
||||||
strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, wallet->GetCredit(txout, ISMINE_ALL)) + "<br>";
|
strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, wallet->GetCredit(txout, ISMINE_ALL)) + "<br>";
|
||||||
|
|
||||||
|
@ -289,7 +289,7 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco
|
||||||
strHTML += "<br><b>" + tr("Inputs") + ":</b>";
|
strHTML += "<br><b>" + tr("Inputs") + ":</b>";
|
||||||
strHTML += "<ul>";
|
strHTML += "<ul>";
|
||||||
|
|
||||||
BOOST_FOREACH(const CTxIn& txin, wtx.tx->vin)
|
for (const CTxIn& txin : wtx.tx->vin)
|
||||||
{
|
{
|
||||||
COutPoint prevout = txin.prevout;
|
COutPoint prevout = txin.prevout;
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,7 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
|
||||||
{
|
{
|
||||||
bool involvesWatchAddress = false;
|
bool involvesWatchAddress = false;
|
||||||
isminetype fAllFromMe = ISMINE_SPENDABLE;
|
isminetype fAllFromMe = ISMINE_SPENDABLE;
|
||||||
BOOST_FOREACH(const CTxIn& txin, wtx.tx->vin)
|
for (const CTxIn& txin : wtx.tx->vin)
|
||||||
{
|
{
|
||||||
isminetype mine = wallet->IsMine(txin);
|
isminetype mine = wallet->IsMine(txin);
|
||||||
if(mine & ISMINE_WATCH_ONLY) involvesWatchAddress = true;
|
if(mine & ISMINE_WATCH_ONLY) involvesWatchAddress = true;
|
||||||
|
@ -86,7 +86,7 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
|
||||||
}
|
}
|
||||||
|
|
||||||
isminetype fAllToMe = ISMINE_SPENDABLE;
|
isminetype fAllToMe = ISMINE_SPENDABLE;
|
||||||
BOOST_FOREACH(const CTxOut& txout, wtx.tx->vout)
|
for (const CTxOut& txout : wtx.tx->vout)
|
||||||
{
|
{
|
||||||
isminetype mine = wallet->IsMine(txout);
|
isminetype mine = wallet->IsMine(txout);
|
||||||
if(mine & ISMINE_WATCH_ONLY) involvesWatchAddress = true;
|
if(mine & ISMINE_WATCH_ONLY) involvesWatchAddress = true;
|
||||||
|
|
|
@ -574,7 +574,7 @@ bool WalletModel::getPrivKey(const CKeyID &address, CKey& vchPrivKeyOut) const
|
||||||
void WalletModel::getOutputs(const std::vector<COutPoint>& vOutpoints, std::vector<COutput>& vOutputs)
|
void WalletModel::getOutputs(const std::vector<COutPoint>& vOutpoints, std::vector<COutput>& vOutputs)
|
||||||
{
|
{
|
||||||
LOCK2(cs_main, wallet->cs_wallet);
|
LOCK2(cs_main, wallet->cs_wallet);
|
||||||
BOOST_FOREACH(const COutPoint& outpoint, vOutpoints)
|
for (const COutPoint& outpoint : vOutpoints)
|
||||||
{
|
{
|
||||||
if (!wallet->mapWallet.count(outpoint.hash)) continue;
|
if (!wallet->mapWallet.count(outpoint.hash)) continue;
|
||||||
int nDepth = wallet->mapWallet[outpoint.hash].GetDepthInMainChain();
|
int nDepth = wallet->mapWallet[outpoint.hash].GetDepthInMainChain();
|
||||||
|
|
|
@ -158,7 +158,7 @@ static bool rest_headers(HTTPRequest* req,
|
||||||
}
|
}
|
||||||
|
|
||||||
CDataStream ssHeader(SER_NETWORK, PROTOCOL_VERSION);
|
CDataStream ssHeader(SER_NETWORK, PROTOCOL_VERSION);
|
||||||
BOOST_FOREACH(const CBlockIndex *pindex, headers) {
|
for (const CBlockIndex *pindex : headers) {
|
||||||
ssHeader << pindex->GetBlockHeader();
|
ssHeader << pindex->GetBlockHeader();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@ static bool rest_headers(HTTPRequest* req,
|
||||||
}
|
}
|
||||||
case RF_JSON: {
|
case RF_JSON: {
|
||||||
UniValue jsonHeaders(UniValue::VARR);
|
UniValue jsonHeaders(UniValue::VARR);
|
||||||
BOOST_FOREACH(const CBlockIndex *pindex, headers) {
|
for (const CBlockIndex *pindex : headers) {
|
||||||
jsonHeaders.push_back(blockheaderToJSON(pindex));
|
jsonHeaders.push_back(blockheaderToJSON(pindex));
|
||||||
}
|
}
|
||||||
std::string strJSON = jsonHeaders.write() + "\n";
|
std::string strJSON = jsonHeaders.write() + "\n";
|
||||||
|
@ -558,7 +558,7 @@ static bool rest_getutxos(HTTPRequest* req, const std::string& strURIPart)
|
||||||
objGetUTXOResponse.push_back(Pair("bitmap", bitmapStringRepresentation));
|
objGetUTXOResponse.push_back(Pair("bitmap", bitmapStringRepresentation));
|
||||||
|
|
||||||
UniValue utxos(UniValue::VARR);
|
UniValue utxos(UniValue::VARR);
|
||||||
BOOST_FOREACH (const CCoin& coin, outs) {
|
for (const CCoin& coin : outs) {
|
||||||
UniValue utxo(UniValue::VOBJ);
|
UniValue utxo(UniValue::VOBJ);
|
||||||
utxo.push_back(Pair("height", (int32_t)coin.nHeight));
|
utxo.push_back(Pair("height", (int32_t)coin.nHeight));
|
||||||
utxo.push_back(Pair("value", ValueFromAmount(coin.out.nValue)));
|
utxo.push_back(Pair("value", ValueFromAmount(coin.out.nValue)));
|
||||||
|
|
|
@ -364,14 +364,14 @@ void entryToJSON(UniValue &info, const CTxMemPoolEntry &e)
|
||||||
info.push_back(Pair("ancestorfees", e.GetModFeesWithAncestors()));
|
info.push_back(Pair("ancestorfees", e.GetModFeesWithAncestors()));
|
||||||
const CTransaction& tx = e.GetTx();
|
const CTransaction& tx = e.GetTx();
|
||||||
std::set<std::string> setDepends;
|
std::set<std::string> setDepends;
|
||||||
BOOST_FOREACH(const CTxIn& txin, tx.vin)
|
for (const CTxIn& txin : tx.vin)
|
||||||
{
|
{
|
||||||
if (mempool.exists(txin.prevout.hash))
|
if (mempool.exists(txin.prevout.hash))
|
||||||
setDepends.insert(txin.prevout.hash.ToString());
|
setDepends.insert(txin.prevout.hash.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
UniValue depends(UniValue::VARR);
|
UniValue depends(UniValue::VARR);
|
||||||
BOOST_FOREACH(const std::string& dep, setDepends)
|
for (const std::string& dep : setDepends)
|
||||||
{
|
{
|
||||||
depends.push_back(dep);
|
depends.push_back(dep);
|
||||||
}
|
}
|
||||||
|
@ -385,7 +385,7 @@ UniValue mempoolToJSON(bool fVerbose)
|
||||||
{
|
{
|
||||||
LOCK(mempool.cs);
|
LOCK(mempool.cs);
|
||||||
UniValue o(UniValue::VOBJ);
|
UniValue o(UniValue::VOBJ);
|
||||||
BOOST_FOREACH(const CTxMemPoolEntry& e, mempool.mapTx)
|
for (const CTxMemPoolEntry& e : mempool.mapTx)
|
||||||
{
|
{
|
||||||
const uint256& hash = e.GetTx().GetHash();
|
const uint256& hash = e.GetTx().GetHash();
|
||||||
UniValue info(UniValue::VOBJ);
|
UniValue info(UniValue::VOBJ);
|
||||||
|
@ -400,7 +400,7 @@ UniValue mempoolToJSON(bool fVerbose)
|
||||||
mempool.queryHashes(vtxid);
|
mempool.queryHashes(vtxid);
|
||||||
|
|
||||||
UniValue a(UniValue::VARR);
|
UniValue a(UniValue::VARR);
|
||||||
BOOST_FOREACH(const uint256& hash, vtxid)
|
for (const uint256& hash : vtxid)
|
||||||
a.push_back(hash.ToString());
|
a.push_back(hash.ToString());
|
||||||
|
|
||||||
return a;
|
return a;
|
||||||
|
@ -485,14 +485,14 @@ UniValue getmempoolancestors(const JSONRPCRequest& request)
|
||||||
|
|
||||||
if (!fVerbose) {
|
if (!fVerbose) {
|
||||||
UniValue o(UniValue::VARR);
|
UniValue o(UniValue::VARR);
|
||||||
BOOST_FOREACH(CTxMemPool::txiter ancestorIt, setAncestors) {
|
for (CTxMemPool::txiter ancestorIt : setAncestors) {
|
||||||
o.push_back(ancestorIt->GetTx().GetHash().ToString());
|
o.push_back(ancestorIt->GetTx().GetHash().ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return o;
|
return o;
|
||||||
} else {
|
} else {
|
||||||
UniValue o(UniValue::VOBJ);
|
UniValue o(UniValue::VOBJ);
|
||||||
BOOST_FOREACH(CTxMemPool::txiter ancestorIt, setAncestors) {
|
for (CTxMemPool::txiter ancestorIt : setAncestors) {
|
||||||
const CTxMemPoolEntry &e = *ancestorIt;
|
const CTxMemPoolEntry &e = *ancestorIt;
|
||||||
const uint256& _hash = e.GetTx().GetHash();
|
const uint256& _hash = e.GetTx().GetHash();
|
||||||
UniValue info(UniValue::VOBJ);
|
UniValue info(UniValue::VOBJ);
|
||||||
|
@ -549,14 +549,14 @@ UniValue getmempooldescendants(const JSONRPCRequest& request)
|
||||||
|
|
||||||
if (!fVerbose) {
|
if (!fVerbose) {
|
||||||
UniValue o(UniValue::VARR);
|
UniValue o(UniValue::VARR);
|
||||||
BOOST_FOREACH(CTxMemPool::txiter descendantIt, setDescendants) {
|
for (CTxMemPool::txiter descendantIt : setDescendants) {
|
||||||
o.push_back(descendantIt->GetTx().GetHash().ToString());
|
o.push_back(descendantIt->GetTx().GetHash().ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return o;
|
return o;
|
||||||
} else {
|
} else {
|
||||||
UniValue o(UniValue::VOBJ);
|
UniValue o(UniValue::VOBJ);
|
||||||
BOOST_FOREACH(CTxMemPool::txiter descendantIt, setDescendants) {
|
for (CTxMemPool::txiter descendantIt : setDescendants) {
|
||||||
const CTxMemPoolEntry &e = *descendantIt;
|
const CTxMemPoolEntry &e = *descendantIt;
|
||||||
const uint256& _hash = e.GetTx().GetHash();
|
const uint256& _hash = e.GetTx().GetHash();
|
||||||
UniValue info(UniValue::VOBJ);
|
UniValue info(UniValue::VOBJ);
|
||||||
|
@ -1256,7 +1256,7 @@ UniValue getchaintips(const JSONRPCRequest& request)
|
||||||
std::set<const CBlockIndex*> setOrphans;
|
std::set<const CBlockIndex*> setOrphans;
|
||||||
std::set<const CBlockIndex*> setPrevs;
|
std::set<const CBlockIndex*> setPrevs;
|
||||||
|
|
||||||
BOOST_FOREACH(const PAIRTYPE(const uint256, CBlockIndex*)& item, mapBlockIndex)
|
for (const PAIRTYPE(const uint256, CBlockIndex*)& item : mapBlockIndex)
|
||||||
{
|
{
|
||||||
if (!chainActive.Contains(item.second)) {
|
if (!chainActive.Contains(item.second)) {
|
||||||
setOrphans.insert(item.second);
|
setOrphans.insert(item.second);
|
||||||
|
@ -1276,7 +1276,7 @@ UniValue getchaintips(const JSONRPCRequest& request)
|
||||||
|
|
||||||
/* Construct the output array. */
|
/* Construct the output array. */
|
||||||
UniValue res(UniValue::VARR);
|
UniValue res(UniValue::VARR);
|
||||||
BOOST_FOREACH(const CBlockIndex* block, setTips)
|
for (const CBlockIndex* block : setTips)
|
||||||
{
|
{
|
||||||
UniValue obj(UniValue::VOBJ);
|
UniValue obj(UniValue::VOBJ);
|
||||||
obj.push_back(Pair("height", block->nHeight));
|
obj.push_back(Pair("height", block->nHeight));
|
||||||
|
|
|
@ -580,7 +580,7 @@ UniValue getblocktemplate(const JSONRPCRequest& request)
|
||||||
entry.push_back(Pair("hash", tx.GetWitnessHash().GetHex()));
|
entry.push_back(Pair("hash", tx.GetWitnessHash().GetHex()));
|
||||||
|
|
||||||
UniValue deps(UniValue::VARR);
|
UniValue deps(UniValue::VARR);
|
||||||
BOOST_FOREACH (const CTxIn &in, tx.vin)
|
for (const CTxIn &in : tx.vin)
|
||||||
{
|
{
|
||||||
if (setTxIndex.count(in.prevout.hash))
|
if (setTxIndex.count(in.prevout.hash))
|
||||||
deps.push_back(setTxIndex[in.prevout.hash]);
|
deps.push_back(setTxIndex[in.prevout.hash]);
|
||||||
|
|
|
@ -149,7 +149,7 @@ public:
|
||||||
obj.push_back(Pair("script", GetTxnOutputType(whichType)));
|
obj.push_back(Pair("script", GetTxnOutputType(whichType)));
|
||||||
obj.push_back(Pair("hex", HexStr(subscript.begin(), subscript.end())));
|
obj.push_back(Pair("hex", HexStr(subscript.begin(), subscript.end())));
|
||||||
UniValue a(UniValue::VARR);
|
UniValue a(UniValue::VARR);
|
||||||
BOOST_FOREACH(const CTxDestination& addr, addresses)
|
for (const CTxDestination& addr : addresses)
|
||||||
a.push_back(CBitcoinAddress(addr).ToString());
|
a.push_back(CBitcoinAddress(addr).ToString());
|
||||||
obj.push_back(Pair("addresses", a));
|
obj.push_back(Pair("addresses", a));
|
||||||
if (whichType == TX_MULTISIG)
|
if (whichType == TX_MULTISIG)
|
||||||
|
|
|
@ -126,7 +126,7 @@ UniValue getpeerinfo(const JSONRPCRequest& request)
|
||||||
|
|
||||||
UniValue ret(UniValue::VARR);
|
UniValue ret(UniValue::VARR);
|
||||||
|
|
||||||
BOOST_FOREACH(const CNodeStats& stats, vstats) {
|
for (const CNodeStats& stats : vstats) {
|
||||||
UniValue obj(UniValue::VOBJ);
|
UniValue obj(UniValue::VOBJ);
|
||||||
CNodeStateStats statestats;
|
CNodeStateStats statestats;
|
||||||
bool fStateStats = GetNodeStateStats(stats.nodeid, statestats);
|
bool fStateStats = GetNodeStateStats(stats.nodeid, statestats);
|
||||||
|
@ -163,7 +163,7 @@ UniValue getpeerinfo(const JSONRPCRequest& request)
|
||||||
obj.push_back(Pair("synced_headers", statestats.nSyncHeight));
|
obj.push_back(Pair("synced_headers", statestats.nSyncHeight));
|
||||||
obj.push_back(Pair("synced_blocks", statestats.nCommonHeight));
|
obj.push_back(Pair("synced_blocks", statestats.nCommonHeight));
|
||||||
UniValue heights(UniValue::VARR);
|
UniValue heights(UniValue::VARR);
|
||||||
BOOST_FOREACH(int height, statestats.vHeightInFlight) {
|
for (int height : statestats.vHeightInFlight) {
|
||||||
heights.push_back(height);
|
heights.push_back(height);
|
||||||
}
|
}
|
||||||
obj.push_back(Pair("inflight", heights));
|
obj.push_back(Pair("inflight", heights));
|
||||||
|
@ -171,14 +171,14 @@ UniValue getpeerinfo(const JSONRPCRequest& request)
|
||||||
obj.push_back(Pair("whitelisted", stats.fWhitelisted));
|
obj.push_back(Pair("whitelisted", stats.fWhitelisted));
|
||||||
|
|
||||||
UniValue sendPerMsgCmd(UniValue::VOBJ);
|
UniValue sendPerMsgCmd(UniValue::VOBJ);
|
||||||
BOOST_FOREACH(const mapMsgCmdSize::value_type &i, stats.mapSendBytesPerMsgCmd) {
|
for (const mapMsgCmdSize::value_type &i : stats.mapSendBytesPerMsgCmd) {
|
||||||
if (i.second > 0)
|
if (i.second > 0)
|
||||||
sendPerMsgCmd.push_back(Pair(i.first, i.second));
|
sendPerMsgCmd.push_back(Pair(i.first, i.second));
|
||||||
}
|
}
|
||||||
obj.push_back(Pair("bytessent_per_msg", sendPerMsgCmd));
|
obj.push_back(Pair("bytessent_per_msg", sendPerMsgCmd));
|
||||||
|
|
||||||
UniValue recvPerMsgCmd(UniValue::VOBJ);
|
UniValue recvPerMsgCmd(UniValue::VOBJ);
|
||||||
BOOST_FOREACH(const mapMsgCmdSize::value_type &i, stats.mapRecvBytesPerMsgCmd) {
|
for (const mapMsgCmdSize::value_type &i : stats.mapRecvBytesPerMsgCmd) {
|
||||||
if (i.second > 0)
|
if (i.second > 0)
|
||||||
recvPerMsgCmd.push_back(Pair(i.first, i.second));
|
recvPerMsgCmd.push_back(Pair(i.first, i.second));
|
||||||
}
|
}
|
||||||
|
@ -474,7 +474,7 @@ UniValue getnetworkinfo(const JSONRPCRequest& request)
|
||||||
UniValue localAddresses(UniValue::VARR);
|
UniValue localAddresses(UniValue::VARR);
|
||||||
{
|
{
|
||||||
LOCK(cs_mapLocalHost);
|
LOCK(cs_mapLocalHost);
|
||||||
BOOST_FOREACH(const PAIRTYPE(CNetAddr, LocalServiceInfo) &item, mapLocalHost)
|
for (const PAIRTYPE(CNetAddr, LocalServiceInfo) &item : mapLocalHost)
|
||||||
{
|
{
|
||||||
UniValue rec(UniValue::VOBJ);
|
UniValue rec(UniValue::VOBJ);
|
||||||
rec.push_back(Pair("address", item.first.ToString()));
|
rec.push_back(Pair("address", item.first.ToString()));
|
||||||
|
|
|
@ -282,7 +282,7 @@ UniValue verifytxoutproof(const JSONRPCRequest& request)
|
||||||
if (!mapBlockIndex.count(merkleBlock.header.GetHash()) || !chainActive.Contains(mapBlockIndex[merkleBlock.header.GetHash()]))
|
if (!mapBlockIndex.count(merkleBlock.header.GetHash()) || !chainActive.Contains(mapBlockIndex[merkleBlock.header.GetHash()]))
|
||||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found in chain");
|
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found in chain");
|
||||||
|
|
||||||
BOOST_FOREACH(const uint256& hash, vMatch)
|
for (const uint256& hash : vMatch)
|
||||||
res.push_back(hash.GetHex());
|
res.push_back(hash.GetHex());
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -373,7 +373,7 @@ UniValue createrawtransaction(const JSONRPCRequest& request)
|
||||||
|
|
||||||
std::set<CBitcoinAddress> setAddress;
|
std::set<CBitcoinAddress> setAddress;
|
||||||
std::vector<std::string> addrList = sendTo.getKeys();
|
std::vector<std::string> addrList = sendTo.getKeys();
|
||||||
BOOST_FOREACH(const std::string& name_, addrList) {
|
for (const std::string& name_ : addrList) {
|
||||||
|
|
||||||
if (name_ == "data") {
|
if (name_ == "data") {
|
||||||
std::vector<unsigned char> data = ParseHexV(sendTo[name_].getValStr(),"Data");
|
std::vector<unsigned char> data = ParseHexV(sendTo[name_].getValStr(),"Data");
|
||||||
|
@ -637,7 +637,7 @@ UniValue signrawtransaction(const JSONRPCRequest& request)
|
||||||
CCoinsViewMemPool viewMempool(&viewChain, mempool);
|
CCoinsViewMemPool viewMempool(&viewChain, mempool);
|
||||||
view.SetBackend(viewMempool); // temporarily switch cache backend to db+mempool view
|
view.SetBackend(viewMempool); // temporarily switch cache backend to db+mempool view
|
||||||
|
|
||||||
BOOST_FOREACH(const CTxIn& txin, mergedTx.vin) {
|
for (const CTxIn& txin : mergedTx.vin) {
|
||||||
view.AccessCoin(txin.prevout); // Load entries from viewChain into view; can fail.
|
view.AccessCoin(txin.prevout); // Load entries from viewChain into view; can fail.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -781,7 +781,7 @@ UniValue signrawtransaction(const JSONRPCRequest& request)
|
||||||
ProduceSignature(MutableTransactionSignatureCreator(&keystore, &mergedTx, i, amount, nHashType), prevPubKey, sigdata);
|
ProduceSignature(MutableTransactionSignatureCreator(&keystore, &mergedTx, i, amount, nHashType), prevPubKey, sigdata);
|
||||||
|
|
||||||
// ... and merge in other signatures:
|
// ... and merge in other signatures:
|
||||||
BOOST_FOREACH(const CMutableTransaction& txv, txVariants) {
|
for (const CMutableTransaction& txv : txVariants) {
|
||||||
if (txv.vin.size() > i) {
|
if (txv.vin.size() > i) {
|
||||||
sigdata = CombineSignatures(prevPubKey, TransactionSignatureChecker(&txConst, i, amount), sigdata, DataFromTransaction(txv, i));
|
sigdata = CombineSignatures(prevPubKey, TransactionSignatureChecker(&txConst, i, amount), sigdata, DataFromTransaction(txv, i));
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ void RPCTypeCheck(const UniValue& params,
|
||||||
bool fAllowNull)
|
bool fAllowNull)
|
||||||
{
|
{
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
BOOST_FOREACH(UniValue::VType t, typesExpected)
|
for (UniValue::VType t : typesExpected)
|
||||||
{
|
{
|
||||||
if (params.size() <= i)
|
if (params.size() <= i)
|
||||||
break;
|
break;
|
||||||
|
@ -103,7 +103,7 @@ void RPCTypeCheckObj(const UniValue& o,
|
||||||
|
|
||||||
if (fStrict)
|
if (fStrict)
|
||||||
{
|
{
|
||||||
BOOST_FOREACH(const std::string& k, o.getKeys())
|
for (const std::string& k : o.getKeys())
|
||||||
{
|
{
|
||||||
if (typesExpected.count(k) == 0)
|
if (typesExpected.count(k) == 0)
|
||||||
{
|
{
|
||||||
|
@ -186,7 +186,7 @@ std::string CRPCTable::help(const std::string& strCommand, const JSONRPCRequest&
|
||||||
jreq.fHelp = true;
|
jreq.fHelp = true;
|
||||||
jreq.params = UniValue();
|
jreq.params = UniValue();
|
||||||
|
|
||||||
BOOST_FOREACH(const PAIRTYPE(std::string, const CRPCCommand*)& command, vCommands)
|
for (const PAIRTYPE(std::string, const CRPCCommand*)& command : vCommands)
|
||||||
{
|
{
|
||||||
const CRPCCommand *pcmd = command.second;
|
const CRPCCommand *pcmd = command.second;
|
||||||
std::string strMethod = pcmd->name;
|
std::string strMethod = pcmd->name;
|
||||||
|
|
|
@ -18,7 +18,7 @@ typedef std::vector<unsigned char> valtype;
|
||||||
unsigned int HaveKeys(const std::vector<valtype>& pubkeys, const CKeyStore& keystore)
|
unsigned int HaveKeys(const std::vector<valtype>& pubkeys, const CKeyStore& keystore)
|
||||||
{
|
{
|
||||||
unsigned int nResult = 0;
|
unsigned int nResult = 0;
|
||||||
BOOST_FOREACH(const valtype& pubkey, pubkeys)
|
for (const valtype& pubkey : pubkeys)
|
||||||
{
|
{
|
||||||
CKeyID keyID = CPubKey(pubkey).GetID();
|
CKeyID keyID = CPubKey(pubkey).GetID();
|
||||||
if (keystore.HaveKey(keyID))
|
if (keystore.HaveKey(keyID))
|
||||||
|
|
|
@ -126,7 +126,7 @@ static bool SignStep(const BaseSignatureCreator& creator, const CScript& scriptP
|
||||||
static CScript PushAll(const std::vector<valtype>& values)
|
static CScript PushAll(const std::vector<valtype>& values)
|
||||||
{
|
{
|
||||||
CScript result;
|
CScript result;
|
||||||
BOOST_FOREACH(const valtype& v, values) {
|
for (const valtype& v : values) {
|
||||||
if (v.size() == 0) {
|
if (v.size() == 0) {
|
||||||
result << OP_0;
|
result << OP_0;
|
||||||
} else if (v.size() == 1 && v[0] >= 1 && v[0] <= 16) {
|
} else if (v.size() == 1 && v[0] >= 1 && v[0] <= 16) {
|
||||||
|
@ -232,12 +232,12 @@ static std::vector<valtype> CombineMultisig(const CScript& scriptPubKey, const B
|
||||||
{
|
{
|
||||||
// Combine all the signatures we've got:
|
// Combine all the signatures we've got:
|
||||||
std::set<valtype> allsigs;
|
std::set<valtype> allsigs;
|
||||||
BOOST_FOREACH(const valtype& v, sigs1)
|
for (const valtype& v : sigs1)
|
||||||
{
|
{
|
||||||
if (!v.empty())
|
if (!v.empty())
|
||||||
allsigs.insert(v);
|
allsigs.insert(v);
|
||||||
}
|
}
|
||||||
BOOST_FOREACH(const valtype& v, sigs2)
|
for (const valtype& v : sigs2)
|
||||||
{
|
{
|
||||||
if (!v.empty())
|
if (!v.empty())
|
||||||
allsigs.insert(v);
|
allsigs.insert(v);
|
||||||
|
@ -248,7 +248,7 @@ static std::vector<valtype> CombineMultisig(const CScript& scriptPubKey, const B
|
||||||
unsigned int nSigsRequired = vSolutions.front()[0];
|
unsigned int nSigsRequired = vSolutions.front()[0];
|
||||||
unsigned int nPubKeys = vSolutions.size()-2;
|
unsigned int nPubKeys = vSolutions.size()-2;
|
||||||
std::map<valtype, valtype> sigs;
|
std::map<valtype, valtype> sigs;
|
||||||
BOOST_FOREACH(const valtype& sig, allsigs)
|
for (const valtype& sig : allsigs)
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < nPubKeys; i++)
|
for (unsigned int i = 0; i < nPubKeys; i++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -94,7 +94,7 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, std::vector<std::v
|
||||||
|
|
||||||
// Scan templates
|
// Scan templates
|
||||||
const CScript& script1 = scriptPubKey;
|
const CScript& script1 = scriptPubKey;
|
||||||
BOOST_FOREACH(const PAIRTYPE(txnouttype, CScript)& tplate, mTemplates)
|
for (const PAIRTYPE(txnouttype, CScript)& tplate : mTemplates)
|
||||||
{
|
{
|
||||||
const CScript& script2 = tplate.second;
|
const CScript& script2 = tplate.second;
|
||||||
vSolutionsRet.clear();
|
vSolutionsRet.clear();
|
||||||
|
@ -293,7 +293,7 @@ CScript GetScriptForMultisig(int nRequired, const std::vector<CPubKey>& keys)
|
||||||
CScript script;
|
CScript script;
|
||||||
|
|
||||||
script << CScript::EncodeOP_N(nRequired);
|
script << CScript::EncodeOP_N(nRequired);
|
||||||
BOOST_FOREACH(const CPubKey& key, keys)
|
for (const CPubKey& key : keys)
|
||||||
script << ToByteVector(key);
|
script << ToByteVector(key);
|
||||||
script << CScript::EncodeOP_N(keys.size()) << OP_CHECKMULTISIG;
|
script << CScript::EncodeOP_N(keys.size()) << OP_CHECKMULTISIG;
|
||||||
return script;
|
return script;
|
||||||
|
|
10
src/sync.cpp
10
src/sync.cpp
|
@ -77,7 +77,7 @@ static void potential_deadlock_detected(const std::pair<void*, void*>& mismatch,
|
||||||
{
|
{
|
||||||
LogPrintf("POTENTIAL DEADLOCK DETECTED\n");
|
LogPrintf("POTENTIAL DEADLOCK DETECTED\n");
|
||||||
LogPrintf("Previous lock order was:\n");
|
LogPrintf("Previous lock order was:\n");
|
||||||
BOOST_FOREACH (const PAIRTYPE(void*, CLockLocation) & i, s2) {
|
for (const PAIRTYPE(void*, CLockLocation) & i : s2) {
|
||||||
if (i.first == mismatch.first) {
|
if (i.first == mismatch.first) {
|
||||||
LogPrintf(" (1)");
|
LogPrintf(" (1)");
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ static void potential_deadlock_detected(const std::pair<void*, void*>& mismatch,
|
||||||
LogPrintf(" %s\n", i.second.ToString());
|
LogPrintf(" %s\n", i.second.ToString());
|
||||||
}
|
}
|
||||||
LogPrintf("Current lock order is:\n");
|
LogPrintf("Current lock order is:\n");
|
||||||
BOOST_FOREACH (const PAIRTYPE(void*, CLockLocation) & i, s1) {
|
for (const PAIRTYPE(void*, CLockLocation) & i : s1) {
|
||||||
if (i.first == mismatch.first) {
|
if (i.first == mismatch.first) {
|
||||||
LogPrintf(" (1)");
|
LogPrintf(" (1)");
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ static void push_lock(void* c, const CLockLocation& locklocation, bool fTry)
|
||||||
|
|
||||||
(*lockstack).push_back(std::make_pair(c, locklocation));
|
(*lockstack).push_back(std::make_pair(c, locklocation));
|
||||||
|
|
||||||
BOOST_FOREACH (const PAIRTYPE(void*, CLockLocation) & i, (*lockstack)) {
|
for (const PAIRTYPE(void*, CLockLocation) & i : (*lockstack)) {
|
||||||
if (i.first == c)
|
if (i.first == c)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -142,14 +142,14 @@ void LeaveCritical()
|
||||||
std::string LocksHeld()
|
std::string LocksHeld()
|
||||||
{
|
{
|
||||||
std::string result;
|
std::string result;
|
||||||
BOOST_FOREACH (const PAIRTYPE(void*, CLockLocation) & i, *lockstack)
|
for (const PAIRTYPE(void*, CLockLocation) & i : *lockstack)
|
||||||
result += i.second.ToString() + std::string("\n");
|
result += i.second.ToString() + std::string("\n");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssertLockHeldInternal(const char* pszName, const char* pszFile, int nLine, void* cs)
|
void AssertLockHeldInternal(const char* pszName, const char* pszFile, int nLine, void* cs)
|
||||||
{
|
{
|
||||||
BOOST_FOREACH (const PAIRTYPE(void*, CLockLocation) & i, *lockstack)
|
for (const PAIRTYPE(void*, CLockLocation) & i : *lockstack)
|
||||||
if (i.first == cs)
|
if (i.first == cs)
|
||||||
return;
|
return;
|
||||||
fprintf(stderr, "Assertion failed: lock %s not held in %s:%i; locks held:\n%s", pszName, pszFile, nLine, LocksHeld().c_str());
|
fprintf(stderr, "Assertion failed: lock %s not held in %s:%i; locks held:\n%s", pszName, pszFile, nLine, LocksHeld().c_str());
|
||||||
|
|
|
@ -93,7 +93,7 @@ void RunTest(const TestVector &test) {
|
||||||
CExtPubKey pubkey;
|
CExtPubKey pubkey;
|
||||||
key.SetMaster(&seed[0], seed.size());
|
key.SetMaster(&seed[0], seed.size());
|
||||||
pubkey = key.Neuter();
|
pubkey = key.Neuter();
|
||||||
BOOST_FOREACH(const TestDerivation &derive, test.vDerive) {
|
for (const TestDerivation &derive : test.vDerive) {
|
||||||
unsigned char data[74];
|
unsigned char data[74];
|
||||||
key.Encode(data);
|
key.Encode(data);
|
||||||
pubkey.Encode(data);
|
pubkey.Encode(data);
|
||||||
|
|
|
@ -194,7 +194,7 @@ BOOST_AUTO_TEST_CASE(coins_cache_simulation_test)
|
||||||
found_an_entry = true;
|
found_an_entry = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BOOST_FOREACH(const CCoinsViewCacheTest *test, stack) {
|
for (const CCoinsViewCacheTest *test : stack) {
|
||||||
test->SelfTest();
|
test->SelfTest();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ static void ResetArgs(const std::string& strArg)
|
||||||
|
|
||||||
// Convert to char*:
|
// Convert to char*:
|
||||||
std::vector<const char*> vecChar;
|
std::vector<const char*> vecChar;
|
||||||
BOOST_FOREACH(std::string& s, vecArg)
|
for (std::string& s : vecArg)
|
||||||
vecChar.push_back(s.c_str());
|
vecChar.push_back(s.c_str());
|
||||||
|
|
||||||
ParseParameters(vecChar.size(), &vecChar[0]);
|
ParseParameters(vecChar.size(), &vecChar[0]);
|
||||||
|
|
|
@ -28,7 +28,7 @@ sign_multisig(CScript scriptPubKey, std::vector<CKey> keys, CTransaction transac
|
||||||
|
|
||||||
CScript result;
|
CScript result;
|
||||||
result << OP_0; // CHECKMULTISIG bug workaround
|
result << OP_0; // CHECKMULTISIG bug workaround
|
||||||
BOOST_FOREACH(const CKey &key, keys)
|
for (const CKey &key : keys)
|
||||||
{
|
{
|
||||||
std::vector<unsigned char> vchSig;
|
std::vector<unsigned char> vchSig;
|
||||||
BOOST_CHECK(key.Sign(hash, vchSig));
|
BOOST_CHECK(key.Sign(hash, vchSig));
|
||||||
|
|
|
@ -54,13 +54,13 @@ class prevector_tester {
|
||||||
local_check(pretype(real_vector.begin(), real_vector.end()) == pre_vector);
|
local_check(pretype(real_vector.begin(), real_vector.end()) == pre_vector);
|
||||||
local_check(pretype(pre_vector.begin(), pre_vector.end()) == pre_vector);
|
local_check(pretype(pre_vector.begin(), pre_vector.end()) == pre_vector);
|
||||||
size_t pos = 0;
|
size_t pos = 0;
|
||||||
BOOST_FOREACH(const T& v, pre_vector) {
|
for (const T& v : pre_vector) {
|
||||||
local_check(v == real_vector[pos++]);
|
local_check(v == real_vector[pos++]);
|
||||||
}
|
}
|
||||||
BOOST_REVERSE_FOREACH(const T& v, pre_vector) {
|
BOOST_REVERSE_FOREACH(const T& v, pre_vector) {
|
||||||
local_check(v == real_vector[--pos]);
|
local_check(v == real_vector[--pos]);
|
||||||
}
|
}
|
||||||
BOOST_FOREACH(const T& v, const_pre_vector) {
|
for (const T& v : const_pre_vector) {
|
||||||
local_check(v == real_vector[pos++]);
|
local_check(v == real_vector[pos++]);
|
||||||
}
|
}
|
||||||
BOOST_REVERSE_FOREACH(const T& v, const_pre_vector) {
|
BOOST_REVERSE_FOREACH(const T& v, const_pre_vector) {
|
||||||
|
|
|
@ -927,7 +927,7 @@ BOOST_AUTO_TEST_CASE(script_build)
|
||||||
|
|
||||||
std::string strGen;
|
std::string strGen;
|
||||||
|
|
||||||
BOOST_FOREACH(TestBuilder& test, tests) {
|
for (TestBuilder& test : tests) {
|
||||||
test.Test();
|
test.Test();
|
||||||
std::string str = JSONPrettyPrint(test.GetJSON());
|
std::string str = JSONPrettyPrint(test.GetJSON());
|
||||||
#ifndef UPDATE_JSON_TESTS
|
#ifndef UPDATE_JSON_TESTS
|
||||||
|
@ -1033,7 +1033,7 @@ sign_multisig(CScript scriptPubKey, std::vector<CKey> keys, CTransaction transac
|
||||||
// and vice-versa)
|
// and vice-versa)
|
||||||
//
|
//
|
||||||
result << OP_0;
|
result << OP_0;
|
||||||
BOOST_FOREACH(const CKey &key, keys)
|
for (const CKey &key : keys)
|
||||||
{
|
{
|
||||||
std::vector<unsigned char> vchSig;
|
std::vector<unsigned char> vchSig;
|
||||||
BOOST_CHECK(key.Sign(hash, vchSig));
|
BOOST_CHECK(key.Sign(hash, vchSig));
|
||||||
|
|
|
@ -121,7 +121,7 @@ TestChain100Setup::CreateAndProcessBlock(const std::vector<CMutableTransaction>&
|
||||||
|
|
||||||
// Replace mempool-selected txns with just coinbase plus passed-in txns:
|
// Replace mempool-selected txns with just coinbase plus passed-in txns:
|
||||||
block.vtx.resize(1);
|
block.vtx.resize(1);
|
||||||
BOOST_FOREACH(const CMutableTransaction& tx, txns)
|
for (const CMutableTransaction& tx : txns)
|
||||||
block.vtx.push_back(MakeTransactionRef(tx));
|
block.vtx.push_back(MakeTransactionRef(tx));
|
||||||
// IncrementExtraNonce creates a valid coinbase and merkleRoot
|
// IncrementExtraNonce creates a valid coinbase and merkleRoot
|
||||||
unsigned int extraNonce = 0;
|
unsigned int extraNonce = 0;
|
||||||
|
|
|
@ -66,7 +66,7 @@ unsigned int ParseScriptFlags(std::string strFlags)
|
||||||
std::vector<std::string> words;
|
std::vector<std::string> words;
|
||||||
boost::algorithm::split(words, strFlags, boost::algorithm::is_any_of(","));
|
boost::algorithm::split(words, strFlags, boost::algorithm::is_any_of(","));
|
||||||
|
|
||||||
BOOST_FOREACH(std::string word, words)
|
for (std::string word : words)
|
||||||
{
|
{
|
||||||
if (!mapFlagNames.count(word))
|
if (!mapFlagNames.count(word))
|
||||||
BOOST_ERROR("Bad test: unknown verification flag '" << word << "'");
|
BOOST_ERROR("Bad test: unknown verification flag '" << word << "'");
|
||||||
|
@ -394,7 +394,7 @@ void CheckWithFlag(const CTransactionRef& output, const CMutableTransaction& inp
|
||||||
static CScript PushAll(const std::vector<valtype>& values)
|
static CScript PushAll(const std::vector<valtype>& values)
|
||||||
{
|
{
|
||||||
CScript result;
|
CScript result;
|
||||||
BOOST_FOREACH(const valtype& v, values) {
|
for (const valtype& v : values) {
|
||||||
if (v.size() == 0) {
|
if (v.size() == 0) {
|
||||||
result << OP_0;
|
result << OP_0;
|
||||||
} else if (v.size() == 1 && v[0] >= 1 && v[0] <= 16) {
|
} else if (v.size() == 1 && v[0] >= 1 && v[0] <= 16) {
|
||||||
|
|
|
@ -95,7 +95,7 @@ void AddTimeData(const CNetAddr& ip, int64_t nOffsetSample)
|
||||||
{
|
{
|
||||||
// If nobody has a time different than ours but within 5 minutes of ours, give a warning
|
// If nobody has a time different than ours but within 5 minutes of ours, give a warning
|
||||||
bool fMatch = false;
|
bool fMatch = false;
|
||||||
BOOST_FOREACH(int64_t nOffset, vSorted)
|
for (int64_t nOffset : vSorted)
|
||||||
if (nOffset != 0 && abs64(nOffset) < 5 * 60)
|
if (nOffset != 0 && abs64(nOffset) < 5 * 60)
|
||||||
fMatch = true;
|
fMatch = true;
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ void AddTimeData(const CNetAddr& ip, int64_t nOffsetSample)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LogAcceptCategory(BCLog::NET)) {
|
if (LogAcceptCategory(BCLog::NET)) {
|
||||||
BOOST_FOREACH(int64_t n, vSorted) {
|
for (int64_t n : vSorted) {
|
||||||
LogPrint(BCLog::NET, "%+d ", n);
|
LogPrint(BCLog::NET, "%+d ", n);
|
||||||
}
|
}
|
||||||
LogPrint(BCLog::NET, "| ");
|
LogPrint(BCLog::NET, "| ");
|
||||||
|
|
|
@ -487,7 +487,7 @@ void TorController::add_onion_cb(TorControlConnection& _conn, const TorControlRe
|
||||||
{
|
{
|
||||||
if (reply.code == 250) {
|
if (reply.code == 250) {
|
||||||
LogPrint(BCLog::TOR, "tor: ADD_ONION successful\n");
|
LogPrint(BCLog::TOR, "tor: ADD_ONION successful\n");
|
||||||
BOOST_FOREACH(const std::string &s, reply.lines) {
|
for (const std::string &s : reply.lines) {
|
||||||
std::map<std::string,std::string> m = ParseTorReplyMapping(s);
|
std::map<std::string,std::string> m = ParseTorReplyMapping(s);
|
||||||
std::map<std::string,std::string>::iterator i;
|
std::map<std::string,std::string>::iterator i;
|
||||||
if ((i = m.find("ServiceID")) != m.end())
|
if ((i = m.find("ServiceID")) != m.end())
|
||||||
|
@ -617,7 +617,7 @@ void TorController::protocolinfo_cb(TorControlConnection& _conn, const TorContro
|
||||||
* 250-AUTH METHODS=NULL
|
* 250-AUTH METHODS=NULL
|
||||||
* 250-AUTH METHODS=HASHEDPASSWORD
|
* 250-AUTH METHODS=HASHEDPASSWORD
|
||||||
*/
|
*/
|
||||||
BOOST_FOREACH(const std::string &s, reply.lines) {
|
for (const std::string &s : reply.lines) {
|
||||||
std::pair<std::string,std::string> l = SplitTorReplyLine(s);
|
std::pair<std::string,std::string> l = SplitTorReplyLine(s);
|
||||||
if (l.first == "AUTH") {
|
if (l.first == "AUTH") {
|
||||||
std::map<std::string,std::string> m = ParseTorReplyMapping(l.second);
|
std::map<std::string,std::string> m = ParseTorReplyMapping(l.second);
|
||||||
|
@ -634,7 +634,7 @@ void TorController::protocolinfo_cb(TorControlConnection& _conn, const TorContro
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BOOST_FOREACH(const std::string &s, methods) {
|
for (const std::string &s : methods) {
|
||||||
LogPrint(BCLog::TOR, "tor: Supported authentication method: %s\n", s);
|
LogPrint(BCLog::TOR, "tor: Supported authentication method: %s\n", s);
|
||||||
}
|
}
|
||||||
// Prefer NULL, otherwise SAFECOOKIE. If a password is provided, use HASHEDPASSWORD
|
// Prefer NULL, otherwise SAFECOOKIE. If a password is provided, use HASHEDPASSWORD
|
||||||
|
|
|
@ -73,12 +73,12 @@ void CTxMemPool::UpdateForDescendants(txiter updateIt, cacheMap &cachedDescendan
|
||||||
setAllDescendants.insert(cit);
|
setAllDescendants.insert(cit);
|
||||||
stageEntries.erase(cit);
|
stageEntries.erase(cit);
|
||||||
const setEntries &setChildren = GetMemPoolChildren(cit);
|
const setEntries &setChildren = GetMemPoolChildren(cit);
|
||||||
BOOST_FOREACH(const txiter childEntry, setChildren) {
|
for (const txiter childEntry : setChildren) {
|
||||||
cacheMap::iterator cacheIt = cachedDescendants.find(childEntry);
|
cacheMap::iterator cacheIt = cachedDescendants.find(childEntry);
|
||||||
if (cacheIt != cachedDescendants.end()) {
|
if (cacheIt != cachedDescendants.end()) {
|
||||||
// We've already calculated this one, just add the entries for this set
|
// We've already calculated this one, just add the entries for this set
|
||||||
// but don't traverse again.
|
// but don't traverse again.
|
||||||
BOOST_FOREACH(const txiter cacheEntry, cacheIt->second) {
|
for (const txiter cacheEntry : cacheIt->second) {
|
||||||
setAllDescendants.insert(cacheEntry);
|
setAllDescendants.insert(cacheEntry);
|
||||||
}
|
}
|
||||||
} else if (!setAllDescendants.count(childEntry)) {
|
} else if (!setAllDescendants.count(childEntry)) {
|
||||||
|
@ -92,7 +92,7 @@ void CTxMemPool::UpdateForDescendants(txiter updateIt, cacheMap &cachedDescendan
|
||||||
int64_t modifySize = 0;
|
int64_t modifySize = 0;
|
||||||
CAmount modifyFee = 0;
|
CAmount modifyFee = 0;
|
||||||
int64_t modifyCount = 0;
|
int64_t modifyCount = 0;
|
||||||
BOOST_FOREACH(txiter cit, setAllDescendants) {
|
for (txiter cit : setAllDescendants) {
|
||||||
if (!setExclude.count(cit->GetTx().GetHash())) {
|
if (!setExclude.count(cit->GetTx().GetHash())) {
|
||||||
modifySize += cit->GetTxSize();
|
modifySize += cit->GetTxSize();
|
||||||
modifyFee += cit->GetModifiedFee();
|
modifyFee += cit->GetModifiedFee();
|
||||||
|
@ -202,7 +202,7 @@ bool CTxMemPool::CalculateMemPoolAncestors(const CTxMemPoolEntry &entry, setEntr
|
||||||
}
|
}
|
||||||
|
|
||||||
const setEntries & setMemPoolParents = GetMemPoolParents(stageit);
|
const setEntries & setMemPoolParents = GetMemPoolParents(stageit);
|
||||||
BOOST_FOREACH(const txiter &phash, setMemPoolParents) {
|
for (const txiter &phash : setMemPoolParents) {
|
||||||
// If this is a new ancestor, add it.
|
// If this is a new ancestor, add it.
|
||||||
if (setAncestors.count(phash) == 0) {
|
if (setAncestors.count(phash) == 0) {
|
||||||
parentHashes.insert(phash);
|
parentHashes.insert(phash);
|
||||||
|
@ -221,13 +221,13 @@ void CTxMemPool::UpdateAncestorsOf(bool add, txiter it, setEntries &setAncestors
|
||||||
{
|
{
|
||||||
setEntries parentIters = GetMemPoolParents(it);
|
setEntries parentIters = GetMemPoolParents(it);
|
||||||
// add or remove this tx as a child of each parent
|
// add or remove this tx as a child of each parent
|
||||||
BOOST_FOREACH(txiter piter, parentIters) {
|
for (txiter piter : parentIters) {
|
||||||
UpdateChild(piter, it, add);
|
UpdateChild(piter, it, add);
|
||||||
}
|
}
|
||||||
const int64_t updateCount = (add ? 1 : -1);
|
const int64_t updateCount = (add ? 1 : -1);
|
||||||
const int64_t updateSize = updateCount * it->GetTxSize();
|
const int64_t updateSize = updateCount * it->GetTxSize();
|
||||||
const CAmount updateFee = updateCount * it->GetModifiedFee();
|
const CAmount updateFee = updateCount * it->GetModifiedFee();
|
||||||
BOOST_FOREACH(txiter ancestorIt, setAncestors) {
|
for (txiter ancestorIt : setAncestors) {
|
||||||
mapTx.modify(ancestorIt, update_descendant_state(updateSize, updateFee, updateCount));
|
mapTx.modify(ancestorIt, update_descendant_state(updateSize, updateFee, updateCount));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -238,7 +238,7 @@ void CTxMemPool::UpdateEntryForAncestors(txiter it, const setEntries &setAncesto
|
||||||
int64_t updateSize = 0;
|
int64_t updateSize = 0;
|
||||||
CAmount updateFee = 0;
|
CAmount updateFee = 0;
|
||||||
int64_t updateSigOpsCost = 0;
|
int64_t updateSigOpsCost = 0;
|
||||||
BOOST_FOREACH(txiter ancestorIt, setAncestors) {
|
for (txiter ancestorIt : setAncestors) {
|
||||||
updateSize += ancestorIt->GetTxSize();
|
updateSize += ancestorIt->GetTxSize();
|
||||||
updateFee += ancestorIt->GetModifiedFee();
|
updateFee += ancestorIt->GetModifiedFee();
|
||||||
updateSigOpsCost += ancestorIt->GetSigOpCost();
|
updateSigOpsCost += ancestorIt->GetSigOpCost();
|
||||||
|
@ -249,7 +249,7 @@ void CTxMemPool::UpdateEntryForAncestors(txiter it, const setEntries &setAncesto
|
||||||
void CTxMemPool::UpdateChildrenForRemoval(txiter it)
|
void CTxMemPool::UpdateChildrenForRemoval(txiter it)
|
||||||
{
|
{
|
||||||
const setEntries &setMemPoolChildren = GetMemPoolChildren(it);
|
const setEntries &setMemPoolChildren = GetMemPoolChildren(it);
|
||||||
BOOST_FOREACH(txiter updateIt, setMemPoolChildren) {
|
for (txiter updateIt : setMemPoolChildren) {
|
||||||
UpdateParent(updateIt, it, false);
|
UpdateParent(updateIt, it, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -266,19 +266,19 @@ void CTxMemPool::UpdateForRemoveFromMempool(const setEntries &entriesToRemove, b
|
||||||
// Here we only update statistics and not data in mapLinks (which
|
// Here we only update statistics and not data in mapLinks (which
|
||||||
// we need to preserve until we're finished with all operations that
|
// we need to preserve until we're finished with all operations that
|
||||||
// need to traverse the mempool).
|
// need to traverse the mempool).
|
||||||
BOOST_FOREACH(txiter removeIt, entriesToRemove) {
|
for (txiter removeIt : entriesToRemove) {
|
||||||
setEntries setDescendants;
|
setEntries setDescendants;
|
||||||
CalculateDescendants(removeIt, setDescendants);
|
CalculateDescendants(removeIt, setDescendants);
|
||||||
setDescendants.erase(removeIt); // don't update state for self
|
setDescendants.erase(removeIt); // don't update state for self
|
||||||
int64_t modifySize = -((int64_t)removeIt->GetTxSize());
|
int64_t modifySize = -((int64_t)removeIt->GetTxSize());
|
||||||
CAmount modifyFee = -removeIt->GetModifiedFee();
|
CAmount modifyFee = -removeIt->GetModifiedFee();
|
||||||
int modifySigOps = -removeIt->GetSigOpCost();
|
int modifySigOps = -removeIt->GetSigOpCost();
|
||||||
BOOST_FOREACH(txiter dit, setDescendants) {
|
for (txiter dit : setDescendants) {
|
||||||
mapTx.modify(dit, update_ancestor_state(modifySize, modifyFee, -1, modifySigOps));
|
mapTx.modify(dit, update_ancestor_state(modifySize, modifyFee, -1, modifySigOps));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BOOST_FOREACH(txiter removeIt, entriesToRemove) {
|
for (txiter removeIt : entriesToRemove) {
|
||||||
setEntries setAncestors;
|
setEntries setAncestors;
|
||||||
const CTxMemPoolEntry &entry = *removeIt;
|
const CTxMemPoolEntry &entry = *removeIt;
|
||||||
std::string dummy;
|
std::string dummy;
|
||||||
|
@ -307,7 +307,7 @@ void CTxMemPool::UpdateForRemoveFromMempool(const setEntries &entriesToRemove, b
|
||||||
// After updating all the ancestor sizes, we can now sever the link between each
|
// After updating all the ancestor sizes, we can now sever the link between each
|
||||||
// transaction being removed and any mempool children (ie, update setMemPoolParents
|
// transaction being removed and any mempool children (ie, update setMemPoolParents
|
||||||
// for each direct child of a transaction being removed).
|
// for each direct child of a transaction being removed).
|
||||||
BOOST_FOREACH(txiter removeIt, entriesToRemove) {
|
for (txiter removeIt : entriesToRemove) {
|
||||||
UpdateChildrenForRemoval(removeIt);
|
UpdateChildrenForRemoval(removeIt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -401,7 +401,7 @@ bool CTxMemPool::addUnchecked(const uint256& hash, const CTxMemPoolEntry &entry,
|
||||||
// to clean up the mess we're leaving here.
|
// to clean up the mess we're leaving here.
|
||||||
|
|
||||||
// Update ancestors with information about this tx
|
// Update ancestors with information about this tx
|
||||||
BOOST_FOREACH (const uint256 &phash, setParentTransactions) {
|
for (const uint256 &phash : setParentTransactions) {
|
||||||
txiter pit = mapTx.find(phash);
|
txiter pit = mapTx.find(phash);
|
||||||
if (pit != mapTx.end()) {
|
if (pit != mapTx.end()) {
|
||||||
UpdateParent(newit, pit, true);
|
UpdateParent(newit, pit, true);
|
||||||
|
@ -424,7 +424,7 @@ void CTxMemPool::removeUnchecked(txiter it, MemPoolRemovalReason reason)
|
||||||
{
|
{
|
||||||
NotifyEntryRemoved(it->GetSharedTx(), reason);
|
NotifyEntryRemoved(it->GetSharedTx(), reason);
|
||||||
const uint256 hash = it->GetTx().GetHash();
|
const uint256 hash = it->GetTx().GetHash();
|
||||||
BOOST_FOREACH(const CTxIn& txin, it->GetTx().vin)
|
for (const CTxIn& txin : it->GetTx().vin)
|
||||||
mapNextTx.erase(txin.prevout);
|
mapNextTx.erase(txin.prevout);
|
||||||
|
|
||||||
if (vTxHashes.size() > 1) {
|
if (vTxHashes.size() > 1) {
|
||||||
|
@ -466,7 +466,7 @@ void CTxMemPool::CalculateDescendants(txiter entryit, setEntries &setDescendants
|
||||||
stage.erase(it);
|
stage.erase(it);
|
||||||
|
|
||||||
const setEntries &setChildren = GetMemPoolChildren(it);
|
const setEntries &setChildren = GetMemPoolChildren(it);
|
||||||
BOOST_FOREACH(const txiter &childiter, setChildren) {
|
for (const txiter &childiter : setChildren) {
|
||||||
if (!setDescendants.count(childiter)) {
|
if (!setDescendants.count(childiter)) {
|
||||||
stage.insert(childiter);
|
stage.insert(childiter);
|
||||||
}
|
}
|
||||||
|
@ -498,7 +498,7 @@ void CTxMemPool::removeRecursive(const CTransaction &origTx, MemPoolRemovalReaso
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setEntries setAllRemoves;
|
setEntries setAllRemoves;
|
||||||
BOOST_FOREACH(txiter it, txToRemove) {
|
for (txiter it : txToRemove) {
|
||||||
CalculateDescendants(it, setAllRemoves);
|
CalculateDescendants(it, setAllRemoves);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -520,7 +520,7 @@ void CTxMemPool::removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMem
|
||||||
// So it's critical that we remove the tx and not depend on the LockPoints.
|
// So it's critical that we remove the tx and not depend on the LockPoints.
|
||||||
txToRemove.insert(it);
|
txToRemove.insert(it);
|
||||||
} else if (it->GetSpendsCoinbase()) {
|
} else if (it->GetSpendsCoinbase()) {
|
||||||
BOOST_FOREACH(const CTxIn& txin, tx.vin) {
|
for (const CTxIn& txin : tx.vin) {
|
||||||
indexed_transaction_set::const_iterator it2 = mapTx.find(txin.prevout.hash);
|
indexed_transaction_set::const_iterator it2 = mapTx.find(txin.prevout.hash);
|
||||||
if (it2 != mapTx.end())
|
if (it2 != mapTx.end())
|
||||||
continue;
|
continue;
|
||||||
|
@ -547,7 +547,7 @@ void CTxMemPool::removeConflicts(const CTransaction &tx)
|
||||||
{
|
{
|
||||||
// Remove transactions which depend on inputs of tx, recursively
|
// Remove transactions which depend on inputs of tx, recursively
|
||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
BOOST_FOREACH(const CTxIn &txin, tx.vin) {
|
for (const CTxIn &txin : tx.vin) {
|
||||||
auto it = mapNextTx.find(txin.prevout);
|
auto it = mapNextTx.find(txin.prevout);
|
||||||
if (it != mapNextTx.end()) {
|
if (it != mapNextTx.end()) {
|
||||||
const CTransaction &txConflict = *it->second;
|
const CTransaction &txConflict = *it->second;
|
||||||
|
@ -642,7 +642,7 @@ void CTxMemPool::check(const CCoinsViewCache *pcoins) const
|
||||||
setEntries setParentCheck;
|
setEntries setParentCheck;
|
||||||
int64_t parentSizes = 0;
|
int64_t parentSizes = 0;
|
||||||
int64_t parentSigOpCost = 0;
|
int64_t parentSigOpCost = 0;
|
||||||
BOOST_FOREACH(const CTxIn &txin, tx.vin) {
|
for (const CTxIn &txin : tx.vin) {
|
||||||
// Check that every mempool transaction's inputs refer to available coins, or other mempool tx's.
|
// Check that every mempool transaction's inputs refer to available coins, or other mempool tx's.
|
||||||
indexed_transaction_set::const_iterator it2 = mapTx.find(txin.prevout.hash);
|
indexed_transaction_set::const_iterator it2 = mapTx.find(txin.prevout.hash);
|
||||||
if (it2 != mapTx.end()) {
|
if (it2 != mapTx.end()) {
|
||||||
|
@ -674,7 +674,7 @@ void CTxMemPool::check(const CCoinsViewCache *pcoins) const
|
||||||
CAmount nFeesCheck = it->GetModifiedFee();
|
CAmount nFeesCheck = it->GetModifiedFee();
|
||||||
int64_t nSigOpCheck = it->GetSigOpCost();
|
int64_t nSigOpCheck = it->GetSigOpCost();
|
||||||
|
|
||||||
BOOST_FOREACH(txiter ancestorIt, setAncestors) {
|
for (txiter ancestorIt : setAncestors) {
|
||||||
nSizeCheck += ancestorIt->GetTxSize();
|
nSizeCheck += ancestorIt->GetTxSize();
|
||||||
nFeesCheck += ancestorIt->GetModifiedFee();
|
nFeesCheck += ancestorIt->GetModifiedFee();
|
||||||
nSigOpCheck += ancestorIt->GetSigOpCost();
|
nSigOpCheck += ancestorIt->GetSigOpCost();
|
||||||
|
@ -848,14 +848,14 @@ void CTxMemPool::PrioritiseTransaction(const uint256& hash, const CAmount& nFeeD
|
||||||
uint64_t nNoLimit = std::numeric_limits<uint64_t>::max();
|
uint64_t nNoLimit = std::numeric_limits<uint64_t>::max();
|
||||||
std::string dummy;
|
std::string dummy;
|
||||||
CalculateMemPoolAncestors(*it, setAncestors, nNoLimit, nNoLimit, nNoLimit, nNoLimit, dummy, false);
|
CalculateMemPoolAncestors(*it, setAncestors, nNoLimit, nNoLimit, nNoLimit, nNoLimit, dummy, false);
|
||||||
BOOST_FOREACH(txiter ancestorIt, setAncestors) {
|
for (txiter ancestorIt : setAncestors) {
|
||||||
mapTx.modify(ancestorIt, update_descendant_state(0, nFeeDelta, 0));
|
mapTx.modify(ancestorIt, update_descendant_state(0, nFeeDelta, 0));
|
||||||
}
|
}
|
||||||
// Now update all descendants' modified fees with ancestors
|
// Now update all descendants' modified fees with ancestors
|
||||||
setEntries setDescendants;
|
setEntries setDescendants;
|
||||||
CalculateDescendants(it, setDescendants);
|
CalculateDescendants(it, setDescendants);
|
||||||
setDescendants.erase(it);
|
setDescendants.erase(it);
|
||||||
BOOST_FOREACH(txiter descendantIt, setDescendants) {
|
for (txiter descendantIt : setDescendants) {
|
||||||
mapTx.modify(descendantIt, update_ancestor_state(0, nFeeDelta, 0, 0));
|
mapTx.modify(descendantIt, update_ancestor_state(0, nFeeDelta, 0, 0));
|
||||||
}
|
}
|
||||||
++nTransactionsUpdated;
|
++nTransactionsUpdated;
|
||||||
|
@ -919,7 +919,7 @@ size_t CTxMemPool::DynamicMemoryUsage() const {
|
||||||
void CTxMemPool::RemoveStaged(setEntries &stage, bool updateDescendants, MemPoolRemovalReason reason) {
|
void CTxMemPool::RemoveStaged(setEntries &stage, bool updateDescendants, MemPoolRemovalReason reason) {
|
||||||
AssertLockHeld(cs);
|
AssertLockHeld(cs);
|
||||||
UpdateForRemoveFromMempool(stage, updateDescendants);
|
UpdateForRemoveFromMempool(stage, updateDescendants);
|
||||||
BOOST_FOREACH(const txiter& it, stage) {
|
for (const txiter& it : stage) {
|
||||||
removeUnchecked(it, reason);
|
removeUnchecked(it, reason);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -933,7 +933,7 @@ int CTxMemPool::Expire(int64_t time) {
|
||||||
it++;
|
it++;
|
||||||
}
|
}
|
||||||
setEntries stage;
|
setEntries stage;
|
||||||
BOOST_FOREACH(txiter removeit, toremove) {
|
for (txiter removeit : toremove) {
|
||||||
CalculateDescendants(removeit, stage);
|
CalculateDescendants(removeit, stage);
|
||||||
}
|
}
|
||||||
RemoveStaged(stage, false, MemPoolRemovalReason::EXPIRY);
|
RemoveStaged(stage, false, MemPoolRemovalReason::EXPIRY);
|
||||||
|
@ -1042,13 +1042,13 @@ void CTxMemPool::TrimToSize(size_t sizelimit, std::vector<COutPoint>* pvNoSpends
|
||||||
std::vector<CTransaction> txn;
|
std::vector<CTransaction> txn;
|
||||||
if (pvNoSpendsRemaining) {
|
if (pvNoSpendsRemaining) {
|
||||||
txn.reserve(stage.size());
|
txn.reserve(stage.size());
|
||||||
BOOST_FOREACH(txiter iter, stage)
|
for (txiter iter : stage)
|
||||||
txn.push_back(iter->GetTx());
|
txn.push_back(iter->GetTx());
|
||||||
}
|
}
|
||||||
RemoveStaged(stage, false, MemPoolRemovalReason::SIZELIMIT);
|
RemoveStaged(stage, false, MemPoolRemovalReason::SIZELIMIT);
|
||||||
if (pvNoSpendsRemaining) {
|
if (pvNoSpendsRemaining) {
|
||||||
BOOST_FOREACH(const CTransaction& tx, txn) {
|
for (const CTransaction& tx : txn) {
|
||||||
BOOST_FOREACH(const CTxIn& txin, tx.vin) {
|
for (const CTxIn& txin : tx.vin) {
|
||||||
if (exists(txin.prevout.hash)) continue;
|
if (exists(txin.prevout.hash)) continue;
|
||||||
if (!mapNextTx.count(txin.prevout)) {
|
if (!mapNextTx.count(txin.prevout)) {
|
||||||
pvNoSpendsRemaining->push_back(txin.prevout);
|
pvNoSpendsRemaining->push_back(txin.prevout);
|
||||||
|
|
|
@ -160,7 +160,7 @@ namespace {
|
||||||
CBlockIndex* FindForkInGlobalIndex(const CChain& chain, const CBlockLocator& locator)
|
CBlockIndex* FindForkInGlobalIndex(const CChain& chain, const CBlockLocator& locator)
|
||||||
{
|
{
|
||||||
// Find the first block the caller has in the main chain
|
// Find the first block the caller has in the main chain
|
||||||
BOOST_FOREACH(const uint256& hash, locator.vHave) {
|
for (const uint256& hash : locator.vHave) {
|
||||||
BlockMap::iterator mi = mapBlockIndex.find(hash);
|
BlockMap::iterator mi = mapBlockIndex.find(hash);
|
||||||
if (mi != mapBlockIndex.end())
|
if (mi != mapBlockIndex.end())
|
||||||
{
|
{
|
||||||
|
@ -297,7 +297,7 @@ bool CheckSequenceLocks(const CTransaction &tx, int flags, LockPoints* lp, bool
|
||||||
// lock on a mempool input, so we can use the return value of
|
// lock on a mempool input, so we can use the return value of
|
||||||
// CheckSequenceLocks to indicate the LockPoints validity
|
// CheckSequenceLocks to indicate the LockPoints validity
|
||||||
int maxInputHeight = 0;
|
int maxInputHeight = 0;
|
||||||
BOOST_FOREACH(int height, prevheights) {
|
for (int height : prevheights) {
|
||||||
// Can ignore mempool inputs since we'll fail if they had non-zero locks
|
// Can ignore mempool inputs since we'll fail if they had non-zero locks
|
||||||
if (height != tip->nHeight+1) {
|
if (height != tip->nHeight+1) {
|
||||||
maxInputHeight = std::max(maxInputHeight, height);
|
maxInputHeight = std::max(maxInputHeight, height);
|
||||||
|
@ -317,7 +317,7 @@ void LimitMempoolSize(CTxMemPool& pool, size_t limit, unsigned long age) {
|
||||||
|
|
||||||
std::vector<COutPoint> vNoSpendsRemaining;
|
std::vector<COutPoint> vNoSpendsRemaining;
|
||||||
pool.TrimToSize(limit, &vNoSpendsRemaining);
|
pool.TrimToSize(limit, &vNoSpendsRemaining);
|
||||||
BOOST_FOREACH(const COutPoint& removed, vNoSpendsRemaining)
|
for (const COutPoint& removed : vNoSpendsRemaining)
|
||||||
pcoinsTip->Uncache(removed);
|
pcoinsTip->Uncache(removed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -434,7 +434,7 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const C
|
||||||
std::set<uint256> setConflicts;
|
std::set<uint256> setConflicts;
|
||||||
{
|
{
|
||||||
LOCK(pool.cs); // protect pool.mapNextTx
|
LOCK(pool.cs); // protect pool.mapNextTx
|
||||||
BOOST_FOREACH(const CTxIn &txin, tx.vin)
|
for (const CTxIn &txin : tx.vin)
|
||||||
{
|
{
|
||||||
auto itConflicting = pool.mapNextTx.find(txin.prevout);
|
auto itConflicting = pool.mapNextTx.find(txin.prevout);
|
||||||
if (itConflicting != pool.mapNextTx.end())
|
if (itConflicting != pool.mapNextTx.end())
|
||||||
|
@ -457,7 +457,7 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const C
|
||||||
bool fReplacementOptOut = true;
|
bool fReplacementOptOut = true;
|
||||||
if (fEnableReplacement)
|
if (fEnableReplacement)
|
||||||
{
|
{
|
||||||
BOOST_FOREACH(const CTxIn &_txin, ptxConflicting->vin)
|
for (const CTxIn &_txin : ptxConflicting->vin)
|
||||||
{
|
{
|
||||||
if (_txin.nSequence < std::numeric_limits<unsigned int>::max()-1)
|
if (_txin.nSequence < std::numeric_limits<unsigned int>::max()-1)
|
||||||
{
|
{
|
||||||
|
@ -499,7 +499,7 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const C
|
||||||
}
|
}
|
||||||
|
|
||||||
// do all inputs exist?
|
// do all inputs exist?
|
||||||
BOOST_FOREACH(const CTxIn txin, tx.vin) {
|
for (const CTxIn txin : tx.vin) {
|
||||||
if (!pcoinsTip->HaveCoinInCache(txin.prevout)) {
|
if (!pcoinsTip->HaveCoinInCache(txin.prevout)) {
|
||||||
coins_to_uncache.push_back(txin.prevout);
|
coins_to_uncache.push_back(txin.prevout);
|
||||||
}
|
}
|
||||||
|
@ -547,7 +547,7 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const C
|
||||||
// Keep track of transactions that spend a coinbase, which we re-scan
|
// Keep track of transactions that spend a coinbase, which we re-scan
|
||||||
// during reorgs to ensure COINBASE_MATURITY is still met.
|
// during reorgs to ensure COINBASE_MATURITY is still met.
|
||||||
bool fSpendsCoinbase = false;
|
bool fSpendsCoinbase = false;
|
||||||
BOOST_FOREACH(const CTxIn &txin, tx.vin) {
|
for (const CTxIn &txin : tx.vin) {
|
||||||
const Coin &coin = view.AccessCoin(txin.prevout);
|
const Coin &coin = view.AccessCoin(txin.prevout);
|
||||||
if (coin.IsCoinBase()) {
|
if (coin.IsCoinBase()) {
|
||||||
fSpendsCoinbase = true;
|
fSpendsCoinbase = true;
|
||||||
|
@ -598,7 +598,7 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const C
|
||||||
// that we have the set of all ancestors we can detect this
|
// that we have the set of all ancestors we can detect this
|
||||||
// pathological case by making sure setConflicts and setAncestors don't
|
// pathological case by making sure setConflicts and setAncestors don't
|
||||||
// intersect.
|
// intersect.
|
||||||
BOOST_FOREACH(CTxMemPool::txiter ancestorIt, setAncestors)
|
for (CTxMemPool::txiter ancestorIt : setAncestors)
|
||||||
{
|
{
|
||||||
const uint256 &hashAncestor = ancestorIt->GetTx().GetHash();
|
const uint256 &hashAncestor = ancestorIt->GetTx().GetHash();
|
||||||
if (setConflicts.count(hashAncestor))
|
if (setConflicts.count(hashAncestor))
|
||||||
|
@ -629,7 +629,7 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const C
|
||||||
std::set<uint256> setConflictsParents;
|
std::set<uint256> setConflictsParents;
|
||||||
const int maxDescendantsToVisit = 100;
|
const int maxDescendantsToVisit = 100;
|
||||||
CTxMemPool::setEntries setIterConflicting;
|
CTxMemPool::setEntries setIterConflicting;
|
||||||
BOOST_FOREACH(const uint256 &hashConflicting, setConflicts)
|
for (const uint256 &hashConflicting : setConflicts)
|
||||||
{
|
{
|
||||||
CTxMemPool::txiter mi = pool.mapTx.find(hashConflicting);
|
CTxMemPool::txiter mi = pool.mapTx.find(hashConflicting);
|
||||||
if (mi == pool.mapTx.end())
|
if (mi == pool.mapTx.end())
|
||||||
|
@ -665,7 +665,7 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const C
|
||||||
oldFeeRate.ToString()));
|
oldFeeRate.ToString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_FOREACH(const CTxIn &txin, mi->GetTx().vin)
|
for (const CTxIn &txin : mi->GetTx().vin)
|
||||||
{
|
{
|
||||||
setConflictsParents.insert(txin.prevout.hash);
|
setConflictsParents.insert(txin.prevout.hash);
|
||||||
}
|
}
|
||||||
|
@ -678,10 +678,10 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const C
|
||||||
if (nConflictingCount <= maxDescendantsToVisit) {
|
if (nConflictingCount <= maxDescendantsToVisit) {
|
||||||
// If not too many to replace, then calculate the set of
|
// If not too many to replace, then calculate the set of
|
||||||
// transactions that would have to be evicted
|
// transactions that would have to be evicted
|
||||||
BOOST_FOREACH(CTxMemPool::txiter it, setIterConflicting) {
|
for (CTxMemPool::txiter it : setIterConflicting) {
|
||||||
pool.CalculateDescendants(it, allConflicting);
|
pool.CalculateDescendants(it, allConflicting);
|
||||||
}
|
}
|
||||||
BOOST_FOREACH(CTxMemPool::txiter it, allConflicting) {
|
for (CTxMemPool::txiter it : allConflicting) {
|
||||||
nConflictingFees += it->GetModifiedFee();
|
nConflictingFees += it->GetModifiedFee();
|
||||||
nConflictingSize += it->GetTxSize();
|
nConflictingSize += it->GetTxSize();
|
||||||
}
|
}
|
||||||
|
@ -775,7 +775,7 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const C
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove conflicting transactions from the mempool
|
// Remove conflicting transactions from the mempool
|
||||||
BOOST_FOREACH(const CTxMemPool::txiter it, allConflicting)
|
for (const CTxMemPool::txiter it : allConflicting)
|
||||||
{
|
{
|
||||||
LogPrint(BCLog::MEMPOOL, "replacing tx %s with %s for %s BTC additional fees, %d delta bytes\n",
|
LogPrint(BCLog::MEMPOOL, "replacing tx %s with %s for %s BTC additional fees, %d delta bytes\n",
|
||||||
it->GetTx().GetHash().ToString(),
|
it->GetTx().GetHash().ToString(),
|
||||||
|
@ -816,7 +816,7 @@ bool AcceptToMemoryPoolWithTime(CTxMemPool& pool, CValidationState &state, const
|
||||||
std::vector<COutPoint> coins_to_uncache;
|
std::vector<COutPoint> coins_to_uncache;
|
||||||
bool res = AcceptToMemoryPoolWorker(pool, state, tx, fLimitFree, pfMissingInputs, nAcceptTime, plTxnReplaced, fOverrideMempoolLimit, nAbsurdFee, coins_to_uncache);
|
bool res = AcceptToMemoryPoolWorker(pool, state, tx, fLimitFree, pfMissingInputs, nAcceptTime, plTxnReplaced, fOverrideMempoolLimit, nAbsurdFee, coins_to_uncache);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
BOOST_FOREACH(const COutPoint& hashTx, coins_to_uncache)
|
for (const COutPoint& hashTx : coins_to_uncache)
|
||||||
pcoinsTip->Uncache(hashTx);
|
pcoinsTip->Uncache(hashTx);
|
||||||
}
|
}
|
||||||
// After we've (potentially) uncached entries, ensure our coins cache is still within its size limits
|
// After we've (potentially) uncached entries, ensure our coins cache is still within its size limits
|
||||||
|
@ -1116,7 +1116,7 @@ void UpdateCoins(const CTransaction& tx, CCoinsViewCache& inputs, CTxUndo &txund
|
||||||
// mark inputs spent
|
// mark inputs spent
|
||||||
if (!tx.IsCoinBase()) {
|
if (!tx.IsCoinBase()) {
|
||||||
txundo.vprevout.reserve(tx.vin.size());
|
txundo.vprevout.reserve(tx.vin.size());
|
||||||
BOOST_FOREACH(const CTxIn &txin, tx.vin) {
|
for (const CTxIn &txin : tx.vin) {
|
||||||
txundo.vprevout.emplace_back();
|
txundo.vprevout.emplace_back();
|
||||||
inputs.SpendCoin(txin.prevout, &txundo.vprevout.back());
|
inputs.SpendCoin(txin.prevout, &txundo.vprevout.back());
|
||||||
}
|
}
|
||||||
|
@ -3097,7 +3097,7 @@ bool TestBlockValidity(CValidationState& state, const CChainParams& chainparams,
|
||||||
uint64_t CalculateCurrentUsage()
|
uint64_t CalculateCurrentUsage()
|
||||||
{
|
{
|
||||||
uint64_t retval = 0;
|
uint64_t retval = 0;
|
||||||
BOOST_FOREACH(const CBlockFileInfo &file, vinfoBlockFile) {
|
for (const CBlockFileInfo &file : vinfoBlockFile) {
|
||||||
retval += file.nSize + file.nUndoSize;
|
retval += file.nSize + file.nUndoSize;
|
||||||
}
|
}
|
||||||
return retval;
|
return retval;
|
||||||
|
@ -3300,13 +3300,13 @@ bool static LoadBlockIndexDB(const CChainParams& chainparams)
|
||||||
// Calculate nChainWork
|
// Calculate nChainWork
|
||||||
std::vector<std::pair<int, CBlockIndex*> > vSortedByHeight;
|
std::vector<std::pair<int, CBlockIndex*> > vSortedByHeight;
|
||||||
vSortedByHeight.reserve(mapBlockIndex.size());
|
vSortedByHeight.reserve(mapBlockIndex.size());
|
||||||
BOOST_FOREACH(const PAIRTYPE(uint256, CBlockIndex*)& item, mapBlockIndex)
|
for (const PAIRTYPE(uint256, CBlockIndex*)& item : mapBlockIndex)
|
||||||
{
|
{
|
||||||
CBlockIndex* pindex = item.second;
|
CBlockIndex* pindex = item.second;
|
||||||
vSortedByHeight.push_back(std::make_pair(pindex->nHeight, pindex));
|
vSortedByHeight.push_back(std::make_pair(pindex->nHeight, pindex));
|
||||||
}
|
}
|
||||||
sort(vSortedByHeight.begin(), vSortedByHeight.end());
|
sort(vSortedByHeight.begin(), vSortedByHeight.end());
|
||||||
BOOST_FOREACH(const PAIRTYPE(int, CBlockIndex*)& item, vSortedByHeight)
|
for (const PAIRTYPE(int, CBlockIndex*)& item : vSortedByHeight)
|
||||||
{
|
{
|
||||||
CBlockIndex* pindex = item.second;
|
CBlockIndex* pindex = item.second;
|
||||||
pindex->nChainWork = (pindex->pprev ? pindex->pprev->nChainWork : 0) + GetBlockProof(*pindex);
|
pindex->nChainWork = (pindex->pprev ? pindex->pprev->nChainWork : 0) + GetBlockProof(*pindex);
|
||||||
|
@ -3355,7 +3355,7 @@ bool static LoadBlockIndexDB(const CChainParams& chainparams)
|
||||||
// Check presence of blk files
|
// Check presence of blk files
|
||||||
LogPrintf("Checking all blk files are present...\n");
|
LogPrintf("Checking all blk files are present...\n");
|
||||||
std::set<int> setBlkDataFiles;
|
std::set<int> setBlkDataFiles;
|
||||||
BOOST_FOREACH(const PAIRTYPE(uint256, CBlockIndex*)& item, mapBlockIndex)
|
for (const PAIRTYPE(uint256, CBlockIndex*)& item : mapBlockIndex)
|
||||||
{
|
{
|
||||||
CBlockIndex* pindex = item.second;
|
CBlockIndex* pindex = item.second;
|
||||||
if (pindex->nStatus & BLOCK_HAVE_DATA) {
|
if (pindex->nStatus & BLOCK_HAVE_DATA) {
|
||||||
|
@ -3611,7 +3611,7 @@ void UnloadBlockIndex()
|
||||||
warningcache[b].clear();
|
warningcache[b].clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_FOREACH(BlockMap::value_type& entry, mapBlockIndex) {
|
for (BlockMap::value_type& entry : mapBlockIndex) {
|
||||||
delete entry.second;
|
delete entry.second;
|
||||||
}
|
}
|
||||||
mapBlockIndex.clear();
|
mapBlockIndex.clear();
|
||||||
|
|
|
@ -285,7 +285,7 @@ bool CCryptoKeyStore::EncryptKeys(CKeyingMaterial& vMasterKeyIn)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
fUseCrypto = true;
|
fUseCrypto = true;
|
||||||
BOOST_FOREACH(KeyMap::value_type& mKey, mapKeys)
|
for (KeyMap::value_type& mKey : mapKeys)
|
||||||
{
|
{
|
||||||
const CKey &key = mKey.second;
|
const CKey &key = mKey.second;
|
||||||
CPubKey vchPubKey = key.GetPubKey();
|
CPubKey vchPubKey = key.GetPubKey();
|
||||||
|
|
|
@ -205,7 +205,7 @@ bool CDB::Recover(const std::string& filename, void *callbackDataIn, bool (*reco
|
||||||
}
|
}
|
||||||
|
|
||||||
DbTxn* ptxn = bitdb.TxnBegin();
|
DbTxn* ptxn = bitdb.TxnBegin();
|
||||||
BOOST_FOREACH(CDBEnv::KeyValPair& row, salvagedData)
|
for (CDBEnv::KeyValPair& row : salvagedData)
|
||||||
{
|
{
|
||||||
if (recoverKVcallback)
|
if (recoverKVcallback)
|
||||||
{
|
{
|
||||||
|
|
|
@ -48,7 +48,7 @@ int64_t static DecodeDumpTime(const std::string &str) {
|
||||||
|
|
||||||
std::string static EncodeDumpString(const std::string &str) {
|
std::string static EncodeDumpString(const std::string &str) {
|
||||||
std::stringstream ret;
|
std::stringstream ret;
|
||||||
BOOST_FOREACH(unsigned char c, str) {
|
for (unsigned char c : str) {
|
||||||
if (c <= 32 || c >= 128 || c == '%') {
|
if (c <= 32 || c >= 128 || c == '%') {
|
||||||
ret << '%' << HexStr(&c, &c + 1);
|
ret << '%' << HexStr(&c, &c + 1);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1106,7 +1106,7 @@ UniValue importmulti(const JSONRPCRequest& mainRequest)
|
||||||
|
|
||||||
UniValue response(UniValue::VARR);
|
UniValue response(UniValue::VARR);
|
||||||
|
|
||||||
BOOST_FOREACH (const UniValue& data, requests.getValues()) {
|
for (const UniValue& data : requests.getValues()) {
|
||||||
const int64_t timestamp = std::max(GetImportTimestamp(data, now), minimumTimestamp);
|
const int64_t timestamp = std::max(GetImportTimestamp(data, now), minimumTimestamp);
|
||||||
const UniValue result = ProcessImport(pwallet, data, timestamp);
|
const UniValue result = ProcessImport(pwallet, data, timestamp);
|
||||||
response.push_back(result);
|
response.push_back(result);
|
||||||
|
|
|
@ -78,7 +78,7 @@ void WalletTxToJSON(const CWalletTx& wtx, UniValue& entry)
|
||||||
uint256 hash = wtx.GetHash();
|
uint256 hash = wtx.GetHash();
|
||||||
entry.push_back(Pair("txid", hash.GetHex()));
|
entry.push_back(Pair("txid", hash.GetHex()));
|
||||||
UniValue conflicts(UniValue::VARR);
|
UniValue conflicts(UniValue::VARR);
|
||||||
BOOST_FOREACH(const uint256& conflict, wtx.GetConflicts())
|
for (const uint256& conflict : wtx.GetConflicts())
|
||||||
conflicts.push_back(conflict.GetHex());
|
conflicts.push_back(conflict.GetHex());
|
||||||
entry.push_back(Pair("walletconflicts", conflicts));
|
entry.push_back(Pair("walletconflicts", conflicts));
|
||||||
entry.push_back(Pair("time", wtx.GetTxTime()));
|
entry.push_back(Pair("time", wtx.GetTxTime()));
|
||||||
|
@ -96,7 +96,7 @@ void WalletTxToJSON(const CWalletTx& wtx, UniValue& entry)
|
||||||
}
|
}
|
||||||
entry.push_back(Pair("bip125-replaceable", rbfStatus));
|
entry.push_back(Pair("bip125-replaceable", rbfStatus));
|
||||||
|
|
||||||
BOOST_FOREACH(const PAIRTYPE(std::string, std::string)& item, wtx.mapValue)
|
for (const PAIRTYPE(std::string, std::string)& item : wtx.mapValue)
|
||||||
entry.push_back(Pair(item.first, item.second));
|
entry.push_back(Pair(item.first, item.second));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -490,7 +490,7 @@ UniValue listaddressgroupings(const JSONRPCRequest& request)
|
||||||
std::map<CTxDestination, CAmount> balances = pwallet->GetAddressBalances();
|
std::map<CTxDestination, CAmount> balances = pwallet->GetAddressBalances();
|
||||||
for (std::set<CTxDestination> grouping : pwallet->GetAddressGroupings()) {
|
for (std::set<CTxDestination> grouping : pwallet->GetAddressGroupings()) {
|
||||||
UniValue jsonGrouping(UniValue::VARR);
|
UniValue jsonGrouping(UniValue::VARR);
|
||||||
BOOST_FOREACH(CTxDestination address, grouping)
|
for (CTxDestination address : grouping)
|
||||||
{
|
{
|
||||||
UniValue addressInfo(UniValue::VARR);
|
UniValue addressInfo(UniValue::VARR);
|
||||||
addressInfo.push_back(CBitcoinAddress(address).ToString());
|
addressInfo.push_back(CBitcoinAddress(address).ToString());
|
||||||
|
@ -616,7 +616,7 @@ UniValue getreceivedbyaddress(const JSONRPCRequest& request)
|
||||||
if (wtx.IsCoinBase() || !CheckFinalTx(*wtx.tx))
|
if (wtx.IsCoinBase() || !CheckFinalTx(*wtx.tx))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
BOOST_FOREACH(const CTxOut& txout, wtx.tx->vout)
|
for (const CTxOut& txout : wtx.tx->vout)
|
||||||
if (txout.scriptPubKey == scriptPubKey)
|
if (txout.scriptPubKey == scriptPubKey)
|
||||||
if (wtx.GetDepthInMainChain() >= nMinDepth)
|
if (wtx.GetDepthInMainChain() >= nMinDepth)
|
||||||
nAmount += txout.nValue;
|
nAmount += txout.nValue;
|
||||||
|
@ -671,7 +671,7 @@ UniValue getreceivedbyaccount(const JSONRPCRequest& request)
|
||||||
if (wtx.IsCoinBase() || !CheckFinalTx(*wtx.tx))
|
if (wtx.IsCoinBase() || !CheckFinalTx(*wtx.tx))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
BOOST_FOREACH(const CTxOut& txout, wtx.tx->vout)
|
for (const CTxOut& txout : wtx.tx->vout)
|
||||||
{
|
{
|
||||||
CTxDestination address;
|
CTxDestination address;
|
||||||
if (ExtractDestination(txout.scriptPubKey, address) && IsMine(*pwallet, address) && setAddress.count(address)) {
|
if (ExtractDestination(txout.scriptPubKey, address) && IsMine(*pwallet, address) && setAddress.count(address)) {
|
||||||
|
@ -950,7 +950,7 @@ UniValue sendmany(const JSONRPCRequest& request)
|
||||||
|
|
||||||
CAmount totalAmount = 0;
|
CAmount totalAmount = 0;
|
||||||
std::vector<std::string> keys = sendTo.getKeys();
|
std::vector<std::string> keys = sendTo.getKeys();
|
||||||
BOOST_FOREACH(const std::string& name_, keys)
|
for (const std::string& name_ : keys)
|
||||||
{
|
{
|
||||||
CBitcoinAddress address(name_);
|
CBitcoinAddress address(name_);
|
||||||
if (!address.IsValid())
|
if (!address.IsValid())
|
||||||
|
@ -1191,7 +1191,7 @@ UniValue ListReceived(CWallet * const pwallet, const UniValue& params, bool fByA
|
||||||
if (nDepth < nMinDepth)
|
if (nDepth < nMinDepth)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
BOOST_FOREACH(const CTxOut& txout, wtx.tx->vout)
|
for (const CTxOut& txout : wtx.tx->vout)
|
||||||
{
|
{
|
||||||
CTxDestination address;
|
CTxDestination address;
|
||||||
if (!ExtractDestination(txout.scriptPubKey, address))
|
if (!ExtractDestination(txout.scriptPubKey, address))
|
||||||
|
@ -1251,7 +1251,7 @@ UniValue ListReceived(CWallet * const pwallet, const UniValue& params, bool fByA
|
||||||
UniValue transactions(UniValue::VARR);
|
UniValue transactions(UniValue::VARR);
|
||||||
if (it != mapTally.end())
|
if (it != mapTally.end())
|
||||||
{
|
{
|
||||||
BOOST_FOREACH(const uint256& _item, (*it).second.txids)
|
for (const uint256& _item : (*it).second.txids)
|
||||||
{
|
{
|
||||||
transactions.push_back(_item.GetHex());
|
transactions.push_back(_item.GetHex());
|
||||||
}
|
}
|
||||||
|
@ -1385,7 +1385,7 @@ void ListTransactions(CWallet* const pwallet, const CWalletTx& wtx, const std::s
|
||||||
// Sent
|
// Sent
|
||||||
if ((!listSent.empty() || nFee != 0) && (fAllAccounts || strAccount == strSentAccount))
|
if ((!listSent.empty() || nFee != 0) && (fAllAccounts || strAccount == strSentAccount))
|
||||||
{
|
{
|
||||||
BOOST_FOREACH(const COutputEntry& s, listSent)
|
for (const COutputEntry& s : listSent)
|
||||||
{
|
{
|
||||||
UniValue entry(UniValue::VOBJ);
|
UniValue entry(UniValue::VOBJ);
|
||||||
if (involvesWatchonly || (::IsMine(*pwallet, s.destination) & ISMINE_WATCH_ONLY)) {
|
if (involvesWatchonly || (::IsMine(*pwallet, s.destination) & ISMINE_WATCH_ONLY)) {
|
||||||
|
@ -1410,7 +1410,7 @@ void ListTransactions(CWallet* const pwallet, const CWalletTx& wtx, const std::s
|
||||||
// Received
|
// Received
|
||||||
if (listReceived.size() > 0 && wtx.GetDepthInMainChain() >= nMinDepth)
|
if (listReceived.size() > 0 && wtx.GetDepthInMainChain() >= nMinDepth)
|
||||||
{
|
{
|
||||||
BOOST_FOREACH(const COutputEntry& r, listReceived)
|
for (const COutputEntry& r : listReceived)
|
||||||
{
|
{
|
||||||
std::string account;
|
std::string account;
|
||||||
if (pwallet->mapAddressBook.count(r.destination)) {
|
if (pwallet->mapAddressBook.count(r.destination)) {
|
||||||
|
@ -1655,11 +1655,11 @@ UniValue listaccounts(const JSONRPCRequest& request)
|
||||||
continue;
|
continue;
|
||||||
wtx.GetAmounts(listReceived, listSent, nFee, strSentAccount, includeWatchonly);
|
wtx.GetAmounts(listReceived, listSent, nFee, strSentAccount, includeWatchonly);
|
||||||
mapAccountBalances[strSentAccount] -= nFee;
|
mapAccountBalances[strSentAccount] -= nFee;
|
||||||
BOOST_FOREACH(const COutputEntry& s, listSent)
|
for (const COutputEntry& s : listSent)
|
||||||
mapAccountBalances[strSentAccount] -= s.amount;
|
mapAccountBalances[strSentAccount] -= s.amount;
|
||||||
if (nDepth >= nMinDepth)
|
if (nDepth >= nMinDepth)
|
||||||
{
|
{
|
||||||
BOOST_FOREACH(const COutputEntry& r, listReceived)
|
for (const COutputEntry& r : listReceived)
|
||||||
if (pwallet->mapAddressBook.count(r.destination)) {
|
if (pwallet->mapAddressBook.count(r.destination)) {
|
||||||
mapAccountBalances[pwallet->mapAddressBook[r.destination].name] += r.amount;
|
mapAccountBalances[pwallet->mapAddressBook[r.destination].name] += r.amount;
|
||||||
}
|
}
|
||||||
|
@ -1669,11 +1669,11 @@ UniValue listaccounts(const JSONRPCRequest& request)
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::list<CAccountingEntry>& acentries = pwallet->laccentries;
|
const std::list<CAccountingEntry>& acentries = pwallet->laccentries;
|
||||||
BOOST_FOREACH(const CAccountingEntry& entry, acentries)
|
for (const CAccountingEntry& entry : acentries)
|
||||||
mapAccountBalances[entry.strAccount] += entry.nCreditDebit;
|
mapAccountBalances[entry.strAccount] += entry.nCreditDebit;
|
||||||
|
|
||||||
UniValue ret(UniValue::VOBJ);
|
UniValue ret(UniValue::VOBJ);
|
||||||
BOOST_FOREACH(const PAIRTYPE(std::string, CAmount)& accountBalance, mapAccountBalances) {
|
for (const PAIRTYPE(std::string, CAmount)& accountBalance : mapAccountBalances) {
|
||||||
ret.push_back(Pair(accountBalance.first, ValueFromAmount(accountBalance.second)));
|
ret.push_back(Pair(accountBalance.first, ValueFromAmount(accountBalance.second)));
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -2338,7 +2338,7 @@ UniValue listlockunspent(const JSONRPCRequest& request)
|
||||||
|
|
||||||
UniValue ret(UniValue::VARR);
|
UniValue ret(UniValue::VARR);
|
||||||
|
|
||||||
BOOST_FOREACH(COutPoint &outpt, vOutpts) {
|
for (COutPoint &outpt : vOutpts) {
|
||||||
UniValue o(UniValue::VOBJ);
|
UniValue o(UniValue::VOBJ);
|
||||||
|
|
||||||
o.push_back(Pair("txid", outpt.hash.GetHex()));
|
o.push_back(Pair("txid", outpt.hash.GetHex()));
|
||||||
|
@ -2456,7 +2456,7 @@ UniValue resendwallettransactions(const JSONRPCRequest& request)
|
||||||
|
|
||||||
std::vector<uint256> txids = pwallet->ResendWalletTransactionsBefore(GetTime(), g_connman.get());
|
std::vector<uint256> txids = pwallet->ResendWalletTransactionsBefore(GetTime(), g_connman.get());
|
||||||
UniValue result(UniValue::VARR);
|
UniValue result(UniValue::VARR);
|
||||||
BOOST_FOREACH(const uint256& txid, txids)
|
for (const uint256& txid : txids)
|
||||||
{
|
{
|
||||||
result.push_back(txid.ToString());
|
result.push_back(txid.ToString());
|
||||||
}
|
}
|
||||||
|
@ -2581,7 +2581,7 @@ UniValue listunspent(const JSONRPCRequest& request)
|
||||||
LOCK2(cs_main, pwallet->cs_wallet);
|
LOCK2(cs_main, pwallet->cs_wallet);
|
||||||
|
|
||||||
pwallet->AvailableCoins(vecOutputs, !include_unsafe, NULL, nMinimumAmount, nMaximumAmount, nMinimumSumAmount, nMaximumCount, nMinDepth, nMaxDepth);
|
pwallet->AvailableCoins(vecOutputs, !include_unsafe, NULL, nMinimumAmount, nMaximumAmount, nMinimumSumAmount, nMaximumCount, nMinDepth, nMaxDepth);
|
||||||
BOOST_FOREACH(const COutput& out, vecOutputs) {
|
for (const COutput& out : vecOutputs) {
|
||||||
CTxDestination address;
|
CTxDestination address;
|
||||||
const CScript& scriptPubKey = out.tx->tx->vout[out.i].scriptPubKey;
|
const CScript& scriptPubKey = out.tx->tx->vout[out.i].scriptPubKey;
|
||||||
bool fValidAddress = ExtractDestination(scriptPubKey, address);
|
bool fValidAddress = ExtractDestination(scriptPubKey, address);
|
||||||
|
|
|
@ -23,7 +23,7 @@ GetResults(std::map<CAmount, CAccountingEntry>& results)
|
||||||
results.clear();
|
results.clear();
|
||||||
BOOST_CHECK(pwalletMain->ReorderTransactions() == DB_LOAD_OK);
|
BOOST_CHECK(pwalletMain->ReorderTransactions() == DB_LOAD_OK);
|
||||||
pwalletMain->ListAccountCreditDebit("", aes);
|
pwalletMain->ListAccountCreditDebit("", aes);
|
||||||
BOOST_FOREACH(CAccountingEntry& ae, aes)
|
for (CAccountingEntry& ae : aes)
|
||||||
{
|
{
|
||||||
results[ae.nOrderPos] = ae;
|
results[ae.nOrderPos] = ae;
|
||||||
}
|
}
|
||||||
|
|
|
@ -297,7 +297,7 @@ bool CWallet::Unlock(const SecureString& strWalletPassphrase)
|
||||||
|
|
||||||
{
|
{
|
||||||
LOCK(cs_wallet);
|
LOCK(cs_wallet);
|
||||||
BOOST_FOREACH(const MasterKeyMap::value_type& pMasterKey, mapMasterKeys)
|
for (const MasterKeyMap::value_type& pMasterKey : mapMasterKeys)
|
||||||
{
|
{
|
||||||
if(!crypter.SetKeyFromPassphrase(strWalletPassphrase, pMasterKey.second.vchSalt, pMasterKey.second.nDeriveIterations, pMasterKey.second.nDerivationMethod))
|
if(!crypter.SetKeyFromPassphrase(strWalletPassphrase, pMasterKey.second.vchSalt, pMasterKey.second.nDeriveIterations, pMasterKey.second.nDerivationMethod))
|
||||||
return false;
|
return false;
|
||||||
|
@ -320,7 +320,7 @@ bool CWallet::ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase,
|
||||||
|
|
||||||
CCrypter crypter;
|
CCrypter crypter;
|
||||||
CKeyingMaterial _vMasterKey;
|
CKeyingMaterial _vMasterKey;
|
||||||
BOOST_FOREACH(MasterKeyMap::value_type& pMasterKey, mapMasterKeys)
|
for (MasterKeyMap::value_type& pMasterKey : mapMasterKeys)
|
||||||
{
|
{
|
||||||
if(!crypter.SetKeyFromPassphrase(strOldWalletPassphrase, pMasterKey.second.vchSalt, pMasterKey.second.nDeriveIterations, pMasterKey.second.nDerivationMethod))
|
if(!crypter.SetKeyFromPassphrase(strOldWalletPassphrase, pMasterKey.second.vchSalt, pMasterKey.second.nDeriveIterations, pMasterKey.second.nDerivationMethod))
|
||||||
return false;
|
return false;
|
||||||
|
@ -412,7 +412,7 @@ std::set<uint256> CWallet::GetConflicts(const uint256& txid) const
|
||||||
|
|
||||||
std::pair<TxSpends::const_iterator, TxSpends::const_iterator> range;
|
std::pair<TxSpends::const_iterator, TxSpends::const_iterator> range;
|
||||||
|
|
||||||
BOOST_FOREACH(const CTxIn& txin, wtx.tx->vin)
|
for (const CTxIn& txin : wtx.tx->vin)
|
||||||
{
|
{
|
||||||
if (mapTxSpends.count(txin.prevout) <= 1)
|
if (mapTxSpends.count(txin.prevout) <= 1)
|
||||||
continue; // No conflict if zero or one spends
|
continue; // No conflict if zero or one spends
|
||||||
|
@ -544,7 +544,7 @@ void CWallet::AddToSpends(const uint256& wtxid)
|
||||||
if (thisTx.IsCoinBase()) // Coinbases don't spend anything!
|
if (thisTx.IsCoinBase()) // Coinbases don't spend anything!
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BOOST_FOREACH(const CTxIn& txin, thisTx.tx->vin)
|
for (const CTxIn& txin : thisTx.tx->vin)
|
||||||
AddToSpends(txin.prevout, wtxid);
|
AddToSpends(txin.prevout, wtxid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -659,7 +659,7 @@ DBErrors CWallet::ReorderTransactions()
|
||||||
}
|
}
|
||||||
std::list<CAccountingEntry> acentries;
|
std::list<CAccountingEntry> acentries;
|
||||||
walletdb.ListAccountCreditDebit("", acentries);
|
walletdb.ListAccountCreditDebit("", acentries);
|
||||||
BOOST_FOREACH(CAccountingEntry& entry, acentries)
|
for (CAccountingEntry& entry : acentries)
|
||||||
{
|
{
|
||||||
txByTime.insert(std::make_pair(entry.nTime, TxPair((CWalletTx*)0, &entry)));
|
txByTime.insert(std::make_pair(entry.nTime, TxPair((CWalletTx*)0, &entry)));
|
||||||
}
|
}
|
||||||
|
@ -689,7 +689,7 @@ DBErrors CWallet::ReorderTransactions()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int64_t nOrderPosOff = 0;
|
int64_t nOrderPosOff = 0;
|
||||||
BOOST_FOREACH(const int64_t& nOffsetStart, nOrderPosOffsets)
|
for (const int64_t& nOffsetStart : nOrderPosOffsets)
|
||||||
{
|
{
|
||||||
if (nOrderPos >= nOffsetStart)
|
if (nOrderPos >= nOffsetStart)
|
||||||
++nOrderPosOff;
|
++nOrderPosOff;
|
||||||
|
@ -778,7 +778,7 @@ bool CWallet::GetAccountPubkey(CPubKey &pubKey, std::string strAccount, bool bFo
|
||||||
for (std::map<uint256, CWalletTx>::iterator it = mapWallet.begin();
|
for (std::map<uint256, CWalletTx>::iterator it = mapWallet.begin();
|
||||||
it != mapWallet.end() && account.vchPubKey.IsValid();
|
it != mapWallet.end() && account.vchPubKey.IsValid();
|
||||||
++it)
|
++it)
|
||||||
BOOST_FOREACH(const CTxOut& txout, (*it).second.tx->vout)
|
for (const CTxOut& txout : (*it).second.tx->vout)
|
||||||
if (txout.scriptPubKey == scriptPubKey) {
|
if (txout.scriptPubKey == scriptPubKey) {
|
||||||
bForceNew = true;
|
bForceNew = true;
|
||||||
break;
|
break;
|
||||||
|
@ -804,7 +804,7 @@ void CWallet::MarkDirty()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
LOCK(cs_wallet);
|
LOCK(cs_wallet);
|
||||||
BOOST_FOREACH(PAIRTYPE(const uint256, CWalletTx)& item, mapWallet)
|
for (PAIRTYPE(const uint256, CWalletTx)& item : mapWallet)
|
||||||
item.second.MarkDirty();
|
item.second.MarkDirty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -922,7 +922,7 @@ bool CWallet::LoadToWallet(const CWalletTx& wtxIn)
|
||||||
wtx.BindWallet(this);
|
wtx.BindWallet(this);
|
||||||
wtxOrdered.insert(std::make_pair(wtx.nOrderPos, TxPair(&wtx, (CAccountingEntry*)0)));
|
wtxOrdered.insert(std::make_pair(wtx.nOrderPos, TxPair(&wtx, (CAccountingEntry*)0)));
|
||||||
AddToSpends(hash);
|
AddToSpends(hash);
|
||||||
BOOST_FOREACH(const CTxIn& txin, wtx.tx->vin) {
|
for (const CTxIn& txin : wtx.tx->vin) {
|
||||||
if (mapWallet.count(txin.prevout.hash)) {
|
if (mapWallet.count(txin.prevout.hash)) {
|
||||||
CWalletTx& prevtx = mapWallet[txin.prevout.hash];
|
CWalletTx& prevtx = mapWallet[txin.prevout.hash];
|
||||||
if (prevtx.nIndex == -1 && !prevtx.hashUnset()) {
|
if (prevtx.nIndex == -1 && !prevtx.hashUnset()) {
|
||||||
|
@ -954,7 +954,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransactionRef& ptx, const CBlockI
|
||||||
AssertLockHeld(cs_wallet);
|
AssertLockHeld(cs_wallet);
|
||||||
|
|
||||||
if (pIndex != NULL) {
|
if (pIndex != NULL) {
|
||||||
BOOST_FOREACH(const CTxIn& txin, tx.vin) {
|
for (const CTxIn& txin : tx.vin) {
|
||||||
std::pair<TxSpends::const_iterator, TxSpends::const_iterator> range = mapTxSpends.equal_range(txin.prevout);
|
std::pair<TxSpends::const_iterator, TxSpends::const_iterator> range = mapTxSpends.equal_range(txin.prevout);
|
||||||
while (range.first != range.second) {
|
while (range.first != range.second) {
|
||||||
if (range.first->second != tx.GetHash()) {
|
if (range.first->second != tx.GetHash()) {
|
||||||
|
@ -1035,7 +1035,7 @@ bool CWallet::AbandonTransaction(const uint256& hashTx)
|
||||||
}
|
}
|
||||||
// If a transaction changes 'conflicted' state, that changes the balance
|
// If a transaction changes 'conflicted' state, that changes the balance
|
||||||
// available of the outputs it spends. So force those to be recomputed
|
// available of the outputs it spends. So force those to be recomputed
|
||||||
BOOST_FOREACH(const CTxIn& txin, wtx.tx->vin)
|
for (const CTxIn& txin : wtx.tx->vin)
|
||||||
{
|
{
|
||||||
if (mapWallet.count(txin.prevout.hash))
|
if (mapWallet.count(txin.prevout.hash))
|
||||||
mapWallet[txin.prevout.hash].MarkDirty();
|
mapWallet[txin.prevout.hash].MarkDirty();
|
||||||
|
@ -1096,7 +1096,7 @@ void CWallet::MarkConflicted(const uint256& hashBlock, const uint256& hashTx)
|
||||||
}
|
}
|
||||||
// If a transaction changes 'conflicted' state, that changes the balance
|
// If a transaction changes 'conflicted' state, that changes the balance
|
||||||
// available of the outputs it spends. So force those to be recomputed
|
// available of the outputs it spends. So force those to be recomputed
|
||||||
BOOST_FOREACH(const CTxIn& txin, wtx.tx->vin)
|
for (const CTxIn& txin : wtx.tx->vin)
|
||||||
{
|
{
|
||||||
if (mapWallet.count(txin.prevout.hash))
|
if (mapWallet.count(txin.prevout.hash))
|
||||||
mapWallet[txin.prevout.hash].MarkDirty();
|
mapWallet[txin.prevout.hash].MarkDirty();
|
||||||
|
@ -1114,7 +1114,7 @@ void CWallet::SyncTransaction(const CTransactionRef& ptx, const CBlockIndex *pin
|
||||||
// If a transaction changes 'conflicted' state, that changes the balance
|
// If a transaction changes 'conflicted' state, that changes the balance
|
||||||
// available of the outputs it spends. So force those to be
|
// available of the outputs it spends. So force those to be
|
||||||
// recomputed, also:
|
// recomputed, also:
|
||||||
BOOST_FOREACH(const CTxIn& txin, tx.vin)
|
for (const CTxIn& txin : tx.vin)
|
||||||
{
|
{
|
||||||
if (mapWallet.count(txin.prevout.hash))
|
if (mapWallet.count(txin.prevout.hash))
|
||||||
mapWallet[txin.prevout.hash].MarkDirty();
|
mapWallet[txin.prevout.hash].MarkDirty();
|
||||||
|
@ -1230,7 +1230,7 @@ CAmount CWallet::GetChange(const CTxOut& txout) const
|
||||||
|
|
||||||
bool CWallet::IsMine(const CTransaction& tx) const
|
bool CWallet::IsMine(const CTransaction& tx) const
|
||||||
{
|
{
|
||||||
BOOST_FOREACH(const CTxOut& txout, tx.vout)
|
for (const CTxOut& txout : tx.vout)
|
||||||
if (IsMine(txout))
|
if (IsMine(txout))
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
|
@ -1244,7 +1244,7 @@ bool CWallet::IsFromMe(const CTransaction& tx) const
|
||||||
CAmount CWallet::GetDebit(const CTransaction& tx, const isminefilter& filter) const
|
CAmount CWallet::GetDebit(const CTransaction& tx, const isminefilter& filter) const
|
||||||
{
|
{
|
||||||
CAmount nDebit = 0;
|
CAmount nDebit = 0;
|
||||||
BOOST_FOREACH(const CTxIn& txin, tx.vin)
|
for (const CTxIn& txin : tx.vin)
|
||||||
{
|
{
|
||||||
nDebit += GetDebit(txin, filter);
|
nDebit += GetDebit(txin, filter);
|
||||||
if (!MoneyRange(nDebit))
|
if (!MoneyRange(nDebit))
|
||||||
|
@ -1257,7 +1257,7 @@ bool CWallet::IsAllFromMe(const CTransaction& tx, const isminefilter& filter) co
|
||||||
{
|
{
|
||||||
LOCK(cs_wallet);
|
LOCK(cs_wallet);
|
||||||
|
|
||||||
BOOST_FOREACH(const CTxIn& txin, tx.vin)
|
for (const CTxIn& txin : tx.vin)
|
||||||
{
|
{
|
||||||
auto mi = mapWallet.find(txin.prevout.hash);
|
auto mi = mapWallet.find(txin.prevout.hash);
|
||||||
if (mi == mapWallet.end())
|
if (mi == mapWallet.end())
|
||||||
|
@ -1277,7 +1277,7 @@ bool CWallet::IsAllFromMe(const CTransaction& tx, const isminefilter& filter) co
|
||||||
CAmount CWallet::GetCredit(const CTransaction& tx, const isminefilter& filter) const
|
CAmount CWallet::GetCredit(const CTransaction& tx, const isminefilter& filter) const
|
||||||
{
|
{
|
||||||
CAmount nCredit = 0;
|
CAmount nCredit = 0;
|
||||||
BOOST_FOREACH(const CTxOut& txout, tx.vout)
|
for (const CTxOut& txout : tx.vout)
|
||||||
{
|
{
|
||||||
nCredit += GetCredit(txout, filter);
|
nCredit += GetCredit(txout, filter);
|
||||||
if (!MoneyRange(nCredit))
|
if (!MoneyRange(nCredit))
|
||||||
|
@ -1289,7 +1289,7 @@ CAmount CWallet::GetCredit(const CTransaction& tx, const isminefilter& filter) c
|
||||||
CAmount CWallet::GetChange(const CTransaction& tx) const
|
CAmount CWallet::GetChange(const CTransaction& tx) const
|
||||||
{
|
{
|
||||||
CAmount nChange = 0;
|
CAmount nChange = 0;
|
||||||
BOOST_FOREACH(const CTxOut& txout, tx.vout)
|
for (const CTxOut& txout : tx.vout)
|
||||||
{
|
{
|
||||||
nChange += GetChange(txout);
|
nChange += GetChange(txout);
|
||||||
if (!MoneyRange(nChange))
|
if (!MoneyRange(nChange))
|
||||||
|
@ -1525,7 +1525,7 @@ void CWallet::ReacceptWalletTransactions()
|
||||||
std::map<int64_t, CWalletTx*> mapSorted;
|
std::map<int64_t, CWalletTx*> mapSorted;
|
||||||
|
|
||||||
// Sort pending wallet transactions based on their initial wallet insertion order
|
// Sort pending wallet transactions based on their initial wallet insertion order
|
||||||
BOOST_FOREACH(PAIRTYPE(const uint256, CWalletTx)& item, mapWallet)
|
for (PAIRTYPE(const uint256, CWalletTx)& item : mapWallet)
|
||||||
{
|
{
|
||||||
const uint256& wtxid = item.first;
|
const uint256& wtxid = item.first;
|
||||||
CWalletTx& wtx = item.second;
|
CWalletTx& wtx = item.second;
|
||||||
|
@ -1539,7 +1539,7 @@ void CWallet::ReacceptWalletTransactions()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to add wallet transactions to memory pool
|
// Try to add wallet transactions to memory pool
|
||||||
BOOST_FOREACH(PAIRTYPE(const int64_t, CWalletTx*)& item, mapSorted)
|
for (PAIRTYPE(const int64_t, CWalletTx*)& item : mapSorted)
|
||||||
{
|
{
|
||||||
CWalletTx& wtx = *(item.second);
|
CWalletTx& wtx = *(item.second);
|
||||||
|
|
||||||
|
@ -1767,7 +1767,7 @@ bool CWalletTx::IsTrusted() const
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Trusted if all inputs are from us and are in the mempool:
|
// Trusted if all inputs are from us and are in the mempool:
|
||||||
BOOST_FOREACH(const CTxIn& txin, tx->vin)
|
for (const CTxIn& txin : tx->vin)
|
||||||
{
|
{
|
||||||
// Transactions not sent by us: not trusted
|
// Transactions not sent by us: not trusted
|
||||||
const CWalletTx* parent = pwallet->GetWalletTx(txin.prevout.hash);
|
const CWalletTx* parent = pwallet->GetWalletTx(txin.prevout.hash);
|
||||||
|
@ -1796,7 +1796,7 @@ std::vector<uint256> CWallet::ResendWalletTransactionsBefore(int64_t nTime, CCon
|
||||||
LOCK(cs_wallet);
|
LOCK(cs_wallet);
|
||||||
// Sort them in chronological order
|
// Sort them in chronological order
|
||||||
std::multimap<unsigned int, CWalletTx*> mapSorted;
|
std::multimap<unsigned int, CWalletTx*> mapSorted;
|
||||||
BOOST_FOREACH(PAIRTYPE(const uint256, CWalletTx)& item, mapWallet)
|
for (PAIRTYPE(const uint256, CWalletTx)& item : mapWallet)
|
||||||
{
|
{
|
||||||
CWalletTx& wtx = item.second;
|
CWalletTx& wtx = item.second;
|
||||||
// Don't rebroadcast if newer than nTime:
|
// Don't rebroadcast if newer than nTime:
|
||||||
|
@ -1804,7 +1804,7 @@ std::vector<uint256> CWallet::ResendWalletTransactionsBefore(int64_t nTime, CCon
|
||||||
continue;
|
continue;
|
||||||
mapSorted.insert(std::make_pair(wtx.nTimeReceived, &wtx));
|
mapSorted.insert(std::make_pair(wtx.nTimeReceived, &wtx));
|
||||||
}
|
}
|
||||||
BOOST_FOREACH(PAIRTYPE(const unsigned int, CWalletTx*)& item, mapSorted)
|
for (PAIRTYPE(const unsigned int, CWalletTx*)& item : mapSorted)
|
||||||
{
|
{
|
||||||
CWalletTx& wtx = *item.second;
|
CWalletTx& wtx = *item.second;
|
||||||
if (wtx.RelayWalletTransaction(connman))
|
if (wtx.RelayWalletTransaction(connman))
|
||||||
|
@ -2228,7 +2228,7 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, const int nConfMin
|
||||||
|
|
||||||
random_shuffle(vCoins.begin(), vCoins.end(), GetRandInt);
|
random_shuffle(vCoins.begin(), vCoins.end(), GetRandInt);
|
||||||
|
|
||||||
BOOST_FOREACH(const COutput &output, vCoins)
|
for (const COutput &output : vCoins)
|
||||||
{
|
{
|
||||||
if (!output.fSpendable)
|
if (!output.fSpendable)
|
||||||
continue;
|
continue;
|
||||||
|
@ -2328,7 +2328,7 @@ bool CWallet::SelectCoins(const std::vector<COutput>& vAvailableCoins, const CAm
|
||||||
// coin control -> return all selected outputs (we want all selected to go into the transaction for sure)
|
// coin control -> return all selected outputs (we want all selected to go into the transaction for sure)
|
||||||
if (coinControl && coinControl->HasSelected() && !coinControl->fAllowOtherInputs)
|
if (coinControl && coinControl->HasSelected() && !coinControl->fAllowOtherInputs)
|
||||||
{
|
{
|
||||||
BOOST_FOREACH(const COutput& out, vCoins)
|
for (const COutput& out : vCoins)
|
||||||
{
|
{
|
||||||
if (!out.fSpendable)
|
if (!out.fSpendable)
|
||||||
continue;
|
continue;
|
||||||
|
@ -2345,7 +2345,7 @@ bool CWallet::SelectCoins(const std::vector<COutput>& vAvailableCoins, const CAm
|
||||||
std::vector<COutPoint> vPresetInputs;
|
std::vector<COutPoint> vPresetInputs;
|
||||||
if (coinControl)
|
if (coinControl)
|
||||||
coinControl->ListSelected(vPresetInputs);
|
coinControl->ListSelected(vPresetInputs);
|
||||||
BOOST_FOREACH(const COutPoint& outpoint, vPresetInputs)
|
for (const COutPoint& outpoint : vPresetInputs)
|
||||||
{
|
{
|
||||||
std::map<uint256, CWalletTx>::const_iterator it = mapWallet.find(outpoint.hash);
|
std::map<uint256, CWalletTx>::const_iterator it = mapWallet.find(outpoint.hash);
|
||||||
if (it != mapWallet.end())
|
if (it != mapWallet.end())
|
||||||
|
@ -2433,7 +2433,7 @@ bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount& nFeeRet, bool ov
|
||||||
coinControl.fOverrideFeeRate = overrideEstimatedFeeRate;
|
coinControl.fOverrideFeeRate = overrideEstimatedFeeRate;
|
||||||
coinControl.nFeeRate = specificFeeRate;
|
coinControl.nFeeRate = specificFeeRate;
|
||||||
|
|
||||||
BOOST_FOREACH(const CTxIn& txin, tx.vin)
|
for (const CTxIn& txin : tx.vin)
|
||||||
coinControl.Select(txin.prevout);
|
coinControl.Select(txin.prevout);
|
||||||
|
|
||||||
CReserveKey reservekey(this);
|
CReserveKey reservekey(this);
|
||||||
|
@ -2449,7 +2449,7 @@ bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount& nFeeRet, bool ov
|
||||||
tx.vout[idx].nValue = wtx.tx->vout[idx].nValue;
|
tx.vout[idx].nValue = wtx.tx->vout[idx].nValue;
|
||||||
|
|
||||||
// Add new txins (keeping original txin scriptSig/order)
|
// Add new txins (keeping original txin scriptSig/order)
|
||||||
BOOST_FOREACH(const CTxIn& txin, wtx.tx->vin)
|
for (const CTxIn& txin : wtx.tx->vin)
|
||||||
{
|
{
|
||||||
if (!coinControl.IsSelected(txin.prevout))
|
if (!coinControl.IsSelected(txin.prevout))
|
||||||
{
|
{
|
||||||
|
@ -2832,7 +2832,7 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey, CCon
|
||||||
AddToWallet(wtxNew);
|
AddToWallet(wtxNew);
|
||||||
|
|
||||||
// Notify that old coins are spent
|
// Notify that old coins are spent
|
||||||
BOOST_FOREACH(const CTxIn& txin, wtxNew.tx->vin)
|
for (const CTxIn& txin : wtxNew.tx->vin)
|
||||||
{
|
{
|
||||||
CWalletTx &coin = mapWallet[txin.prevout.hash];
|
CWalletTx &coin = mapWallet[txin.prevout.hash];
|
||||||
coin.BindWallet(this);
|
coin.BindWallet(this);
|
||||||
|
@ -3010,7 +3010,7 @@ bool CWallet::DelAddressBook(const CTxDestination& address)
|
||||||
|
|
||||||
// Delete destdata tuples associated with address
|
// Delete destdata tuples associated with address
|
||||||
std::string strAddress = CBitcoinAddress(address).ToString();
|
std::string strAddress = CBitcoinAddress(address).ToString();
|
||||||
BOOST_FOREACH(const PAIRTYPE(std::string, std::string) &item, mapAddressBook[address].destdata)
|
for (const PAIRTYPE(std::string, std::string) &item : mapAddressBook[address].destdata)
|
||||||
{
|
{
|
||||||
CWalletDB(*dbw).EraseDestData(strAddress, item.first);
|
CWalletDB(*dbw).EraseDestData(strAddress, item.first);
|
||||||
}
|
}
|
||||||
|
@ -3055,7 +3055,7 @@ bool CWallet::NewKeyPool()
|
||||||
{
|
{
|
||||||
LOCK(cs_wallet);
|
LOCK(cs_wallet);
|
||||||
CWalletDB walletdb(*dbw);
|
CWalletDB walletdb(*dbw);
|
||||||
BOOST_FOREACH(int64_t nIndex, setKeyPool)
|
for (int64_t nIndex : setKeyPool)
|
||||||
walletdb.ErasePool(nIndex);
|
walletdb.ErasePool(nIndex);
|
||||||
setKeyPool.clear();
|
setKeyPool.clear();
|
||||||
|
|
||||||
|
@ -3305,7 +3305,7 @@ std::set< std::set<CTxDestination> > CWallet::GetAddressGroupings()
|
||||||
{
|
{
|
||||||
bool any_mine = false;
|
bool any_mine = false;
|
||||||
// group all input addresses with each other
|
// group all input addresses with each other
|
||||||
BOOST_FOREACH(CTxIn txin, pcoin->tx->vin)
|
for (CTxIn txin : pcoin->tx->vin)
|
||||||
{
|
{
|
||||||
CTxDestination address;
|
CTxDestination address;
|
||||||
if(!IsMine(txin)) /* If this input isn't mine, ignore it */
|
if(!IsMine(txin)) /* If this input isn't mine, ignore it */
|
||||||
|
@ -3319,7 +3319,7 @@ std::set< std::set<CTxDestination> > CWallet::GetAddressGroupings()
|
||||||
// group change with input addresses
|
// group change with input addresses
|
||||||
if (any_mine)
|
if (any_mine)
|
||||||
{
|
{
|
||||||
BOOST_FOREACH(CTxOut txout, pcoin->tx->vout)
|
for (CTxOut txout : pcoin->tx->vout)
|
||||||
if (IsChange(txout))
|
if (IsChange(txout))
|
||||||
{
|
{
|
||||||
CTxDestination txoutAddr;
|
CTxDestination txoutAddr;
|
||||||
|
@ -3350,18 +3350,18 @@ std::set< std::set<CTxDestination> > CWallet::GetAddressGroupings()
|
||||||
|
|
||||||
std::set< std::set<CTxDestination>* > uniqueGroupings; // a set of pointers to groups of addresses
|
std::set< std::set<CTxDestination>* > uniqueGroupings; // a set of pointers to groups of addresses
|
||||||
std::map< CTxDestination, std::set<CTxDestination>* > setmap; // map addresses to the unique group containing it
|
std::map< CTxDestination, std::set<CTxDestination>* > setmap; // map addresses to the unique group containing it
|
||||||
BOOST_FOREACH(std::set<CTxDestination> _grouping, groupings)
|
for (std::set<CTxDestination> _grouping : groupings)
|
||||||
{
|
{
|
||||||
// make a set of all the groups hit by this new group
|
// make a set of all the groups hit by this new group
|
||||||
std::set< std::set<CTxDestination>* > hits;
|
std::set< std::set<CTxDestination>* > hits;
|
||||||
std::map< CTxDestination, std::set<CTxDestination>* >::iterator it;
|
std::map< CTxDestination, std::set<CTxDestination>* >::iterator it;
|
||||||
BOOST_FOREACH(CTxDestination address, _grouping)
|
for (CTxDestination address : _grouping)
|
||||||
if ((it = setmap.find(address)) != setmap.end())
|
if ((it = setmap.find(address)) != setmap.end())
|
||||||
hits.insert((*it).second);
|
hits.insert((*it).second);
|
||||||
|
|
||||||
// merge all hit groups into a new single group and delete old groups
|
// merge all hit groups into a new single group and delete old groups
|
||||||
std::set<CTxDestination>* merged = new std::set<CTxDestination>(_grouping);
|
std::set<CTxDestination>* merged = new std::set<CTxDestination>(_grouping);
|
||||||
BOOST_FOREACH(std::set<CTxDestination>* hit, hits)
|
for (std::set<CTxDestination>* hit : hits)
|
||||||
{
|
{
|
||||||
merged->insert(hit->begin(), hit->end());
|
merged->insert(hit->begin(), hit->end());
|
||||||
uniqueGroupings.erase(hit);
|
uniqueGroupings.erase(hit);
|
||||||
|
@ -3370,12 +3370,12 @@ std::set< std::set<CTxDestination> > CWallet::GetAddressGroupings()
|
||||||
uniqueGroupings.insert(merged);
|
uniqueGroupings.insert(merged);
|
||||||
|
|
||||||
// update setmap
|
// update setmap
|
||||||
BOOST_FOREACH(CTxDestination element, *merged)
|
for (CTxDestination element : *merged)
|
||||||
setmap[element] = merged;
|
setmap[element] = merged;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set< std::set<CTxDestination> > ret;
|
std::set< std::set<CTxDestination> > ret;
|
||||||
BOOST_FOREACH(std::set<CTxDestination>* uniqueGrouping, uniqueGroupings)
|
for (std::set<CTxDestination>* uniqueGrouping : uniqueGroupings)
|
||||||
{
|
{
|
||||||
ret.insert(*uniqueGrouping);
|
ret.insert(*uniqueGrouping);
|
||||||
delete uniqueGrouping;
|
delete uniqueGrouping;
|
||||||
|
@ -3388,7 +3388,7 @@ std::set<CTxDestination> CWallet::GetAccountAddresses(const std::string& strAcco
|
||||||
{
|
{
|
||||||
LOCK(cs_wallet);
|
LOCK(cs_wallet);
|
||||||
std::set<CTxDestination> result;
|
std::set<CTxDestination> result;
|
||||||
BOOST_FOREACH(const PAIRTYPE(CTxDestination, CAddressBookData)& item, mapAddressBook)
|
for (const PAIRTYPE(CTxDestination, CAddressBookData)& item : mapAddressBook)
|
||||||
{
|
{
|
||||||
const CTxDestination& address = item.first;
|
const CTxDestination& address = item.first;
|
||||||
const std::string& strName = item.second.name;
|
const std::string& strName = item.second.name;
|
||||||
|
@ -3438,7 +3438,7 @@ void CWallet::GetAllReserveKeys(std::set<CKeyID>& setAddress) const
|
||||||
CWalletDB walletdb(*dbw);
|
CWalletDB walletdb(*dbw);
|
||||||
|
|
||||||
LOCK2(cs_main, cs_wallet);
|
LOCK2(cs_main, cs_wallet);
|
||||||
BOOST_FOREACH(const int64_t& id, setKeyPool)
|
for (const int64_t& id : setKeyPool)
|
||||||
{
|
{
|
||||||
CKeyPool keypool;
|
CKeyPool keypool;
|
||||||
if (!walletdb.ReadPool(id, keypool))
|
if (!walletdb.ReadPool(id, keypool))
|
||||||
|
@ -3513,7 +3513,7 @@ public:
|
||||||
std::vector<CTxDestination> vDest;
|
std::vector<CTxDestination> vDest;
|
||||||
int nRequired;
|
int nRequired;
|
||||||
if (ExtractDestinations(script, type, vDest, nRequired)) {
|
if (ExtractDestinations(script, type, vDest, nRequired)) {
|
||||||
BOOST_FOREACH(const CTxDestination &dest, vDest)
|
for (const CTxDestination &dest : vDest)
|
||||||
boost::apply_visitor(*this, dest);
|
boost::apply_visitor(*this, dest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3548,7 +3548,7 @@ void CWallet::GetKeyBirthTimes(std::map<CTxDestination, int64_t> &mapKeyBirth) c
|
||||||
std::map<CKeyID, CBlockIndex*> mapKeyFirstBlock;
|
std::map<CKeyID, CBlockIndex*> mapKeyFirstBlock;
|
||||||
std::set<CKeyID> setKeys;
|
std::set<CKeyID> setKeys;
|
||||||
GetKeys(setKeys);
|
GetKeys(setKeys);
|
||||||
BOOST_FOREACH(const CKeyID &keyid, setKeys) {
|
for (const CKeyID &keyid : setKeys) {
|
||||||
if (mapKeyBirth.count(keyid) == 0)
|
if (mapKeyBirth.count(keyid) == 0)
|
||||||
mapKeyFirstBlock[keyid] = pindexMax;
|
mapKeyFirstBlock[keyid] = pindexMax;
|
||||||
}
|
}
|
||||||
|
@ -3567,10 +3567,10 @@ void CWallet::GetKeyBirthTimes(std::map<CTxDestination, int64_t> &mapKeyBirth) c
|
||||||
if (blit != mapBlockIndex.end() && chainActive.Contains(blit->second)) {
|
if (blit != mapBlockIndex.end() && chainActive.Contains(blit->second)) {
|
||||||
// ... which are already in a block
|
// ... which are already in a block
|
||||||
int nHeight = blit->second->nHeight;
|
int nHeight = blit->second->nHeight;
|
||||||
BOOST_FOREACH(const CTxOut &txout, wtx.tx->vout) {
|
for (const CTxOut &txout : wtx.tx->vout) {
|
||||||
// iterate over all their outputs
|
// iterate over all their outputs
|
||||||
CAffectedKeysVisitor(*this, vAffected).Process(txout.scriptPubKey);
|
CAffectedKeysVisitor(*this, vAffected).Process(txout.scriptPubKey);
|
||||||
BOOST_FOREACH(const CKeyID &keyid, vAffected) {
|
for (const CKeyID &keyid : vAffected) {
|
||||||
// ... and all their affected keys
|
// ... and all their affected keys
|
||||||
std::map<CKeyID, CBlockIndex*>::iterator rit = mapKeyFirstBlock.find(keyid);
|
std::map<CKeyID, CBlockIndex*>::iterator rit = mapKeyFirstBlock.find(keyid);
|
||||||
if (rit != mapKeyFirstBlock.end() && nHeight < rit->second->nHeight)
|
if (rit != mapKeyFirstBlock.end() && nHeight < rit->second->nHeight)
|
||||||
|
@ -3891,7 +3891,7 @@ CWallet* CWallet::CreateWalletFromFile(const std::string walletFile)
|
||||||
{
|
{
|
||||||
CWalletDB walletdb(*walletInstance->dbw);
|
CWalletDB walletdb(*walletInstance->dbw);
|
||||||
|
|
||||||
BOOST_FOREACH(const CWalletTx& wtxOld, vWtx)
|
for (const CWalletTx& wtxOld : vWtx)
|
||||||
{
|
{
|
||||||
uint256 hash = wtxOld.GetHash();
|
uint256 hash = wtxOld.GetHash();
|
||||||
std::map<uint256, CWalletTx>::iterator mi = walletInstance->mapWallet.find(hash);
|
std::map<uint256, CWalletTx>::iterator mi = walletInstance->mapWallet.find(hash);
|
||||||
|
|
|
@ -208,7 +208,7 @@ CAmount CWalletDB::GetAccountCreditDebit(const std::string& strAccount)
|
||||||
ListAccountCreditDebit(strAccount, entries);
|
ListAccountCreditDebit(strAccount, entries);
|
||||||
|
|
||||||
CAmount nCreditDebit = 0;
|
CAmount nCreditDebit = 0;
|
||||||
BOOST_FOREACH (const CAccountingEntry& entry, entries)
|
for (const CAccountingEntry& entry : entries)
|
||||||
nCreditDebit += entry.nCreditDebit;
|
nCreditDebit += entry.nCreditDebit;
|
||||||
|
|
||||||
return nCreditDebit;
|
return nCreditDebit;
|
||||||
|
@ -635,7 +635,7 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet)
|
||||||
if ((wss.nKeys + wss.nCKeys + wss.nWatchKeys) != wss.nKeyMeta)
|
if ((wss.nKeys + wss.nCKeys + wss.nWatchKeys) != wss.nKeyMeta)
|
||||||
pwallet->UpdateTimeFirstKey(1);
|
pwallet->UpdateTimeFirstKey(1);
|
||||||
|
|
||||||
BOOST_FOREACH(uint256 hash, wss.vWalletUpgrade)
|
for (uint256 hash : wss.vWalletUpgrade)
|
||||||
WriteTx(pwallet->mapWallet[hash]);
|
WriteTx(pwallet->mapWallet[hash]);
|
||||||
|
|
||||||
// Rewrite encrypted wallets of versions 0.4.0 and 0.5.0rc:
|
// Rewrite encrypted wallets of versions 0.4.0 and 0.5.0rc:
|
||||||
|
@ -650,7 +650,7 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet)
|
||||||
|
|
||||||
pwallet->laccentries.clear();
|
pwallet->laccentries.clear();
|
||||||
ListAccountCreditDebit("*", pwallet->laccentries);
|
ListAccountCreditDebit("*", pwallet->laccentries);
|
||||||
BOOST_FOREACH(CAccountingEntry& entry, pwallet->laccentries) {
|
for (CAccountingEntry& entry : pwallet->laccentries) {
|
||||||
pwallet->wtxOrdered.insert(make_pair(entry.nOrderPos, CWallet::TxPair((CWalletTx*)0, &entry)));
|
pwallet->wtxOrdered.insert(make_pair(entry.nOrderPos, CWallet::TxPair((CWalletTx*)0, &entry)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -736,7 +736,7 @@ DBErrors CWalletDB::ZapSelectTx(std::vector<uint256>& vTxHashIn, std::vector<uin
|
||||||
// erase each matching wallet TX
|
// erase each matching wallet TX
|
||||||
bool delerror = false;
|
bool delerror = false;
|
||||||
std::vector<uint256>::iterator it = vTxHashIn.begin();
|
std::vector<uint256>::iterator it = vTxHashIn.begin();
|
||||||
BOOST_FOREACH (uint256 hash, vTxHash) {
|
for (uint256 hash : vTxHash) {
|
||||||
while (it < vTxHashIn.end() && (*it) < hash) {
|
while (it < vTxHashIn.end() && (*it) < hash) {
|
||||||
it++;
|
it++;
|
||||||
}
|
}
|
||||||
|
@ -767,7 +767,7 @@ DBErrors CWalletDB::ZapWalletTx(std::vector<CWalletTx>& vWtx)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
// erase each wallet TX
|
// erase each wallet TX
|
||||||
BOOST_FOREACH (uint256& hash, vTxHash) {
|
for (uint256& hash : vTxHash) {
|
||||||
if (!EraseTx(hash))
|
if (!EraseTx(hash))
|
||||||
return DB_CORRUPT;
|
return DB_CORRUPT;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue