mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-29 15:35:50 +00:00
Merge ripple_client into ripple_net
This commit is contained in:
@@ -487,7 +487,7 @@ int RippleMain::run (int argc, char const* const* argv)
|
||||
setCallingThreadName ("rpc");
|
||||
std::vector<std::string> vCmd = vm["parameters"].as<std::vector<std::string> > ();
|
||||
|
||||
iResult = commandLineRPC (vCmd);
|
||||
iResult = RPCCall::fromCommandLine (vCmd);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
|
||||
#include "beast/modules/beast_db/beast_db.h"
|
||||
|
||||
#include "../ripple_client/ripple_client.h"
|
||||
#include "../ripple_hyperleveldb/ripple_hyperleveldb.h"
|
||||
#include "../ripple_net/ripple_net.h"
|
||||
#include "../ripple_websocket/ripple_websocket.h"
|
||||
@@ -33,8 +32,6 @@ namespace ripple
|
||||
# include "main/ripple_FatalErrorReporter.h"
|
||||
#include "main/ripple_FatalErrorReporter.cpp"
|
||||
|
||||
# include "rpc/RPCErr.h"
|
||||
# include "rpc/RPCUtil.h"
|
||||
# include "rpc/RPCHandler.h"
|
||||
#include "rpc/RPCHandler.cpp"
|
||||
# include "rpc/RPCServerHandler.h"
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
|
||||
#include "../ripple_core/ripple_core.h"
|
||||
|
||||
#include "../ripple_client/ripple_client.h"
|
||||
#include "../ripple_net/ripple_net.h"
|
||||
|
||||
#include "beast/modules/beast_sqdb/beast_sqdb.h"
|
||||
#include "beast/modules/beast_sqlite/beast_sqlite.h"
|
||||
@@ -126,7 +126,6 @@ namespace ripple
|
||||
#include "main/ripple_Application.h"
|
||||
#include "tx/TransactionQueue.h"
|
||||
#include "ledger/OrderBookDB.h"
|
||||
#include "rpc/CallRPC.h"
|
||||
#include "tx/Transactor.h"
|
||||
#include "tx/ChangeTransactor.h"
|
||||
#include "tx/ripple_TransactionAcquire.h"
|
||||
@@ -144,7 +143,6 @@ namespace ripple
|
||||
#include "paths/ripple_Pathfinder.h"
|
||||
#include "tx/PaymentTransactor.h"
|
||||
#include "peers/PeerDoor.h"
|
||||
#include "rpc/RPCSub.h"
|
||||
#include "tx/RegularKeySetTransactor.h"
|
||||
#include "paths/ripple_RippleState.h"
|
||||
#include "tx/AccountSetTransactor.h"
|
||||
|
||||
@@ -8,9 +8,7 @@
|
||||
|
||||
#include "ripple_app.h"
|
||||
|
||||
#include "../ripple_client/ripple_client.h"
|
||||
#include "../ripple_net/ripple_net.h"
|
||||
#include "../ripple_websocket/ripple_websocket.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning (push)
|
||||
@@ -20,8 +18,7 @@
|
||||
namespace ripple
|
||||
{
|
||||
|
||||
# include "rpc/RPCErr.h"
|
||||
#include "paths/ripple_PathRequest.cpp" // needs RPCErr.h
|
||||
#include "paths/ripple_PathRequest.cpp"
|
||||
#include "paths/ripple_RippleCalc.cpp"
|
||||
#include "paths/ripple_PathState.cpp"
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,74 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (c) 2011-2013, OpenCoin, Inc.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef __CALLRPC__
|
||||
#define __CALLRPC__
|
||||
|
||||
class RPCParser
|
||||
{
|
||||
public:
|
||||
Json::Value parseCommand (std::string strMethod, Json::Value jvParams);
|
||||
|
||||
private:
|
||||
typedef Json::Value (RPCParser::*parseFuncPtr) (const Json::Value& jvParams);
|
||||
|
||||
Json::Value parseAccountRaw (const Json::Value& jvParams, bool bPeer);
|
||||
|
||||
Json::Value parseAccountItems (const Json::Value& jvParams);
|
||||
Json::Value parseAccountLines (const Json::Value& jvParams);
|
||||
Json::Value parseAccountTransactions (const Json::Value& jvParams);
|
||||
Json::Value parseAsIs (const Json::Value& jvParams);
|
||||
Json::Value parseBookOffers (const Json::Value& jvParams);
|
||||
Json::Value parseConnect (const Json::Value& jvParams);
|
||||
#if ENABLE_INSECURE
|
||||
Json::Value parseDataDelete (const Json::Value& jvParams);
|
||||
Json::Value parseDataFetch (const Json::Value& jvParams);
|
||||
Json::Value parseDataStore (const Json::Value& jvParams);
|
||||
#endif
|
||||
Json::Value parseEvented (const Json::Value& jvParams);
|
||||
Json::Value parseFeature (const Json::Value& jvParams);
|
||||
Json::Value parseFetchInfo (const Json::Value& jvParams);
|
||||
Json::Value parseGetCounts (const Json::Value& jvParams);
|
||||
Json::Value parseInternal (const Json::Value& jvParams);
|
||||
Json::Value parseJson (const Json::Value& jvParams);
|
||||
Json::Value parseLedger (const Json::Value& jvParams);
|
||||
Json::Value parseLedgerId (const Json::Value& jvParams);
|
||||
#if ENABLE_INSECURE
|
||||
Json::Value parseLogin (const Json::Value& jvParams);
|
||||
#endif
|
||||
Json::Value parseLogLevel (const Json::Value& jvParams);
|
||||
Json::Value parseOwnerInfo (const Json::Value& jvParams);
|
||||
Json::Value parseProofCreate (const Json::Value& jvParams);
|
||||
Json::Value parseProofSolve (const Json::Value& jvParams);
|
||||
Json::Value parseProofVerify (const Json::Value& jvParams);
|
||||
Json::Value parseRandom (const Json::Value& jvParams);
|
||||
Json::Value parseRipplePathFind (const Json::Value& jvParams);
|
||||
Json::Value parseSMS (const Json::Value& jvParams);
|
||||
Json::Value parseSignSubmit (const Json::Value& jvParams);
|
||||
Json::Value parseTx (const Json::Value& jvParams);
|
||||
Json::Value parseTxHistory (const Json::Value& jvParams);
|
||||
Json::Value parseTxAccount (const Json::Value& jvParams);
|
||||
Json::Value parseUnlAdd (const Json::Value& jvParams);
|
||||
Json::Value parseUnlDelete (const Json::Value& jvParams);
|
||||
Json::Value parseValidationCreate (const Json::Value& jvParams);
|
||||
Json::Value parseValidationSeed (const Json::Value& jvParams);
|
||||
Json::Value parseWalletAccounts (const Json::Value& jvParams);
|
||||
Json::Value parseWalletPropose (const Json::Value& jvParams);
|
||||
Json::Value parseWalletSeed (const Json::Value& jvParams);
|
||||
};
|
||||
|
||||
extern int commandLineRPC (const std::vector<std::string>& vCmd);
|
||||
|
||||
extern void callRPC (
|
||||
boost::asio::io_service& io_service,
|
||||
const std::string& strIp, const int iPort,
|
||||
const std::string& strUsername, const std::string& strPassword,
|
||||
const std::string& strPath, const std::string& strMethod,
|
||||
const Json::Value& jvParams, const bool bSSL,
|
||||
FUNCTION_TYPE<void (const Json::Value& jvInput)> callbackFuncP = FUNCTION_TYPE<void (const Json::Value& jvInput)> ());
|
||||
#endif
|
||||
|
||||
// vim:ts=4
|
||||
@@ -1,23 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (c) 2011-2013, OpenCoin, Inc.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include "BeastConfig.h"
|
||||
|
||||
#include "../ripple_client/ripple_client.h"
|
||||
#include "../ripple_core/ripple_core.h"
|
||||
#include "../ripple_net/ripple_net.h"
|
||||
|
||||
namespace ripple
|
||||
{
|
||||
|
||||
# include "../ripple_app/rpc/RPCErr.h"
|
||||
#include "../ripple_app/rpc/RPCErr.cpp"
|
||||
#include "../ripple_app/rpc/RPCUtil.cpp"
|
||||
#include "../ripple_app/rpc/CallRPC.cpp"
|
||||
#include "../ripple_app/rpc/RPCSub.cpp"
|
||||
#include "../ripple_app/misc/ripple_InfoSub.cpp"
|
||||
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (c) 2011-2013, OpenCoin, Inc.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
/** Client classes.
|
||||
|
||||
This module provides classes that perform client interaction with the server.
|
||||
|
||||
@defgroup ripple_client
|
||||
*/
|
||||
|
||||
#ifndef RIPPLE_CLIENT_H
|
||||
#define RIPPLE_CLIENT_H
|
||||
|
||||
#include "beast/modules/beast_core/beast_core.h" // Must come before <boost/bind.hpp>
|
||||
|
||||
#include <boost/unordered_set.hpp> // InfoSub
|
||||
|
||||
#include "../ripple_core/ripple_core.h"
|
||||
#include "../ripple_data/ripple_data.h"
|
||||
|
||||
namespace ripple
|
||||
{
|
||||
|
||||
#include "../ripple_app/rpc/RPCUtil.h" // only for RPCServerHandler
|
||||
#include "../ripple_app/rpc/CallRPC.h"
|
||||
#include "../ripple_app/misc/ripple_InfoSub.h"
|
||||
#include "../ripple_app/rpc/RPCSub.h"
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -26,18 +26,12 @@
|
||||
#include <boost/mpl/at.hpp>
|
||||
#include <boost/mpl/vector.hpp>
|
||||
|
||||
#include "beast/modules/beast_asio/beast_asio.h"
|
||||
|
||||
#include "ripple_net.h"
|
||||
|
||||
// VFALCO TODO Remove this dependency on theConfig
|
||||
#include "../modules/ripple_core/ripple_core.h" // theConfig for HttpsClient
|
||||
|
||||
namespace ripple
|
||||
{
|
||||
|
||||
#include "basics/impl/MultiSocketType.h"
|
||||
|
||||
#include "basics/RippleSSLContext.cpp"
|
||||
#include "basics/MultiSocket.cpp"
|
||||
#include "basics/HTTPRequest.cpp"
|
||||
@@ -46,4 +40,10 @@ namespace ripple
|
||||
#include "basics/RPCServer.cpp"
|
||||
#include "basics/SNTPClient.cpp"
|
||||
|
||||
#include "rpc/RPCCall.cpp"
|
||||
#include "rpc/RPCErr.cpp"
|
||||
#include "rpc/RPCSub.cpp"
|
||||
#include "rpc/RPCUtil.cpp"
|
||||
#include "rpc/InfoSub.cpp"
|
||||
|
||||
}
|
||||
|
||||
@@ -7,10 +7,17 @@
|
||||
#ifndef RIPPLE_NET_H_INCLUDED
|
||||
#define RIPPLE_NET_H_INCLUDED
|
||||
|
||||
#include "beast/modules/beast_core/beast_core.h" // Must come before <boost/bind.hpp>
|
||||
|
||||
#include <boost/unordered_set.hpp> // For InfoSub
|
||||
|
||||
#include "beast/modules/beast_asio/beast_asio.h"
|
||||
|
||||
#include "../ripple_basics/ripple_basics.h"
|
||||
#include "../ripple_core/ripple_core.h"
|
||||
#include "../ripple_data/ripple_data.h"
|
||||
|
||||
// VFALCO TODO MOVE TO .cpp ASAP!, make users abstract!
|
||||
#include "../ripple_websocket/ripple_websocket.h"
|
||||
|
||||
namespace ripple
|
||||
@@ -24,6 +31,12 @@ namespace ripple
|
||||
#include "basics/RPCDoor.h"
|
||||
#include "basics/SNTPClient.h"
|
||||
|
||||
# include "rpc/RPCErr.h"
|
||||
# include "rpc/RPCUtil.h"
|
||||
#include "rpc/RPCCall.h"
|
||||
# include "rpc/InfoSub.h"
|
||||
#include "rpc/RPCSub.h"
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
// VFALCO TODO Figure out how to clean up these globals
|
||||
|
||||
InfoSub::InfoSub (Source& source)
|
||||
: m_source (source)
|
||||
, mLock (this, "InfoSub", __FILE__, __LINE__)
|
||||
: mLock (this, "InfoSub", __FILE__, __LINE__)
|
||||
, m_source (source)
|
||||
{
|
||||
static Atomic <int> s_seq_id;
|
||||
mSeq = ++s_seq_id;
|
||||
@@ -4,8 +4,8 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_INFOSUB_H
|
||||
#define RIPPLE_INFOSUB_H
|
||||
#ifndef RIPPLE_NET_RPC_INFOSUB_H_INCLUDED
|
||||
#define RIPPLE_NET_RPC_INFOSUB_H_INCLUDED
|
||||
|
||||
// Operations that clients may wish to perform against the network
|
||||
// Master operational handler, server sequencer, network tracker
|
||||
1147
modules/ripple_net/rpc/RPCCall.cpp
Normal file
1147
modules/ripple_net/rpc/RPCCall.cpp
Normal file
File diff suppressed because it is too large
Load Diff
34
modules/ripple_net/rpc/RPCCall.h
Normal file
34
modules/ripple_net/rpc/RPCCall.h
Normal file
@@ -0,0 +1,34 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (c) 2011-2013, OpenCoin, Inc.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_NET_RPC_RPCCALL_H_INCLUDED
|
||||
#define RIPPLE_NET_RPC_RPCCALL_H_INCLUDED
|
||||
|
||||
//
|
||||
// This a trusted interface, the user is expected to provide valid input to perform valid requests.
|
||||
// Error catching and reporting is not a requirement of this command line interface.
|
||||
//
|
||||
// Improvements to be more strict and to provide better diagnostics are welcome.
|
||||
//
|
||||
|
||||
/** Processes Ripple RPC calls.
|
||||
*/
|
||||
class RPCCall
|
||||
{
|
||||
public:
|
||||
|
||||
static int fromCommandLine (const std::vector<std::string>& vCmd);
|
||||
|
||||
static void fromNetwork (
|
||||
boost::asio::io_service& io_service,
|
||||
const std::string& strIp, const int iPort,
|
||||
const std::string& strUsername, const std::string& strPassword,
|
||||
const std::string& strPath, const std::string& strMethod,
|
||||
const Json::Value& jvParams, const bool bSSL,
|
||||
FUNCTION_TYPE<void (const Json::Value& jvInput)> callbackFuncP = FUNCTION_TYPE<void (const Json::Value& jvInput)> ());
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -4,8 +4,8 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef __RPCERR__
|
||||
#define __RPCERR__
|
||||
#ifndef RIPPLE_NET_RPC_RPCERR_H_INCLUDED
|
||||
#define RIPPLE_NET_RPC_RPCERR_H_INCLUDED
|
||||
|
||||
enum
|
||||
{
|
||||
@@ -38,11 +38,11 @@ RPCSub::RPCSub (InfoSub::Source& source, boost::asio::io_service& io_service,
|
||||
if (mPort < 0)
|
||||
mPort = mSSL ? 443 : 80;
|
||||
|
||||
WriteLog (lsINFO, RPCSub) << boost::str (boost::format ("callRPC sub: ip='%s' port=%d ssl=%d path='%s'")
|
||||
% mIp
|
||||
% mPort
|
||||
% mSSL
|
||||
% mPath);
|
||||
WriteLog (lsINFO, RPCSub) <<
|
||||
"RPCCall::fromNetwork sub: ip=" << mIp <<
|
||||
" port=" << mPort <<
|
||||
" ssl= "<< (mSSL ? "yes" : "no") <<
|
||||
" path='" << mPath << "'";
|
||||
}
|
||||
|
||||
// XXX Could probably create a bunch of send jobs in a single get of the lock.
|
||||
@@ -81,9 +81,9 @@ void RPCSub::sendThread ()
|
||||
// XXX Might not need this in a try.
|
||||
try
|
||||
{
|
||||
WriteLog (lsINFO, RPCSub) << boost::str (boost::format ("callRPC calling: %s") % mIp);
|
||||
WriteLog (lsINFO, RPCSub) << "RPCCall::fromNetwork: " << mIp;
|
||||
|
||||
callRPC (
|
||||
RPCCall::fromNetwork (
|
||||
m_io_service,
|
||||
mIp, mPort,
|
||||
mUsername, mPassword,
|
||||
@@ -93,7 +93,7 @@ void RPCSub::sendThread ()
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
WriteLog (lsINFO, RPCSub) << boost::str (boost::format ("callRPC exception: %s") % e.what ());
|
||||
WriteLog (lsINFO, RPCSub) << "RPCCall::fromNetwork exception: " << e.what ();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -104,14 +104,15 @@ void RPCSub::send (const Json::Value& jvObj, bool broadcast)
|
||||
{
|
||||
ScopedLockType sl (mLock, __FILE__, __LINE__);
|
||||
|
||||
if (RPC_EVENT_QUEUE_MAX == mDeque.size ())
|
||||
if (mDeque.size () >= eventQueueMax)
|
||||
{
|
||||
// Drop the previous event.
|
||||
WriteLog (lsWARNING, RPCSub) << boost::str (boost::format ("callRPC drop"));
|
||||
WriteLog (lsWARNING, RPCSub) << "RPCCall::fromNetwork drop";
|
||||
mDeque.pop_back ();
|
||||
}
|
||||
|
||||
WriteLog (broadcast ? lsDEBUG : lsINFO, RPCSub) << boost::str (boost::format ("callRPC push: %s") % jvObj);
|
||||
WriteLog (broadcast ? lsDEBUG : lsINFO, RPCSub) <<
|
||||
"RPCCall::fromNetwork push: " << jvObj;
|
||||
|
||||
mDeque.push_back (std::make_pair (mSeq++, jvObj));
|
||||
|
||||
@@ -120,8 +121,8 @@ void RPCSub::send (const Json::Value& jvObj, bool broadcast)
|
||||
// Start a sending thread.
|
||||
mSending = true;
|
||||
|
||||
WriteLog (lsINFO, RPCSub) << boost::str (boost::format ("callRPC start"));
|
||||
|
||||
WriteLog (lsINFO, RPCSub) << "RPCCall::fromNetwork start";
|
||||
|
||||
m_jobQueue.addJob (
|
||||
jtCLIENT, "RPCSub::sendThread", BIND_TYPE (&RPCSub::sendThread, this));
|
||||
}
|
||||
@@ -4,11 +4,8 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_RPCSUB_H_INCLUDED
|
||||
#define RIPPLE_RPCSUB_H_INCLUDED
|
||||
|
||||
// VFALCO TODO replace this macro with a language constant
|
||||
#define RPC_EVENT_QUEUE_MAX 32
|
||||
#ifndef RIPPLE_NET_RPC_RPCSUB_H_INCLUDED
|
||||
#define RIPPLE_NET_RPC_RPCSUB_H_INCLUDED
|
||||
|
||||
// Subscription object for JSON-RPC
|
||||
// VFALCO TODO Move the implementation into the .cpp
|
||||
@@ -48,6 +45,12 @@ protected:
|
||||
void sendThread ();
|
||||
|
||||
private:
|
||||
// VFALCO TODO replace this macro with a language constant
|
||||
enum
|
||||
{
|
||||
eventQueueMax = 32
|
||||
};
|
||||
|
||||
boost::asio::io_service& m_io_service;
|
||||
JobQueue& m_jobQueue;
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_RPC_RPCUTIL_H_INCLUDED
|
||||
#define RIPPLE_RPC_RPCUTIL_H_INCLUDEDRIPPLE_RPC_H_INCLUDED
|
||||
#ifndef RIPPLE_NET_RPC_RPCUTIL_H_INCLUDED
|
||||
#define RIPPLE_NET_RPC_RPCUTIL_H_INCLUDED
|
||||
|
||||
// VFALCO TODO Wrap these up into a class. It looks like they just do some
|
||||
// convenience packaging of JSON data from the pieces. It looks
|
||||
Reference in New Issue
Block a user