Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 4 additions & 22 deletions depends/packages/boost.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,6 @@ $(package)_patches_darwin=darwin.diff
$(package)_patches_linux=

define $(package)_set_vars
$(package)_config_opts_release=variant=release
$(package)_config_opts_debug=variant=debug
$(package)_config_opts=--layout=system
$(package)_config_opts+=threading=multi link=static -sNO_BZIP2=1 -sNO_ZLIB=1
$(package)_config_opts_linux=threadapi=pthread runtime-link=shared
$(package)_config_opts_darwin=--toolset=darwin-4.2.1 runtime-link=shared
$(package)_config_opts_mingw32=binary-format=pe target-os=windows threadapi=win32 runtime-link=static
$(package)_config_opts_x86_64_mingw32=address-model=64
$(package)_config_opts_i686_mingw32=address-model=32
$(package)_config_opts_i686_linux=address-model=32 architecture=x86
$(package)_toolset_$(host_os)=gcc
$(package)_archiver_$(host_os)=$($(package)_ar)
$(package)_toolset_darwin=darwin
$(package)_archiver_darwin=$($(package)_libtool)
$(package)_config_libraries=chrono,filesystem,program_options,system,thread,test
$(package)_cxxflags=-std=c++11 -fvisibility=hidden
$(package)_cxxflags_linux=-fPIC
$(package)_cxxflags_freebsd=-fPIC
endef

define $(package)_preprocess_cmds
Expand All @@ -37,14 +19,14 @@ define $(package)_preprocess_cmds_darwin
endef

define $(package)_config_cmds
./bootstrap.sh --without-icu --with-libraries=$($(package)_config_libraries) && \
sed -i -e "s|using gcc ;|using $(boost_toolset_$(host_os)) : : $($(package)_cxx) : <cxxflags>\"$($(package)_cxxflags) $($(package)_cppflags)\" <linkflags>\"$($(package)_ldflags)\" <archiver>\"$(boost_archiver_$(host_os))\" <striper>\"$(host_STRIP)\" <ranlib>\"$(host_RANLIB)\" <rc>\"$(host_WINDRES)\" : ;|" project-config.jam
echo "Header-only install, skipping bootstrap"
endef

define $(package)_build_cmds
./b2 -d2 -j2 -d1 --prefix=$($(package)_staging_prefix_dir) $($(package)_config_opts) stage
echo "Header-only install, skipping build"
endef

define $(package)_stage_cmds
./b2 -d0 -j4 --prefix=$($(package)_staging_prefix_dir) $($(package)_config_opts) install
mkdir -p $($(package)_staging_prefix_dir)/include && \
cp -r boost $($(package)_staging_prefix_dir)/include
endef
3 changes: 1 addition & 2 deletions src/alert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,8 @@ bool CAlert::ProcessAlert(const std::vector<unsigned char>& alertKey, bool fThre
}

