mirror of
https://github.com/XRPLF/clio.git
synced 2025-11-20 11:45:53 +00:00
folder reorg
This commit is contained in:
@@ -36,7 +36,7 @@ add_executable (reporting_main
|
||||
add_executable (reporting_tests
|
||||
unittests/main.cpp
|
||||
)
|
||||
add_library(reporting reporting/BackendInterface.h)
|
||||
add_library(reporting backend/BackendInterface.h)
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/deps")
|
||||
include(ExternalProject)
|
||||
message(${CMAKE_CURRENT_BINARY_DIR})
|
||||
@@ -67,17 +67,16 @@ include(Postgres)
|
||||
|
||||
|
||||
target_sources(reporting PRIVATE
|
||||
reporting/ETLSource.cpp
|
||||
reporting/CassandraBackend.cpp
|
||||
reporting/PostgresBackend.cpp
|
||||
reporting/BackendIndexer.cpp
|
||||
reporting/BackendInterface.cpp
|
||||
reporting/Pg.cpp
|
||||
reporting/P2pProxy.cpp
|
||||
reporting/DBHelpers.cpp
|
||||
reporting/ReportingETL.cpp
|
||||
reporting/server/session.cpp
|
||||
reporting/server/SubscriptionManager.cpp
|
||||
backend/CassandraBackend.cpp
|
||||
backend/PostgresBackend.cpp
|
||||
backend/BackendIndexer.cpp
|
||||
backend/BackendInterface.cpp
|
||||
backend/Pg.cpp
|
||||
backend/DBHelpers.cpp
|
||||
etl/ETLSource.cpp
|
||||
etl/ReportingETL.cpp
|
||||
server/session.cpp
|
||||
server/SubscriptionManager.cpp
|
||||
handlers/AccountInfo.cpp
|
||||
handlers/Tx.cpp
|
||||
handlers/RPCHelpers.cpp
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
#define RIPPLE_APP_REPORTING_BACKENDFACTORY_H_INCLUDED
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <reporting/BackendInterface.h>
|
||||
#include <reporting/CassandraBackend.h>
|
||||
#include <reporting/PostgresBackend.h>
|
||||
#include <backend/BackendInterface.h>
|
||||
#include <backend/CassandraBackend.h>
|
||||
#include <backend/PostgresBackend.h>
|
||||
|
||||
namespace Backend {
|
||||
std::unique_ptr<BackendInterface>
|
||||
@@ -1,4 +1,4 @@
|
||||
#include <reporting/BackendInterface.h>
|
||||
#include <backend/BackendInterface.h>
|
||||
|
||||
namespace Backend {
|
||||
BackendIndexer::BackendIndexer(boost::json::object const& config)
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <ripple/protocol/Indexes.h>
|
||||
#include <ripple/protocol/STLedgerEntry.h>
|
||||
#include <reporting/BackendInterface.h>
|
||||
#include <backend/BackendInterface.h>
|
||||
namespace Backend {
|
||||
bool
|
||||
BackendInterface::finishWrites(uint32_t ledgerSequence) const
|
||||
@@ -2,7 +2,7 @@
|
||||
#define RIPPLE_APP_REPORTING_BACKENDINTERFACE_H_INCLUDED
|
||||
#include <ripple/ledger/ReadView.h>
|
||||
#include <boost/asio.hpp>
|
||||
#include <reporting/DBHelpers.h>
|
||||
#include <backend/DBHelpers.h>
|
||||
namespace std {
|
||||
template <>
|
||||
struct hash<ripple::uint256>
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <functional>
|
||||
#include <reporting/CassandraBackend.h>
|
||||
#include <reporting/DBHelpers.h>
|
||||
#include <backend/CassandraBackend.h>
|
||||
#include <backend/DBHelpers.h>
|
||||
#include <unordered_map>
|
||||
/*
|
||||
namespace std {
|
||||
@@ -31,8 +31,8 @@
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <reporting/BackendInterface.h>
|
||||
#include <reporting/DBHelpers.h>
|
||||
#include <backend/BackendInterface.h>
|
||||
#include <backend/DBHelpers.h>
|
||||
|
||||
namespace Backend {
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include <boost/format.hpp>
|
||||
#include <memory>
|
||||
#include <reporting/DBHelpers.h>
|
||||
#include <backend/DBHelpers.h>
|
||||
|
||||
static bool
|
||||
writeToLedgersDB(ripple::LedgerInfo const& info, PgQuery& pgQuery)
|
||||
@@ -23,7 +23,7 @@
|
||||
#include <ripple/basics/Log.h>
|
||||
#include <ripple/protocol/TxMeta.h>
|
||||
#include <boost/container/flat_set.hpp>
|
||||
#include <reporting/Pg.h>
|
||||
#include <backend/Pg.h>
|
||||
|
||||
/// Struct used to keep track of what to write to transactions and
|
||||
/// account_transactions tables in Postgres
|
||||
@@ -39,7 +39,7 @@
|
||||
#include <exception>
|
||||
#include <functional>
|
||||
#include <iterator>
|
||||
#include <reporting/Pg.h>
|
||||
#include <backend/Pg.h>
|
||||
#include <signal.h>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <boost/asio.hpp>
|
||||
#include <boost/format.hpp>
|
||||
#include <reporting/PostgresBackend.h>
|
||||
#include <backend/PostgresBackend.h>
|
||||
namespace Backend {
|
||||
|
||||
PostgresBackend::PostgresBackend(boost::json::object const& config)
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef RIPPLE_APP_REPORTING_POSTGRESBACKEND_H_INCLUDED
|
||||
#define RIPPLE_APP_REPORTING_POSTGRESBACKEND_H_INCLUDED
|
||||
#include <boost/json.hpp>
|
||||
#include <reporting/BackendInterface.h>
|
||||
#include <backend/BackendInterface.h>
|
||||
|
||||
namespace Backend {
|
||||
class PostgresBackend : public BackendInterface
|
||||
@@ -19,15 +19,15 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/beast/net/IPEndpoint.h>
|
||||
#include <ripple/protocol/STLedgerEntry.h>
|
||||
#include <boost/asio/strand.hpp>
|
||||
#include <boost/beast/http.hpp>
|
||||
#include <boost/json.hpp>
|
||||
#include <boost/json/src.hpp>
|
||||
#include <boost/log/trivial.hpp>
|
||||
#include <ripple/beast/net/IPEndpoint.h>
|
||||
#include <reporting/ETLSource.h>
|
||||
#include <reporting/ReportingETL.h>
|
||||
#include <etl/ETLSource.h>
|
||||
#include <etl/ReportingETL.h>
|
||||
|
||||
// Create ETL source without grpc endpoint
|
||||
// Fetch ledger and load initial ledger will fail for this source
|
||||
@@ -578,13 +578,7 @@ ETLLoadBalancer::ETLLoadBalancer(
|
||||
for (auto& entry : config)
|
||||
{
|
||||
std::unique_ptr<ETLSource> source = ETLSource::make_ETLSource(
|
||||
entry.as_object(),
|
||||
ioContext,
|
||||
backend,
|
||||
subscriptions,
|
||||
nwvl,
|
||||
*this
|
||||
);
|
||||
entry.as_object(), ioContext, backend, subscriptions, nwvl, *this);
|
||||
|
||||
sources_.push_back(std::move(source));
|
||||
BOOST_LOG_TRIVIAL(info) << __func__ << " : added etl source - "
|
||||
@@ -644,7 +638,7 @@ ETLLoadBalancer::fetchLedger(uint32_t ledgerSequence, bool getObjects)
|
||||
}
|
||||
|
||||
std::unique_ptr<org::xrpl::rpc::v1::XRPLedgerAPIService::Stub>
|
||||
ETLLoadBalancer::getP2pForwardingStub() const
|
||||
ETLLoadBalancer::getRippledForwardingStub() const
|
||||
{
|
||||
if (sources_.size() == 0)
|
||||
return nullptr;
|
||||
@@ -653,7 +647,7 @@ ETLLoadBalancer::getP2pForwardingStub() const
|
||||
auto numAttempts = 0;
|
||||
while (numAttempts < sources_.size())
|
||||
{
|
||||
auto stub = sources_[sourceIdx]->getP2pForwardingStub();
|
||||
auto stub = sources_[sourceIdx]->getRippledForwardingStub();
|
||||
if (!stub)
|
||||
{
|
||||
sourceIdx = (sourceIdx + 1) % sources_.size();
|
||||
@@ -666,7 +660,7 @@ ETLLoadBalancer::getP2pForwardingStub() const
|
||||
}
|
||||
|
||||
boost::json::object
|
||||
ETLLoadBalancer::forwardToP2p(boost::json::object const& request) const
|
||||
ETLLoadBalancer::forwardToRippled(boost::json::object const& request) const
|
||||
{
|
||||
boost::json::object res;
|
||||
if (sources_.size() == 0)
|
||||
@@ -676,7 +670,7 @@ ETLLoadBalancer::forwardToP2p(boost::json::object const& request) const
|
||||
auto numAttempts = 0;
|
||||
while (numAttempts < sources_.size())
|
||||
{
|
||||
res = sources_[sourceIdx]->forwardToP2p(request);
|
||||
res = sources_[sourceIdx]->forwardToRippled(request);
|
||||
|
||||
if (!res.contains("forwarded") || res.at("forwarded") != true)
|
||||
{
|
||||
@@ -691,7 +685,7 @@ ETLLoadBalancer::forwardToP2p(boost::json::object const& request) const
|
||||
}
|
||||
|
||||
std::unique_ptr<org::xrpl::rpc::v1::XRPLedgerAPIService::Stub>
|
||||
ETLSource::getP2pForwardingStub() const
|
||||
ETLSource::getRippledForwardingStub() const
|
||||
{
|
||||
if (!connected_)
|
||||
return nullptr;
|
||||
@@ -712,7 +706,7 @@ ETLSource::getP2pForwardingStub() const
|
||||
}
|
||||
|
||||
boost::json::object
|
||||
ETLSource::forwardToP2p(boost::json::object const& request) const
|
||||
ETLSource::forwardToRippled(boost::json::object const& request) const
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(debug) << "Attempting to forward request to tx. "
|
||||
<< "request = " << boost::json::serialize(request);
|
||||
@@ -778,8 +772,7 @@ ETLSource::forwardToP2p(boost::json::object const& request) const
|
||||
|
||||
auto begin = static_cast<char const*>(buffer.data().data());
|
||||
auto end = begin + buffer.data().size();
|
||||
auto parsed =
|
||||
boost::json::parse(std::string(begin, end));
|
||||
auto parsed = boost::json::parse(std::string(begin, end));
|
||||
|
||||
if (!parsed.is_object())
|
||||
{
|
||||
@@ -25,23 +25,23 @@
|
||||
#include <boost/beast/core.hpp>
|
||||
#include <boost/beast/core/string.hpp>
|
||||
#include <boost/beast/websocket.hpp>
|
||||
#include <reporting/BackendInterface.h>
|
||||
#include <reporting/server/SubscriptionManager.h>
|
||||
#include <backend/BackendInterface.h>
|
||||
#include <server/SubscriptionManager.h>
|
||||
|
||||
#include "org/xrpl/rpc/v1/xrp_ledger.grpc.pb.h"
|
||||
#include <grpcpp/grpcpp.h>
|
||||
#include <reporting/ETLHelpers.h>
|
||||
#include <etl/ETLHelpers.h>
|
||||
|
||||
class ETLLoadBalancer;
|
||||
class SubscriptionManager;
|
||||
|
||||
/// This class manages a connection to a single ETL source. This is almost
|
||||
/// always a p2p node, but really could be another reporting node. This class
|
||||
/// subscribes to the ledgers and transactions_proposed streams of the
|
||||
/// associated p2p node, and keeps track of which ledgers the p2p node has. This
|
||||
/// class also has methods for extracting said ledgers. Lastly this class
|
||||
/// forwards transactions received on the transactions_proposed streams to any
|
||||
/// subscribers.
|
||||
/// always a rippled node, but really could be another reporting node. This
|
||||
/// class subscribes to the ledgers and transactions_proposed streams of the
|
||||
/// associated rippled node, and keeps track of which ledgers the rippled node
|
||||
/// has. This class also has methods for extracting said ledgers. Lastly this
|
||||
/// class forwards transactions received on the transactions_proposed streams to
|
||||
/// any subscribers.
|
||||
|
||||
class ETLSource
|
||||
{
|
||||
@@ -316,13 +316,13 @@ public:
|
||||
void
|
||||
close(bool startAgain);
|
||||
|
||||
/// Get grpc stub to forward requests to p2p node
|
||||
/// Get grpc stub to forward requests to rippled node
|
||||
/// @return stub to send requests to ETL source
|
||||
std::unique_ptr<org::xrpl::rpc::v1::XRPLedgerAPIService::Stub>
|
||||
getP2pForwardingStub() const;
|
||||
getRippledForwardingStub() const;
|
||||
|
||||
boost::json::object
|
||||
forwardToP2p(boost::json::object const& request) const;
|
||||
forwardToRippled(boost::json::object const& request) const;
|
||||
};
|
||||
/// This class is used to manage connections to transaction processing processes
|
||||
/// This class spawns a listener for each etl source, which listens to messages
|
||||
@@ -420,16 +420,16 @@ public:
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// Randomly select a p2p node to forward a gRPC request to
|
||||
/// @return gRPC stub to forward requests to p2p node
|
||||
/// Randomly select a rippled node to forward a gRPC request to
|
||||
/// @return gRPC stub to forward requests to rippled node
|
||||
std::unique_ptr<org::xrpl::rpc::v1::XRPLedgerAPIService::Stub>
|
||||
getP2pForwardingStub() const;
|
||||
getRippledForwardingStub() const;
|
||||
|
||||
/// Forward a JSON RPC request to a randomly selected p2p node
|
||||
/// Forward a JSON RPC request to a randomly selected rippled node
|
||||
/// @param request JSON-RPC request
|
||||
/// @return response received from p2p node
|
||||
/// @return response received from rippled node
|
||||
boost::json::object
|
||||
forwardToP2p(boost::json::object const& request) const;
|
||||
forwardToRippled(boost::json::object const& request) const;
|
||||
|
||||
private:
|
||||
/// f is a function that takes an ETLSource as an argument and returns a
|
||||
@@ -18,8 +18,8 @@
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/basics/StringUtilities.h>
|
||||
#include <reporting/DBHelpers.h>
|
||||
#include <reporting/ReportingETL.h>
|
||||
#include <backend/DBHelpers.h>
|
||||
#include <etl/ReportingETL.h>
|
||||
|
||||
#include <ripple/beast/core/CurrentThreadName.h>
|
||||
#include <boost/asio/connect.hpp>
|
||||
@@ -25,10 +25,9 @@
|
||||
#include <boost/beast/core.hpp>
|
||||
#include <boost/beast/core/string.hpp>
|
||||
#include <boost/beast/websocket.hpp>
|
||||
#include <reporting/BackendInterface.h>
|
||||
#include <reporting/ETLSource.h>
|
||||
#include <reporting/Pg.h>
|
||||
#include <reporting/server/SubscriptionManager.h>
|
||||
#include <backend/BackendInterface.h>
|
||||
#include <etl/ETLSource.h>
|
||||
#include <server/SubscriptionManager.h>
|
||||
|
||||
#include "org/xrpl/rpc/v1/xrp_ledger.grpc.pb.h"
|
||||
#include <grpcpp/grpcpp.h>
|
||||
@@ -6,10 +6,8 @@
|
||||
#include <ripple/protocol/jss.h>
|
||||
#include <boost/json.hpp>
|
||||
#include <algorithm>
|
||||
#include <backend/BackendInterface.h>
|
||||
#include <handlers/RPCHelpers.h>
|
||||
#include <reporting/BackendInterface.h>
|
||||
#include <reporting/DBHelpers.h>
|
||||
#include <reporting/Pg.h>
|
||||
|
||||
void
|
||||
addChannel(boost::json::array& jsonLines, ripple::SLE const& line)
|
||||
@@ -17,7 +15,8 @@ addChannel(boost::json::array& jsonLines, ripple::SLE const& line)
|
||||
boost::json::object jDst;
|
||||
jDst["channel_id"] = ripple::to_string(line.key());
|
||||
jDst["account"] = ripple::to_string(line.getAccountID(ripple::sfAccount));
|
||||
jDst["destination_account"] = ripple::to_string(line.getAccountID(ripple::sfDestination));
|
||||
jDst["destination_account"] =
|
||||
ripple::to_string(line.getAccountID(ripple::sfDestination));
|
||||
jDst["amount"] = line[ripple::sfAmount].getText();
|
||||
jDst["balance"] = line[ripple::sfBalance].getText();
|
||||
if (publicKeyType(line[ripple::sfPublicKey]))
|
||||
@@ -151,13 +150,8 @@ doAccountChannels(
|
||||
return true;
|
||||
};
|
||||
|
||||
auto nextCursor =
|
||||
traverseOwnedNodes(
|
||||
backend,
|
||||
accountID,
|
||||
*ledgerSequence,
|
||||
cursor,
|
||||
addToResponse);
|
||||
auto nextCursor = traverseOwnedNodes(
|
||||
backend, accountID, *ledgerSequence, cursor, addToResponse);
|
||||
|
||||
if (nextCursor)
|
||||
response["next_cursor"] = ripple::strHex(*nextCursor);
|
||||
|
||||
@@ -6,10 +6,8 @@
|
||||
#include <ripple/protocol/jss.h>
|
||||
#include <boost/json.hpp>
|
||||
#include <algorithm>
|
||||
#include <backend/BackendInterface.h>
|
||||
#include <handlers/RPCHelpers.h>
|
||||
#include <reporting/BackendInterface.h>
|
||||
#include <reporting/DBHelpers.h>
|
||||
#include <reporting/Pg.h>
|
||||
|
||||
boost::json::object
|
||||
doAccountCurrencies(
|
||||
@@ -49,7 +47,6 @@ doAccountCurrencies(
|
||||
|
||||
accountID = *parsed;
|
||||
|
||||
|
||||
std::set<std::string> send, receive;
|
||||
auto const addToResponse = [&](ripple::SLE const& sle) {
|
||||
if (sle.getType() == ripple::ltRIPPLE_STATE)
|
||||
@@ -73,11 +70,7 @@ doAccountCurrencies(
|
||||
};
|
||||
|
||||
traverseOwnedNodes(
|
||||
backend,
|
||||
accountID,
|
||||
*ledgerSequence,
|
||||
beast::zero,
|
||||
addToResponse);
|
||||
backend, accountID, *ledgerSequence, beast::zero, addToResponse);
|
||||
|
||||
response["send_currencies"] = boost::json::value(boost::json::array_kind);
|
||||
boost::json::array& jsonSend = response.at("send_currencies").as_array();
|
||||
@@ -85,8 +78,10 @@ doAccountCurrencies(
|
||||
for (auto const& currency : send)
|
||||
jsonSend.push_back(currency.c_str());
|
||||
|
||||
response["receive_currencies"] = boost::json::value(boost::json::array_kind);
|
||||
boost::json::array& jsonReceive = response.at("receive_currencies").as_array();
|
||||
response["receive_currencies"] =
|
||||
boost::json::value(boost::json::array_kind);
|
||||
boost::json::array& jsonReceive =
|
||||
response.at("receive_currencies").as_array();
|
||||
|
||||
for (auto const& currency : receive)
|
||||
jsonReceive.push_back(currency.c_str());
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include <ripple/protocol/STLedgerEntry.h>
|
||||
#include <boost/json.hpp>
|
||||
#include <handlers/RPCHelpers.h>
|
||||
#include <reporting/BackendInterface.h>
|
||||
#include <backend/BackendInterface.h>
|
||||
|
||||
// {
|
||||
// account: <ident>,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <ripple/app/paths/RippleState.h>
|
||||
#include <ripple/app/ledger/Ledger.h>
|
||||
#include <ripple/app/paths/RippleState.h>
|
||||
#include <ripple/basics/StringUtilities.h>
|
||||
#include <ripple/protocol/ErrorCodes.h>
|
||||
#include <ripple/protocol/Indexes.h>
|
||||
@@ -7,9 +7,8 @@
|
||||
#include <ripple/protocol/jss.h>
|
||||
#include <boost/json.hpp>
|
||||
#include <algorithm>
|
||||
#include <backend/BackendInterface.h>
|
||||
#include <handlers/RPCHelpers.h>
|
||||
#include <reporting/BackendInterface.h>
|
||||
#include <reporting/DBHelpers.h>
|
||||
|
||||
void
|
||||
addLine(
|
||||
@@ -39,13 +38,19 @@ addLine(
|
||||
if (peerAccount and peerAccount != lineAccountIDPeer)
|
||||
return;
|
||||
|
||||
bool lineAuth = flags & (viewLowest ? ripple::lsfLowAuth : ripple::lsfHighAuth);
|
||||
bool lineAuthPeer = flags & (!viewLowest ? ripple::lsfLowAuth : ripple::lsfHighAuth);
|
||||
bool lineNoRipple = flags & (viewLowest ? ripple::lsfLowNoRipple : ripple::lsfHighNoRipple);
|
||||
bool lineAuth =
|
||||
flags & (viewLowest ? ripple::lsfLowAuth : ripple::lsfHighAuth);
|
||||
bool lineAuthPeer =
|
||||
flags & (!viewLowest ? ripple::lsfLowAuth : ripple::lsfHighAuth);
|
||||
bool lineNoRipple =
|
||||
flags & (viewLowest ? ripple::lsfLowNoRipple : ripple::lsfHighNoRipple);
|
||||
bool lineDefaultRipple = flags & ripple::lsfDefaultRipple;
|
||||
bool lineNoRipplePeer = flags & (!viewLowest ? ripple::lsfLowNoRipple : ripple::lsfHighNoRipple);
|
||||
bool lineFreeze = flags & (viewLowest ? ripple::lsfLowFreeze : ripple::lsfHighFreeze);
|
||||
bool lineFreezePeer = flags & (!viewLowest ? ripple::lsfLowFreeze : ripple::lsfHighFreeze);
|
||||
bool lineNoRipplePeer = flags &
|
||||
(!viewLowest ? ripple::lsfLowNoRipple : ripple::lsfHighNoRipple);
|
||||
bool lineFreeze =
|
||||
flags & (viewLowest ? ripple::lsfLowFreeze : ripple::lsfHighFreeze);
|
||||
bool lineFreezePeer =
|
||||
flags & (!viewLowest ? ripple::lsfLowFreeze : ripple::lsfHighFreeze);
|
||||
|
||||
ripple::STAmount const& saBalance(balance);
|
||||
ripple::STAmount const& saLimit(lineLimit);
|
||||
@@ -167,7 +172,6 @@ doAccountLines(
|
||||
cursor = ripple::uint256::fromVoid(bytes->data());
|
||||
}
|
||||
|
||||
|
||||
response["lines"] = boost::json::value(boost::json::array_kind);
|
||||
boost::json::array& jsonLines = response.at("lines").as_array();
|
||||
|
||||
@@ -185,13 +189,8 @@ doAccountLines(
|
||||
return true;
|
||||
};
|
||||
|
||||
auto nextCursor =
|
||||
traverseOwnedNodes(
|
||||
backend,
|
||||
accountID,
|
||||
*ledgerSequence,
|
||||
cursor,
|
||||
addToResponse);
|
||||
auto nextCursor = traverseOwnedNodes(
|
||||
backend, accountID, *ledgerSequence, cursor, addToResponse);
|
||||
|
||||
if (nextCursor)
|
||||
response["next_cursor"] = ripple::strHex(*nextCursor);
|
||||
|
||||
@@ -7,9 +7,8 @@
|
||||
#include <ripple/protocol/jss.h>
|
||||
#include <boost/json.hpp>
|
||||
#include <algorithm>
|
||||
#include <backend/BackendInterface.h>
|
||||
#include <handlers/RPCHelpers.h>
|
||||
#include <reporting/BackendInterface.h>
|
||||
#include <reporting/DBHelpers.h>
|
||||
|
||||
std::unordered_map<std::string, ripple::LedgerEntryType> types{
|
||||
{"state", ripple::ltRIPPLE_STATE},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <ripple/app/paths/RippleState.h>
|
||||
#include <ripple/app/ledger/Ledger.h>
|
||||
#include <ripple/app/paths/RippleState.h>
|
||||
#include <ripple/basics/StringUtilities.h>
|
||||
#include <ripple/protocol/ErrorCodes.h>
|
||||
#include <ripple/protocol/Indexes.h>
|
||||
@@ -7,9 +7,8 @@
|
||||
#include <ripple/protocol/jss.h>
|
||||
#include <boost/json.hpp>
|
||||
#include <algorithm>
|
||||
#include <backend/BackendInterface.h>
|
||||
#include <handlers/RPCHelpers.h>
|
||||
#include <reporting/BackendInterface.h>
|
||||
#include <reporting/DBHelpers.h>
|
||||
|
||||
void
|
||||
addOffer(boost::json::array& offersJson, ripple::SLE const& offer)
|
||||
@@ -149,13 +148,8 @@ doAccountOffers(
|
||||
return true;
|
||||
};
|
||||
|
||||
auto nextCursor =
|
||||
traverseOwnedNodes(
|
||||
backend,
|
||||
accountID,
|
||||
*ledgerSequence,
|
||||
cursor,
|
||||
addToResponse);
|
||||
auto nextCursor = traverseOwnedNodes(
|
||||
backend, accountID, *ledgerSequence, cursor, addToResponse);
|
||||
|
||||
if (nextCursor)
|
||||
response["next_cursor"] = ripple::strHex(*nextCursor);
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
//==============================================================================
|
||||
|
||||
#include <handlers/RPCHelpers.h>
|
||||
#include <reporting/BackendInterface.h>
|
||||
#include <backend/BackendInterface.h>
|
||||
|
||||
// {
|
||||
// account: account,
|
||||
|
||||
@@ -6,10 +6,9 @@
|
||||
#include <ripple/protocol/jss.h>
|
||||
#include <boost/json.hpp>
|
||||
#include <algorithm>
|
||||
#include <backend/BackendInterface.h>
|
||||
#include <backend/DBHelpers.h>
|
||||
#include <handlers/RPCHelpers.h>
|
||||
#include <reporting/BackendInterface.h>
|
||||
#include <reporting/DBHelpers.h>
|
||||
#include <reporting/Pg.h>
|
||||
|
||||
boost::json::object
|
||||
doBookOffers(
|
||||
@@ -251,8 +250,8 @@ doBookOffers(
|
||||
backend.fetchBookOffers(bookBase, *ledgerSequence, limit, cursor);
|
||||
auto end = std::chrono::system_clock::now();
|
||||
|
||||
BOOST_LOG_TRIVIAL(warning) << "Time loading books: "
|
||||
<< ((end - start).count() / 1000000000.0);
|
||||
BOOST_LOG_TRIVIAL(warning)
|
||||
<< "Time loading books: " << ((end - start).count() / 1000000000.0);
|
||||
|
||||
if (warning)
|
||||
response["warning"] = *warning;
|
||||
@@ -270,13 +269,17 @@ doBookOffers(
|
||||
{
|
||||
ripple::SerialIter it{obj.blob.data(), obj.blob.size()};
|
||||
ripple::SLE offer{it, obj.key};
|
||||
ripple::uint256 bookDir = offer.getFieldH256(ripple::sfBookDirectory);
|
||||
ripple::uint256 bookDir =
|
||||
offer.getFieldH256(ripple::sfBookDirectory);
|
||||
|
||||
boost::json::object offerJson = toJson(offer);
|
||||
offerJson["quality"] = ripple::amountFromQuality(getQuality(bookDir)).getText();
|
||||
offerJson["quality"] =
|
||||
ripple::amountFromQuality(getQuality(bookDir)).getText();
|
||||
jsonOffers.push_back(offerJson);
|
||||
}
|
||||
catch (std::exception const& e) {}
|
||||
catch (std::exception const& e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
end = std::chrono::system_clock::now();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <handlers/RPCHelpers.h>
|
||||
#include <reporting/BackendInterface.h>
|
||||
#include <backend/BackendInterface.h>
|
||||
|
||||
boost::json::object
|
||||
doLedger(boost::json::object const& request, BackendInterface const& backend)
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include <ripple/protocol/STLedgerEntry.h>
|
||||
#include <boost/json.hpp>
|
||||
#include <handlers/RPCHelpers.h>
|
||||
#include <reporting/BackendInterface.h>
|
||||
#include <backend/BackendInterface.h>
|
||||
// Get state nodes from a ledger
|
||||
// Inputs:
|
||||
// limit: integer, maximum number of entries
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <ripple/protocol/STLedgerEntry.h>
|
||||
#include <boost/json.hpp>
|
||||
#include <handlers/RPCHelpers.h>
|
||||
#include <reporting/BackendInterface.h>
|
||||
#include <backend/BackendInterface.h>
|
||||
// {
|
||||
// ledger_hash : <ledger>
|
||||
// ledger_index : <ledger_index>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <handlers/RPCHelpers.h>
|
||||
#include <reporting/BackendInterface.h>
|
||||
#include <backend/BackendInterface.h>
|
||||
|
||||
boost::json::object
|
||||
doLedgerRange(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <handlers/RPCHelpers.h>
|
||||
#include <reporting/BackendInterface.h>
|
||||
#include <backend/BackendInterface.h>
|
||||
|
||||
std::optional<ripple::AccountID>
|
||||
accountFromStringStrict(std::string const& account)
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <ripple/protocol/STLedgerEntry.h>
|
||||
#include <ripple/protocol/STTx.h>
|
||||
#include <boost/json.hpp>
|
||||
#include <reporting/BackendInterface.h>
|
||||
#include <backend/BackendInterface.h>
|
||||
|
||||
std::optional<ripple::AccountID>
|
||||
accountFromStringStrict(std::string const& account);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <handlers/RPCHelpers.h>
|
||||
#include <reporting/BackendInterface.h>
|
||||
#include <backend/BackendInterface.h>
|
||||
boost::json::object
|
||||
doServerInfo(
|
||||
boost::json::object const& request,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <boost/json.hpp>
|
||||
#include <reporting/server/session.h>
|
||||
#include <handlers/RPCHelpers.h>
|
||||
#include <server/session.h>
|
||||
|
||||
static std::unordered_set<std::string> validStreams{
|
||||
"ledger",
|
||||
@@ -159,7 +159,8 @@ subscribeToAccountsProposed(
|
||||
std::shared_ptr<session>& session,
|
||||
SubscriptionManager& manager)
|
||||
{
|
||||
boost::json::array const& accounts = request.at("accounts_proposed").as_array();
|
||||
boost::json::array const& accounts =
|
||||
request.at("accounts_proposed").as_array();
|
||||
|
||||
for (auto const& account : accounts)
|
||||
{
|
||||
@@ -183,7 +184,8 @@ unsubscribeToAccountsProposed(
|
||||
std::shared_ptr<session>& session,
|
||||
SubscriptionManager& manager)
|
||||
{
|
||||
boost::json::array const& accounts = request.at("accounts_proposed").as_array();
|
||||
boost::json::array const& accounts =
|
||||
request.at("accounts_proposed").as_array();
|
||||
|
||||
for (auto const& account : accounts)
|
||||
{
|
||||
@@ -201,7 +203,6 @@ unsubscribeToAccountsProposed(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
boost::json::object
|
||||
doSubscribe(
|
||||
boost::json::object const& request,
|
||||
@@ -223,7 +224,6 @@ doSubscribe(
|
||||
|
||||
if (request.contains("accounts"))
|
||||
{
|
||||
|
||||
if (!request.at("accounts").is_array())
|
||||
{
|
||||
response["error"] = "accounts must be array";
|
||||
@@ -248,7 +248,8 @@ doSubscribe(
|
||||
return response;
|
||||
}
|
||||
|
||||
boost::json::array accounts = request.at("accounts_proposed").as_array();
|
||||
boost::json::array accounts =
|
||||
request.at("accounts_proposed").as_array();
|
||||
boost::json::value error = validateAccounts(request, accounts);
|
||||
|
||||
if (!error.is_null())
|
||||
@@ -304,7 +305,8 @@ doUnsubscribe(
|
||||
|
||||
if (request.contains("accounts_proposed"))
|
||||
{
|
||||
boost::json::array accounts = request.at("accounts_proposed").as_array();
|
||||
boost::json::array accounts =
|
||||
request.at("accounts_proposed").as_array();
|
||||
boost::json::value error = validateAccounts(request, accounts);
|
||||
|
||||
if (!error.is_null())
|
||||
|
||||
@@ -17,9 +17,8 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <backend/BackendInterface.h>
|
||||
#include <handlers/RPCHelpers.h>
|
||||
#include <reporting/BackendInterface.h>
|
||||
#include <reporting/Pg.h>
|
||||
|
||||
// {
|
||||
// transaction: <hex>
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2020 Ripple Labs 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 <boost/json.hpp>
|
||||
#include <reporting/server/session.h>
|
||||
|
||||
// We only forward requests where ledger_index is "current" or "closed"
|
||||
// otherwise, attempt to handle here
|
||||
bool
|
||||
shouldForwardToP2p(boost::json::object const& request)
|
||||
{
|
||||
if(request.contains("forward") && request.at("forward").is_bool())
|
||||
return request.at("forward").as_bool();
|
||||
|
||||
std::string strCommand = request.contains("command")
|
||||
? request.at("command").as_string().c_str()
|
||||
: request.at("method").as_string().c_str();
|
||||
|
||||
if (forwardCommands.find(strCommand) != forwardCommands.end())
|
||||
return true;
|
||||
|
||||
if (request.contains("ledger_index"))
|
||||
{
|
||||
auto indexValue = request.at("ledger_index");
|
||||
if (!indexValue.is_uint64())
|
||||
{
|
||||
std::string index = indexValue.as_string().c_str();
|
||||
return index == "current" || index == "closed";
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of rippled: https://github.com/ripple/rippled
|
||||
Copyright (c) 2020 Ripple Labs 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.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_APP_REPORTING_P2PPROXY_H_INCLUDED
|
||||
#define RIPPLE_APP_REPORTING_P2PPROXY_H_INCLUDED
|
||||
|
||||
#include <boost/json.hpp>
|
||||
|
||||
/// Whether a request should be forwarded, based on request parameters
|
||||
/// @param request request json
|
||||
/// @return true if should be forwarded
|
||||
bool
|
||||
shouldForwardToP2p(boost::json::object const& request);
|
||||
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <handlers/RPCHelpers.h>
|
||||
#include <reporting/server/SubscriptionManager.h>
|
||||
#include <server/SubscriptionManager.h>
|
||||
|
||||
void
|
||||
SubscriptionManager::subLedger(std::shared_ptr<session>& session)
|
||||
@@ -20,10 +20,10 @@
|
||||
#ifndef SUBSCRIPTION_MANAGER_H
|
||||
#define SUBSCRIPTION_MANAGER_H
|
||||
|
||||
#include <reporting/server/session.h>
|
||||
#include <server/session.h>
|
||||
|
||||
#include <set>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
|
||||
class session;
|
||||
|
||||
@@ -41,10 +41,10 @@ class SubscriptionManager
|
||||
|
||||
std::array<subscriptions, finalEntry> streamSubscribers_;
|
||||
std::unordered_map<ripple::AccountID, subscriptions> accountSubscribers_;
|
||||
std::unordered_map<ripple::AccountID, subscriptions> accountProposedSubscribers_;
|
||||
std::unordered_map<ripple::AccountID, subscriptions>
|
||||
accountProposedSubscribers_;
|
||||
|
||||
public:
|
||||
|
||||
static std::shared_ptr<SubscriptionManager>
|
||||
make_SubscriptionManager()
|
||||
{
|
||||
@@ -71,22 +71,32 @@ public:
|
||||
unsubTransactions(std::shared_ptr<session>& session);
|
||||
|
||||
void
|
||||
pubTransaction(Backend::TransactionAndMetadata const& blob, std::uint32_t seq);
|
||||
pubTransaction(
|
||||
Backend::TransactionAndMetadata const& blob,
|
||||
std::uint32_t seq);
|
||||
|
||||
void
|
||||
subAccount(ripple::AccountID const& account, std::shared_ptr<session>& session);
|
||||
subAccount(
|
||||
ripple::AccountID const& account,
|
||||
std::shared_ptr<session>& session);
|
||||
|
||||
void
|
||||
unsubAccount(ripple::AccountID const& account, std::shared_ptr<session>& session);
|
||||
unsubAccount(
|
||||
ripple::AccountID const& account,
|
||||
std::shared_ptr<session>& session);
|
||||
|
||||
void
|
||||
forwardProposedTransaction(boost::json::object const& response);
|
||||
|
||||
void
|
||||
subProposedAccount(ripple::AccountID const& account, std::shared_ptr<session>& session);
|
||||
subProposedAccount(
|
||||
ripple::AccountID const& account,
|
||||
std::shared_ptr<session>& session);
|
||||
|
||||
void
|
||||
unsubProposedAccount(ripple::AccountID const& account, std::shared_ptr<session>& session);
|
||||
unsubProposedAccount(
|
||||
ripple::AccountID const& account,
|
||||
std::shared_ptr<session>& session);
|
||||
|
||||
void
|
||||
subProposedTransactions(std::shared_ptr<session>& session);
|
||||
@@ -24,7 +24,7 @@
|
||||
#include <boost/beast/core.hpp>
|
||||
#include <boost/beast/websocket.hpp>
|
||||
|
||||
#include <reporting/server/SubscriptionManager.h>
|
||||
#include <server/SubscriptionManager.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#include <reporting/P2pProxy.h>
|
||||
#include <reporting/server/session.h>
|
||||
#include <server/session.h>
|
||||
|
||||
void
|
||||
fail(boost::beast::error_code ec, char const* what)
|
||||
@@ -7,6 +6,31 @@ fail(boost::beast::error_code ec, char const* what)
|
||||
std::cerr << what << ": " << ec.message() << "\n";
|
||||
}
|
||||
|
||||
bool
|
||||
shouldForwardToRippled(boost::json::object const& request)
|
||||
{
|
||||
if (request.contains("forward") && request.at("forward").is_bool())
|
||||
return request.at("forward").as_bool();
|
||||
|
||||
std::string strCommand = request.contains("command")
|
||||
? request.at("command").as_string().c_str()
|
||||
: request.at("method").as_string().c_str();
|
||||
|
||||
if (forwardCommands.find(strCommand) != forwardCommands.end())
|
||||
return true;
|
||||
|
||||
if (request.contains("ledger_index"))
|
||||
{
|
||||
auto indexValue = request.at("ledger_index");
|
||||
if (!indexValue.is_uint64())
|
||||
{
|
||||
std::string index = indexValue.as_string().c_str();
|
||||
return index == "current" || index == "closed";
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
std::pair<boost::json::object, uint32_t>
|
||||
buildResponse(
|
||||
boost::json::object const& request,
|
||||
@@ -19,8 +43,8 @@ buildResponse(
|
||||
BOOST_LOG_TRIVIAL(info) << "Received rpc command : " << request;
|
||||
boost::json::object response;
|
||||
|
||||
if (shouldForwardToP2p(request))
|
||||
return {balancer->forwardToP2p(request), 10};
|
||||
if (shouldForwardToRippled(request))
|
||||
return {balancer->forwardToRippled(request), 10};
|
||||
|
||||
switch (commandMap[command])
|
||||
{
|
||||
@@ -24,10 +24,10 @@
|
||||
#include <boost/beast/core.hpp>
|
||||
#include <boost/beast/websocket.hpp>
|
||||
|
||||
#include <reporting/BackendInterface.h>
|
||||
#include <reporting/ETLSource.h>
|
||||
#include <reporting/server/SubscriptionManager.h>
|
||||
#include <backend/BackendInterface.h>
|
||||
#include <etl/ETLSource.h>
|
||||
#include <server/DOSGuard.h>
|
||||
#include <server/SubscriptionManager.h>
|
||||
|
||||
class session;
|
||||
class SubscriptionManager;
|
||||
@@ -23,15 +23,15 @@
|
||||
#include <boost/log/expressions.hpp>
|
||||
#include <boost/log/trivial.hpp>
|
||||
#include <algorithm>
|
||||
#include <backend/BackendFactory.h>
|
||||
#include <cstdlib>
|
||||
#include <etl/ReportingETL.h>
|
||||
#include <fstream>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <reporting/BackendFactory.h>
|
||||
#include <reporting/ReportingETL.h>
|
||||
#include <reporting/server/listener.h>
|
||||
#include <reporting/server/session.h>
|
||||
#include <server/listener.h>
|
||||
#include <server/session.h>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#include <algorithm>
|
||||
#include <backend/DBHelpers.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <handlers/RPCHelpers.h>
|
||||
#include <reporting/DBHelpers.h>
|
||||
|
||||
#include <boost/log/core.hpp>
|
||||
#include <boost/log/expressions.hpp>
|
||||
#include <boost/log/trivial.hpp>
|
||||
#include <reporting/BackendFactory.h>
|
||||
#include <reporting/BackendInterface.h>
|
||||
#include <backend/BackendFactory.h>
|
||||
#include <backend/BackendInterface.h>
|
||||
|
||||
// Demonstrate some basic assertions.
|
||||
TEST(BackendTest, Basic)
|
||||
|
||||
Reference in New Issue
Block a user