1#include <xrpld/rpc/RPCSub.h>
3#include <xrpld/rpc/RPCCall.h>
5#include <xrpl/basics/Log.h>
6#include <xrpl/basics/StringUtilities.h>
7#include <xrpl/basics/contract.h>
8#include <xrpl/core/Job.h>
9#include <xrpl/core/JobQueue.h>
10#include <xrpl/core/ServiceRegistry.h>
11#include <xrpl/json/json_value.h>
12#include <xrpl/json/to_string.h>
13#include <xrpl/server/InfoSub.h>
15#include <boost/asio/io_context.hpp>
35 boost::asio::io_context& ioContext,
47 ,
j_(registry.getJournal(
"RPCSub"))
48 ,
logs_(registry.getLogs())
56 else if (pUrl.
scheme ==
"https")
60 else if (pUrl.
scheme !=
"http")
62 Throw<std::runtime_error>(
"Only http and https is supported.");
70 port_ = ssl_ ? 443 : 80;
78 JLOG(
j_.info()) <<
"RPCCall::fromNetwork sub: ip=" <<
ip_ <<
" port=" <<
port_
79 <<
" ssl= " << (
ssl_ ?
"yes" :
"no") <<
" path='" <<
path_ <<
"'";
89 auto jm = broadcast ?
j_.debug() :
j_.info();
90 JLOG(jm) <<
"RPCCall::fromNetwork push: " << jvObj;
97 JLOG(
j_.info()) <<
"RPCCall::fromNetwork start";
142 auto const [seq, env] =
deque_.front();
147 jvEvent[
"seq"] = seq;
159 JLOG(
j_.info()) <<
"RPCCall::fromNetwork: " <<
ip_;
176 JLOG(
j_.info()) <<
"RPCCall::fromNetwork exception: " << e.
what();
213 boost::asio::io_context& ioContext,
A generic endpoint for log messages.
Abstracts the source of subscription data.
Resource::Consumer Consumer
A pool of threads to perform work.
Manages partitions for logging.
void send(json::Value const &jvObj, bool broadcast) override
~RPCSubImp() override=default
RPCSubImp(InfoSub::Source &source, boost::asio::io_context &ioContext, JobQueue &jobQueue, std::string const &strUrl, std::string strUsername, std::string strPassword, ServiceRegistry ®istry)
void setUsername(std::string const &strUsername) override
void setPassword(std::string const &strPassword) override
boost::asio::io_context & ioContext_
std::deque< std::pair< int, json::Value > > deque_
RPCSub(InfoSub::Source &source)
Service registry for dependency injection.
void fromNetwork(boost::asio::io_context &ioContext, std::string const &strIp, std::uint16_t const iPort, std::string const &strUsername, std::string const &strPassword, std::string const &strPath, std::string const &strMethod, json::Value const &jvParams, bool const bSSL, bool const quiet, Logs &logs, std::function< void(json::Value const &jvInput)> callbackFuncP, std::unordered_map< std::string, std::string > headers)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::shared_ptr< RPCSub > makeRPCSub(InfoSub::Source &source, boost::asio::io_context &ioContext, JobQueue &jobQueue, std::string const &strUrl, std::string const &strUsername, std::string const &strPassword, ServiceRegistry ®istry)
XRPL_NO_SANITIZE_ADDRESS void Throw(Args &&... args)
bool parseUrl(ParsedUrl &pUrl, std::string const &strUrl)
std::optional< std::uint16_t > port