// Check if this alert has been cancelled
for (PAIRTYPE(const uint256, CAlert)& item : mapAlerts)
for (auto& [hash, alert] : mapAlerts)
{
const CAlert& alert = item.second;
if (alert.Cancels(*this))
{
LogPrint("alert", "alert already cancelled by %d\n", alert.nID);
Expand Down
2 changes: 0 additions & 2 deletions src/fluxd.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
#include <vector>
#include <thread>
// Copyright (c) 2009-2013 The Bitcoin Core developers
// Copyright (c) 2018-2022 The Flux Developers
// Distributed under the MIT software license, see the accompanying
Expand Down
6 changes: 3 additions & 3 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -650,12 +650,12 @@ void CleanupBlockRevFiles()
// keeping a separate counter. Once we hit a gap (or if 0 doesn't exist)
// start removing block files.
int nContigCounter = 0;
for (const PAIRTYPE(string, path)& item : mapBlockFiles) {
if (atoi(item.first) == nContigCounter) {
for (const auto& [fileIndex, filePath] : mapBlockFiles) {
if (atoi(fileIndex) == nContigCounter) {
nContigCounter++;
continue;
}
remove(item.second);
remove(filePath);
}
}

Expand Down
19 changes: 7 additions & 12 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6051,15 +6051,13 @@ bool static LoadBlockIndexDB()
// Calculate nChainWork
vector<pair<int, CBlockIndex*> > vSortedByHeight;
vSortedByHeight.reserve(mapBlockIndex.size());
for (const PAIRTYPE(uint256, CBlockIndex*)& item : mapBlockIndex)
for (const auto& [hash, pindex] : mapBlockIndex)
{
CBlockIndex* pindex = item.second;
vSortedByHeight.push_back(make_pair(pindex->nHeight, pindex));
}
sort(vSortedByHeight.begin(), vSortedByHeight.end());
for (const PAIRTYPE(int, CBlockIndex*)& item : vSortedByHeight)
for (const auto& [height, pindex] : vSortedByHeight)
{
CBlockIndex* pindex = item.second;
pindex->nChainWork = (pindex->pprev ? pindex->pprev->nChainWork : 0) + GetBlockProof(*pindex);
// We can link the chain of blocks for which we've received transactions at some point.
// Pruned nodes may have deleted the block.
Expand Down Expand Up @@ -6143,9 +6141,8 @@ bool static LoadBlockIndexDB()
// Check presence of blk files
LogPrintf("Checking all blk files are present...\n");
set<int> setBlkDataFiles;
for (const PAIRTYPE(uint256, CBlockIndex*)& item : mapBlockIndex)
for (const auto& [hash, pindex] : mapBlockIndex)
{
CBlockIndex* pindex = item.second;
if (pindex->nStatus & BLOCK_HAVE_DATA) {
setBlkDataFiles.insert(pindex->nFile);
}
Expand Down Expand Up @@ -6181,9 +6178,8 @@ bool static LoadBlockIndexDB()
fTimestampIndex = fInsightExplorer;

// Fill in-memory data
for (const PAIRTYPE(uint256, CBlockIndex*)& item : mapBlockIndex)
for (const auto& [hash, pindex] : mapBlockIndex)
{
CBlockIndex* pindex = item.second;
// - This relationship will always be true even if pprev has multiple
// children, because hashSproutAnchor is technically a property of pprev,
// not its children.
Expand Down Expand Up @@ -6873,9 +6869,8 @@ std::string GetWarnings(const std::string& strFor)
// Alerts
{
LOCK(cs_mapAlerts);
for (PAIRTYPE(const uint256, CAlert)& item : mapAlerts)
for (auto& [alertHash, alert] : mapAlerts)
{
const CAlert& alert = item.second;
if (alert.AppliesToMe() && alert.nPriority > nPriority)
{
nPriority = alert.nPriority;
Expand Down Expand Up @@ -7228,8 +7223,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
// Relay alerts
{
LOCK(cs_mapAlerts);
for (PAIRTYPE(const uint256, CAlert)& item : mapAlerts)
item.second.RelayTo(pfrom);
for (auto& [alertHash, alert] : mapAlerts)
alert.RelayTo(pfrom);
}

pfrom->fSuccessfullyConnected = true;
Expand Down
1 change: 0 additions & 1 deletion src/mempool_limit.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <set>
#include <vector>

#include "boost/optional.hpp"
#include "primitives/transaction.h"
#include "uint256.h"

Expand Down
9 changes: 0 additions & 9 deletions src/net.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
#include <vector>
#include <condition_variable>
#include <mutex>
#include <condition_variable>
#include <thread>
#include <condition_variable>
#include <chrono>
#include <mutex>
#include <condition_variable>
// Copyright (c) 2009-2014 The Bitcoin Core developers
// Copyright (c) 2018-2022 The Flux Developers
// Distributed under the MIT software license, see the accompanying
Expand Down
8 changes: 4 additions & 4 deletions src/rpc/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -485,12 +485,12 @@ UniValue getnetworkinfo(const UniValue& params, bool fHelp)
UniValue localAddresses(UniValue::VARR);
{
LOCK(cs_mapLocalHost);
for (const PAIRTYPE(CNetAddr, LocalServiceInfo) &item : mapLocalHost)
for (const auto& [addr, serviceInfo] : mapLocalHost)
{
UniValue rec(UniValue::VOBJ);
rec.pushKV("address", item.first.ToString());
rec.pushKV("port", item.second.nPort);
rec.pushKV("score", item.second.nScore);
rec.pushKV("address", addr.ToString());
rec.pushKV("port", serviceInfo.nPort);
rec.pushKV("score", serviceInfo.nScore);
localAddresses.push_back(rec);
}
}
Expand Down
13 changes: 6 additions & 7 deletions src/rpc/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,16 @@ void RPCTypeCheckObj(const UniValue& o,
const map<string, UniValue::VType>& typesExpected,
bool fAllowNull)
{
for (const PAIRTYPE(string, UniValue::VType)& t : typesExpected)
for (const auto& [fieldName, expectedType] : typesExpected)
{
const UniValue& v = find_value(o, t.first);
const UniValue& v = find_value(o, fieldName);
if (!fAllowNull && v.isNull())
throw JSONRPCError(RPC_TYPE_ERROR, strprintf("Missing %s", t.first));
throw JSONRPCError(RPC_TYPE_ERROR, strprintf("Missing %s", fieldName));

if (!((v.type() == t.second) || (fAllowNull && (v.isNull()))))
if (!((v.type() == expectedType) || (fAllowNull && (v.isNull()))))
{
string err = strprintf("Expected type %s for %s, got %s",
uvTypeName(t.second), t.first, uvTypeName(v.type()));
uvTypeName(expectedType), fieldName, uvTypeName(v.type()));
throw JSONRPCError(RPC_TYPE_ERROR, err);
}
}
Expand Down Expand Up @@ -171,9 +171,8 @@ std::string CRPCTable::help(const std::string& strCommand) const
vCommands.push_back(make_pair(mi->second->category + mi->first, mi->second));
sort(vCommands.begin(), vCommands.end());

for (const PAIRTYPE(string, const CRPCCommand*)& command : vCommands)
for (const auto& [sortKey, pcmd] : vCommands)
{
const CRPCCommand *pcmd = command.second;
string strMethod = pcmd->name;
// We already filter duplicates, but these deprecated screw up the sort order
if (strMethod.find("label") != string::npos)
Expand Down
5 changes: 2 additions & 3 deletions src/script/standard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,8 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, vector<vector<unsi

// Scan templates
const CScript& script1 = scriptPubKey;
for (const PAIRTYPE(txnouttype, CScript)& tplate : mTemplates)
for (const auto& [txType, script2] : mTemplates)
{
const CScript& script2 = tplate.second;
vSolutionsRet.clear();

opcodetype opcode1, opcode2;
Expand All @@ -86,7 +85,7 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, vector<vector<unsi
if (pc1 == script1.end() && pc2 == script2.end())
{
// Found a match
typeRet = tplate.first;
typeRet = txType;
if (typeRet == TX_MULTISIG)
{
// Additional checks for TX_MULTISIG:
Expand Down
40 changes: 20 additions & 20 deletions src/sync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,38 +76,38 @@ static void potential_deadlock_detected(const std::pair<void*, void*>& mismatch,

LogPrintf("POTENTIAL DEADLOCK DETECTED\n");
LogPrintf("Previous lock order was:\n");
for (const PAIRTYPE(void*, CLockLocation) & i : s2) {
if (i.first == mismatch.first) {
for (const auto& [lockPtr, lockLoc] :s2) {
if (lockPtr == mismatch.first) {
LogPrintf(" (1)");
if (!firstLocked && secondLocked && i.second.fTry)
if (!firstLocked && secondLocked && lockLoc.fTry)
onlyMaybeDeadlock = true;
firstLocked = true;
}
if (i.first == mismatch.second) {
if (lockPtr == mismatch.second) {
LogPrintf(" (2)");
if (!secondLocked && firstLocked && i.second.fTry)
if (!secondLocked && firstLocked && lockLoc.fTry)
onlyMaybeDeadlock = true;
secondLocked = true;
}
LogPrintf(" %s\n", i.second.ToString());
LogPrintf(" %s\n", lockLoc.ToString());
}
firstLocked = false;
secondLocked = false;
LogPrintf("Current lock order is:\n");
for (const PAIRTYPE(void*, CLockLocation) & i : s1) {
if (i.first == mismatch.first) {
for (const auto& [lockPtr, lockLoc] :s1) {
if (lockPtr == mismatch.first) {
LogPrintf(" (1)");
if (!firstLocked && secondLocked && i.second.fTry)
if (!firstLocked && secondLocked && lockLoc.fTry)
onlyMaybeDeadlock = true;
firstLocked = true;
}
if (i.first == mismatch.second) {
if (lockPtr == mismatch.second) {
LogPrintf(" (2)");
if (!secondLocked && firstLocked && i.second.fTry)
if (!secondLocked && firstLocked && lockLoc.fTry)
onlyMaybeDeadlock = true;
secondLocked = true;
}
LogPrintf(" %s\n", i.second.ToString());
LogPrintf(" %s\n", lockLoc.ToString());
}
assert(onlyMaybeDeadlock);
}
Expand All @@ -122,16 +122,16 @@ static void push_lock(void* c, const CLockLocation& locklocation, bool fTry)
(*lockstack).push_back(std::make_pair(c, locklocation));

if (!fTry) {
for (const PAIRTYPE(void*, CLockLocation) & i : (*lockstack)) {
if (i.first == c)
for (const auto& [lockPtr, lockLoc] :(*lockstack)) {
if (lockPtr == c)
break;

std::pair<void*, void*> p1 = std::make_pair(i.first, c);
std::pair<void*, void*> p1 = std::make_pair(lockPtr, c);
if (lockorders.count(p1))
continue;
lockorders[p1] = (*lockstack);

std::pair<void*, void*> p2 = std::make_pair(c, i.first);
std::pair<void*, void*> p2 = std::make_pair(c, lockPtr);
if (lockorders.count(p2))
potential_deadlock_detected(p1, lockorders[p2], lockorders[p1]);
}
Expand Down Expand Up @@ -159,15 +159,15 @@ void LeaveCritical()
std::string LocksHeld()
{
std::string result;
for (const PAIRTYPE(void*, CLockLocation) & i : *lockstack)
result += i.second.ToString() + std::string("\n");
for (const auto& [lockPtr, lockLoc] :*lockstack)
result += lockLoc.ToString() + std::string("\n");
return result;
}

void AssertLockHeldInternal(const char* pszName, const char* pszFile, int nLine, void* cs)
{
for (const PAIRTYPE(void*, CLockLocation) & i : *lockstack)
if (i.first == cs)
for (const auto& [lockPtr, lockLoc] :*lockstack)
if (lockPtr == cs)
return;
fprintf(stderr, "Assertion failed: lock %s not held in %s:%i; locks held:\n%s", pszName, pszFile, nLine, LocksHeld().c_str());
abort();
Expand Down
4 changes: 2 additions & 2 deletions src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,10 +390,10 @@ void ParseParameters(int argc, const char* const argv[])
}

// New 0.6 features:
for (const PAIRTYPE(string,string)& entry : mapArgs)
for (const auto& [key, value] : mapArgs)
{
// interpret -nofoo as -foo=0 (and -nofoo=0 as -foo=1) as long as -foo not set
InterpretNegativeSetting(entry.first, mapArgs);
InterpretNegativeSetting(key, mapArgs);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/util/fs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ bool FileLock::TryLock()
if (m_hFile == INVALID_HANDLE_VALUE) {
return false;
}
_OVERLAPPED overlapped = {};
OVERLAPPED overlapped = {};
if (!LockFileEx(m_hFile, LOCKFILE_EXCLUSIVE_LOCK | LOCKFILE_FAIL_IMMEDIATELY, 0,
std::numeric_limits<DWORD>::max(), std::numeric_limits<DWORD>::max(), &overlapped)) {
m_reason = GetErrorReason();
Expand Down
2 changes: 0 additions & 2 deletions src/utilstrencodings.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
#define UEND(a) ((unsigned char*)&((&(a))[1]))
#define ARRAYLEN(array) (sizeof(array)/sizeof((array)[0]))

/** This is needed because the foreach macro can't get over the comma in pair<t1, t2> */
#define PAIRTYPE(t1, t2) std::pair<t1, t2>

/** Used by SanitizeString() */
enum SafeChars
Expand Down
14 changes: 7 additions & 7 deletions src/wallet/rpcwallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ void WalletTxToJSON(const CWalletTx& wtx, UniValue& entry)
entry.pushKV("walletconflicts", conflicts);
entry.pushKV("time", wtx.GetTxTime());
entry.pushKV("timereceived", (int64_t)wtx.nTimeReceived);
for (const PAIRTYPE(string,string)& item : wtx.mapValue)
entry.pushKV(item.first, item.second);
for (const auto& [key, value] : wtx.mapValue)
entry.pushKV(key, value);

entry.pushKV("vJoinSplit", TxJoinSplitToJSON(wtx));
}
Expand Down Expand Up @@ -1740,9 +1740,9 @@ UniValue listaccounts(const UniValue& params, bool fHelp)
includeWatchonly = includeWatchonly | ISMINE_WATCH_ONLY;

map<string, CAmount> mapAccountBalances;
for (const PAIRTYPE(CTxDestination, CAddressBookData)& entry : pwalletMain->mapAddressBook) {
if (IsMine(*pwalletMain, entry.first) & includeWatchonly) // This address belongs to me
mapAccountBalances[entry.second.name] = 0;
for (const auto& [dest, addrBookData] : pwalletMain->mapAddressBook) {
if (IsMine(*pwalletMain, dest) & includeWatchonly) // This address belongs to me
mapAccountBalances[addrBookData.name] = 0;
}

for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it)
Expand Down Expand Up @@ -1775,8 +1775,8 @@ UniValue listaccounts(const UniValue& params, bool fHelp)
mapAccountBalances[entry.strAccount] += entry.nCreditDebit;

UniValue ret(UniValue::VOBJ);
for (const PAIRTYPE(string, CAmount)& accountBalance : mapAccountBalances) {
ret.pushKV(accountBalance.first, ValueFromAmount(accountBalance.second));
for (const auto& [accountName, balance] : mapAccountBalances) {
ret.pushKV(accountName, ValueFromAmount(balance));
}
return ret;
}
Expand Down
Loading
Loading