Merge pull request #5513

856e862 namespace: drop most boost namespaces and a few header cleanups (Cory Fields)
9b1ab86 namespace: drop boost::assign altogether here (Cory Fields)
a324199 namespace: remove boost namespace pollution (Cory Fields)
This commit is contained in:
Wladimir J. van der Laan 2015-01-06 20:16:56 +01:00
commit 729ba31749
No known key found for this signature in database
GPG key ID: 74810B012346C9A6
20 changed files with 90 additions and 128 deletions

View file

@ -15,8 +15,6 @@
#define _(x) std::string(x) /* Keep the _() around in case gettext or such will be used later to translate non-UI */ #define _(x) std::string(x) /* Keep the _() around in case gettext or such will be used later to translate non-UI */
using namespace std; using namespace std;
using namespace boost;
using namespace boost::asio;
using namespace json_spirit; using namespace json_spirit;
std::string HelpMessageCli() std::string HelpMessageCli()
@ -108,12 +106,12 @@ Object CallRPC(const string& strMethod, const Array& params)
// Connect to localhost // Connect to localhost
bool fUseSSL = GetBoolArg("-rpcssl", false); bool fUseSSL = GetBoolArg("-rpcssl", false);
asio::io_service io_service; boost::asio::io_service io_service;
ssl::context context(io_service, ssl::context::sslv23); boost::asio::ssl::context context(io_service, boost::asio::ssl::context::sslv23);
context.set_options(ssl::context::no_sslv2 | ssl::context::no_sslv3); context.set_options(boost::asio::ssl::context::no_sslv2 | boost::asio::ssl::context::no_sslv3);
asio::ssl::stream<asio::ip::tcp::socket> sslStream(io_service, context); boost::asio::ssl::stream<boost::asio::ip::tcp::socket> sslStream(io_service, context);
SSLIOStreamDevice<asio::ip::tcp> d(sslStream, fUseSSL); SSLIOStreamDevice<boost::asio::ip::tcp> d(sslStream, fUseSSL);
iostreams::stream< SSLIOStreamDevice<asio::ip::tcp> > stream(d); boost::iostreams::stream< SSLIOStreamDevice<boost::asio::ip::tcp> > stream(d);
const bool fConnected = d.connect(GetArg("-rpcconnect", "127.0.0.1"), GetArg("-rpcport", itostr(BaseParams().RPCPort()))); const bool fConnected = d.connect(GetArg("-rpcconnect", "127.0.0.1"), GetArg("-rpcport", itostr(BaseParams().RPCPort())));
if (!fConnected) if (!fConnected)

View file

@ -22,7 +22,6 @@
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <boost/assign/list_of.hpp> #include <boost/assign/list_of.hpp>
using namespace boost::assign;
using namespace std; using namespace std;
static bool fCreateBlank; static bool fCreateBlank;
@ -375,7 +374,7 @@ static void MutateTxSign(CMutableTransaction& tx, const string& flagStr)
if (!prevOut.isObject()) if (!prevOut.isObject())
throw runtime_error("expected prevtxs internal object"); throw runtime_error("expected prevtxs internal object");
map<string,UniValue::VType> types = map_list_of("txid", UniValue::VSTR)("vout",UniValue::VNUM)("scriptPubKey",UniValue::VSTR); map<string,UniValue::VType> types = boost::assign::map_list_of("txid", UniValue::VSTR)("vout",UniValue::VNUM)("scriptPubKey",UniValue::VSTR);
if (!prevOut.checkObject(types)) if (!prevOut.checkObject(types))
throw runtime_error("prevtxs internal object typecheck fail"); throw runtime_error("prevtxs internal object typecheck fail");

View file

@ -14,7 +14,6 @@
#include <boost/assign/list_of.hpp> #include <boost/assign/list_of.hpp>
using namespace std; using namespace std;
using namespace boost::assign;
struct SeedSpec6 { struct SeedSpec6 {
uint8_t addr[16]; uint8_t addr[16];
@ -157,11 +156,11 @@ public:
vSeeds.push_back(CDNSSeedData("bitcoinstats.com", "seed.bitcoinstats.com")); vSeeds.push_back(CDNSSeedData("bitcoinstats.com", "seed.bitcoinstats.com"));
vSeeds.push_back(CDNSSeedData("xf2.org", "bitseed.xf2.org")); vSeeds.push_back(CDNSSeedData("xf2.org", "bitseed.xf2.org"));
base58Prefixes[PUBKEY_ADDRESS] = list_of(0); base58Prefixes[PUBKEY_ADDRESS] = boost::assign::list_of(0);
base58Prefixes[SCRIPT_ADDRESS] = list_of(5); base58Prefixes[SCRIPT_ADDRESS] = boost::assign::list_of(5);
base58Prefixes[SECRET_KEY] = list_of(128); base58Prefixes[SECRET_KEY] = boost::assign::list_of(128);
base58Prefixes[EXT_PUBLIC_KEY] = list_of(0x04)(0x88)(0xB2)(0x1E); base58Prefixes[EXT_PUBLIC_KEY] = boost::assign::list_of(0x04)(0x88)(0xB2)(0x1E);
base58Prefixes[EXT_SECRET_KEY] = list_of(0x04)(0x88)(0xAD)(0xE4); base58Prefixes[EXT_SECRET_KEY] = boost::assign::list_of(0x04)(0x88)(0xAD)(0xE4);
convertSeed6(vFixedSeeds, pnSeed6_main, ARRAYLEN(pnSeed6_main)); convertSeed6(vFixedSeeds, pnSeed6_main, ARRAYLEN(pnSeed6_main));
@ -215,11 +214,11 @@ public:
vSeeds.push_back(CDNSSeedData("bluematt.me", "testnet-seed.bluematt.me")); vSeeds.push_back(CDNSSeedData("bluematt.me", "testnet-seed.bluematt.me"));
vSeeds.push_back(CDNSSeedData("bitcoin.schildbach.de", "testnet-seed.bitcoin.schildbach.de")); vSeeds.push_back(CDNSSeedData("bitcoin.schildbach.de", "testnet-seed.bitcoin.schildbach.de"));
base58Prefixes[PUBKEY_ADDRESS] = list_of(111); base58Prefixes[PUBKEY_ADDRESS] = boost::assign::list_of(111);
base58Prefixes[SCRIPT_ADDRESS] = list_of(196); base58Prefixes[SCRIPT_ADDRESS] = boost::assign::list_of(196);
base58Prefixes[SECRET_KEY] = list_of(239); base58Prefixes[SECRET_KEY] = boost::assign::list_of(239);
base58Prefixes[EXT_PUBLIC_KEY] = list_of(0x04)(0x35)(0x87)(0xCF); base58Prefixes[EXT_PUBLIC_KEY] = boost::assign::list_of(0x04)(0x35)(0x87)(0xCF);
base58Prefixes[EXT_SECRET_KEY] = list_of(0x04)(0x35)(0x83)(0x94); base58Prefixes[EXT_SECRET_KEY] = boost::assign::list_of(0x04)(0x35)(0x83)(0x94);
convertSeed6(vFixedSeeds, pnSeed6_test, ARRAYLEN(pnSeed6_test)); convertSeed6(vFixedSeeds, pnSeed6_test, ARRAYLEN(pnSeed6_test));

View file

@ -9,10 +9,6 @@
#include <assert.h> #include <assert.h>
#include <boost/assign/list_of.hpp>
using namespace boost::assign;
/** /**
* Main network * Main network
*/ */

View file

@ -20,8 +20,6 @@
#include <boost/algorithm/string/split.hpp> #include <boost/algorithm/string/split.hpp>
#include <boost/assign/list_of.hpp> #include <boost/assign/list_of.hpp>
using namespace boost;
using namespace boost::algorithm;
using namespace std; using namespace std;
CScript ParseScript(std::string s) CScript ParseScript(std::string s)
@ -44,13 +42,13 @@ CScript ParseScript(std::string s)
string strName(name); string strName(name);
mapOpNames[strName] = (opcodetype)op; mapOpNames[strName] = (opcodetype)op;
// Convenience: OP_ADD and just ADD are both recognized: // Convenience: OP_ADD and just ADD are both recognized:
replace_first(strName, "OP_", ""); boost::algorithm::replace_first(strName, "OP_", "");
mapOpNames[strName] = (opcodetype)op; mapOpNames[strName] = (opcodetype)op;
} }
} }
vector<string> words; vector<string> words;
split(words, s, is_any_of(" \t\n"), token_compress_on); boost::algorithm::split(words, s, boost::algorithm::is_any_of(" \t\n"), boost::algorithm::token_compress_on);
for (std::vector<std::string>::const_iterator w = words.begin(); w != words.end(); ++w) for (std::vector<std::string>::const_iterator w = words.begin(); w != words.end(); ++w)
{ {
@ -58,20 +56,20 @@ CScript ParseScript(std::string s)
{ {
// Empty string, ignore. (boost::split given '' will return one word) // Empty string, ignore. (boost::split given '' will return one word)
} }
else if (all(*w, is_digit()) || else if (all(*w, boost::algorithm::is_digit()) ||
(starts_with(*w, "-") && all(string(w->begin()+1, w->end()), is_digit()))) (boost::algorithm::starts_with(*w, "-") && all(string(w->begin()+1, w->end()), boost::algorithm::is_digit())))
{ {
// Number // Number
int64_t n = atoi64(*w); int64_t n = atoi64(*w);
result << n; result << n;
} }
else if (starts_with(*w, "0x") && (w->begin()+2 != w->end()) && IsHex(string(w->begin()+2, w->end()))) else if (boost::algorithm::starts_with(*w, "0x") && (w->begin()+2 != w->end()) && IsHex(string(w->begin()+2, w->end())))
{ {
// Raw hex data, inserted NOT pushed onto stack: // Raw hex data, inserted NOT pushed onto stack:
std::vector<unsigned char> raw = ParseHex(string(w->begin()+2, w->end())); std::vector<unsigned char> raw = ParseHex(string(w->begin()+2, w->end()));
result.insert(result.end(), raw.begin(), raw.end()); result.insert(result.end(), raw.begin(), raw.end());
} }
else if (w->size() >= 2 && starts_with(*w, "'") && ends_with(*w, "'")) else if (w->size() >= 2 && boost::algorithm::starts_with(*w, "'") && boost::algorithm::ends_with(*w, "'"))
{ {
// Single-quoted string, pushed as data. NOTE: this is poor-man's // Single-quoted string, pushed as data. NOTE: this is poor-man's
// parsing, spaces/tabs/newlines in single-quoted strings won't work. // parsing, spaces/tabs/newlines in single-quoted strings won't work.

View file

@ -24,7 +24,6 @@
#include <openssl/rand.h> #include <openssl/rand.h>
using namespace std; using namespace std;
using namespace boost;
unsigned int nWalletDBUpdated; unsigned int nWalletDBUpdated;
@ -73,9 +72,9 @@ bool CDBEnv::Open(const boost::filesystem::path& pathIn)
boost::this_thread::interruption_point(); boost::this_thread::interruption_point();
path = pathIn; path = pathIn;
filesystem::path pathLogDir = path / "database"; boost::filesystem::path pathLogDir = path / "database";
TryCreateDirectory(pathLogDir); TryCreateDirectory(pathLogDir);
filesystem::path pathErrorFile = path / "db.log"; boost::filesystem::path pathErrorFile = path / "db.log";
LogPrintf("CDBEnv::Open : LogDir=%s ErrorFile=%s\n", pathLogDir.string(), pathErrorFile.string()); LogPrintf("CDBEnv::Open : LogDir=%s ErrorFile=%s\n", pathLogDir.string(), pathErrorFile.string());
unsigned int nEnvFlags = 0; unsigned int nEnvFlags = 0;

View file

@ -43,7 +43,6 @@
#include <boost/thread.hpp> #include <boost/thread.hpp>
#include <openssl/crypto.h> #include <openssl/crypto.h>
using namespace boost;
using namespace std; using namespace std;
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
@ -427,12 +426,12 @@ void ThreadImport(std::vector<boost::filesystem::path> vImportFiles)
} }
// hardcoded $DATADIR/bootstrap.dat // hardcoded $DATADIR/bootstrap.dat
filesystem::path pathBootstrap = GetDataDir() / "bootstrap.dat"; boost::filesystem::path pathBootstrap = GetDataDir() / "bootstrap.dat";
if (filesystem::exists(pathBootstrap)) { if (boost::filesystem::exists(pathBootstrap)) {
FILE *file = fopen(pathBootstrap.string().c_str(), "rb"); FILE *file = fopen(pathBootstrap.string().c_str(), "rb");
if (file) { if (file) {
CImportingNow imp; CImportingNow imp;
filesystem::path pathBootstrapOld = GetDataDir() / "bootstrap.dat.old"; boost::filesystem::path pathBootstrapOld = GetDataDir() / "bootstrap.dat.old";
LogPrintf("Importing bootstrap.dat...\n"); LogPrintf("Importing bootstrap.dat...\n");
LoadExternalBlockFile(file); LoadExternalBlockFile(file);
RenameOver(pathBootstrap, pathBootstrapOld); RenameOver(pathBootstrap, pathBootstrapOld);
@ -816,7 +815,7 @@ bool AppInit2(boost::thread_group& threadGroup)
return false; return false;
} }
if (filesystem::exists(GetDataDir() / strWalletFile)) if (boost::filesystem::exists(GetDataDir() / strWalletFile))
{ {
CDBEnv::VerifyResult r = bitdb.Verify(strWalletFile, CWalletDB::Recover); CDBEnv::VerifyResult r = bitdb.Verify(strWalletFile, CWalletDB::Recover);
if (r == CDBEnv::RECOVER_OK) if (r == CDBEnv::RECOVER_OK)
@ -937,20 +936,20 @@ bool AppInit2(boost::thread_group& threadGroup)
fReindex = GetBoolArg("-reindex", false); fReindex = GetBoolArg("-reindex", false);
// Upgrading to 0.8; hard-link the old blknnnn.dat files into /blocks/ // Upgrading to 0.8; hard-link the old blknnnn.dat files into /blocks/
filesystem::path blocksDir = GetDataDir() / "blocks"; boost::filesystem::path blocksDir = GetDataDir() / "blocks";
if (!filesystem::exists(blocksDir)) if (!boost::filesystem::exists(blocksDir))
{ {
filesystem::create_directories(blocksDir); boost::filesystem::create_directories(blocksDir);
bool linked = false; bool linked = false;
for (unsigned int i = 1; i < 10000; i++) { for (unsigned int i = 1; i < 10000; i++) {
filesystem::path source = GetDataDir() / strprintf("blk%04u.dat", i); boost::filesystem::path source = GetDataDir() / strprintf("blk%04u.dat", i);
if (!filesystem::exists(source)) break; if (!boost::filesystem::exists(source)) break;
filesystem::path dest = blocksDir / strprintf("blk%05u.dat", i-1); boost::filesystem::path dest = blocksDir / strprintf("blk%05u.dat", i-1);
try { try {
filesystem::create_hard_link(source, dest); boost::filesystem::create_hard_link(source, dest);
LogPrintf("Hardlinked %s -> %s\n", source.string(), dest.string()); LogPrintf("Hardlinked %s -> %s\n", source.string(), dest.string());
linked = true; linked = true;
} catch (const filesystem::filesystem_error& e) { } catch (const boost::filesystem::filesystem_error& e) {
// Note: hardlink creation failing is not a disaster, it just means // Note: hardlink creation failing is not a disaster, it just means
// blocks will get re-downloaded from peers. // blocks will get re-downloaded from peers.
LogPrintf("Error hardlinking blk%04u.dat : %s\n", i, e.what()); LogPrintf("Error hardlinking blk%04u.dat : %s\n", i, e.what());

View file

@ -29,7 +29,6 @@
#include <boost/filesystem/fstream.hpp> #include <boost/filesystem/fstream.hpp>
#include <boost/thread.hpp> #include <boost/thread.hpp>
using namespace boost;
using namespace std; using namespace std;
#if defined(NDEBUG) #if defined(NDEBUG)
@ -2789,7 +2788,7 @@ bool AbortNode(const std::string &strMessage, const std::string &userMessage) {
bool CheckDiskSpace(uint64_t nAdditionalBytes) bool CheckDiskSpace(uint64_t nAdditionalBytes)
{ {
uint64_t nFreeBytesAvailable = filesystem::space(GetDataDir()).available; uint64_t nFreeBytesAvailable = boost::filesystem::space(GetDataDir()).available;
// Check for nMinDiskSpace bytes (currently 50MB) // Check for nMinDiskSpace bytes (currently 50MB)
if (nFreeBytesAvailable < nMinDiskSpace + nAdditionalBytes) if (nFreeBytesAvailable < nMinDiskSpace + nAdditionalBytes)

View file

@ -49,7 +49,6 @@
#endif #endif
#endif #endif
using namespace boost;
using namespace std; using namespace std;
namespace { namespace {

View file

@ -46,7 +46,6 @@
#include <QUrlQuery> #include <QUrlQuery>
#endif #endif
using namespace boost;
using namespace std; using namespace std;
const int BITCOIN_IPC_CONNECT_TIMEOUT = 1000; // milliseconds const int BITCOIN_IPC_CONNECT_TIMEOUT = 1000; // milliseconds

View file

@ -23,8 +23,6 @@
#include "json/json_spirit_utils.h" #include "json/json_spirit_utils.h"
#include "json/json_spirit_value.h" #include "json/json_spirit_value.h"
using namespace boost;
using namespace boost::assign;
using namespace json_spirit; using namespace json_spirit;
using namespace std; using namespace std;

View file

@ -26,8 +26,6 @@
#include "json/json_spirit_writer_template.h" #include "json/json_spirit_writer_template.h"
using namespace std; using namespace std;
using namespace boost;
using namespace boost::asio;
using namespace json_spirit; using namespace json_spirit;
//! Number of bytes to allocate and read at most at once in post data //! Number of bytes to allocate and read at most at once in post data

View file

@ -25,8 +25,6 @@
#include "json/json_spirit_utils.h" #include "json/json_spirit_utils.h"
#include "json/json_spirit_value.h" #include "json/json_spirit_value.h"
using namespace boost;
using namespace boost::assign;
using namespace json_spirit; using namespace json_spirit;
using namespace std; using namespace std;
@ -232,7 +230,7 @@ Value listunspent(const Array& params, bool fHelp)
+ HelpExampleRpc("listunspent", "6, 9999999 \"[\\\"1PGFqEzfmQch1gKD3ra4k18PNj3tTUUSqg\\\",\\\"1LtvqCaApEdUGFkpKMM4MstjcaL4dKg8SP\\\"]\"") + HelpExampleRpc("listunspent", "6, 9999999 \"[\\\"1PGFqEzfmQch1gKD3ra4k18PNj3tTUUSqg\\\",\\\"1LtvqCaApEdUGFkpKMM4MstjcaL4dKg8SP\\\"]\"")
); );
RPCTypeCheck(params, list_of(int_type)(int_type)(array_type)); RPCTypeCheck(params, boost::assign::list_of(int_type)(int_type)(array_type));
int nMinDepth = 1; int nMinDepth = 1;
if (params.size() > 0) if (params.size() > 0)
@ -336,7 +334,7 @@ Value createrawtransaction(const Array& params, bool fHelp)
+ HelpExampleRpc("createrawtransaction", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\", \"{\\\"address\\\":0.01}\"") + HelpExampleRpc("createrawtransaction", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\", \"{\\\"address\\\":0.01}\"")
); );
RPCTypeCheck(params, list_of(array_type)(obj_type)); RPCTypeCheck(params, boost::assign::list_of(array_type)(obj_type));
Array inputs = params[0].get_array(); Array inputs = params[0].get_array();
Object sendTo = params[1].get_obj(); Object sendTo = params[1].get_obj();
@ -430,7 +428,7 @@ Value decoderawtransaction(const Array& params, bool fHelp)
+ HelpExampleRpc("decoderawtransaction", "\"hexstring\"") + HelpExampleRpc("decoderawtransaction", "\"hexstring\"")
); );
RPCTypeCheck(params, list_of(str_type)); RPCTypeCheck(params, boost::assign::list_of(str_type));
CTransaction tx; CTransaction tx;
@ -468,7 +466,7 @@ Value decodescript(const Array& params, bool fHelp)
+ HelpExampleRpc("decodescript", "\"hexstring\"") + HelpExampleRpc("decodescript", "\"hexstring\"")
); );
RPCTypeCheck(params, list_of(str_type)); RPCTypeCheck(params, boost::assign::list_of(str_type));
Object r; Object r;
CScript script; CScript script;
@ -534,7 +532,7 @@ Value signrawtransaction(const Array& params, bool fHelp)
+ HelpExampleRpc("signrawtransaction", "\"myhex\"") + HelpExampleRpc("signrawtransaction", "\"myhex\"")
); );
RPCTypeCheck(params, list_of(str_type)(array_type)(array_type)(str_type), true); RPCTypeCheck(params, boost::assign::list_of(str_type)(array_type)(array_type)(str_type), true);
vector<unsigned char> txData(ParseHexV(params[0], "argument 1")); vector<unsigned char> txData(ParseHexV(params[0], "argument 1"));
CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION); CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION);
@ -606,7 +604,7 @@ Value signrawtransaction(const Array& params, bool fHelp)
Object prevOut = p.get_obj(); Object prevOut = p.get_obj();
RPCTypeCheck(prevOut, map_list_of("txid", str_type)("vout", int_type)("scriptPubKey", str_type)); RPCTypeCheck(prevOut, boost::assign::map_list_of("txid", str_type)("vout", int_type)("scriptPubKey", str_type));
uint256 txid = ParseHashO(prevOut, "txid"); uint256 txid = ParseHashO(prevOut, "txid");
@ -634,7 +632,7 @@ Value signrawtransaction(const Array& params, bool fHelp)
// if redeemScript given and not using the local wallet (private keys // if redeemScript given and not using the local wallet (private keys
// given), add redeemScript to the tempKeystore so it can be signed: // given), add redeemScript to the tempKeystore so it can be signed:
if (fGivenKeys && scriptPubKey.IsPayToScriptHash()) { if (fGivenKeys && scriptPubKey.IsPayToScriptHash()) {
RPCTypeCheck(prevOut, map_list_of("txid", str_type)("vout", int_type)("scriptPubKey", str_type)("redeemScript",str_type)); RPCTypeCheck(prevOut, boost::assign::map_list_of("txid", str_type)("vout", int_type)("scriptPubKey", str_type)("redeemScript",str_type));
Value v = find_value(prevOut, "redeemScript"); Value v = find_value(prevOut, "redeemScript");
if (!(v == Value::null)) { if (!(v == Value::null)) {
vector<unsigned char> rsData(ParseHexV(v, "redeemScript")); vector<unsigned char> rsData(ParseHexV(v, "redeemScript"));
@ -724,7 +722,7 @@ Value sendrawtransaction(const Array& params, bool fHelp)
+ HelpExampleRpc("sendrawtransaction", "\"signedhex\"") + HelpExampleRpc("sendrawtransaction", "\"signedhex\"")
); );
RPCTypeCheck(params, list_of(str_type)(bool_type)); RPCTypeCheck(params, boost::assign::list_of(str_type)(bool_type));
// parse hex string from parameter // parse hex string from parameter
CTransaction tx; CTransaction tx;

View file

@ -26,7 +26,6 @@
#include <boost/thread.hpp> #include <boost/thread.hpp>
#include "json/json_spirit_writer_template.h" #include "json/json_spirit_writer_template.h"
using namespace boost;
using namespace boost::asio; using namespace boost::asio;
using namespace json_spirit; using namespace json_spirit;
using namespace std; using namespace std;
@ -39,7 +38,7 @@ static std::string rpcWarmupStatus("RPC server started");
static CCriticalSection cs_rpcWarmup; static CCriticalSection cs_rpcWarmup;
//! These are created by StartRPCThreads, destroyed in StopRPCThreads //! These are created by StartRPCThreads, destroyed in StopRPCThreads
static asio::io_service* rpc_io_service = NULL; static boost::asio::io_service* rpc_io_service = NULL;
static map<string, boost::shared_ptr<deadline_timer> > deadlineTimers; static map<string, boost::shared_ptr<deadline_timer> > deadlineTimers;
static ssl::context* rpc_ssl_context = NULL; static ssl::context* rpc_ssl_context = NULL;
static boost::thread_group* rpc_worker_group = NULL; static boost::thread_group* rpc_worker_group = NULL;
@ -428,7 +427,7 @@ class AcceptedConnectionImpl : public AcceptedConnection
{ {
public: public:
AcceptedConnectionImpl( AcceptedConnectionImpl(
asio::io_service& io_service, boost::asio::io_service& io_service,
ssl::context &context, ssl::context &context,
bool fUseSSL) : bool fUseSSL) :
sslStream(io_service, context), sslStream(io_service, context),
@ -453,11 +452,11 @@ public:
} }
typename Protocol::endpoint peer; typename Protocol::endpoint peer;
asio::ssl::stream<typename Protocol::socket> sslStream; boost::asio::ssl::stream<typename Protocol::socket> sslStream;
private: private:
SSLIOStreamDevice<Protocol> _d; SSLIOStreamDevice<Protocol> _d;
iostreams::stream< SSLIOStreamDevice<Protocol> > _stream; boost::iostreams::stream< SSLIOStreamDevice<Protocol> > _stream;
}; };
void ServiceConnection(AcceptedConnection *conn); void ServiceConnection(AcceptedConnection *conn);
@ -504,7 +503,7 @@ static void RPCAcceptHandler(boost::shared_ptr< basic_socket_acceptor<Protocol,
const boost::system::error_code& error) const boost::system::error_code& error)
{ {
// Immediately start accepting new connections, except when we're cancelled or our socket is closed. // Immediately start accepting new connections, except when we're cancelled or our socket is closed.
if (error != asio::error::operation_aborted && acceptor->is_open()) if (error != boost::asio::error::operation_aborted && acceptor->is_open())
RPCListen(acceptor, context, fUseSSL); RPCListen(acceptor, context, fUseSSL);
AcceptedConnectionImpl<ip::tcp>* tcp_conn = dynamic_cast< AcceptedConnectionImpl<ip::tcp>* >(conn.get()); AcceptedConnectionImpl<ip::tcp>* tcp_conn = dynamic_cast< AcceptedConnectionImpl<ip::tcp>* >(conn.get());
@ -535,7 +534,7 @@ static ip::tcp::endpoint ParseEndpoint(const std::string &strEndpoint, int defau
std::string addr; std::string addr;
int port = defaultPort; int port = defaultPort;
SplitHostPort(strEndpoint, port, addr); SplitHostPort(strEndpoint, port, addr);
return ip::tcp::endpoint(asio::ip::address::from_string(addr), port); return ip::tcp::endpoint(boost::asio::ip::address::from_string(addr), port);
} }
void StartRPCThreads() void StartRPCThreads()
@ -590,7 +589,7 @@ void StartRPCThreads()
} }
assert(rpc_io_service == NULL); assert(rpc_io_service == NULL);
rpc_io_service = new asio::io_service(); rpc_io_service = new boost::asio::io_service();
rpc_ssl_context = new ssl::context(*rpc_io_service, ssl::context::sslv23); rpc_ssl_context = new ssl::context(*rpc_io_service, ssl::context::sslv23);
const bool fUseSSL = GetBoolArg("-rpcssl", false); const bool fUseSSL = GetBoolArg("-rpcssl", false);
@ -599,14 +598,14 @@ void StartRPCThreads()
{ {
rpc_ssl_context->set_options(ssl::context::no_sslv2 | ssl::context::no_sslv3); rpc_ssl_context->set_options(ssl::context::no_sslv2 | ssl::context::no_sslv3);
filesystem::path pathCertFile(GetArg("-rpcsslcertificatechainfile", "server.cert")); boost::filesystem::path pathCertFile(GetArg("-rpcsslcertificatechainfile", "server.cert"));
if (!pathCertFile.is_complete()) pathCertFile = filesystem::path(GetDataDir()) / pathCertFile; if (!pathCertFile.is_complete()) pathCertFile = boost::filesystem::path(GetDataDir()) / pathCertFile;
if (filesystem::exists(pathCertFile)) rpc_ssl_context->use_certificate_chain_file(pathCertFile.string()); if (boost::filesystem::exists(pathCertFile)) rpc_ssl_context->use_certificate_chain_file(pathCertFile.string());
else LogPrintf("ThreadRPCServer ERROR: missing server certificate file %s\n", pathCertFile.string()); else LogPrintf("ThreadRPCServer ERROR: missing server certificate file %s\n", pathCertFile.string());
filesystem::path pathPKFile(GetArg("-rpcsslprivatekeyfile", "server.pem")); boost::filesystem::path pathPKFile(GetArg("-rpcsslprivatekeyfile", "server.pem"));
if (!pathPKFile.is_complete()) pathPKFile = filesystem::path(GetDataDir()) / pathPKFile; if (!pathPKFile.is_complete()) pathPKFile = boost::filesystem::path(GetDataDir()) / pathPKFile;
if (filesystem::exists(pathPKFile)) rpc_ssl_context->use_private_key_file(pathPKFile.string(), ssl::context::pem); if (boost::filesystem::exists(pathPKFile)) rpc_ssl_context->use_private_key_file(pathPKFile.string(), ssl::context::pem);
else LogPrintf("ThreadRPCServer ERROR: missing server private key file %s\n", pathPKFile.string()); else LogPrintf("ThreadRPCServer ERROR: missing server private key file %s\n", pathPKFile.string());
string strCiphers = GetArg("-rpcsslciphers", "TLSv1.2+HIGH:TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!3DES:@STRENGTH"); string strCiphers = GetArg("-rpcsslciphers", "TLSv1.2+HIGH:TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!3DES:@STRENGTH");
@ -618,8 +617,8 @@ void StartRPCThreads()
int defaultPort = GetArg("-rpcport", BaseParams().RPCPort()); int defaultPort = GetArg("-rpcport", BaseParams().RPCPort());
if (!mapArgs.count("-rpcallowip")) // Default to loopback if not allowing external IPs if (!mapArgs.count("-rpcallowip")) // Default to loopback if not allowing external IPs
{ {
vEndpoints.push_back(ip::tcp::endpoint(asio::ip::address_v6::loopback(), defaultPort)); vEndpoints.push_back(ip::tcp::endpoint(boost::asio::ip::address_v6::loopback(), defaultPort));
vEndpoints.push_back(ip::tcp::endpoint(asio::ip::address_v4::loopback(), defaultPort)); vEndpoints.push_back(ip::tcp::endpoint(boost::asio::ip::address_v4::loopback(), defaultPort));
if (mapArgs.count("-rpcbind")) if (mapArgs.count("-rpcbind"))
{ {
LogPrintf("WARNING: option -rpcbind was ignored because -rpcallowip was not specified, refusing to allow everyone to connect\n"); LogPrintf("WARNING: option -rpcbind was ignored because -rpcallowip was not specified, refusing to allow everyone to connect\n");
@ -641,8 +640,8 @@ void StartRPCThreads()
} }
} }
} else { // No specific bind address specified, bind to any } else { // No specific bind address specified, bind to any
vEndpoints.push_back(ip::tcp::endpoint(asio::ip::address_v6::any(), defaultPort)); vEndpoints.push_back(ip::tcp::endpoint(boost::asio::ip::address_v6::any(), defaultPort));
vEndpoints.push_back(ip::tcp::endpoint(asio::ip::address_v4::any(), defaultPort)); vEndpoints.push_back(ip::tcp::endpoint(boost::asio::ip::address_v4::any(), defaultPort));
// Prefer making the socket dual IPv6/IPv4 instead of binding // Prefer making the socket dual IPv6/IPv4 instead of binding
// to both addresses seperately. // to both addresses seperately.
bBindAny = true; bBindAny = true;
@ -654,7 +653,7 @@ void StartRPCThreads()
BOOST_FOREACH(const ip::tcp::endpoint &endpoint, vEndpoints) BOOST_FOREACH(const ip::tcp::endpoint &endpoint, vEndpoints)
{ {
try { try {
asio::ip::address bindAddress = endpoint.address(); boost::asio::ip::address bindAddress = endpoint.address();
straddress = bindAddress.to_string(); straddress = bindAddress.to_string();
LogPrintf("Binding RPC on address %s port %i (IPv4+IPv6 bind any: %i)\n", straddress, endpoint.port(), bBindAny); LogPrintf("Binding RPC on address %s port %i (IPv4+IPv6 bind any: %i)\n", straddress, endpoint.port(), bBindAny);
boost::system::error_code v6_only_error; boost::system::error_code v6_only_error;
@ -665,7 +664,7 @@ void StartRPCThreads()
// Try making the socket dual IPv6/IPv4 when listening on the IPv6 "any" address // Try making the socket dual IPv6/IPv4 when listening on the IPv6 "any" address
acceptor->set_option(boost::asio::ip::v6_only( acceptor->set_option(boost::asio::ip::v6_only(
!bBindAny || bindAddress != asio::ip::address_v6::any()), v6_only_error); !bBindAny || bindAddress != boost::asio::ip::address_v6::any()), v6_only_error);
acceptor->bind(endpoint); acceptor->bind(endpoint);
acceptor->listen(socket_base::max_connections); acceptor->listen(socket_base::max_connections);
@ -675,7 +674,7 @@ void StartRPCThreads()
fListening = true; fListening = true;
rpc_acceptors.push_back(acceptor); rpc_acceptors.push_back(acceptor);
// If dual IPv6/IPv4 bind successful, skip binding to IPv4 separately // If dual IPv6/IPv4 bind successful, skip binding to IPv4 separately
if(bBindAny && bindAddress == asio::ip::address_v6::any() && !v6_only_error) if(bBindAny && bindAddress == boost::asio::ip::address_v6::any() && !v6_only_error)
break; break;
} }
catch (const boost::system::system_error& e) catch (const boost::system::system_error& e)
@ -693,7 +692,7 @@ void StartRPCThreads()
rpc_worker_group = new boost::thread_group(); rpc_worker_group = new boost::thread_group();
for (int i = 0; i < GetArg("-rpcthreads", 4); i++) for (int i = 0; i < GetArg("-rpcthreads", 4); i++)
rpc_worker_group->create_thread(boost::bind(&asio::io_service::run, rpc_io_service)); rpc_worker_group->create_thread(boost::bind(&boost::asio::io_service::run, rpc_io_service));
fRPCRunning = true; fRPCRunning = true;
} }
@ -701,12 +700,12 @@ void StartDummyRPCThread()
{ {
if(rpc_io_service == NULL) if(rpc_io_service == NULL)
{ {
rpc_io_service = new asio::io_service(); rpc_io_service = new boost::asio::io_service();
/* Create dummy "work" to keep the thread from exiting when no timeouts active, /* Create dummy "work" to keep the thread from exiting when no timeouts active,
* see http://www.boost.org/doc/libs/1_51_0/doc/html/boost_asio/reference/io_service.html#boost_asio.reference.io_service.stopping_the_io_service_from_running_out_of_work */ * see http://www.boost.org/doc/libs/1_51_0/doc/html/boost_asio/reference/io_service.html#boost_asio.reference.io_service.stopping_the_io_service_from_running_out_of_work */
rpc_dummy_work = new asio::io_service::work(*rpc_io_service); rpc_dummy_work = new boost::asio::io_service::work(*rpc_io_service);
rpc_worker_group = new boost::thread_group(); rpc_worker_group = new boost::thread_group();
rpc_worker_group->create_thread(boost::bind(&asio::io_service::run, rpc_io_service)); rpc_worker_group->create_thread(boost::bind(&boost::asio::io_service::run, rpc_io_service));
fRPCRunning = true; fRPCRunning = true;
} }
} }
@ -719,7 +718,7 @@ void StopRPCThreads()
// First, cancel all timers and acceptors // First, cancel all timers and acceptors
// This is not done automatically by ->stop(), and in some cases the destructor of // This is not done automatically by ->stop(), and in some cases the destructor of
// asio::io_service can hang if this is skipped. // boost::asio::io_service can hang if this is skipped.
boost::system::error_code ec; boost::system::error_code ec;
BOOST_FOREACH(const boost::shared_ptr<ip::tcp::acceptor> &acceptor, rpc_acceptors) BOOST_FOREACH(const boost::shared_ptr<ip::tcp::acceptor> &acceptor, rpc_acceptors)
{ {
@ -787,7 +786,7 @@ void RPCRunLater(const std::string& name, boost::function<void(void)> func, int6
deadlineTimers.insert(make_pair(name, deadlineTimers.insert(make_pair(name,
boost::shared_ptr<deadline_timer>(new deadline_timer(*rpc_io_service)))); boost::shared_ptr<deadline_timer>(new deadline_timer(*rpc_io_service))));
} }
deadlineTimers[name]->expires_from_now(posix_time::seconds(nSeconds)); deadlineTimers[name]->expires_from_now(boost::posix_time::seconds(nSeconds));
deadlineTimers[name]->async_wait(boost::bind(RPCRunHandler, _1, func)); deadlineTimers[name]->async_wait(boost::bind(RPCRunHandler, _1, func));
} }

View file

@ -23,8 +23,6 @@
#include "json/json_spirit_value.h" #include "json/json_spirit_value.h"
using namespace std; using namespace std;
using namespace boost;
using namespace boost::assign;
using namespace json_spirit; using namespace json_spirit;
int64_t nWalletUnlockTime; int64_t nWalletUnlockTime;
@ -1873,9 +1871,9 @@ Value lockunspent(const Array& params, bool fHelp)
); );
if (params.size() == 1) if (params.size() == 1)
RPCTypeCheck(params, list_of(bool_type)); RPCTypeCheck(params, boost::assign::list_of(bool_type));
else else
RPCTypeCheck(params, list_of(bool_type)(array_type)); RPCTypeCheck(params, boost::assign::list_of(bool_type)(array_type));
bool fUnlock = params[0].get_bool(); bool fUnlock = params[0].get_bool();
@ -1892,7 +1890,7 @@ Value lockunspent(const Array& params, bool fHelp)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, expected object"); throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, expected object");
const Object& o = output.get_obj(); const Object& o = output.get_obj();
RPCTypeCheck(o, map_list_of("txid", str_type)("vout", int_type)); RPCTypeCheck(o, boost::assign::map_list_of("txid", str_type)("vout", int_type));
string txid = find_value(o, "txid").get_str(); string txid = find_value(o, "txid").get_str();
if (!IsHex(txid)) if (!IsHex(txid))

View file

@ -20,7 +20,6 @@
#include <boost/tuple/tuple.hpp> #include <boost/tuple/tuple.hpp>
using namespace std; using namespace std;
using namespace boost::tuples;
BOOST_AUTO_TEST_SUITE(bloom_tests) BOOST_AUTO_TEST_SUITE(bloom_tests)

View file

@ -15,12 +15,10 @@
#include "wallet_ismine.h" #include "wallet_ismine.h"
#endif #endif
#include <boost/assign/std/vector.hpp>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
using namespace std; using namespace std;
using namespace boost::assign;
typedef vector<unsigned char> valtype; typedef vector<unsigned char> valtype;
@ -81,22 +79,21 @@ BOOST_AUTO_TEST_CASE(multisig_verify)
CScript s; CScript s;
// Test a AND b: // Test a AND b:
keys.clear(); keys.assign(1,key[0]);
keys += key[0],key[1]; // magic operator+= from boost.assign keys.push_back(key[1]);
s = sign_multisig(a_and_b, keys, txTo[0], 0); s = sign_multisig(a_and_b, keys, txTo[0], 0);
BOOST_CHECK(VerifyScript(s, a_and_b, flags, SignatureChecker(txTo[0], 0), &err)); BOOST_CHECK(VerifyScript(s, a_and_b, flags, SignatureChecker(txTo[0], 0), &err));
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_OK, ScriptErrorString(err)); BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_OK, ScriptErrorString(err));
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
{ {
keys.clear(); keys.assign(1,key[i]);
keys += key[i];
s = sign_multisig(a_and_b, keys, txTo[0], 0); s = sign_multisig(a_and_b, keys, txTo[0], 0);
BOOST_CHECK_MESSAGE(!VerifyScript(s, a_and_b, flags, SignatureChecker(txTo[0], 0), &err), strprintf("a&b 1: %d", i)); BOOST_CHECK_MESSAGE(!VerifyScript(s, a_and_b, flags, SignatureChecker(txTo[0], 0), &err), strprintf("a&b 1: %d", i));
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_INVALID_STACK_OPERATION, ScriptErrorString(err)); BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_INVALID_STACK_OPERATION, ScriptErrorString(err));
keys.clear(); keys.assign(1,key[1]);
keys += key[1],key[i]; keys.push_back(key[i]);
s = sign_multisig(a_and_b, keys, txTo[0], 0); s = sign_multisig(a_and_b, keys, txTo[0], 0);
BOOST_CHECK_MESSAGE(!VerifyScript(s, a_and_b, flags, SignatureChecker(txTo[0], 0), &err), strprintf("a&b 2: %d", i)); BOOST_CHECK_MESSAGE(!VerifyScript(s, a_and_b, flags, SignatureChecker(txTo[0], 0), &err), strprintf("a&b 2: %d", i));
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_EVAL_FALSE, ScriptErrorString(err)); BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_EVAL_FALSE, ScriptErrorString(err));
@ -105,8 +102,7 @@ BOOST_AUTO_TEST_CASE(multisig_verify)
// Test a OR b: // Test a OR b:
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
{ {
keys.clear(); keys.assign(1,key[i]);
keys += key[i];
s = sign_multisig(a_or_b, keys, txTo[1], 0); s = sign_multisig(a_or_b, keys, txTo[1], 0);
if (i == 0 || i == 1) if (i == 0 || i == 1)
{ {
@ -132,8 +128,8 @@ BOOST_AUTO_TEST_CASE(multisig_verify)
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
for (int j = 0; j < 4; j++) for (int j = 0; j < 4; j++)
{ {
keys.clear(); keys.assign(1,key[i]);
keys += key[i],key[j]; keys.push_back(key[j]);
s = sign_multisig(escrow, keys, txTo[2], 0); s = sign_multisig(escrow, keys, txTo[2], 0);
if (i < j && i < 3 && j < 3) if (i < j && i < 3 && j < 3)
{ {

View file

@ -23,12 +23,6 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
#include "json/json_spirit_reader_template.h" #include "json/json_spirit_reader_template.h"
@ -37,7 +31,6 @@
using namespace std; using namespace std;
using namespace json_spirit; using namespace json_spirit;
using namespace boost::algorithm;
// Uncomment if you want to output updated JSON tests. // Uncomment if you want to output updated JSON tests.
// #define UPDATE_JSON_TESTS // #define UPDATE_JSON_TESTS

View file

@ -24,7 +24,6 @@
using namespace std; using namespace std;
using namespace json_spirit; using namespace json_spirit;
using namespace boost::algorithm;
// In script_tests.cpp // In script_tests.cpp
extern Array read_json(const std::string& jsondata); extern Array read_json(const std::string& jsondata);
@ -47,7 +46,7 @@ unsigned int ParseScriptFlags(string strFlags)
} }
unsigned int flags = 0; unsigned int flags = 0;
vector<string> words; vector<string> words;
split(words, strFlags, is_any_of(",")); boost::algorithm::split(words, strFlags, boost::algorithm::is_any_of(","));
BOOST_FOREACH(string word, words) BOOST_FOREACH(string word, words)
{ {

View file

@ -18,7 +18,6 @@
#include <boost/scoped_ptr.hpp> #include <boost/scoped_ptr.hpp>
#include <boost/thread.hpp> #include <boost/thread.hpp>
using namespace boost;
using namespace std; using namespace std;
static uint64_t nAccountingEntryNumber = 0; static uint64_t nAccountingEntryNumber = 0;
@ -865,20 +864,20 @@ bool BackupWallet(const CWallet& wallet, const string& strDest)
bitdb.mapFileUseCount.erase(wallet.strWalletFile); bitdb.mapFileUseCount.erase(wallet.strWalletFile);
// Copy wallet.dat // Copy wallet.dat
filesystem::path pathSrc = GetDataDir() / wallet.strWalletFile; boost::filesystem::path pathSrc = GetDataDir() / wallet.strWalletFile;
filesystem::path pathDest(strDest); boost::filesystem::path pathDest(strDest);
if (filesystem::is_directory(pathDest)) if (boost::filesystem::is_directory(pathDest))
pathDest /= wallet.strWalletFile; pathDest /= wallet.strWalletFile;
try { try {
#if BOOST_VERSION >= 104000 #if BOOST_VERSION >= 104000
filesystem::copy_file(pathSrc, pathDest, filesystem::copy_option::overwrite_if_exists); boost::filesystem::copy_file(pathSrc, pathDest, boost::filesystem::copy_option::overwrite_if_exists);
#else #else
filesystem::copy_file(pathSrc, pathDest); boost::filesystem::copy_file(pathSrc, pathDest);
#endif #endif
LogPrintf("copied wallet.dat to %s\n", pathDest.string()); LogPrintf("copied wallet.dat to %s\n", pathDest.string());
return true; return true;
} catch (const filesystem::filesystem_error& e) { } catch (const boost::filesystem::filesystem_error& e) {
LogPrintf("error copying wallet.dat to %s - %s\n", pathDest.string(), e.what()); LogPrintf("error copying wallet.dat to %s - %s\n", pathDest.string(), e.what());
return false; return false;
} }