From: svost Date: Sat, 8 Jan 2022 21:05:16 +0000 (+0300) Subject: Drop some boost deps X-Git-Tag: nvc-v0.5.10~22 X-Git-Url: https://git.novaco.in/?p=novacoin.git;a=commitdiff_plain;h=60cf27d9500deb3bc80ffa8ce5dc3e8284a4c658 Drop some boost deps --- diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index b411be4..4bda0c9 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -13,12 +13,12 @@ #undef printf -#include #include #include #include #include +#include #define printf OutputDebugStringF @@ -338,7 +338,7 @@ bool HTTPAuthorized(ix::WebSocketHttpHeaders& mapHeaders) std::string strAuth = mapHeaders["authorization"]; if (strAuth.substr(0,6) != "Basic ") return false; - std::string strUserPass64 = strAuth.substr(6); boost::algorithm::trim(strUserPass64); + std::string strUserPass64 = std::regex_replace(strAuth.substr(6), static_cast("\\s+"), ""); std::string strUserPass = DecodeBase64(strUserPass64); return TimingResistantEqual(strUserPass, strRPCUserColonPass); } diff --git a/src/checkpoints.cpp b/src/checkpoints.cpp index ae59188..396fb24 100644 --- a/src/checkpoints.cpp +++ b/src/checkpoints.cpp @@ -2,15 +2,14 @@ // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include // for 'map_list_of()' -#include - #include "checkpoints.h" - -#include "txdb-leveldb.h" #include "main.h" +#include "txdb-leveldb.h" #include "uint256.h" +#include + + namespace Checkpoints { typedef std::map > MapCheckpoints; @@ -24,31 +23,31 @@ namespace Checkpoints // + Contains no strange transactions // static MapCheckpoints mapCheckpoints = - boost::assign::map_list_of - ( 0, std::make_pair(hashGenesisBlock, 1360105017) ) - ( 13560, std::make_pair(uint256("0xa1591a0fcbf11f282d671581edb9f0aadcd06fee69761081e0a3245914c13729"), 1364674052) ) - ( 143990, std::make_pair(uint256("0x00000000001ff5c3940a9f73ad4a990f64955179bde0f743c76dbf0031429efc"), 1418953493) ) - ( 149000, std::make_pair(uint256("0x7a24acfcadcf43054e7f7d9f273522c0dfc5791ba4006e0273e7521a8d36c525"), 1420872125) ) - ( 160000, std::make_pair(uint256("0x000000000001cb1133043d38d077c0e93f66c8b2566779f10f182137d1e34a68"), 1425150237) ) - ( 200000, std::make_pair(uint256("0x0000000000029f8bbf66e6ea6f3e5db55009404aae0fe395a53dd33142b2bff2"), 1441127233) ) - ( 221047, std::make_pair(uint256("0xa28aef712e7aa0c285bfe29351ca21ed416689139e3063ef770fc826a8b9e9da"), 1449431646) ) - ( 243100, std::make_pair(uint256("0x000000000006522d1ebc0734cb0e6b83f5d4da0c3cbc72bd91b82016f611c4f0"), 1458215793) ) - ( 532000, std::make_pair(uint256("0x0000000000018b7eba5e189c41605780c8a855f74144fa837fa05fa4c67b6ba9"), 1569359486) ) - ( 561108, std::make_pair(uint256("0x2f3cf523ae1022300b4f40073e506d15ef0d6e208f123aed5b93016f81a10e1e"), 1580943827) ) - ( 712891, std::make_pair(uint256("0xaaafebcb23c1b8ab49f7517b7a34bcc420cc6f284d9ffc672c1f47b5af2b0088"), 1640557462) ) - ; + { + { 0, {hashGenesisBlock, 1360105017} }, + { 13560, {uint256("0xa1591a0fcbf11f282d671581edb9f0aadcd06fee69761081e0a3245914c13729"), 1364674052} }, + { 143990, {uint256("0x00000000001ff5c3940a9f73ad4a990f64955179bde0f743c76dbf0031429efc"), 1418953493} }, + { 149000, {uint256("0x7a24acfcadcf43054e7f7d9f273522c0dfc5791ba4006e0273e7521a8d36c525"), 1420872125} }, + { 160000, {uint256("0x000000000001cb1133043d38d077c0e93f66c8b2566779f10f182137d1e34a68"), 1425150237} }, + { 200000, {uint256("0x0000000000029f8bbf66e6ea6f3e5db55009404aae0fe395a53dd33142b2bff2"), 1441127233} }, + { 221047, {uint256("0xa28aef712e7aa0c285bfe29351ca21ed416689139e3063ef770fc826a8b9e9da"), 1449431646} }, + { 243100, {uint256("0x000000000006522d1ebc0734cb0e6b83f5d4da0c3cbc72bd91b82016f611c4f0"), 1458215793} }, + { 532000, {uint256("0x0000000000018b7eba5e189c41605780c8a855f74144fa837fa05fa4c67b6ba9"), 1569359486} }, + { 561108, {uint256("0x2f3cf523ae1022300b4f40073e506d15ef0d6e208f123aed5b93016f81a10e1e"), 1580943827} }, + { 712891, {uint256("0xaaafebcb23c1b8ab49f7517b7a34bcc420cc6f284d9ffc672c1f47b5af2b0088"), 1640557462} } + }; static ListBannedBlocks listBanned = - boost::assign::list_of + { // Invalid block #221047 with future timestamp of 2016/02/23 09:24:17 UTC - ( uint256("0x46223e5432ceffe650d5729b4bb8479dcdf0ca1e534fa8e69382dc87b42ea94b") ) - ; + uint256("0x46223e5432ceffe650d5729b4bb8479dcdf0ca1e534fa8e69382dc87b42ea94b") + }; // TestNet has no checkpoints static MapCheckpoints mapCheckpointsTestnet = - boost::assign::map_list_of - ( 0, std::make_pair(hashGenesisBlockTestNet, 1360105017) ) - ; + { + { 0, { hashGenesisBlockTestNet, 1360105017 } } + }; bool CheckHardened(int nHeight, const uint256& hash) { diff --git a/src/init.cpp b/src/init.cpp index f549c1a..665f07e 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -11,7 +11,7 @@ #include "ipcollector.h" #include "interface.h" #include "checkpoints.h" -#include + #include #include #include @@ -270,7 +270,7 @@ std::string HelpMessage() #endif " -paytxfee= " + _("Fee per KB to add to transactions you send") + "\n" + - " -mininput= " + str(boost::format(_("When creating transactions, ignore inputs with value less than this (default: %s)")) % FormatMoney(MIN_TXOUT_AMOUNT)) + "\n" + + " -mininput= " + (_("When creating transactions, ignore inputs with value less than this (default: ") + FormatMoney(MIN_TXOUT_AMOUNT) + ")") + "\n" + #ifdef QT_GUI " -server " + _("Accept command line and JSON-RPC commands") + "\n" + #endif diff --git a/src/kernel.cpp b/src/kernel.cpp index 876e829..a2a0e0e 100644 --- a/src/kernel.cpp +++ b/src/kernel.cpp @@ -5,8 +5,6 @@ // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include - #include "kernel.h" #include "kernel_worker.h" #include "txdb-leveldb.h" @@ -30,25 +28,25 @@ typedef std::map MapModifierCheckpoints; // Hard checkpoints of stake modifiers to ensure they are deterministic static std::map mapStakeModifierCheckpoints = - boost::assign::map_list_of - ( 0, 0x0e00670bu ) - ( 12661, 0x5d84115du ) - (143990, 0x9c592c78u ) - (149000, 0x48f2bdc4u ) - (160000, 0x789df0f0u ) - (200000, 0x01ec1503u ) - (221047, 0x0b39ef50u ) - (243100, 0xe928d83au ) - (532000, 0x3e5c2b81u ) - (561108, 0x9c1860b0u ) - (712891, 0xee193895u ) - ; + { + { 0, 0x0e00670bu }, + { 12661, 0x5d84115du }, + {143990, 0x9c592c78u }, + {149000, 0x48f2bdc4u }, + {160000, 0x789df0f0u }, + {200000, 0x01ec1503u }, + {221047, 0x0b39ef50u }, + {243100, 0xe928d83au }, + {532000, 0x3e5c2b81u }, + {561108, 0x9c1860b0u }, + {712891, 0xee193895u } + }; // Hard checkpoints of stake modifiers to ensure they are deterministic (testNet) static std::map mapStakeModifierCheckpointsTestNet = - boost::assign::map_list_of - ( 0, 0x0e00670bu ) - ; + { + { 0, 0x0e00670bu } + }; // Pregenerated entropy bits table (from genesis to #9689) // diff --git a/src/main.cpp b/src/main.cpp index 1345324..b345ef3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -11,12 +11,13 @@ #include "interface.h" #include "checkqueue.h" #include "kernel.h" -#include #include #include #include "main.h" +#include + using namespace std; using namespace boost; @@ -2047,10 +2048,8 @@ bool CBlock::SetBestChain(CTxDB& txdb, CBlockIndex* pindexNew) std::string strCmd = GetArg("-blocknotify", ""); if (!fIsInitialDownload && !strCmd.empty()) - { - boost::replace_all(strCmd, "%s", hashBestChain.GetHex()); - boost::thread t(runCommand, strCmd); // thread runs free - } + // thread runs free + boost::thread t(runCommand, regex_replace(strCmd, static_cast("%s"), hashBestChain.GetHex())); return true; } diff --git a/src/net.cpp b/src/net.cpp index 75280b3..f8f296a 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -57,7 +57,7 @@ static CNode* pnodeLocalHost = NULL; static CNode* pnodeSync = NULL; CAddress addrSeenByPeer(CService("0.0.0.0", nPortZero), nLocalServices); uint64_t nLocalHostNonce = 0; -boost::array vnThreadsRunning; +std::array vnThreadsRunning; static std::vector vhListenSocket; CAddrMan addrman; diff --git a/src/net.h b/src/net.h index 093ba85..bede389 100644 --- a/src/net.h +++ b/src/net.h @@ -5,21 +5,20 @@ #ifndef BITCOIN_NET_H #define BITCOIN_NET_H -#include -#include -#ifndef Q_MOC_RUN -#include -#endif +#include "mruset.h" +#include "netbase.h" +#include "addrman.h" +#include "hash.h" + #include #ifndef WIN32 #include #endif -#include "mruset.h" -#include "netbase.h" -#include "addrman.h" -#include "hash.h" +#include +#include + class CRequestTracker; class CNode; @@ -127,7 +126,7 @@ extern bool fDiscover; extern uint64_t nLocalServices; extern uint64_t nLocalHostNonce; extern CAddress addrSeenByPeer; -extern boost::array vnThreadsRunning; +extern std::array vnThreadsRunning; extern CAddrMan addrman; extern std::vector vNodes; diff --git a/src/netbase.cpp b/src/netbase.cpp index b68a43a..07ee7f7 100644 --- a/src/netbase.cpp +++ b/src/netbase.cpp @@ -21,8 +21,6 @@ typedef SSIZE_T ssize_t; #endif -#include // for to_lower() -#include // for startswith() and endswith() using namespace std; @@ -36,7 +34,7 @@ bool fNameLookup = false; static const unsigned char pchIPv4[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff }; enum Network ParseNetwork(std::string net) { - boost::to_lower(net); + transform(net.begin(), net.end(), net.begin(), ::tolower); if (net == "ipv4") return NET_IPV4; if (net == "ipv6") return NET_IPV6; if (net == "tor" || net == "onion") return NET_TOR; @@ -128,7 +126,7 @@ bool LookupHost(const char *pszName, std::vector& vIP, unsigned int nM std::string strHost(pszName); if (strHost.empty()) return false; - if (boost::algorithm::starts_with(strHost, "[") && boost::algorithm::ends_with(strHost, "]")) + if ((strHost.compare(0,1, "[") == 0) && (strHost.compare(strHost.length()-1,1, "]") == 0)) { strHost = strHost.substr(1, strHost.size() - 2); } diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index ca56968..18c3134 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -11,9 +11,6 @@ #include "kernel.h" #include "bitcoinrpc.h" -#include -#include - using namespace json_spirit; using namespace std; @@ -83,7 +80,7 @@ Value scaninput(const Array& params, bool fHelp) " days - time window, 90 days by default.\n" ); - RPCTypeCheck(params, boost::assign::list_of(obj_type)); + RPCTypeCheck(params, { obj_type }); Object scanParams = params[0].get_obj(); @@ -139,7 +136,7 @@ Value scaninput(const Array& params, bool fHelp) if (nOut < 0 || nOut > (int)tx.vout.size() - 1) { stringstream strErrorMsg; - strErrorMsg << boost::format("Invalid parameter, input number %d is out of range") % nOut; + strErrorMsg << "Invalid parameter, input number " << to_string(nOut) << " is out of range"; throw JSONRPCError(RPC_INVALID_PARAMETER, strErrorMsg.str()); } @@ -152,7 +149,7 @@ Value scaninput(const Array& params, bool fHelp) if (nOut < 0 || nOut > (int)tx.vout.size() - 1) { stringstream strErrorMsg; - strErrorMsg << boost::format("Invalid parameter, input number %d is out of range") % nOut; + strErrorMsg << "Invalid parameter, input number " << to_string(nOut) << " is out of range"; throw JSONRPCError(RPC_INVALID_PARAMETER, strErrorMsg.str()); } diff --git a/src/rpcrawtransaction.cpp b/src/rpcrawtransaction.cpp index 4c1f0f0..b064d0a 100644 --- a/src/rpcrawtransaction.cpp +++ b/src/rpcrawtransaction.cpp @@ -3,8 +3,6 @@ // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include - #include "base58.h" #include "bitcoinrpc.h" #include "txdb-leveldb.h" @@ -15,7 +13,6 @@ using namespace std; using namespace boost; -using namespace boost::assign; using namespace json_spirit; void ScriptPubKeyToJSON(const CScript& scriptPubKey, Object& out, bool fIncludeHex) @@ -169,7 +166,7 @@ Value listunspent(const Array& params, bool fHelp) "Results are an array of Objects, each of which has:\n" "{txid, vout, scriptPubKey, amount, confirmations}"); - RPCTypeCheck(params, list_of(int_type)(int_type)(array_type)); + RPCTypeCheck(params, {int_type, int_type, array_type}); int nMinDepth = 1; if (params.size() > 0) @@ -258,7 +255,7 @@ Value createrawtransaction(const Array& params, bool fHelp) "Note that the transaction's inputs are not signed, and\n" "it is not stored in the wallet or transmitted to the network."); - RPCTypeCheck(params, list_of(array_type)(obj_type)); + RPCTypeCheck(params, {array_type, obj_type}); Array inputs = params[0].get_array(); Object sendTo = params[1].get_obj(); @@ -336,7 +333,7 @@ Value decoderawtransaction(const Array& params, bool fHelp) "decoderawtransaction \n" "Return a JSON object representing the serialized, hex-encoded transaction."); - RPCTypeCheck(params, list_of(str_type)); + RPCTypeCheck(params, {str_type}); vector txData(ParseHex(params[0].get_str())); CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION); @@ -361,7 +358,7 @@ Value decodescript(const Array& params, bool fHelp) "decodescript \n" "Decode a hex-encoded script."); - RPCTypeCheck(params, list_of(str_type)); + RPCTypeCheck(params, {str_type}); Object r; CScript script; @@ -394,7 +391,7 @@ Value signrawtransaction(const Array& params, bool fHelp) " complete : 1 if transaction has a complete set of signature (0 if not)" + HelpRequiringPassphrase()); - RPCTypeCheck(params, list_of(str_type)(array_type)(array_type)(str_type), true); + RPCTypeCheck(params, {str_type, array_type, array_type, str_type}, true); vector txData(ParseHex(params[0].get_str())); CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION); @@ -475,7 +472,7 @@ Value signrawtransaction(const Array& params, bool fHelp) Object prevOut = p.get_obj(); - RPCTypeCheck(prevOut, map_list_of("txid", str_type)("vout", int_type)("scriptPubKey", str_type)); + RPCTypeCheck(prevOut, {{"txid", str_type}, {"vout", int_type}, {"scriptPubKey", str_type}}); string txidHex = find_value(prevOut, "txid").get_str(); if (!IsHex(txidHex)) @@ -513,7 +510,7 @@ Value signrawtransaction(const Array& params, bool fHelp) Value v = find_value(prevOut, "redeemScript"); if (fGivenKeys && scriptPubKey.IsPayToScriptHash()) { - RPCTypeCheck(prevOut, map_list_of("txid", str_type)("vout", int_type)("scriptPubKey", str_type)("redeemScript",str_type)); + RPCTypeCheck(prevOut, {{"txid", str_type}, {"vout", int_type}, {"scriptPubKey", str_type}, {"redeemScript",str_type}}); Value v = find_value(prevOut, "redeemScript"); if (!(v == Value::null)) { @@ -531,14 +528,14 @@ Value signrawtransaction(const Array& params, bool fHelp) if (params.size() > 3 && params[3].type() != null_type) { static map mapSigHashValues = - boost::assign::map_list_of - (string("ALL"), int(SIGHASH_ALL)) - (string("ALL|ANYONECANPAY"), int(SIGHASH_ALL|SIGHASH_ANYONECANPAY)) - (string("NONE"), int(SIGHASH_NONE)) - (string("NONE|ANYONECANPAY"), int(SIGHASH_NONE|SIGHASH_ANYONECANPAY)) - (string("SINGLE"), int(SIGHASH_SINGLE)) - (string("SINGLE|ANYONECANPAY"), int(SIGHASH_SINGLE|SIGHASH_ANYONECANPAY)) - ; + { + {"ALL", SIGHASH_ALL}, + {"ALL|ANYONECANPAY", SIGHASH_ALL|SIGHASH_ANYONECANPAY}, + {"NONE", SIGHASH_NONE}, + {"NONE|ANYONECANPAY", SIGHASH_NONE|SIGHASH_ANYONECANPAY}, + {"SINGLE", SIGHASH_SINGLE}, + {"SINGLE|ANYONECANPAY", SIGHASH_SINGLE|SIGHASH_ANYONECANPAY} + }; string strHashType = params[3].get_str(); if (mapSigHashValues.count(strHashType)) nHashType = mapSigHashValues[strHashType]; @@ -589,7 +586,7 @@ Value sendrawtransaction(const Array& params, bool fHelp) "sendrawtransaction \n" "Submits raw transaction (serialized, hex-encoded) to local node and network."); - RPCTypeCheck(params, list_of(str_type)); + RPCTypeCheck(params, {str_type}); // parse hex string from parameter vector txData(ParseHex(params[0].get_str())); diff --git a/src/util.cpp b/src/util.cpp index 465b5dd..79de9db 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -8,9 +8,6 @@ #include "sync.h" #include "version.h" -#include -#include // for to_lower() -#include // for startswith() and endswith() #include #include #include @@ -502,8 +499,8 @@ void ParseParameters(int argc, const char* const argv[]) str = str.substr(0, is_index); } #ifdef WIN32 - boost::to_lower(str); - if (boost::algorithm::starts_with(str, "/")) + std::transform(str.begin(), str.end(), str.begin(), ::tolower); + if (str.compare(0,1, "/") == 0) str = "-" + str.substr(1); #endif if (str[0] != '-') @@ -1389,7 +1386,16 @@ std::string FormatSubVersion(const std::string& name, int nClientVersion, const ss << "/"; ss << name << ":" << FormatVersion(nClientVersion); if (!comments.empty()) - ss << "(" << boost::algorithm::join(comments, "; ") << ")"; + { + ss << "("; + for (const auto& st : comments) + { + ss << st; + if (st == comments.back()) break; + ss << "; "; + } + ss << ")"; + } ss << "/"; return ss.str(); } diff --git a/src/wallet.cpp b/src/wallet.cpp index 04ce995..1b4025d 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -11,10 +11,12 @@ #include "base58.h" #include "kernel.h" #include "coincontrol.h" -#include +#include "main.h" + #include + #include -#include "main.h" +#include using namespace std; extern int64_t nReserveBalance; @@ -736,10 +738,8 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn) std::string strCmd = GetArg("-walletnotify", ""); if ( !strCmd.empty()) - { - boost::replace_all(strCmd, "%s", wtxIn.GetHash().GetHex()); - boost::thread t(runCommand, strCmd); // thread runs free - } + // thread runs free + boost::thread t(runCommand, regex_replace(strCmd, static_cast("%s"), wtxIn.GetHash().GetHex())); } return true; diff --git a/src/walletdb.cpp b/src/walletdb.cpp index 65cb655..42becb3 100644 --- a/src/walletdb.cpp +++ b/src/walletdb.cpp @@ -7,20 +7,13 @@ #include "wallet.h" #include "base58.h" -#include -#include - #include #include -#include -#include -#include -#include -#include +#include +#include using namespace std; -using namespace boost; static uint64_t nAccountingEntryNumber = 0; @@ -891,13 +884,13 @@ bool ImportWallet(CWallet *pwallet, const string& strLocation) std::string strLabel; bool fLabel = true; for (unsigned int nStr = 2; nStr < vstr.size(); nStr++) { - if (boost::algorithm::starts_with(vstr[nStr], "#")) + if (vstr[nStr].compare(0,1, "#") == 0) break; if (vstr[nStr] == "change=1") fLabel = false; if (vstr[nStr] == "reserve=1") fLabel = false; - if (boost::algorithm::starts_with(vstr[nStr], "label=")) { + if (vstr[nStr].compare(0,6, "label=") == 0) { strLabel = DecodeDumpString(vstr[nStr].substr(6)); fLabel = true; }