Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --cc src/db.h
- index 9826194,a8bb073..0000000
- --- a/src/db.h
- +++ b/src/db.h
- @@@ -447,18 -437,34 +447,36 @@@ public
- }
- template<typename T>
- - bool WriteSetting(const string& strKey, const T& value)
- + bool WriteSetting(const std::string& strKey, const T& value)
- {
- nWalletDBUpdated++;
- - return Write(make_pair(string("setting"), strKey), value);
- + return Write(std::make_pair(std::string("setting"), strKey), value);
- }
- - bool ReadAccount(const string& strAccount, CAccount& account);
- - bool WriteAccount(const string& strAccount, const CAccount& account);
- +
- + bool ReadAccount(const std::string& strAccount, CAccount& account);
- + bool WriteAccount(const std::string& strAccount, const CAccount& account);
- ++
- bool WriteAccountingEntry(const CAccountingEntry& acentry);
- - int64 GetAccountCreditDebit(const string& strAccount);
- - void ListAccountCreditDebit(const string& strAccount, list<CAccountingEntry>& acentries);
- + int64 GetAccountCreditDebit(const std::string& strAccount);
- + void ListAccountCreditDebit(const std::string& strAccount, std::list<CAccountingEntry>& acentries);
- - bool ReadMonitorURLs(const string& what, set<string>& urls)
- ++ bool ReadMonitorURLs(const std::string& what, std::set<std::string>& urls)
- + {
- - return Read(make_pair(string("monitor"), what), urls);
- ++ return Read(make_pair(std::string("monitor"), what), urls);
- + }
- +
- - bool WriteMonitorURLs(const string& what, const set<string>& urls)
- ++ bool WriteMonitorURLs(const std::string& what, const std::set<std::string>& urls)
- + {
- + nWalletDBUpdated++;
- - return Write(make_pair(string("monitor"), what), urls);
- ++ return Write(make_pair(std::string("monitor"), what), urls);
- + }
- +
- - bool EraseMonitorURLs(const string& what)
- ++ bool EraseMonitorURLs(const std::string& what)
- + {
- + nWalletDBUpdated++;
- - return Erase(make_pair(string("monitor"), what));
- ++ return Erase(make_pair(std::string("monitor"), what));
- + }
- +
- bool LoadWallet();
- protected:
- void ReserveKeyFromKeyPool(int64& nIndex, CKeyPool& keypool);
- diff --git a/src/main.h b/src/main.h
- index 8635a6e..24f3b7f 100644
- --- a/src/main.h
- +++ b/src/main.h
- @@ -64,8 +64,8 @@ extern double dHashesPerSec;
- extern int64 nHPSTimerStart;
- extern CCriticalSection cs_mapMonitored;
- -extern set<string> setMonitorTx; // set of urls listening for new transactions
- -extern set<string> setMonitorBlocks; // set of urls listening for new blocks
- +extern std::set<std::string> setMonitorTx; // set of urls listening for new transactions
- +extern std::set<std::string> setMonitorBlocks; // set of urls listening for new blocks
- // Settings
- extern int fGenerateBitcoins;
- @@ -412,7 +412,7 @@ public:
- printf("%s\n", ToString().c_str());
- }
- - string Address() const;
- + std::string Address() const;
- };
- diff --git a/src/rpcmonitor.cpp b/src/rpcmonitor.cpp
- index 05b21b2..1e2c2fa 100644
- --- a/src/rpcmonitor.cpp
- +++ b/src/rpcmonitor.cpp
- @@ -22,13 +22,13 @@ typedef boost::asio::ssl::stream<boost::asio::ip::tcp::socket> SSLStream;
- using namespace boost::asio;
- using namespace json_spirit;
- -extern string HTTPPost(const string& host, const string& path, const string& strMsg,
- - const map<string,string>& mapRequestHeaders);
- -extern string JSONRPCReply(const Value& result, const Value& error, const Value& id);
- -extern string JSONRPCRequest(const string& strMethod, const Array& params, const Value& id);
- -extern int ReadHTTP(std::basic_istream<char>& stream, map<string, string>& mapHeadersRet, string& strMessageRet);
- +extern std::string HTTPPost(const std::string& host, const std::string& path, const std::string& strMsg,
- + const std::map<std::string,std::string>& mapRequestHeaders);
- +extern std::string JSONRPCReply(const Value& result, const Value& error, const Value& id);
- +extern std::string JSONRPCRequest(const std::string& strMethod, const Array& params, const Value& id);
- +extern int ReadHTTP(std::basic_istream<char>& stream, std::map<std::string, std::string>& mapHeadersRet, std::string& strMessageRet);
- extern double GetDifficulty(const CBlockIndex* blockindex = pindexBest);
- -extern void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDepth, bool fLong, Array& ret);
- +extern void ListTransactions(const CWalletTx& wtx, const std::string& strAccount, int nMinDepth, bool fLong, Array& ret);
- void ThreadHTTPPOST2(void* parg);
- @@ -36,7 +36,7 @@ void ThreadHTTPPOST2(void* parg);
- class CPOSTRequest
- {
- public:
- - CPOSTRequest(const string &_url, const string& _body) : url(_url), body(_body)
- + CPOSTRequest(const std::string &_url, const std::string& _body) : url(_url), body(_body)
- {
- }
- @@ -54,23 +54,23 @@ public:
- printf("URL PARSING FAILED: %s\n", url.c_str());
- return true;
- }
- - string protocol = urlparts[1];
- - string host = urlparts[2];
- - string s_port = urlparts[3]; // Note: includes colon, e.g. ":8080"
- + std::string protocol = urlparts[1];
- + std::string host = urlparts[2];
- + std::string s_port = urlparts[3]; // Note: includes colon, e.g. ":8080"
- bool fSSL = (protocol == "https" ? true : false);
- int port = (fSSL ? 443 : 80);
- if (s_port.size() > 1) { port = atoi(s_port.c_str()+1); }
- - string path = urlparts[4];
- - map<string, string> headers;
- + std::string path = urlparts[4];
- + std::map<std::string, std::string> headers;
- #ifdef USE_SSL
- - asio::io_service io_service;
- - ssl::context context(io_service, ssl::context::sslv23);
- + boost::asio::io_service io_service;
- + ssl::context context = context(io_service, ssl::context::sslv23);
- context.set_options(ssl::context::no_sslv2);
- SSLStream sslStream(io_service, context);
- SSLIOStreamDevice d(sslStream, fSSL);
- iostreams::stream<SSLIOStreamDevice> stream(d);
- - if (!d.connect(host, lexical_cast<string>(port)))
- + if (!d.connect(host, lexical_cast<std::string>(port)))
- {
- printf("POST: Couldn't connect to %s:%d", host.c_str(), port);
- return false;
- @@ -81,12 +81,12 @@ public:
- printf("Cannot POST to SSL server, bitcoin compiled without full openssl libraries.");
- return false;
- }
- - ip::tcp::iostream stream(host, lexical_cast<string>(port));
- + ip::tcp::iostream stream(host, boost::lexical_cast<std::string>(port));
- #endif
- stream << HTTPPost(host, path, body, headers) << std::flush;
- - map<string, string> mapResponseHeaders;
- - string strReply;
- + std::map<std::string, std::string> mapResponseHeaders;
- + std::string strReply;
- int status = ReadHTTP(stream, mapResponseHeaders, strReply);
- // printf(" HTTP response %d: %s\n", status, strReply.c_str());
- @@ -94,11 +94,11 @@ public:
- }
- protected:
- - string url;
- - string body;
- + std::string url;
- + std::string body;
- };
- -static vector<shared_ptr<CPOSTRequest> > vPOSTQueue;
- +static std::vector<boost::shared_ptr<CPOSTRequest> > vPOSTQueue;
- static CCriticalSection cs_vPOSTQueue;
- @@ -113,7 +113,7 @@ Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex)
- result.push_back(Pair("nonce", (boost::uint64_t)block.nNonce));
- result.push_back(Pair("difficulty", GetDifficulty(blockindex)));
- Array txhashes;
- - foreach (const CTransaction&tx, block.vtx)
- + BOOST_FOREACH(const CTransaction&tx, block.vtx)
- txhashes.push_back(tx.GetHash().GetHex());
- result.push_back(Pair("tx", txhashes));
- @@ -129,14 +129,14 @@ void monitorBlock(const CBlock& block, const CBlockIndex* pblockindex)
- Array params; // JSON-RPC requests are always "params" : [ ... ]
- params.push_back(blockToJSON(block, pblockindex));
- - string postBody = JSONRPCRequest("monitorblock", params, Value());
- + std::string postBody = JSONRPCRequest("monitorblock", params, Value());
- CRITICAL_BLOCK(cs_mapMonitored)
- CRITICAL_BLOCK(cs_vPOSTQueue)
- {
- - foreach(const string& url, setMonitorBlocks)
- + BOOST_FOREACH(const std::string& url, setMonitorBlocks)
- {
- - shared_ptr<CPOSTRequest> postRequest(new CPOSTRequest(url, postBody));
- + boost::shared_ptr<CPOSTRequest> postRequest(new CPOSTRequest(url, postBody));
- vPOSTQueue.push_back(postRequest);
- }
- }
- @@ -149,14 +149,14 @@ void monitorTx(const CWalletTx& wtx)
- if (params.empty())
- return; // Not our transaction
- - string postBody = JSONRPCRequest("monitortx", params, Value());
- + std::string postBody = JSONRPCRequest("monitortx", params, Value());
- CRITICAL_BLOCK(cs_mapMonitored)
- CRITICAL_BLOCK(cs_vPOSTQueue)
- {
- - foreach(const string& url, setMonitorTx)
- + BOOST_FOREACH(const std::string& url, setMonitorTx)
- {
- - shared_ptr<CPOSTRequest> postRequest(new CPOSTRequest(url, postBody));
- + boost::shared_ptr<CPOSTRequest> postRequest(new CPOSTRequest(url, postBody));
- vPOSTQueue.push_back(postRequest);
- }
- }
- @@ -165,21 +165,21 @@ void monitorTx(const CWalletTx& wtx)
- Value listmonitored(const Array& params, bool fHelp)
- {
- if (fHelp || params.size() != 0)
- - throw runtime_error(
- + throw std::runtime_error(
- "listmonitored\n"
- "Returns list of urls that receive notification when new blocks are accepted.");
- Array ret;
- CRITICAL_BLOCK(cs_mapMonitored)
- {
- - foreach(const string& url, setMonitorBlocks)
- + BOOST_FOREACH(const std::string& url, setMonitorBlocks)
- {
- Object item;
- item.push_back(Pair("category", "block"));
- item.push_back(Pair("url", url));
- ret.push_back(item);
- }
- - foreach(const string& url, setMonitorTx)
- + BOOST_FOREACH(const std::string& url, setMonitorTx)
- {
- Object item;
- item.push_back(Pair("category", "tx"));
- @@ -193,11 +193,11 @@ Value listmonitored(const Array& params, bool fHelp)
- Value monitortx(const Array& params, bool fHelp)
- {
- if (fHelp || params.size() < 1 || params.size() > 3)
- - throw runtime_error(
- + throw std::runtime_error(
- "monitortx <url> [monitor=true]\n"
- "POST transaction information to <url> as wallet transactions are sent/received.\n"
- "[monitor] true will start monitoring, false will stop.");
- - string url = params[0].get_str();
- + std::string url = params[0].get_str();
- bool fMonitor = true;
- if (params.size() > 1)
- fMonitor = params[1].get_bool();
- @@ -219,11 +219,11 @@ Value monitortx(const Array& params, bool fHelp)
- Value monitorblocks(const Array& params, bool fHelp)
- {
- if (fHelp || params.size() < 1 || params.size() > 3)
- - throw runtime_error(
- + throw std::runtime_error(
- "monitorblocks <url> [monitor=true]\n"
- "POST block information to <url> as blocks are added to the block chain.\n"
- "[monitor] true will start monitoring, false will stop.");
- - string url = params[0].get_str();
- + std::string url = params[0].get_str();
- bool fMonitor = true;
- if (params.size() > 1)
- fMonitor = params[1].get_bool();
- @@ -270,13 +270,13 @@ void ThreadHTTPPOST2(void* parg)
- if (fShutdown)
- return;
- - vector<shared_ptr<CPOSTRequest> > work;
- + std::vector<boost::shared_ptr<CPOSTRequest> > work;
- CRITICAL_BLOCK(cs_vPOSTQueue)
- {
- work = vPOSTQueue;
- vPOSTQueue.clear();
- }
- - foreach (shared_ptr<CPOSTRequest> r, work)
- + BOOST_FOREACH (boost::shared_ptr<CPOSTRequest> r, work)
- r->POST();
- if (vPOSTQueue.empty())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement