diff --git a/modules/ripple_client/ripple_client.cpp b/modules/ripple_client/ripple_client.cpp new file mode 100644 index 0000000000..7af7bbded2 --- /dev/null +++ b/modules/ripple_client/ripple_client.cpp @@ -0,0 +1,45 @@ +//------------------------------------------------------------------------------ +/* + Copyright (c) 2011-2013, OpenCoin, Inc. + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ +//============================================================================== + +/** Add this to get the @ref ripple_client module. + + @file ripple_client.cpp + @ingroup ripple_client +*/ + +#include "ripple_client.h" + +// VFALCO: TODO, fix these warnings! +#ifdef _MSC_VER +//#pragma warning (push) // Causes spurious C4503 "decorated name exceeds maximum length" +#pragma warning (disable: 4018) // signed/unsigned mismatch +#pragma warning (disable: 4244) // conversion, possible loss of data +#endif + +#include "src/cpp/ripple/CallRPC.cpp" +#include "src/cpp/ripple/HttpsClient.cpp" +#include "src/cpp/ripple/rpc.cpp" +#include "src/cpp/ripple/RPCDoor.cpp" +#include "src/cpp/ripple/RPCErr.cpp" +#include "src/cpp/ripple/RPCHandler.cpp" +#include "src/cpp/ripple/RPCServer.cpp" +#include "src/cpp/ripple/RPCSub.cpp" + +#ifdef _MSC_VER +//#pragma warning (pop) +#endif diff --git a/modules/ripple_client/ripple_client.h b/modules/ripple_client/ripple_client.h new file mode 100644 index 0000000000..3be7ebbbe0 --- /dev/null +++ b/modules/ripple_client/ripple_client.h @@ -0,0 +1,37 @@ +//------------------------------------------------------------------------------ +/* + Copyright (c) 2011-2013, OpenCoin, Inc. + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ +//============================================================================== + +/** Include this to get the @ref ripple_client module. + + @file ripple_client.h + @ingroup ripple_client +*/ + +/** Client classes. + + This module provides classes that perform client interaction with the server. + + @defgroup ripple_client +*/ + +#ifndef RIPPLE_CLIENT_H +#define RIPPLE_CLIENT_H + + + +#endif diff --git a/newcoin.vcxproj b/newcoin.vcxproj index c677929588..7c19ffcbbe 100644 --- a/newcoin.vcxproj +++ b/newcoin.vcxproj @@ -168,6 +168,7 @@ + @@ -175,14 +176,20 @@ true true + true + true true true + true + true true true + true + true @@ -532,9 +539,24 @@ - - - + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + @@ -555,7 +577,12 @@ - + + true + true + true + true + @@ -693,12 +720,42 @@ true true - - - - - - + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + + + true + true + true + true + true @@ -857,44 +914,63 @@ + - true - true + false + false + false + false - true - true + false + false + false + false - true - true + false + false + false + false - true - true + false + false + false + false - true - true + false + false + false + false - true - true + false + false + false + false - true - true + false + false + false + false - true - true + false + false + false + false - true - true + false + false + false + false true @@ -1338,16 +1414,22 @@ $(SrcDir)\%(Filename).pb.h;$(SrcDir)\%(Filename).pb.cc - true - true + false + false + false + false - true - true + false + false + false + false - true - true + false + false + false + false true diff --git a/newcoin.vcxproj.filters b/newcoin.vcxproj.filters index e83f634c67..434a037f35 100644 --- a/newcoin.vcxproj.filters +++ b/newcoin.vcxproj.filters @@ -95,6 +95,9 @@ {c441b367-d096-401f-a3f0-5ac24290d7b7} + + {3f351c55-360d-40bc-a136-4944ce572efd} + @@ -433,15 +436,6 @@ 1. Modules\ripple_main - - 1. Modules\ripple_client - - - 1. Modules\ripple_client - - - 1. Modules\ripple_client - 1. Modules\ripple_main @@ -508,9 +502,6 @@ 1. Modules\ripple_ledger\transactions - - 1. Modules\ripple_client - 1. Modules\ripple_main @@ -535,21 +526,6 @@ 1. Modules\ripple_net - - 1. Modules\ripple_client - - - 1. Modules\ripple_client - - - 1. Modules\ripple_client - - - 1. Modules\ripple_client - - - 1. Modules\ripple_client - 1. Modules\ripple_ledger\serialization @@ -571,9 +547,6 @@ 1. Modules\ripple_net - - 1. Modules\ripple_net - 1. Modules\ripple_net @@ -697,6 +670,39 @@ 1. Modules\ripple_ledger\processing + + 1. Modules\ripple_client\rpc + + + 1. Modules\ripple_client\rpc + + + 1. Modules\ripple_client\rpc + + + 1. Modules\ripple_client\rpc + + + 1. Modules\ripple_client\rpc + + + 1. Modules\ripple_client\rpc + + + 1. Modules\ripple_client\rpc + + + 1. Modules\ripple_client + + + 1. Modules\ripple_ledger\transactions + + + 1. Modules\ripple_ledger\transactions + + + 1. Modules\ripple_client\rpc + @@ -1065,15 +1071,6 @@ 1. Modules\ripple_net - - 1. Modules\ripple_client - - - 1. Modules\ripple_client - - - 1. Modules\ripple_client - 1. Modules\ripple_main @@ -1134,9 +1131,6 @@ 1. Modules\ripple_ledger\transactions - - 1. Modules\ripple_client - 1. Modules\ripple_main @@ -1155,21 +1149,6 @@ 1. Modules\ripple_net - - 1. Modules\ripple_client - - - 1. Modules\ripple_client - - - 1. Modules\ripple_client - - - 1. Modules\ripple_client - - - 1. Modules\ripple_client - 1. Modules\ripple_ledger\serialization @@ -1194,12 +1173,6 @@ 1. Modules\ripple_net - - 1. Modules\ripple_client - - - 1. Modules\ripple_net - 1. Modules\ripple_net @@ -1326,6 +1299,42 @@ 1. Modules\ripple_ledger\processing + + 1. Modules\ripple_client\rpc + + + 1. Modules\ripple_client\rpc + + + 1. Modules\ripple_client\rpc + + + 1. Modules\ripple_client\rpc + + + 1. Modules\ripple_client\rpc + + + 1. Modules\ripple_client\rpc + + + 1. Modules\ripple_client\rpc + + + 1. Modules\ripple_client\rpc + + + 1. Modules\ripple_client + + + 1. Modules\ripple_ledger\transactions + + + 1. Modules\ripple_ledger\transactions + + + 1. Modules\ripple_client\rpc + diff --git a/src/cpp/ripple/HttpsClient.cpp b/src/cpp/ripple/HttpsClient.cpp index 9e4c313c7a..e5530417af 100644 --- a/src/cpp/ripple/HttpsClient.cpp +++ b/src/cpp/ripple/HttpsClient.cpp @@ -14,8 +14,6 @@ #include "Config.h" #include "Log.h" -SETUP_LOG(); - #define CLIENT_MAX_HEADER (32*1024) using namespace boost::system; @@ -84,7 +82,7 @@ void HttpsClient::httpsGet( void HttpsClient::httpsNext() { - cLog(lsTRACE) << "Fetch: " << mDeqSites[0]; + WriteLog (lsTRACE, HttpsClient) << "Fetch: " << mDeqSites[0]; boost::shared_ptr query(new boost::asio::ip::tcp::resolver::query(mDeqSites[0], boost::lexical_cast(mPort), ip::resolver_query_base::numeric_service)); @@ -92,7 +90,7 @@ void HttpsClient::httpsNext() mDeadline.expires_from_now(mTimeout, mShutdown); - cLog(lsTRACE) << "expires_from_now: " << mShutdown.message(); + WriteLog (lsTRACE, HttpsClient) << "expires_from_now: " << mShutdown.message(); if (!mShutdown) { @@ -105,7 +103,7 @@ void HttpsClient::httpsNext() if (!mShutdown) { - cLog(lsTRACE) << "Resolving: " << mDeqSites[0]; + WriteLog (lsTRACE, HttpsClient) << "Resolving: " << mDeqSites[0]; mResolver.async_resolve(*mQuery, boost::bind( @@ -124,20 +122,20 @@ void HttpsClient::handleDeadline(const boost::system::error_code& ecResult) if (ecResult == boost::asio::error::operation_aborted) { // Timer canceled because deadline no longer needed. - cLog(lsTRACE) << "Deadline cancelled."; + WriteLog (lsTRACE, HttpsClient) << "Deadline cancelled."; nothing(); // Aborter is done. } else if (ecResult) { - cLog(lsTRACE) << "Deadline error: " << mDeqSites[0] << ": " << ecResult.message(); + WriteLog (lsTRACE, HttpsClient) << "Deadline error: " << mDeqSites[0] << ": " << ecResult.message(); // Can't do anything sound. abort(); } else { - cLog(lsTRACE) << "Deadline arrived."; + WriteLog (lsTRACE, HttpsClient) << "Deadline arrived."; // Mark us as shutting down. // XXX Use our own error code. @@ -161,7 +159,7 @@ void HttpsClient::handleShutdown( { if (ecResult) { - cLog(lsTRACE) << "Shutdown error: " << mDeqSites[0] << ": " << ecResult.message(); + WriteLog (lsTRACE, HttpsClient) << "Shutdown error: " << mDeqSites[0] << ": " << ecResult.message(); } } @@ -175,13 +173,13 @@ void HttpsClient::handleResolve( if (mShutdown) { - cLog(lsTRACE) << "Resolve error: " << mDeqSites[0] << ": " << mShutdown.message(); + WriteLog (lsTRACE, HttpsClient) << "Resolve error: " << mDeqSites[0] << ": " << mShutdown.message(); invokeComplete(mShutdown); } else { - cLog(lsTRACE) << "Resolve complete."; + WriteLog (lsTRACE, HttpsClient) << "Resolve complete."; boost::asio::async_connect( mSocket.lowest_layer(), @@ -200,19 +198,19 @@ void HttpsClient::handleConnect(const boost::system::error_code& ecResult) if (mShutdown) { - cLog(lsTRACE) << "Connect error: " << mShutdown.message(); + WriteLog (lsTRACE, HttpsClient) << "Connect error: " << mShutdown.message(); } if (!mShutdown) { - cLog(lsTRACE) << "Connected."; + WriteLog (lsTRACE, HttpsClient) << "Connected."; if (theConfig.SSL_VERIFY) { mShutdown = mSocket.verify(mDeqSites[0]); if (mShutdown) { - cLog(lsTRACE) << "set_verify_callback: " << mDeqSites[0] << ": " << mShutdown.message(); + WriteLog (lsTRACE, HttpsClient) << "set_verify_callback: " << mDeqSites[0] << ": " << mShutdown.message(); } } } @@ -243,13 +241,13 @@ void HttpsClient::handleRequest(const boost::system::error_code& ecResult) if (mShutdown) { - cLog(lsTRACE) << "Handshake error:" << mShutdown.message(); + WriteLog (lsTRACE, HttpsClient) << "Handshake error:" << mShutdown.message(); invokeComplete(mShutdown); } else { - cLog(lsTRACE) << "Session started."; + WriteLog (lsTRACE, HttpsClient) << "Session started."; mBuild(mRequest, mDeqSites[0]); @@ -269,13 +267,13 @@ void HttpsClient::handleWrite(const boost::system::error_code& ecResult, std::si if (mShutdown) { - cLog(lsTRACE) << "Write error: " << mShutdown.message(); + WriteLog (lsTRACE, HttpsClient) << "Write error: " << mShutdown.message(); invokeComplete(mShutdown); } else { - cLog(lsTRACE) << "Wrote."; + WriteLog (lsTRACE, HttpsClient) << "Wrote."; mSocket.async_read_until( mHeader, @@ -290,7 +288,7 @@ void HttpsClient::handleWrite(const boost::system::error_code& ecResult, std::si void HttpsClient::handleHeader(const boost::system::error_code& ecResult, std::size_t bytes_transferred) { std::string strHeader((std::istreambuf_iterator(&mHeader)), std::istreambuf_iterator()); - cLog(lsTRACE) << "Header: \"" << strHeader << "\""; + WriteLog (lsTRACE, HttpsClient) << "Header: \"" << strHeader << "\""; static boost::regex reStatus("\\`HTTP/1\\S+ (\\d{3}) .*\\'"); // HTTP/1.1 200 OK static boost::regex reSize("\\`.*\\r\\nContent-Length:\\s+([0-9]+).*\\'"); @@ -302,7 +300,7 @@ void HttpsClient::handleHeader(const boost::system::error_code& ecResult, std::s if (!bMatch) { // XXX Use our own error code. - cLog(lsTRACE) << "No status code"; + WriteLog (lsTRACE, HttpsClient) << "No status code"; invokeComplete(boost::system::error_code(errc::bad_address, system_category())); return; } @@ -339,7 +337,7 @@ void HttpsClient::handleData(const boost::system::error_code& ecResult, std::siz if (mShutdown && mShutdown != boost::asio::error::eof) { - cLog(lsTRACE) << "Read error: " << mShutdown.message(); + WriteLog (lsTRACE, HttpsClient) << "Read error: " << mShutdown.message(); invokeComplete(mShutdown); } @@ -347,7 +345,7 @@ void HttpsClient::handleData(const boost::system::error_code& ecResult, std::siz { if (mShutdown) { - cLog(lsTRACE) << "Complete."; + WriteLog (lsTRACE, HttpsClient) << "Complete."; nothing(); } @@ -369,10 +367,10 @@ void HttpsClient::invokeComplete(const boost::system::error_code& ecResult, int if (ecCancel) { - cLog(lsTRACE) << "HttpsClient::invokeComplete: Deadline cancel error: " << ecCancel.message(); + WriteLog (lsTRACE, HttpsClient) << "HttpsClient::invokeComplete: Deadline cancel error: " << ecCancel.message(); } - cLog(lsDEBUG) << "HttpsClient::invokeComplete: Deadline popping: " << mDeqSites.size(); + WriteLog (lsDEBUG, HttpsClient) << "HttpsClient::invokeComplete: Deadline popping: " << mDeqSites.size(); if (!mDeqSites.empty()) { mDeqSites.pop_front(); @@ -446,7 +444,7 @@ void HttpsClient::httpsRequest( #define SMS_TIMEOUT 30 bool responseSMS(const boost::system::error_code& ecResult, int iStatus, const std::string& strData) { - cLog(lsINFO) << "SMS: Response:" << iStatus << " :" << strData; + WriteLog (lsINFO, HttpsClient) << "SMS: Response:" << iStatus << " :" << strData; return true; } @@ -459,7 +457,7 @@ void HttpsClient::sendSMS(boost::asio::io_service& io_service, const std::string if (theConfig.SMS_URL == "" || !parseUrl(theConfig.SMS_URL, strScheme, strDomain, iPort, strPath)) { - cLog(lsWARNING) << "SMSRequest: Bad URL:" << theConfig.SMS_URL; + WriteLog (lsWARNING, HttpsClient) << "SMSRequest: Bad URL:" << theConfig.SMS_URL; } else { @@ -475,8 +473,8 @@ void HttpsClient::sendSMS(boost::asio::io_service& io_service, const std::string % theConfig.SMS_SECRET % urlEncode(strText)); - // cLog(lsINFO) << "SMS: Request:" << strURI; - cLog(lsINFO) << "SMS: Request: '" << strText << "'"; + // WriteLog (lsINFO) << "SMS: Request:" << strURI; + WriteLog (lsINFO, HttpsClient) << "SMS: Request: '" << strText << "'"; if (iPort < 0) iPort = bSSL ? 443 : 80; diff --git a/src/cpp/ripple/RPCDoor.cpp b/src/cpp/ripple/RPCDoor.cpp index 219f281970..c6bb17bad3 100644 --- a/src/cpp/ripple/RPCDoor.cpp +++ b/src/cpp/ripple/RPCDoor.cpp @@ -5,8 +5,6 @@ #include #include -SETUP_LOG(); - using namespace std; using namespace boost::asio::ip; @@ -14,13 +12,13 @@ RPCDoor::RPCDoor(boost::asio::io_service& io_service) : mAcceptor(io_service, tcp::endpoint(address::from_string(theConfig.RPC_IP), theConfig.RPC_PORT)), mDelayTimer(io_service) { - cLog(lsINFO) << "RPC port: " << theConfig.RPC_IP << " " << theConfig.RPC_PORT << " allow remote: " << theConfig.RPC_ALLOW_REMOTE; + WriteLog (lsINFO, RPCDoor) << "RPC port: " << theConfig.RPC_IP << " " << theConfig.RPC_PORT << " allow remote: " << theConfig.RPC_ALLOW_REMOTE; startListening(); } RPCDoor::~RPCDoor() { - cLog(lsINFO) << "RPC port: " << theConfig.RPC_IP << " " << theConfig.RPC_PORT << " allow remote: " << theConfig.RPC_ALLOW_REMOTE; + WriteLog (lsINFO, RPCDoor) << "RPC port: " << theConfig.RPC_IP << " " << theConfig.RPC_PORT << " allow remote: " << theConfig.RPC_ALLOW_REMOTE; } void RPCDoor::startListening() @@ -63,7 +61,7 @@ void RPCDoor::handleConnect(RPCServer::pointer new_connection, { if (error == boost::system::errc::too_many_files_open) delay = true; - cLog(lsINFO) << "RPCDoor::handleConnect Error: " << error; + WriteLog (lsINFO, RPCDoor) << "RPCDoor::handleConnect Error: " << error; } if (delay) diff --git a/src/cpp/ripple/RPCErr.cpp b/src/cpp/ripple/RPCErr.cpp index 566b420ce8..9b51968bec 100644 --- a/src/cpp/ripple/RPCErr.cpp +++ b/src/cpp/ripple/RPCErr.cpp @@ -6,7 +6,10 @@ #include "../json/writer.h" -SETUP_LOG(); +// For logging +struct RPCErr +{ +}; Json::Value rpcError(int iError, Json::Value jvResult) { @@ -88,7 +91,7 @@ Json::Value rpcError(int iError, Json::Value jvResult) if (i >= 0) { - cLog(lsDEBUG) << "rpcError: " + WriteLog (lsDEBUG, RPCErr) << "rpcError: " << errorInfoA[i].pToken << ": " << errorInfoA[i].pMessage << std::endl; } diff --git a/src/cpp/ripple/RPCHandler.cpp b/src/cpp/ripple/RPCHandler.cpp index 0d2d492799..efe296e10c 100644 --- a/src/cpp/ripple/RPCHandler.cpp +++ b/src/cpp/ripple/RPCHandler.cpp @@ -25,8 +25,6 @@ #include "PFRequest.h" #include "ProofOfWork.h" -SETUP_LOG(); - static const int rpcCOST_DEFAULT = 10; static const int rpcCOST_EXCEPTION = 20; static const int rpcCOST_EXPENSIVE = 50; @@ -81,7 +79,7 @@ Json::Value RPCHandler::transactionSign(Json::Value jvRequest, bool bSubmit) RippleAddress naSeed; RippleAddress raSrcAddressID; - cLog(lsDEBUG) << boost::str(boost::format("transactionSign: %s") % jvRequest); + WriteLog (lsDEBUG, RPCHandler) << boost::str(boost::format("transactionSign: %s") % jvRequest); if (!jvRequest.isMember("secret") || !jvRequest.isMember("tx_json")) { @@ -114,7 +112,7 @@ Json::Value RPCHandler::transactionSign(Json::Value jvRequest, bool bSubmit) AccountState::pointer asSrc = mNetOps->getAccountState(mNetOps->getCurrentLedger(), raSrcAddressID); if (!asSrc) { - cLog(lsDEBUG) << boost::str(boost::format("transactionSign: Failed to find source account in current ledger: %s") + WriteLog (lsDEBUG, RPCHandler) << boost::str(boost::format("transactionSign: Failed to find source account in current ledger: %s") % raSrcAddressID.humanAccountID()); return rpcError(rpcSRC_ACT_NOT_FOUND); @@ -187,13 +185,13 @@ Json::Value RPCHandler::transactionSign(Json::Value jvRequest, bool bSubmit) if (!bValid || !pf.findPaths(theConfig.PATH_SEARCH_SIZE, 3, spsPaths)) { - cLog(lsDEBUG) << "transactionSign: build_path: No paths found."; + WriteLog (lsDEBUG, RPCHandler) << "transactionSign: build_path: No paths found."; return rpcError(rpcNO_PATH); } else { - cLog(lsDEBUG) << "transactionSign: build_path: " << spsPaths.getJson(0); + WriteLog (lsDEBUG, RPCHandler) << "transactionSign: build_path: " << spsPaths.getJson(0); } if (!spsPaths.isEmpty()) @@ -243,7 +241,7 @@ Json::Value RPCHandler::transactionSign(Json::Value jvRequest, bool bSubmit) { naMasterAccountPublic.setAccountPublic(naMasterGenerator, iIndex); - cLog(lsWARNING) << "authorize: " << iIndex << " : " << naMasterAccountPublic.humanAccountID() << " : " << raSrcAddressID.humanAccountID(); + WriteLog (lsWARNING, RPCHandler) << "authorize: " << iIndex << " : " << naMasterAccountPublic.humanAccountID() << " : " << raSrcAddressID.humanAccountID(); bFound = raSrcAddressID.getAccountID() == naMasterAccountPublic.getAccountID(); if (!bFound) @@ -458,7 +456,7 @@ Json::Value RPCHandler::authorize(Ledger::ref lrLedger, { naMasterAccountPublic.setAccountPublic(naMasterGenerator, iIndex); - cLog(lsDEBUG) << "authorize: " << iIndex << " : " << naMasterAccountPublic.humanAccountID() << " : " << naSrcAccountID.humanAccountID(); + WriteLog (lsDEBUG, RPCHandler) << "authorize: " << iIndex << " : " << naMasterAccountPublic.humanAccountID() << " : " << naSrcAccountID.humanAccountID(); bFound = naSrcAccountID.getAccountID() == naMasterAccountPublic.getAccountID(); if (!bFound) @@ -489,7 +487,7 @@ Json::Value RPCHandler::authorize(Ledger::ref lrLedger, if (saSrcBalance < saFee) { - cLog(lsINFO) << "authorize: Insufficient funds for fees: fee=" << saFee.getText() << " balance=" << saSrcBalance.getText(); + WriteLog (lsINFO, RPCHandler) << "authorize: Insufficient funds for fees: fee=" << saFee.getText() << " balance=" << saSrcBalance.getText(); return rpcError(rpcINSUF_FUNDS); } @@ -1207,7 +1205,7 @@ Json::Value RPCHandler::doBookOffers(Json::Value jvRequest, int& cost, ScopedLoc if (!jvTakerPays.isMember("currency") || !STAmount::currencyFromString(uTakerPaysCurrencyID, jvTakerPays["currency"].asString())) { - cLog(lsINFO) << "Bad taker_pays currency."; + WriteLog (lsINFO, RPCHandler) << "Bad taker_pays currency."; return rpcError(rpcSRC_CUR_MALFORMED); } @@ -1219,7 +1217,7 @@ Json::Value RPCHandler::doBookOffers(Json::Value jvRequest, int& cost, ScopedLoc || (!uTakerPaysCurrencyID != !uTakerPaysIssuerID) || ACCOUNT_ONE == uTakerPaysIssuerID) { - cLog(lsINFO) << "Bad taker_pays issuer."; + WriteLog (lsINFO, RPCHandler) << "Bad taker_pays issuer."; return rpcError(rpcSRC_ISR_MALFORMED); } @@ -1232,7 +1230,7 @@ Json::Value RPCHandler::doBookOffers(Json::Value jvRequest, int& cost, ScopedLoc if (!jvTakerGets.isMember("currency") || !STAmount::currencyFromString(uTakerGetsCurrencyID, jvTakerGets["currency"].asString())) { - cLog(lsINFO) << "Bad taker_pays currency."; + WriteLog (lsINFO, RPCHandler) << "Bad taker_pays currency."; return rpcError(rpcSRC_CUR_MALFORMED); } @@ -1244,14 +1242,14 @@ Json::Value RPCHandler::doBookOffers(Json::Value jvRequest, int& cost, ScopedLoc || (!uTakerGetsCurrencyID != !uTakerGetsIssuerID) || ACCOUNT_ONE == uTakerGetsIssuerID) { - cLog(lsINFO) << "Bad taker_gets issuer."; + WriteLog (lsINFO, RPCHandler) << "Bad taker_gets issuer."; return rpcError(rpcDST_ISR_MALFORMED); } if (uTakerPaysCurrencyID == uTakerGetsCurrencyID && uTakerPaysIssuerID == uTakerGetsIssuerID) { - cLog(lsINFO) << "taker_gets same as taker_pays."; + WriteLog (lsINFO, RPCHandler) << "taker_gets same as taker_pays."; return rpcError(rpcBAD_MARKET); } @@ -1355,7 +1353,7 @@ Json::Value RPCHandler::doRipplePathFind(Json::Value jvRequest, int& cost, Scope int jc = theApp->getJobQueue().getJobCountGE(jtCLIENT); if (jc > 200) { - cLog(lsDEBUG) << "Too busy for RPF: " << jc; + WriteLog (lsDEBUG, RPCHandler) << "Too busy for RPF: " << jc; return rpcError(rpcTOO_BUSY); } @@ -1392,7 +1390,7 @@ Json::Value RPCHandler::doRipplePathFind(Json::Value jvRequest, int& cost, Scope || !saDstAmount.bSetJson(jvRequest["destination_amount"]) || (!!saDstAmount.getCurrency() && (!saDstAmount.getIssuer() || ACCOUNT_ONE == saDstAmount.getIssuer()))) { - cLog(lsINFO) << "Bad destination_amount."; + WriteLog (lsINFO, RPCHandler) << "Bad destination_amount."; jvResult = rpcError(rpcINVALID_PARAMS); } else if ( @@ -1402,7 +1400,7 @@ Json::Value RPCHandler::doRipplePathFind(Json::Value jvRequest, int& cost, Scope || !jvRequest["source_currencies"].size()) // Don't allow empty currencies. ) { - cLog(lsINFO) << "Bad source_currencies."; + WriteLog (lsINFO, RPCHandler) << "Bad source_currencies."; jvResult = rpcError(rpcINVALID_PARAMS); } else @@ -1460,7 +1458,7 @@ Json::Value RPCHandler::doRipplePathFind(Json::Value jvRequest, int& cost, Scope if (!jvSource.isMember("currency") || !STAmount::currencyFromString(uSrcCurrencyID, jvSource["currency"].asString())) { - cLog(lsINFO) << "Bad currency."; + WriteLog (lsINFO, RPCHandler) << "Bad currency."; return rpcError(rpcSRC_CUR_MALFORMED); } @@ -1474,7 +1472,7 @@ Json::Value RPCHandler::doRipplePathFind(Json::Value jvRequest, int& cost, Scope (uSrcIssuerID.isZero() != uSrcCurrencyID.isZero()) || (ACCOUNT_ONE == uSrcIssuerID))) { - cLog(lsINFO) << "Bad issuer."; + WriteLog (lsINFO, RPCHandler) << "Bad issuer."; return rpcError(rpcSRC_ISR_MALFORMED); } @@ -1485,7 +1483,7 @@ Json::Value RPCHandler::doRipplePathFind(Json::Value jvRequest, int& cost, Scope if (!bValid || !pf.findPaths(theConfig.PATH_SEARCH_SIZE, 3, spsComputed)) { - cLog(lsWARNING) << "ripple_path_find: No paths found."; + WriteLog (lsWARNING, RPCHandler) << "ripple_path_find: No paths found."; } else { @@ -1521,10 +1519,10 @@ Json::Value RPCHandler::doRipplePathFind(Json::Value jvRequest, int& cost, Scope false, // --> Allow direct ripple to be added to path set. to path set. true); // --> Stand alone mode, no point in deleting unfundeds. - // cLog(lsDEBUG) << "ripple_path_find: PATHS IN: " << spsComputed.size() << " : " << spsComputed.getJson(0); - // cLog(lsDEBUG) << "ripple_path_find: PATHS EXP: " << vpsExpanded.size(); + // WriteLog (lsDEBUG, RPCHandler) << "ripple_path_find: PATHS IN: " << spsComputed.size() << " : " << spsComputed.getJson(0); + // WriteLog (lsDEBUG, RPCHandler) << "ripple_path_find: PATHS EXP: " << vpsExpanded.size(); - cLog(lsWARNING) + WriteLog (lsWARNING, RPCHandler) << boost::str(boost::format("ripple_path_find: saMaxAmount=%s saDstAmount=%s saMaxAmountAct=%s saDstAmountAct=%s") % saMaxAmount % saDstAmount @@ -1555,7 +1553,7 @@ Json::Value RPCHandler::doRipplePathFind(Json::Value jvRequest, int& cost, Scope transResultInfo(terResult, strToken, strHuman); - cLog(lsDEBUG) + WriteLog (lsDEBUG, RPCHandler) << boost::str(boost::format("ripple_path_find: %s %s %s") % strToken % strHuman @@ -1568,7 +1566,7 @@ Json::Value RPCHandler::doRipplePathFind(Json::Value jvRequest, int& cost, Scope jvResult["alternatives"] = jvArray; } - cLog(lsDEBUG) + WriteLog (lsDEBUG, RPCHandler) << boost::str(boost::format("ripple_path_find< %s") % jvResult); @@ -2025,7 +2023,7 @@ Json::Value RPCHandler::doValidationCreate(Json::Value jvRequest, int& cost, Sco if (!jvRequest.isMember("secret")) { - cLog(lsDEBUG) << "Creating random validation seed."; + WriteLog (lsDEBUG, RPCHandler) << "Creating random validation seed."; raSeed.setSeedRandom(); // Get a random seed. } @@ -2815,7 +2813,7 @@ Json::Value RPCHandler::doLedgerEntry(Json::Value jvRequest, int& cost, ScopedLo || jvRippleState["accounts"][0u].asString() == jvRippleState["accounts"][1u].asString() ) { - cLog(lsINFO) + WriteLog (lsINFO, RPCHandler) << boost::str(boost::format("ledger_entry: ripple_state: accounts: %d currency: %d array: %d size: %d equal: %d") % jvRippleState.isMember("accounts") % jvRippleState.isMember("currency") @@ -2930,7 +2928,7 @@ Json::Value RPCHandler::doSubscribe(Json::Value jvRequest, int& cost, ScopedLock if (!mInfoSub && !jvRequest.isMember("url")) { // Must be a JSON-RPC call. - cLog(lsINFO) << boost::str(boost::format("doSubscribe: RPC subscribe requires a url")); + WriteLog (lsINFO, RPCHandler) << boost::str(boost::format("doSubscribe: RPC subscribe requires a url")); return rpcError(rpcINVALID_PARAMS); } @@ -2955,14 +2953,14 @@ Json::Value RPCHandler::doSubscribe(Json::Value jvRequest, int& cost, ScopedLock ispSub = mNetOps->findRpcSub(strUrl); if (!ispSub) { - cLog(lsDEBUG) << boost::str(boost::format("doSubscribe: building: %s") % strUrl); + WriteLog (lsDEBUG, RPCHandler) << boost::str(boost::format("doSubscribe: building: %s") % strUrl); RPCSub::pointer rspSub = boost::make_shared(strUrl, strUsername, strPassword); ispSub = mNetOps->addRpcSub(strUrl, boost::dynamic_pointer_cast(rspSub)); } else { - cLog(lsTRACE) << boost::str(boost::format("doSubscribe: reusing: %s") % strUrl); + WriteLog (lsTRACE, RPCHandler) << boost::str(boost::format("doSubscribe: reusing: %s") % strUrl); if (jvRequest.isMember("username")) dynamic_cast(&*ispSub)->setUsername(strUsername); @@ -2982,7 +2980,7 @@ Json::Value RPCHandler::doSubscribe(Json::Value jvRequest, int& cost, ScopedLock } else if (!jvRequest["streams"].isArray()) { - cLog(lsINFO) << boost::str(boost::format("doSubscribe: streams requires an array.")); + WriteLog (lsINFO, RPCHandler) << boost::str(boost::format("doSubscribe: streams requires an array.")); return rpcError(rpcINVALID_PARAMS); } @@ -3068,7 +3066,7 @@ Json::Value RPCHandler::doSubscribe(Json::Value jvRequest, int& cost, ScopedLock { mNetOps->subAccount(ispSub, usnaAccoundIds, uLedgerIndex, false); - cLog(lsDEBUG) << boost::str(boost::format("doSubscribe: accounts: %d") % usnaAccoundIds.size()); + WriteLog (lsDEBUG, RPCHandler) << boost::str(boost::format("doSubscribe: accounts: %d") % usnaAccoundIds.size()); } } @@ -3109,7 +3107,7 @@ Json::Value RPCHandler::doSubscribe(Json::Value jvRequest, int& cost, ScopedLock if (!jvTakerPays.isMember("currency") || !STAmount::currencyFromString(uTakerPaysCurrencyID, jvTakerPays["currency"].asString())) { - cLog(lsINFO) << "Bad taker_pays currency."; + WriteLog (lsINFO, RPCHandler) << "Bad taker_pays currency."; return rpcError(rpcSRC_CUR_MALFORMED); } @@ -3121,7 +3119,7 @@ Json::Value RPCHandler::doSubscribe(Json::Value jvRequest, int& cost, ScopedLock || (!uTakerPaysCurrencyID != !uTakerPaysIssuerID) || ACCOUNT_ONE == uTakerPaysIssuerID) { - cLog(lsINFO) << "Bad taker_pays issuer."; + WriteLog (lsINFO, RPCHandler) << "Bad taker_pays issuer."; return rpcError(rpcSRC_ISR_MALFORMED); } @@ -3130,7 +3128,7 @@ Json::Value RPCHandler::doSubscribe(Json::Value jvRequest, int& cost, ScopedLock if (!jvTakerGets.isMember("currency") || !STAmount::currencyFromString(uTakerGetsCurrencyID, jvTakerGets["currency"].asString())) { - cLog(lsINFO) << "Bad taker_pays currency."; + WriteLog (lsINFO, RPCHandler) << "Bad taker_pays currency."; return rpcError(rpcSRC_CUR_MALFORMED); } @@ -3142,7 +3140,7 @@ Json::Value RPCHandler::doSubscribe(Json::Value jvRequest, int& cost, ScopedLock || (!uTakerGetsCurrencyID != !uTakerGetsIssuerID) || ACCOUNT_ONE == uTakerGetsIssuerID) { - cLog(lsINFO) << "Bad taker_gets issuer."; + WriteLog (lsINFO, RPCHandler) << "Bad taker_gets issuer."; return rpcError(rpcDST_ISR_MALFORMED); } @@ -3150,7 +3148,7 @@ Json::Value RPCHandler::doSubscribe(Json::Value jvRequest, int& cost, ScopedLock if (uTakerPaysCurrencyID == uTakerGetsCurrencyID && uTakerPaysIssuerID == uTakerGetsIssuerID) { - cLog(lsINFO) << "taker_gets same as taker_pays."; + WriteLog (lsINFO, RPCHandler) << "taker_gets same as taker_pays."; return rpcError(rpcBAD_MARKET); } @@ -3168,7 +3166,7 @@ Json::Value RPCHandler::doSubscribe(Json::Value jvRequest, int& cost, ScopedLock if (!Ledger::isValidBook(uTakerPaysCurrencyID, uTakerPaysIssuerID, uTakerGetsCurrencyID, uTakerGetsIssuerID)) { - cLog(lsWARNING) << "Bad market: " << + WriteLog (lsWARNING, RPCHandler) << "Bad market: " << uTakerPaysCurrencyID << ":" << uTakerPaysIssuerID << " -> " << uTakerGetsCurrencyID << ":" << uTakerGetsIssuerID; return rpcError(rpcBAD_MARKET); @@ -3335,7 +3333,7 @@ Json::Value RPCHandler::doUnsubscribe(Json::Value jvRequest, int& cost, ScopedLo if (!jvTakerPays.isMember("currency") || !STAmount::currencyFromString(uTakerPaysCurrencyID, jvTakerPays["currency"].asString())) { - cLog(lsINFO) << "Bad taker_pays currency."; + WriteLog (lsINFO, RPCHandler) << "Bad taker_pays currency."; return rpcError(rpcSRC_CUR_MALFORMED); } @@ -3347,7 +3345,7 @@ Json::Value RPCHandler::doUnsubscribe(Json::Value jvRequest, int& cost, ScopedLo || (!uTakerPaysCurrencyID != !uTakerPaysIssuerID) || ACCOUNT_ONE == uTakerPaysIssuerID) { - cLog(lsINFO) << "Bad taker_pays issuer."; + WriteLog (lsINFO, RPCHandler) << "Bad taker_pays issuer."; return rpcError(rpcSRC_ISR_MALFORMED); } @@ -3356,7 +3354,7 @@ Json::Value RPCHandler::doUnsubscribe(Json::Value jvRequest, int& cost, ScopedLo if (!jvTakerGets.isMember("currency") || !STAmount::currencyFromString(uTakerGetsCurrencyID, jvTakerGets["currency"].asString())) { - cLog(lsINFO) << "Bad taker_pays currency."; + WriteLog (lsINFO, RPCHandler) << "Bad taker_pays currency."; return rpcError(rpcSRC_CUR_MALFORMED); } @@ -3368,7 +3366,7 @@ Json::Value RPCHandler::doUnsubscribe(Json::Value jvRequest, int& cost, ScopedLo || (!uTakerGetsCurrencyID != !uTakerGetsIssuerID) || ACCOUNT_ONE == uTakerGetsIssuerID) { - cLog(lsINFO) << "Bad taker_gets issuer."; + WriteLog (lsINFO, RPCHandler) << "Bad taker_gets issuer."; return rpcError(rpcDST_ISR_MALFORMED); } @@ -3376,7 +3374,7 @@ Json::Value RPCHandler::doUnsubscribe(Json::Value jvRequest, int& cost, ScopedLo if (uTakerPaysCurrencyID == uTakerGetsCurrencyID && uTakerPaysIssuerID == uTakerGetsIssuerID) { - cLog(lsINFO) << "taker_gets same as taker_pays."; + WriteLog (lsINFO, RPCHandler) << "taker_gets same as taker_pays."; return rpcError(rpcBAD_MARKET); } @@ -3397,7 +3395,7 @@ Json::Value RPCHandler::doRpcCommand(const std::string& strMethod, Json::Value& { if (cost == 0) cost = rpcCOST_DEFAULT; - cLog(lsTRACE) << "doRpcCommand:" << strMethod << ":" << jvParams; + WriteLog (lsTRACE, RPCHandler) << "doRpcCommand:" << strMethod << ":" << jvParams; if (!jvParams.isArray() || jvParams.size() > 1) return rpcError(rpcINVALID_PARAMS); @@ -3441,7 +3439,7 @@ Json::Value RPCHandler::doCommand(const Json::Value& jvRequest, int iRole, int & int jc = theApp->getJobQueue().getJobCountGE(jtCLIENT); if (jc > 500) { - cLog(lsDEBUG) << "Too busy for command: " << jc; + WriteLog (lsDEBUG, RPCHandler) << "Too busy for command: " << jc; return rpcError(rpcTOO_BUSY); } } @@ -3451,8 +3449,8 @@ Json::Value RPCHandler::doCommand(const Json::Value& jvRequest, int iRole, int & std::string strCommand = jvRequest["command"].asString(); - cLog(lsTRACE) << "COMMAND:" << strCommand; - cLog(lsTRACE) << "REQUEST:" << jvRequest; + WriteLog (lsTRACE, RPCHandler) << "COMMAND:" << strCommand; + WriteLog (lsTRACE, RPCHandler) << "REQUEST:" << jvRequest; mRole = iRole; @@ -3547,7 +3545,7 @@ Json::Value RPCHandler::doCommand(const Json::Value& jvRequest, int iRole, int & if ((commandsA[i].iOptions & optNetwork) && (mNetOps->getOperatingMode() < NetworkOPs::omSYNCING)) { - cLog(lsINFO) << "Insufficient network mode for RPC: " << mNetOps->strOperatingMode(); + WriteLog (lsINFO, RPCHandler) << "Insufficient network mode for RPC: " << mNetOps->strOperatingMode(); return rpcError(rpcNO_NETWORK); } @@ -3584,7 +3582,7 @@ Json::Value RPCHandler::doCommand(const Json::Value& jvRequest, int iRole, int & } catch (std::exception& e) { - cLog(lsINFO) << "Caught throw: " << e.what(); + WriteLog (lsINFO, RPCHandler) << "Caught throw: " << e.what(); if (cost == rpcCOST_DEFAULT) cost = rpcCOST_EXCEPTION; @@ -3608,9 +3606,9 @@ Json::Value RPCInternalHandler::runHandler(const std::string& name, const Json:: { if (name == h->mName) { - cLog(lsWARNING) << "Internal command " << name << ": " << params; + WriteLog (lsWARNING, RPCHandler) << "Internal command " << name << ": " << params; Json::Value ret = h->mHandler(params); - cLog(lsWARNING) << "Internal command returns: " << ret; + WriteLog (lsWARNING, RPCHandler) << "Internal command returns: " << ret; return ret; } h = h->mNextHandler; diff --git a/src/cpp/ripple/RPCServer.cpp b/src/cpp/ripple/RPCServer.cpp index 53044300eb..eb6063fd0d 100644 --- a/src/cpp/ripple/RPCServer.cpp +++ b/src/cpp/ripple/RPCServer.cpp @@ -17,8 +17,6 @@ #include "../json/reader.h" #include "../json/writer.h" -SETUP_LOG(); - #ifndef RPC_MAXIMUM_QUERY #define RPC_MAXIMUM_QUERY (1024*1024) #endif @@ -66,7 +64,7 @@ void RPCServer::handle_read_line(const boost::system::error_code& e) if (action == haDO_REQUEST) { // request with no body - cLog(lsWARNING) << "RPC HTTP request with no body"; + WriteLog (lsWARNING, RPCServer) << "RPC HTTP request with no body"; boost::system::error_code ignore_ec; mSocket.shutdown(boost::asio::ip::tcp::socket::shutdown_both, ignore_ec); return; @@ -82,7 +80,7 @@ void RPCServer::handle_read_line(const boost::system::error_code& e) int rLen = mHTTPRequest.getDataSize(); if ((rLen < 0) || (rLen > RPC_MAXIMUM_QUERY)) { - cLog(lsWARNING) << "Illegal RPC request length " << rLen; + WriteLog (lsWARNING, RPCServer) << "Illegal RPC request length " << rLen; boost::system::error_code ignore_ec; mSocket.shutdown(boost::asio::ip::tcp::socket::shutdown_both, ignore_ec); return; @@ -95,7 +93,7 @@ void RPCServer::handle_read_line(const boost::system::error_code& e) mQueryVec.resize(rLen - alreadyHave); boost::asio::async_read(mSocket, boost::asio::buffer(mQueryVec), boost::bind(&RPCServer::handle_read_req, shared_from_this(), boost::asio::placeholders::error)); - cLog(lsTRACE) << "Waiting for completed request: " << rLen; + WriteLog (lsTRACE, RPCServer) << "Waiting for completed request: " << rLen; } else { // we have the whole thing @@ -112,7 +110,7 @@ void RPCServer::handle_read_line(const boost::system::error_code& e) std::string RPCServer::handleRequest(const std::string& requestStr) { - cLog(lsTRACE) << "handleRequest " << requestStr; + WriteLog (lsTRACE, RPCServer) << "handleRequest " << requestStr; Json::Value id; @@ -163,10 +161,10 @@ std::string RPCServer::handleRequest(const std::string& requestStr) RPCHandler mRPCHandler(mNetOps); - cLog(lsTRACE) << valParams; + WriteLog (lsTRACE, RPCServer) << valParams; int cost = 10; Json::Value result = mRPCHandler.doRpcCommand(strMethod, valParams, mRole, cost); - cLog(lsTRACE) << result; + WriteLog (lsTRACE, RPCServer) << result; std::string strReply = JSONRPCReply(result, Json::Value(), id); return HTTPReply(200, strReply); diff --git a/src/cpp/ripple/RPCSub.cpp b/src/cpp/ripple/RPCSub.cpp index 779cff0ed1..d04b483af6 100644 --- a/src/cpp/ripple/RPCSub.cpp +++ b/src/cpp/ripple/RPCSub.cpp @@ -5,8 +5,6 @@ #include "CallRPC.h" -SETUP_LOG(); - RPCSub::RPCSub(const std::string& strUrl, const std::string& strUsername, const std::string& strPassword) : mUrl(strUrl), mSSL(false), mUsername(strUsername), mPassword(strPassword), mSending(false) { @@ -30,7 +28,7 @@ RPCSub::RPCSub(const std::string& strUrl, const std::string& strUsername, const if (mPort < 0) mPort = mSSL ? 443 : 80; - cLog(lsINFO) << boost::str(boost::format("callRPC sub: ip='%s' port=%d ssl=%d path='%s'") + WriteLog (lsINFO, RPCSub) << boost::str(boost::format("callRPC sub: ip='%s' port=%d ssl=%d path='%s'") % mIp % mPort % mSSL @@ -73,7 +71,7 @@ void RPCSub::sendThread() // XXX Might not need this in a try. try { - cLog(lsINFO) << boost::str(boost::format("callRPC calling: %s") % mIp); + WriteLog (lsINFO, RPCSub) << boost::str(boost::format("callRPC calling: %s") % mIp); callRPC( theApp->getIOService(), @@ -85,7 +83,7 @@ void RPCSub::sendThread() } catch (const std::exception& e) { - cLog(lsINFO) << boost::str(boost::format("callRPC exception: %s") % e.what()); + WriteLog (lsINFO, RPCSub) << boost::str(boost::format("callRPC exception: %s") % e.what()); } } } while (bSend); @@ -98,11 +96,11 @@ void RPCSub::send(const Json::Value& jvObj, bool broadcast) if (RPC_EVENT_QUEUE_MAX == mDeque.size()) { // Drop the previous event. - cLog(lsWARNING) << boost::str(boost::format("callRPC drop")); + WriteLog (lsWARNING, RPCSub) << boost::str(boost::format("callRPC drop")); mDeque.pop_back(); } - cLog(broadcast ? lsDEBUG : lsINFO) << boost::str(boost::format("callRPC push: %s") % jvObj); + WriteLog (broadcast ? lsDEBUG : lsINFO, RPCSub) << boost::str(boost::format("callRPC push: %s") % jvObj); mDeque.push_back(std::make_pair(mSeq++, jvObj)); @@ -111,7 +109,7 @@ void RPCSub::send(const Json::Value& jvObj, bool broadcast) // Start a sending thread. mSending = true; - cLog(lsINFO) << boost::str(boost::format("callRPC start")); + WriteLog (lsINFO, RPCSub) << boost::str(boost::format("callRPC start")); boost::thread(boost::bind(&RPCSub::sendThread, this)).detach(); } } diff --git a/src/cpp/ripple/rpc.cpp b/src/cpp/ripple/rpc.cpp index 1353260d57..309d1bf1bd 100644 --- a/src/cpp/ripple/rpc.cpp +++ b/src/cpp/ripple/rpc.cpp @@ -17,7 +17,10 @@ #include "Log.h" #include "Version.h" -SETUP_LOG(); +// Used for logging +struct RPC +{ +}; using namespace boost; using namespace boost::asio; @@ -77,7 +80,7 @@ std::string rfc1123Time() std::string HTTPReply(int nStatus, const std::string& strMsg) { - cLog(lsTRACE) << "HTTP Reply " << nStatus << " " << strMsg; + WriteLog (lsTRACE, RPC) << "HTTP Reply " << nStatus << " " << strMsg; if (nStatus == 401) return strprintf("HTTP/1.0 401 Authorization Required\r\n"