mirror of
https://github.com/XRPLF/clio.git
synced 2025-12-06 17:27:58 +00:00
@@ -308,8 +308,9 @@ BackendInterface::fetchFees(std::uint32_t const seq, boost::asio::yield_context&
|
||||
if (sle.getFieldIndex(ripple::sfBaseFee) != -1)
|
||||
fees.base = sle.getFieldU64(ripple::sfBaseFee);
|
||||
|
||||
if (sle.getFieldIndex(ripple::sfReferenceFeeUnits) != -1)
|
||||
fees.units = sle.getFieldU32(ripple::sfReferenceFeeUnits);
|
||||
// deprecated?
|
||||
// if (sle.getFieldIndex(ripple::sfReferenceFeeUnits) != -1)
|
||||
// fees.units = sle.getFieldU32(ripple::sfReferenceFeeUnits);
|
||||
|
||||
if (sle.getFieldIndex(ripple::sfReserveBase) != -1)
|
||||
fees.reserve = sle.getFieldU32(ripple::sfReserveBase);
|
||||
|
||||
@@ -19,13 +19,14 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ripple/ledger/ReadView.h>
|
||||
#include <backend/DBHelpers.h>
|
||||
#include <backend/LedgerCache.h>
|
||||
#include <backend/Types.h>
|
||||
#include <config/Config.h>
|
||||
#include <log/Logger.h>
|
||||
|
||||
#include <ripple/protocol/Fees.h>
|
||||
#include <ripple/protocol/LedgerHeader.h>
|
||||
#include <boost/asio/spawn.hpp>
|
||||
#include <boost/json.hpp>
|
||||
|
||||
@@ -98,7 +99,7 @@ synchronous(F&& f)
|
||||
* ctx, and is used to pass a stream of data into the method.
|
||||
*/
|
||||
boost::asio::io_context ctx;
|
||||
boost::asio::io_context::strand strand(ctx);
|
||||
boost::asio::strand<boost::asio::io_context::executor_type> strand(ctx.get_executor());
|
||||
std::optional<boost::asio::io_context::work> work;
|
||||
|
||||
/*! @brief Place the ctx within the vector of serialized handlers. */
|
||||
@@ -203,11 +204,11 @@ public:
|
||||
}
|
||||
|
||||
/*! @brief Fetches a specific ledger by sequence number. */
|
||||
virtual std::optional<ripple::LedgerInfo>
|
||||
virtual std::optional<ripple::LedgerHeader>
|
||||
fetchLedgerBySequence(std::uint32_t const sequence, boost::asio::yield_context& yield) const = 0;
|
||||
|
||||
/*! @brief Fetches a specific ledger by hash. */
|
||||
virtual std::optional<ripple::LedgerInfo>
|
||||
virtual std::optional<ripple::LedgerHeader>
|
||||
fetchLedgerByHash(ripple::uint256 const& hash, boost::asio::yield_context& yield) const = 0;
|
||||
|
||||
/*! @brief Fetches the latest ledger sequence. */
|
||||
@@ -475,11 +476,11 @@ public:
|
||||
/**
|
||||
* @brief Writes to a specific ledger.
|
||||
*
|
||||
* @param ledgerInfo Const on ledger information.
|
||||
* @param ledgerHeader r-value string representing ledger header.
|
||||
* @param ledgerHeader Ledger header.
|
||||
* @param blob r-value string serialization of ledger header.
|
||||
*/
|
||||
virtual void
|
||||
writeLedger(ripple::LedgerInfo const& ledgerInfo, std::string&& ledgerHeader) = 0;
|
||||
writeLedger(ripple::LedgerHeader const& ledgerHeader, std::string&& blob) = 0;
|
||||
|
||||
/**
|
||||
* @brief Writes a new ledger object.
|
||||
|
||||
@@ -29,7 +29,8 @@
|
||||
#include <util/LedgerUtils.h>
|
||||
#include <util/Profiler.h>
|
||||
|
||||
#include <ripple/app/tx/impl/details/NFTokenUtils.h>
|
||||
#include <ripple/protocol/LedgerHeader.h>
|
||||
#include <ripple/protocol/nft.h>
|
||||
#include <boost/asio/spawn.hpp>
|
||||
|
||||
namespace Backend::Cassandra {
|
||||
@@ -199,9 +200,9 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
writeLedger(ripple::LedgerInfo const& ledgerInfo, std::string&& header) override
|
||||
writeLedger(ripple::LedgerHeader const& ledgerInfo, std::string&& blob) override
|
||||
{
|
||||
executor_.write(schema_->insertLedgerHeader, ledgerInfo.seq, std::move(header));
|
||||
executor_.write(schema_->insertLedgerHeader, ledgerInfo.seq, std::move(blob));
|
||||
|
||||
executor_.write(schema_->insertLedgerHash, ledgerInfo.hash, ledgerInfo.seq);
|
||||
|
||||
@@ -232,7 +233,7 @@ public:
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::optional<ripple::LedgerInfo>
|
||||
std::optional<ripple::LedgerHeader>
|
||||
fetchLedgerBySequence(std::uint32_t const sequence, boost::asio::yield_context& yield) const override
|
||||
{
|
||||
log_.trace() << __func__ << " call for seq " << sequence;
|
||||
@@ -261,7 +262,7 @@ public:
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::optional<ripple::LedgerInfo>
|
||||
std::optional<ripple::LedgerHeader>
|
||||
fetchLedgerByHash(ripple::uint256 const& hash, boost::asio::yield_context& yield) const override
|
||||
{
|
||||
log_.trace() << __func__ << " call";
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
|
||||
#include <ripple/basics/Log.h>
|
||||
#include <ripple/basics/StringUtilities.h>
|
||||
#include <ripple/ledger/ReadView.h>
|
||||
#include <ripple/protocol/SField.h>
|
||||
#include <ripple/protocol/STAccount.h>
|
||||
#include <ripple/protocol/TxMeta.h>
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#include <boost/json.hpp>
|
||||
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include <log/Logger.h>
|
||||
#include <util/Expected.h>
|
||||
|
||||
#include <boost/asio/async_result.hpp>
|
||||
#include <boost/asio.hpp>
|
||||
#include <boost/asio/spawn.hpp>
|
||||
|
||||
#include <atomic>
|
||||
@@ -75,11 +75,7 @@ public:
|
||||
using FutureType = typename HandleType::FutureType;
|
||||
using FutureWithCallbackType = typename HandleType::FutureWithCallbackType;
|
||||
using ResultType = typename HandleType::ResultType;
|
||||
|
||||
using CompletionTokenType = boost::asio::yield_context;
|
||||
using FunctionType = void(boost::system::error_code);
|
||||
using AsyncResultType = boost::asio::async_result<CompletionTokenType, FunctionType>;
|
||||
using HandlerType = typename AsyncResultType::completion_handler_type;
|
||||
|
||||
DefaultExecutionStrategy(Settings settings, HandleType const& handle)
|
||||
: maxWriteRequestsOutstanding_{settings.maxWriteRequestsOutstanding}
|
||||
@@ -224,29 +220,29 @@ public:
|
||||
[[maybe_unused]] ResultOrErrorType
|
||||
read(CompletionTokenType token, std::vector<StatementType> const& statements)
|
||||
{
|
||||
auto handler = HandlerType{token};
|
||||
auto result = AsyncResultType{handler};
|
||||
auto const numStatements = statements.size();
|
||||
std::optional<FutureWithCallbackType> future;
|
||||
|
||||
// todo: perhaps use policy instead
|
||||
while (true)
|
||||
{
|
||||
numReadRequestsOutstanding_ += numStatements;
|
||||
// TODO: see if we can avoid using shared_ptr for self here
|
||||
auto init = [this, &statements, &future]<typename Self>(Self& self) {
|
||||
future.emplace(handle_.get().asyncExecute(
|
||||
statements, [sself = std::make_shared<Self>(std::move(self))](auto&& res) mutable {
|
||||
boost::asio::post(
|
||||
sself->get_io_executor(), [sself = std::move(sself), res = std::move(res)]() mutable {
|
||||
sself->complete(std::move(res));
|
||||
sself.reset();
|
||||
});
|
||||
}));
|
||||
};
|
||||
|
||||
auto const future = handle_.get().asyncExecute(statements, [handler](auto&&) mutable {
|
||||
boost::asio::post(boost::asio::get_associated_executor(handler), [handler]() mutable {
|
||||
handler(boost::system::error_code{});
|
||||
});
|
||||
});
|
||||
|
||||
// suspend coroutine until completion handler is called
|
||||
result.get();
|
||||
|
||||
auto res = boost::asio::async_compose<CompletionTokenType, void(ResultOrErrorType)>(init, token);
|
||||
numReadRequestsOutstanding_ -= numStatements;
|
||||
|
||||
// it's safe to call blocking get on future here as we already
|
||||
// waited for the coroutine to resume above.
|
||||
if (auto res = future.get(); res)
|
||||
if (res)
|
||||
{
|
||||
return res;
|
||||
}
|
||||
@@ -271,28 +267,28 @@ public:
|
||||
[[maybe_unused]] ResultOrErrorType
|
||||
read(CompletionTokenType token, StatementType const& statement)
|
||||
{
|
||||
auto handler = HandlerType{token};
|
||||
auto result = AsyncResultType{handler};
|
||||
std::optional<FutureWithCallbackType> future;
|
||||
|
||||
// todo: perhaps use policy instead
|
||||
while (true)
|
||||
{
|
||||
++numReadRequestsOutstanding_;
|
||||
// TODO: see if we can avoid using shared_ptr for self here
|
||||
auto init = [this, &statement, &future]<typename Self>(Self& self) {
|
||||
future.emplace(handle_.get().asyncExecute(
|
||||
statement, [sself = std::make_shared<Self>(std::move(self))](auto&& res) mutable {
|
||||
boost::asio::post(
|
||||
sself->get_io_executor(), [sself = std::move(sself), res = std::move(res)]() mutable {
|
||||
sself->complete(std::move(res));
|
||||
sself.reset();
|
||||
});
|
||||
}));
|
||||
};
|
||||
|
||||
auto const future = handle_.get().asyncExecute(statement, [handler](auto const&) mutable {
|
||||
boost::asio::post(boost::asio::get_associated_executor(handler), [handler]() mutable {
|
||||
handler(boost::system::error_code{});
|
||||
});
|
||||
});
|
||||
|
||||
// suspend coroutine until completion handler is called
|
||||
result.get();
|
||||
|
||||
auto res = boost::asio::async_compose<CompletionTokenType, void(ResultOrErrorType)>(init, token);
|
||||
--numReadRequestsOutstanding_;
|
||||
|
||||
// it's safe to call blocking get on future here as we already
|
||||
// waited for the coroutine to resume above.
|
||||
if (auto res = future.get(); res)
|
||||
if (res)
|
||||
{
|
||||
return res;
|
||||
}
|
||||
@@ -318,9 +314,6 @@ public:
|
||||
std::vector<ResultType>
|
||||
readEach(CompletionTokenType token, std::vector<StatementType> const& statements)
|
||||
{
|
||||
auto handler = HandlerType{token};
|
||||
auto result = AsyncResultType{handler};
|
||||
|
||||
std::atomic_bool hadError = false;
|
||||
std::atomic_int numOutstanding = statements.size();
|
||||
numReadRequestsOutstanding_ += statements.size();
|
||||
@@ -328,29 +321,30 @@ public:
|
||||
auto futures = std::vector<FutureWithCallbackType>{};
|
||||
futures.reserve(numOutstanding);
|
||||
|
||||
// used as the handler for each async statement individually
|
||||
auto executionHandler = [handler, &hadError, &numOutstanding](auto const& res) mutable {
|
||||
if (not res)
|
||||
hadError = true;
|
||||
auto init = [this, &statements, &futures, &hadError, &numOutstanding]<typename Self>(Self& self) {
|
||||
auto sself = std::make_shared<Self>(std::move(self)); // TODO: see if we can avoid this
|
||||
auto executionHandler = [&hadError, &numOutstanding, sself = std::move(sself)](auto const& res) mutable {
|
||||
if (not res)
|
||||
hadError = true;
|
||||
|
||||
// when all async operations complete unblock the result
|
||||
if (--numOutstanding == 0)
|
||||
boost::asio::post(boost::asio::get_associated_executor(handler), [handler]() mutable {
|
||||
handler(boost::system::error_code{});
|
||||
// when all async operations complete unblock the result
|
||||
if (--numOutstanding == 0)
|
||||
boost::asio::post(sself->get_io_executor(), [sself = std::move(sself)]() mutable {
|
||||
sself->complete();
|
||||
sself.reset();
|
||||
});
|
||||
};
|
||||
|
||||
std::transform(
|
||||
std::cbegin(statements),
|
||||
std::cend(statements),
|
||||
std::back_inserter(futures),
|
||||
[this, &executionHandler](auto const& statement) {
|
||||
return handle_.get().asyncExecute(statement, executionHandler);
|
||||
});
|
||||
};
|
||||
|
||||
std::transform(
|
||||
std::cbegin(statements),
|
||||
std::cend(statements),
|
||||
std::back_inserter(futures),
|
||||
[this, &executionHandler](auto const& statement) {
|
||||
return handle_.get().asyncExecute(statement, executionHandler);
|
||||
});
|
||||
|
||||
// suspend coroutine until completion handler is called
|
||||
result.get();
|
||||
|
||||
boost::asio::async_compose<CompletionTokenType, void()>(init, token);
|
||||
numReadRequestsOutstanding_ -= statements.size();
|
||||
|
||||
if (hadError)
|
||||
@@ -359,8 +353,7 @@ public:
|
||||
std::vector<ResultType> results;
|
||||
results.reserve(futures.size());
|
||||
|
||||
// it's safe to call blocking get on futures here as we already
|
||||
// waited for the coroutine to resume above.
|
||||
// it's safe to call blocking get on futures here as we already waited for the coroutine to resume above.
|
||||
std::transform(
|
||||
std::make_move_iterator(std::begin(futures)),
|
||||
std::make_move_iterator(std::end(futures)),
|
||||
|
||||
@@ -90,6 +90,7 @@ invokeHelper(CassFuture* ptr, void* cbPtr)
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: cb_ can be deleted before cassandra-driver calls it if the user fails to hold onto the future object
|
||||
/* implicit */ FutureWithCallback::FutureWithCallback(CassFuture* ptr, fn_t&& cb)
|
||||
: Future{ptr}, cb_{std::make_unique<fn_t>(std::move(cb))}
|
||||
{
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
|
||||
#include <etl/ETLService.h>
|
||||
|
||||
#include <ripple/protocol/LedgerHeader.h>
|
||||
|
||||
using namespace clio;
|
||||
|
||||
// Database must be populated when this starts
|
||||
@@ -80,7 +82,7 @@ ETLService::monitor()
|
||||
if (!rng)
|
||||
{
|
||||
log_.info() << "Database is empty. Will download a ledger from the network.";
|
||||
std::optional<ripple::LedgerInfo> ledger;
|
||||
std::optional<ripple::LedgerHeader> ledger;
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
#include <log/Logger.h>
|
||||
#include <subscriptions/SubscriptionManager.h>
|
||||
|
||||
#include "org/xrpl/rpc/v1/xrp_ledger.grpc.pb.h"
|
||||
#include <ripple/proto/org/xrpl/rpc/v1/xrp_ledger.grpc.pb.h>
|
||||
#include <grpcpp/grpcpp.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
@@ -25,8 +25,8 @@
|
||||
#include <log/Logger.h>
|
||||
#include <subscriptions/SubscriptionManager.h>
|
||||
|
||||
#include <ripple/proto/org/xrpl/rpc/v1/xrp_ledger.grpc.pb.h>
|
||||
#include <boost/asio.hpp>
|
||||
#include "org/xrpl/rpc/v1/xrp_ledger.grpc.pb.h"
|
||||
#include <grpcpp/grpcpp.h>
|
||||
|
||||
class Source;
|
||||
|
||||
@@ -26,9 +26,7 @@
|
||||
#include <log/Logger.h>
|
||||
#include <subscriptions/SubscriptionManager.h>
|
||||
|
||||
#include "org/xrpl/rpc/v1/xrp_ledger.grpc.pb.h"
|
||||
#include <grpcpp/grpcpp.h>
|
||||
|
||||
#include <ripple/proto/org/xrpl/rpc/v1/xrp_ledger.grpc.pb.h>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/asio.hpp>
|
||||
#include <boost/beast/core.hpp>
|
||||
@@ -37,6 +35,7 @@
|
||||
#include <boost/beast/websocket.hpp>
|
||||
#include <boost/uuid/uuid.hpp>
|
||||
#include <boost/uuid/uuid_generators.hpp>
|
||||
#include <grpcpp/grpcpp.h>
|
||||
|
||||
class LoadBalancer;
|
||||
class Source;
|
||||
|
||||
@@ -21,13 +21,12 @@
|
||||
|
||||
#include <log/Logger.h>
|
||||
|
||||
#include <ripple/ledger/ReadView.h>
|
||||
#include <ripple/proto/org/xrpl/rpc/v1/xrp_ledger.grpc.pb.h>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/asio/spawn.hpp>
|
||||
#include <boost/beast/core.hpp>
|
||||
#include <boost/beast/core/string.hpp>
|
||||
#include <boost/beast/websocket.hpp>
|
||||
#include "org/xrpl/rpc/v1/xrp_ledger.grpc.pb.h"
|
||||
#include <grpcpp/grpcpp.h>
|
||||
|
||||
#include <chrono>
|
||||
|
||||
@@ -46,7 +46,7 @@ class ForwardCache
|
||||
|
||||
mutable std::shared_mutex mtx_;
|
||||
std::unordered_map<std::string, ResponseType> latestForwarded_;
|
||||
boost::asio::io_context::strand strand_;
|
||||
boost::asio::strand<boost::asio::io_context::executor_type> strand_;
|
||||
Source const& source_;
|
||||
std::uint32_t duration_ = 10;
|
||||
|
||||
@@ -55,7 +55,7 @@ class ForwardCache
|
||||
|
||||
public:
|
||||
ForwardCache(clio::Config const& config, boost::asio::io_context& ioc, Source const& source)
|
||||
: strand_(ioc), source_(source)
|
||||
: strand_(ioc.get_executor()), source_(source)
|
||||
{
|
||||
if (config.contains("cache"))
|
||||
{
|
||||
|
||||
@@ -23,8 +23,7 @@
|
||||
#include <etl/Source.h>
|
||||
#include <log/Logger.h>
|
||||
|
||||
#include <ripple/ledger/ReadView.h>
|
||||
#include "org/xrpl/rpc/v1/xrp_ledger.grpc.pb.h"
|
||||
#include <ripple/proto/org/xrpl/rpc/v1/xrp_ledger.grpc.pb.h>
|
||||
#include <grpcpp/grpcpp.h>
|
||||
|
||||
#include <optional>
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include <util/Profiler.h>
|
||||
|
||||
#include <ripple/beast/core/CurrentThreadName.h>
|
||||
#include <ripple/ledger/ReadView.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
@@ -85,7 +84,7 @@ public:
|
||||
* nft_token_transactions tables (mostly transaction hashes, corresponding nodestore hashes and affected accounts)
|
||||
*/
|
||||
FormattedTransactionsData
|
||||
insertTransactions(ripple::LedgerInfo const& ledger, GetLedgerResponseType& data)
|
||||
insertTransactions(ripple::LedgerHeader const& ledger, GetLedgerResponseType& data)
|
||||
{
|
||||
FormattedTransactionsData result;
|
||||
|
||||
@@ -140,7 +139,7 @@ public:
|
||||
* @param sequence the sequence of the ledger to download
|
||||
* @return The ledger downloaded, with a full transaction and account state map
|
||||
*/
|
||||
std::optional<ripple::LedgerInfo>
|
||||
std::optional<ripple::LedgerHeader>
|
||||
loadInitialLedger(uint32_t sequence)
|
||||
{
|
||||
// check that database is actually empty
|
||||
@@ -158,7 +157,7 @@ public:
|
||||
if (!ledgerData)
|
||||
return {};
|
||||
|
||||
ripple::LedgerInfo lgrInfo = util::deserializeHeader(ripple::makeSlice(ledgerData->ledger_header()));
|
||||
ripple::LedgerHeader lgrInfo = util::deserializeHeader(ripple::makeSlice(ledgerData->ledger_header()));
|
||||
|
||||
log_.debug() << "Deserialized ledger header. " << util::toString(lgrInfo);
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include <util/LedgerUtils.h>
|
||||
#include <util/Profiler.h>
|
||||
|
||||
#include <ripple/ledger/ReadView.h>
|
||||
#include <ripple/protocol/LedgerHeader.h>
|
||||
|
||||
#include <chrono>
|
||||
|
||||
@@ -47,7 +47,7 @@ class LedgerPublisher
|
||||
{
|
||||
clio::Logger log_{"ETL"};
|
||||
|
||||
boost::asio::io_context::strand publishStrand_;
|
||||
boost::asio::strand<boost::asio::io_context::executor_type> publishStrand_;
|
||||
|
||||
std::shared_ptr<BackendInterface> backend_;
|
||||
std::shared_ptr<SubscriptionManagerType> subscriptions_;
|
||||
@@ -71,7 +71,7 @@ public:
|
||||
std::shared_ptr<BackendInterface> backend,
|
||||
std::shared_ptr<SubscriptionManager> subscriptions,
|
||||
SystemState const& state)
|
||||
: publishStrand_{ioc}, backend_{backend}, subscriptions_{subscriptions}, state_{std::cref(state)}
|
||||
: publishStrand_{ioc.get_executor()}, backend_{backend}, subscriptions_{subscriptions}, state_{std::cref(state)}
|
||||
{
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ public:
|
||||
* @param lgrInfo the ledger to publish
|
||||
*/
|
||||
void
|
||||
publish(ripple::LedgerInfo const& lgrInfo)
|
||||
publish(ripple::LedgerHeader const& lgrInfo)
|
||||
{
|
||||
boost::asio::post(publishStrand_, [this, lgrInfo = lgrInfo]() {
|
||||
log_.info() << "Publishing ledger " << std::to_string(lgrInfo.seq);
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#include <util/Profiler.h>
|
||||
|
||||
#include <ripple/beast/core/CurrentThreadName.h>
|
||||
#include "org/xrpl/rpc/v1/xrp_ledger.grpc.pb.h"
|
||||
#include <ripple/proto/org/xrpl/rpc/v1/xrp_ledger.grpc.pb.h>
|
||||
#include <grpcpp/grpcpp.h>
|
||||
|
||||
#include <chrono>
|
||||
@@ -163,11 +163,11 @@ private:
|
||||
* @param rawData data extracted from an ETL source
|
||||
* @return the newly built ledger and data to write to the database
|
||||
*/
|
||||
std::pair<ripple::LedgerInfo, bool>
|
||||
std::pair<ripple::LedgerHeader, bool>
|
||||
buildNextLedger(GetLedgerResponseType& rawData)
|
||||
{
|
||||
log_.debug() << "Beginning ledger update";
|
||||
ripple::LedgerInfo lgrInfo = util::deserializeHeader(ripple::makeSlice(rawData.ledger_header()));
|
||||
ripple::LedgerHeader lgrInfo = util::deserializeHeader(ripple::makeSlice(rawData.ledger_header()));
|
||||
|
||||
log_.debug() << "Deserialized ledger header. " << util::toString(lgrInfo);
|
||||
backend_->startWrites();
|
||||
@@ -191,7 +191,7 @@ private:
|
||||
log_.fatal()
|
||||
<< "Failed to build next ledger: " << e.what()
|
||||
<< " Possible cause: The ETL node is not compatible with the version of the rippled lib Clio is using.";
|
||||
return {ripple::LedgerInfo{}, false};
|
||||
return {ripple::LedgerHeader{}, false};
|
||||
}
|
||||
|
||||
log_.debug() << "Inserted all transactions. Number of transactions = "
|
||||
@@ -217,7 +217,7 @@ private:
|
||||
* @param rawData Ledger data from GRPC
|
||||
*/
|
||||
void
|
||||
updateCache(ripple::LedgerInfo const& lgrInfo, GetLedgerResponseType& rawData)
|
||||
updateCache(ripple::LedgerHeader const& lgrInfo, GetLedgerResponseType& rawData)
|
||||
{
|
||||
std::vector<Backend::LedgerObject> cacheUpdates;
|
||||
cacheUpdates.reserve(rawData.ledger_objects().objects_size());
|
||||
@@ -348,7 +348,7 @@ private:
|
||||
* @param rawData Ledger data from GRPC
|
||||
*/
|
||||
void
|
||||
writeSuccessors(ripple::LedgerInfo const& lgrInfo, GetLedgerResponseType& rawData)
|
||||
writeSuccessors(ripple::LedgerHeader const& lgrInfo, GetLedgerResponseType& rawData)
|
||||
{
|
||||
// Write successor info, if included from rippled
|
||||
if (rawData.object_neighbors_included())
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include <boost/json.hpp>
|
||||
#include <boost/program_options.hpp>
|
||||
|
||||
#include <fstream>
|
||||
#include <main/Build.h>
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
|
||||
@@ -230,6 +230,8 @@ tag_invoke(boost::json::value_from_tag, boost::json::value& jv, BookChange const
|
||||
}
|
||||
|
||||
[[nodiscard]] boost::json::object const
|
||||
computeBookChanges(ripple::LedgerInfo const& lgrInfo, std::vector<Backend::TransactionAndMetadata> const& transactions);
|
||||
computeBookChanges(
|
||||
ripple::LedgerHeader const& lgrInfo,
|
||||
std::vector<Backend::TransactionAndMetadata> const& transactions);
|
||||
|
||||
} // namespace RPC
|
||||
|
||||
@@ -251,7 +251,7 @@ toJson(ripple::SLE const& sle)
|
||||
}
|
||||
|
||||
boost::json::object
|
||||
toJson(ripple::LedgerInfo const& lgrInfo)
|
||||
toJson(ripple::LedgerHeader const& lgrInfo)
|
||||
{
|
||||
boost::json::object header;
|
||||
header["ledger_sequence"] = lgrInfo.seq;
|
||||
@@ -284,7 +284,7 @@ parseStringAsUInt(std::string const& value)
|
||||
return index;
|
||||
}
|
||||
|
||||
std::variant<Status, ripple::LedgerInfo>
|
||||
std::variant<Status, ripple::LedgerHeader>
|
||||
ledgerInfoFromRequest(std::shared_ptr<Backend::BackendInterface const> const& backend, Web::Context const& ctx)
|
||||
{
|
||||
auto hashValue = ctx.params.contains("ledger_hash") ? ctx.params.at("ledger_hash") : nullptr;
|
||||
@@ -339,7 +339,7 @@ ledgerInfoFromRequest(std::shared_ptr<Backend::BackendInterface const> const& ba
|
||||
}
|
||||
|
||||
// extract ledgerInfoFromRequest's parameter from context
|
||||
std::variant<Status, ripple::LedgerInfo>
|
||||
std::variant<Status, ripple::LedgerHeader>
|
||||
getLedgerInfoFromHashOrSeq(
|
||||
BackendInterface const& backend,
|
||||
boost::asio::yield_context& yield,
|
||||
@@ -347,7 +347,7 @@ getLedgerInfoFromHashOrSeq(
|
||||
std::optional<uint32_t> ledgerIndex,
|
||||
uint32_t maxSeq)
|
||||
{
|
||||
std::optional<ripple::LedgerInfo> lgrInfo;
|
||||
std::optional<ripple::LedgerHeader> lgrInfo;
|
||||
auto const err = Status{RippledError::rpcLGR_NOT_FOUND, "ledgerNotFound"};
|
||||
if (ledgerHash)
|
||||
{
|
||||
@@ -373,7 +373,7 @@ getLedgerInfoFromHashOrSeq(
|
||||
}
|
||||
|
||||
std::vector<unsigned char>
|
||||
ledgerInfoToBlob(ripple::LedgerInfo const& info, bool includeHash)
|
||||
ledgerInfoToBlob(ripple::LedgerHeader const& info, bool includeHash)
|
||||
{
|
||||
ripple::Serializer s;
|
||||
s.add32(info.seq);
|
||||
@@ -664,7 +664,7 @@ std::shared_ptr<ripple::SLE const>
|
||||
read(
|
||||
std::shared_ptr<Backend::BackendInterface const> const& backend,
|
||||
ripple::Keylet const& keylet,
|
||||
ripple::LedgerInfo const& lgrInfo,
|
||||
ripple::LedgerHeader const& lgrInfo,
|
||||
Web::Context const& context)
|
||||
{
|
||||
if (auto const blob = backend->fetchLedgerObject(keylet.key, lgrInfo.seq, context.yield); blob)
|
||||
|
||||
@@ -23,17 +23,18 @@
|
||||
* This file contains a variety of utility functions used when executing the handlers.
|
||||
*/
|
||||
|
||||
#include <ripple/app/ledger/Ledger.h>
|
||||
#include <ripple/protocol/Indexes.h>
|
||||
#include <ripple/protocol/STLedgerEntry.h>
|
||||
#include <ripple/protocol/STTx.h>
|
||||
#include <backend/BackendInterface.h>
|
||||
#include <rpc/JS.h>
|
||||
#include <rpc/common/Types.h>
|
||||
#include <util/JsonUtils.h>
|
||||
#include <webserver/Context.h>
|
||||
|
||||
#include <ripple/protocol/Indexes.h>
|
||||
#include <ripple/protocol/Rate.h>
|
||||
#include <ripple/protocol/STLedgerEntry.h>
|
||||
#include <ripple/protocol/STTx.h>
|
||||
|
||||
#include <fmt/core.h>
|
||||
#include <util/JsonUtils.h>
|
||||
|
||||
namespace RPC {
|
||||
|
||||
@@ -74,7 +75,7 @@ boost::json::object
|
||||
toJson(ripple::SLE const& sle);
|
||||
|
||||
boost::json::object
|
||||
toJson(ripple::LedgerInfo const& info);
|
||||
toJson(ripple::LedgerHeader const& info);
|
||||
|
||||
boost::json::object
|
||||
toJson(ripple::TxMeta const& meta);
|
||||
@@ -85,15 +86,15 @@ toBoostJson(RippledJson const& value);
|
||||
|
||||
boost::json::object
|
||||
generatePubLedgerMessage(
|
||||
ripple::LedgerInfo const& lgrInfo,
|
||||
ripple::LedgerHeader const& lgrInfo,
|
||||
ripple::Fees const& fees,
|
||||
std::string const& ledgerRange,
|
||||
std::uint32_t txnCount);
|
||||
|
||||
std::variant<Status, ripple::LedgerInfo>
|
||||
std::variant<Status, ripple::LedgerHeader>
|
||||
ledgerInfoFromRequest(std::shared_ptr<Backend::BackendInterface const> const& backend, Web::Context const& ctx);
|
||||
|
||||
std::variant<Status, ripple::LedgerInfo>
|
||||
std::variant<Status, ripple::LedgerHeader>
|
||||
getLedgerInfoFromHashOrSeq(
|
||||
BackendInterface const& backend,
|
||||
boost::asio::yield_context& yield,
|
||||
@@ -129,7 +130,7 @@ std::shared_ptr<ripple::SLE const>
|
||||
read(
|
||||
std::shared_ptr<Backend::BackendInterface const> const& backend,
|
||||
ripple::Keylet const& keylet,
|
||||
ripple::LedgerInfo const& lgrInfo,
|
||||
ripple::LedgerHeader const& lgrInfo,
|
||||
Web::Context const& context);
|
||||
|
||||
std::variant<Status, std::pair<ripple::PublicKey, ripple::SecretKey>>
|
||||
@@ -139,7 +140,7 @@ std::vector<ripple::AccountID>
|
||||
getAccountsFromTransaction(boost::json::object const& transaction);
|
||||
|
||||
std::vector<unsigned char>
|
||||
ledgerInfoToBlob(ripple::LedgerInfo const& info, bool includeHash = false);
|
||||
ledgerInfoToBlob(ripple::LedgerHeader const& info, bool includeHash = false);
|
||||
|
||||
bool
|
||||
isGlobalFrozen(
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
#include <boost/asio/spawn.hpp>
|
||||
#include <boost/json/value.hpp>
|
||||
#include <boost/json/value_from.hpp>
|
||||
|
||||
namespace Server {
|
||||
struct ConnectionBase;
|
||||
|
||||
@@ -56,8 +56,6 @@ struct DefaultProcessor final
|
||||
}
|
||||
else if constexpr (HandlerWithoutInput<HandlerType>)
|
||||
{
|
||||
using OutType = HandlerReturnType<typename HandlerType::Output>;
|
||||
|
||||
// no input to pass, ignore the value
|
||||
if (auto const ret = handler.process(ctx); not ret)
|
||||
return Error{ret.error()}; // forward Status
|
||||
|
||||
@@ -65,7 +65,7 @@ AccountChannelsHandler::process(AccountChannelsHandler::Input input, Context con
|
||||
if (auto status = std::get_if<Status>(&lgrInfoOrStatus))
|
||||
return Error{*status};
|
||||
|
||||
auto const lgrInfo = std::get<ripple::LedgerInfo>(lgrInfoOrStatus);
|
||||
auto const lgrInfo = std::get<ripple::LedgerHeader>(lgrInfoOrStatus);
|
||||
auto const accountID = accountFromStringStrict(input.account);
|
||||
auto const accountLedgerObject =
|
||||
sharedPtrBackend_->fetchLedgerObject(ripple::keylet::account(*accountID).key, lgrInfo.seq, ctx.yield);
|
||||
@@ -139,13 +139,15 @@ tag_invoke(boost::json::value_to_tag<AccountChannelsHandler::Input>, boost::json
|
||||
void
|
||||
tag_invoke(boost::json::value_from_tag, boost::json::value& jv, AccountChannelsHandler::Output const& output)
|
||||
{
|
||||
using boost::json::value_from;
|
||||
|
||||
auto obj = boost::json::object{
|
||||
{JS(account), output.account},
|
||||
{JS(ledger_hash), output.ledgerHash},
|
||||
{JS(ledger_index), output.ledgerIndex},
|
||||
{JS(validated), output.validated},
|
||||
{JS(limit), output.limit},
|
||||
{JS(channels), output.channels},
|
||||
{JS(channels), value_from(output.channels)},
|
||||
};
|
||||
|
||||
if (output.marker)
|
||||
|
||||
@@ -30,7 +30,7 @@ AccountCurrenciesHandler::process(AccountCurrenciesHandler::Input input, Context
|
||||
if (auto const status = std::get_if<Status>(&lgrInfoOrStatus))
|
||||
return Error{*status};
|
||||
|
||||
auto const lgrInfo = std::get<ripple::LedgerInfo>(lgrInfoOrStatus);
|
||||
auto const lgrInfo = std::get<ripple::LedgerHeader>(lgrInfoOrStatus);
|
||||
auto const accountID = accountFromStringStrict(input.account);
|
||||
|
||||
auto const accountLedgerObject =
|
||||
@@ -81,12 +81,14 @@ AccountCurrenciesHandler::process(AccountCurrenciesHandler::Input input, Context
|
||||
void
|
||||
tag_invoke(boost::json::value_from_tag, boost::json::value& jv, AccountCurrenciesHandler::Output const& output)
|
||||
{
|
||||
using boost::json::value_from;
|
||||
|
||||
jv = {
|
||||
{JS(ledger_hash), output.ledgerHash},
|
||||
{JS(ledger_index), output.ledgerIndex},
|
||||
{JS(validated), output.validated},
|
||||
{JS(receive_currencies), output.receiveCurrencies},
|
||||
{JS(send_currencies), output.sendCurrencies},
|
||||
{JS(receive_currencies), value_from(output.receiveCurrencies)},
|
||||
{JS(send_currencies), value_from(output.sendCurrencies)},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ AccountInfoHandler::process(AccountInfoHandler::Input input, Context const& ctx)
|
||||
if (auto const status = std::get_if<Status>(&lgrInfoOrStatus))
|
||||
return Error{*status};
|
||||
|
||||
auto const lgrInfo = std::get<ripple::LedgerInfo>(lgrInfoOrStatus);
|
||||
auto const lgrInfo = std::get<ripple::LedgerHeader>(lgrInfoOrStatus);
|
||||
auto const accountStr = input.account.value_or(input.ident.value_or(""));
|
||||
auto const accountID = accountFromStringStrict(accountStr);
|
||||
auto const accountKeylet = ripple::keylet::account(*accountID);
|
||||
|
||||
@@ -99,7 +99,7 @@ AccountLinesHandler::process(AccountLinesHandler::Input input, Context const& ct
|
||||
if (auto status = std::get_if<Status>(&lgrInfoOrStatus))
|
||||
return Error{*status};
|
||||
|
||||
auto const lgrInfo = std::get<ripple::LedgerInfo>(lgrInfoOrStatus);
|
||||
auto const lgrInfo = std::get<ripple::LedgerHeader>(lgrInfoOrStatus);
|
||||
auto const accountID = accountFromStringStrict(input.account);
|
||||
auto const accountLedgerObject =
|
||||
sharedPtrBackend_->fetchLedgerObject(ripple::keylet::account(*accountID).key, lgrInfo.seq, ctx.yield);
|
||||
@@ -185,13 +185,15 @@ tag_invoke(boost::json::value_to_tag<AccountLinesHandler::Input>, boost::json::v
|
||||
void
|
||||
tag_invoke(boost::json::value_from_tag, boost::json::value& jv, AccountLinesHandler::Output const& output)
|
||||
{
|
||||
using boost::json::value_from;
|
||||
|
||||
auto obj = boost::json::object{
|
||||
{JS(account), output.account},
|
||||
{JS(ledger_hash), output.ledgerHash},
|
||||
{JS(ledger_index), output.ledgerIndex},
|
||||
{JS(validated), output.validated},
|
||||
{JS(limit), output.limit},
|
||||
{JS(lines), output.lines},
|
||||
{JS(lines), value_from(output.lines)},
|
||||
};
|
||||
|
||||
if (output.marker)
|
||||
|
||||
@@ -19,7 +19,8 @@
|
||||
|
||||
#include <rpc/handlers/AccountNFTs.h>
|
||||
|
||||
#include <ripple/app/tx/impl/details/NFTokenUtils.h>
|
||||
#include <ripple/protocol/Serializer.h>
|
||||
#include <ripple/protocol/nft.h>
|
||||
|
||||
namespace RPC {
|
||||
|
||||
@@ -33,7 +34,7 @@ AccountNFTsHandler::process(AccountNFTsHandler::Input input, Context const& ctx)
|
||||
if (auto const status = std::get_if<Status>(&lgrInfoOrStatus))
|
||||
return Error{*status};
|
||||
|
||||
auto const lgrInfo = std::get<ripple::LedgerInfo>(lgrInfoOrStatus);
|
||||
auto const lgrInfo = std::get<ripple::LedgerHeader>(lgrInfoOrStatus);
|
||||
auto const accountID = accountFromStringStrict(input.account);
|
||||
auto const accountLedgerObject =
|
||||
sharedPtrBackend_->fetchLedgerObject(ripple::keylet::account(*accountID).key, lgrInfo.seq, ctx.yield);
|
||||
|
||||
@@ -44,7 +44,7 @@ AccountObjectsHandler::process(AccountObjectsHandler::Input input, Context const
|
||||
if (auto const status = std::get_if<Status>(&lgrInfoOrStatus))
|
||||
return Error{*status};
|
||||
|
||||
auto const lgrInfo = std::get<ripple::LedgerInfo>(lgrInfoOrStatus);
|
||||
auto const lgrInfo = std::get<ripple::LedgerHeader>(lgrInfoOrStatus);
|
||||
auto const accountID = accountFromStringStrict(input.account);
|
||||
auto const accountLedgerObject =
|
||||
sharedPtrBackend_->fetchLedgerObject(ripple::keylet::account(*accountID).key, lgrInfo.seq, ctx.yield);
|
||||
|
||||
@@ -50,7 +50,7 @@ AccountOffersHandler::process(AccountOffersHandler::Input input, Context const&
|
||||
if (auto const status = std::get_if<Status>(&lgrInfoOrStatus))
|
||||
return Error{*status};
|
||||
|
||||
auto const lgrInfo = std::get<ripple::LedgerInfo>(lgrInfoOrStatus);
|
||||
auto const lgrInfo = std::get<ripple::LedgerHeader>(lgrInfoOrStatus);
|
||||
auto const accountID = accountFromStringStrict(input.account);
|
||||
auto const accountLedgerObject =
|
||||
sharedPtrBackend_->fetchLedgerObject(ripple::keylet::account(*accountID).key, lgrInfo.seq, ctx.yield);
|
||||
|
||||
@@ -61,7 +61,7 @@ AccountTxHandler::process(AccountTxHandler::Input input, Context const& ctx) con
|
||||
if (auto status = std::get_if<Status>(&lgrInfoOrStatus))
|
||||
return Error{*status};
|
||||
|
||||
maxIndex = minIndex = std::get<ripple::LedgerInfo>(lgrInfoOrStatus).seq;
|
||||
maxIndex = minIndex = std::get<ripple::LedgerHeader>(lgrInfoOrStatus).seq;
|
||||
}
|
||||
|
||||
std::optional<Backend::TransactionsCursor> cursor;
|
||||
|
||||
@@ -31,7 +31,7 @@ BookChangesHandler::process(BookChangesHandler::Input input, Context const& ctx)
|
||||
if (auto const status = std::get_if<Status>(&lgrInfoOrStatus))
|
||||
return Error{*status};
|
||||
|
||||
auto const lgrInfo = std::get<ripple::LedgerInfo>(lgrInfoOrStatus);
|
||||
auto const lgrInfo = std::get<ripple::LedgerHeader>(lgrInfoOrStatus);
|
||||
auto const transactions = sharedPtrBackend_->fetchAllTransactionsInLedger(lgrInfo.seq, ctx.yield);
|
||||
|
||||
Output response;
|
||||
@@ -79,7 +79,9 @@ tag_invoke(boost::json::value_to_tag<BookChangesHandler::Input>, boost::json::va
|
||||
}
|
||||
|
||||
[[nodiscard]] boost::json::object const
|
||||
computeBookChanges(ripple::LedgerInfo const& lgrInfo, std::vector<Backend::TransactionAndMetadata> const& transactions)
|
||||
computeBookChanges(
|
||||
ripple::LedgerHeader const& lgrInfo,
|
||||
std::vector<Backend::TransactionAndMetadata> const& transactions)
|
||||
{
|
||||
using boost::json::value_from;
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ BookOffersHandler::process(Input input, Context const& ctx) const
|
||||
if (auto const status = std::get_if<Status>(&lgrInfoOrStatus))
|
||||
return Error{*status};
|
||||
|
||||
auto const lgrInfo = std::get<ripple::LedgerInfo>(lgrInfoOrStatus);
|
||||
auto const lgrInfo = std::get<ripple::LedgerHeader>(lgrInfoOrStatus);
|
||||
auto const book = std::get<ripple::Book>(bookMaybe);
|
||||
auto const bookKey = getBookBase(book);
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ DepositAuthorizedHandler::process(DepositAuthorizedHandler::Input input, Context
|
||||
if (auto status = std::get_if<Status>(&lgrInfoOrStatus))
|
||||
return Error{*status};
|
||||
|
||||
auto const lgrInfo = std::get<ripple::LedgerInfo>(lgrInfoOrStatus);
|
||||
auto const lgrInfo = std::get<ripple::LedgerHeader>(lgrInfoOrStatus);
|
||||
auto const sourceAccountID = accountFromStringStrict(input.sourceAccount);
|
||||
auto const destinationAccountID = accountFromStringStrict(input.destinationAccount);
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ GatewayBalancesHandler::process(GatewayBalancesHandler::Input input, Context con
|
||||
return Error{*status};
|
||||
|
||||
// check account
|
||||
auto const lgrInfo = std::get<ripple::LedgerInfo>(lgrInfoOrStatus);
|
||||
auto const lgrInfo = std::get<ripple::LedgerHeader>(lgrInfoOrStatus);
|
||||
auto const accountID = accountFromStringStrict(input.account);
|
||||
auto const accountLedgerObject =
|
||||
sharedPtrBackend_->fetchLedgerObject(ripple::keylet::account(*accountID).key, lgrInfo.seq, ctx.yield);
|
||||
|
||||
@@ -30,7 +30,7 @@ LedgerHandler::process(LedgerHandler::Input input, Context const& ctx) const
|
||||
if (auto const status = std::get_if<Status>(&lgrInfoOrStatus))
|
||||
return Error{*status};
|
||||
|
||||
auto const lgrInfo = std::get<ripple::LedgerInfo>(lgrInfoOrStatus);
|
||||
auto const lgrInfo = std::get<ripple::LedgerHeader>(lgrInfoOrStatus);
|
||||
Output output;
|
||||
|
||||
if (input.binary)
|
||||
@@ -51,8 +51,6 @@ LedgerHandler::process(LedgerHandler::Input input, Context const& ctx) const
|
||||
output.header[JS(ledger_index)] = std::to_string(lgrInfo.seq);
|
||||
output.header[JS(parent_close_time)] = lgrInfo.parentCloseTime.time_since_epoch().count();
|
||||
output.header[JS(parent_hash)] = ripple::strHex(lgrInfo.parentHash);
|
||||
output.header[JS(seqNum)] = std::to_string(lgrInfo.seq);
|
||||
output.header[JS(totalCoins)] = ripple::to_string(lgrInfo.drops);
|
||||
output.header[JS(total_coins)] = ripple::to_string(lgrInfo.drops);
|
||||
output.header[JS(transaction_hash)] = ripple::strHex(lgrInfo.txHash);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include <rpc/handlers/LedgerData.h>
|
||||
|
||||
#include <ripple/app/ledger/LedgerToJson.h>
|
||||
#include <ripple/protocol/serialize.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@@ -68,7 +68,7 @@ LedgerDataHandler::process(Input input, Context const& ctx) const
|
||||
if (auto const status = std::get_if<Status>(&lgrInfoOrStatus))
|
||||
return Error{*status};
|
||||
|
||||
auto const lgrInfo = std::get<ripple::LedgerInfo>(lgrInfoOrStatus);
|
||||
auto const lgrInfo = std::get<ripple::LedgerHeader>(lgrInfoOrStatus);
|
||||
|
||||
// no marker -> first call, return header information
|
||||
auto header = boost::json::object();
|
||||
@@ -93,8 +93,6 @@ LedgerDataHandler::process(Input input, Context const& ctx) const
|
||||
header[JS(ledger_index)] = std::to_string(lgrInfo.seq);
|
||||
header[JS(parent_close_time)] = lgrInfo.parentCloseTime.time_since_epoch().count();
|
||||
header[JS(parent_hash)] = ripple::strHex(lgrInfo.parentHash);
|
||||
header[JS(seqNum)] = std::to_string(lgrInfo.seq);
|
||||
header[JS(totalCoins)] = ripple::to_string(lgrInfo.drops);
|
||||
header[JS(total_coins)] = ripple::to_string(lgrInfo.drops);
|
||||
header[JS(transaction_hash)] = ripple::strHex(lgrInfo.txHash);
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ LedgerEntryHandler::process(LedgerEntryHandler::Input input, Context const& ctx)
|
||||
if (auto const status = std::get_if<Status>(&lgrInfoOrStatus))
|
||||
return Error{*status};
|
||||
|
||||
auto const lgrInfo = std::get<ripple::LedgerInfo>(lgrInfoOrStatus);
|
||||
auto const lgrInfo = std::get<ripple::LedgerHeader>(lgrInfoOrStatus);
|
||||
auto const ledgerObject = sharedPtrBackend_->fetchLedgerObject(key, lgrInfo.seq, ctx.yield);
|
||||
|
||||
if (!ledgerObject || ledgerObject->size() == 0)
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#include <rpc/RPCHelpers.h>
|
||||
#include <rpc/handlers/NFTBuyOffers.h>
|
||||
|
||||
#include <ripple/app/tx/impl/details/NFTokenUtils.h>
|
||||
#include <ripple/protocol/Indexes.h>
|
||||
|
||||
using namespace ripple;
|
||||
|
||||
@@ -63,7 +63,7 @@ NFTHistoryHandler::process(NFTHistoryHandler::Input input, Context const& ctx) c
|
||||
if (auto status = std::get_if<Status>(&lgrInfoOrStatus))
|
||||
return Error{*status};
|
||||
|
||||
maxIndex = minIndex = std::get<ripple::LedgerInfo>(lgrInfoOrStatus).seq;
|
||||
maxIndex = minIndex = std::get<ripple::LedgerHeader>(lgrInfoOrStatus).seq;
|
||||
}
|
||||
|
||||
std::optional<Backend::TransactionsCursor> cursor;
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
#include <rpc/RPCHelpers.h>
|
||||
#include <rpc/handlers/NFTInfo.h>
|
||||
|
||||
#include <ripple/app/tx/impl/details/NFTokenUtils.h>
|
||||
#include <ripple/protocol/Indexes.h>
|
||||
#include <ripple/protocol/nft.h>
|
||||
|
||||
using namespace ripple;
|
||||
using namespace ::RPC;
|
||||
@@ -39,7 +39,7 @@ NFTInfoHandler::process(NFTInfoHandler::Input input, Context const& ctx) const
|
||||
if (auto const status = std::get_if<Status>(&lgrInfoOrStatus))
|
||||
return Error{*status};
|
||||
|
||||
auto const lgrInfo = std::get<LedgerInfo>(lgrInfoOrStatus);
|
||||
auto const lgrInfo = std::get<LedgerHeader>(lgrInfoOrStatus);
|
||||
auto const maybeNft = sharedPtrBackend_->fetchNFT(tokenID, lgrInfo.seq, ctx.yield);
|
||||
|
||||
if (not maybeNft.has_value())
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#include <rpc/RPCHelpers.h>
|
||||
#include <rpc/handlers/NFTOffersCommon.h>
|
||||
|
||||
#include <ripple/app/tx/impl/details/NFTokenUtils.h>
|
||||
#include <ripple/protocol/Indexes.h>
|
||||
|
||||
using namespace ripple;
|
||||
@@ -68,7 +67,7 @@ NFTOffersHandlerBase::iterateOfferDirectory(
|
||||
if (auto const status = std::get_if<Status>(&lgrInfoOrStatus))
|
||||
return Error{*status};
|
||||
|
||||
auto const lgrInfo = std::get<LedgerInfo>(lgrInfoOrStatus);
|
||||
auto const lgrInfo = std::get<LedgerHeader>(lgrInfoOrStatus);
|
||||
|
||||
// TODO: just check for existence without pulling
|
||||
if (not sharedPtrBackend_->fetchLedgerObject(directory.key, lgrInfo.seq, yield))
|
||||
@@ -139,10 +138,12 @@ NFTOffersHandlerBase::iterateOfferDirectory(
|
||||
void
|
||||
tag_invoke(boost::json::value_from_tag, boost::json::value& jv, NFTOffersHandlerBase::Output const& output)
|
||||
{
|
||||
using boost::json::value_from;
|
||||
|
||||
auto object = boost::json::object{
|
||||
{JS(nft_id), output.nftID},
|
||||
{JS(validated), output.validated},
|
||||
{JS(offers), output.offers},
|
||||
{JS(offers), value_from(output.offers)},
|
||||
};
|
||||
|
||||
if (output.marker)
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#include <rpc/RPCHelpers.h>
|
||||
#include <rpc/handlers/NFTSellOffers.h>
|
||||
|
||||
#include <ripple/app/tx/impl/details/NFTokenUtils.h>
|
||||
#include <ripple/protocol/Indexes.h>
|
||||
|
||||
using namespace ripple;
|
||||
|
||||
@@ -34,7 +34,7 @@ NoRippleCheckHandler::process(NoRippleCheckHandler::Input input, Context const&
|
||||
if (auto status = std::get_if<Status>(&lgrInfoOrStatus))
|
||||
return Error{*status};
|
||||
|
||||
auto const lgrInfo = std::get<ripple::LedgerInfo>(lgrInfoOrStatus);
|
||||
auto const lgrInfo = std::get<ripple::LedgerHeader>(lgrInfoOrStatus);
|
||||
auto const accountID = accountFromStringStrict(input.account);
|
||||
auto const keylet = ripple::keylet::account(*accountID).key;
|
||||
auto const accountObj = sharedPtrBackend_->fetchLedgerObject(keylet, lgrInfo.seq, ctx.yield);
|
||||
@@ -46,7 +46,8 @@ NoRippleCheckHandler::process(NoRippleCheckHandler::Input input, Context const&
|
||||
auto sle = ripple::SLE{it, keylet};
|
||||
auto accountSeq = sle.getFieldU32(ripple::sfSequence);
|
||||
bool const bDefaultRipple = sle.getFieldU32(ripple::sfFlags) & ripple::lsfDefaultRipple;
|
||||
auto const fees = input.transactions ? sharedPtrBackend_->fetchFees(lgrInfo.seq, ctx.yield) : std::nullopt;
|
||||
// TODO: remove if no longer needed
|
||||
// auto const fees = input.transactions ? sharedPtrBackend_->fetchFees(lgrInfo.seq, ctx.yield) : std::nullopt;
|
||||
|
||||
auto output = NoRippleCheckHandler::Output();
|
||||
|
||||
@@ -57,7 +58,8 @@ NoRippleCheckHandler::process(NoRippleCheckHandler::Input input, Context const&
|
||||
boost::json::object tx;
|
||||
tx[JS(Sequence)] = accountSeq;
|
||||
tx[JS(Account)] = ripple::toBase58(accountID);
|
||||
tx[JS(Fee)] = toBoostJson(fees->units.jsonClipped());
|
||||
// TODO: deprecated?
|
||||
// tx[JS(Fee)] = toBoostJson(fees->units.jsonClipped());
|
||||
|
||||
return tx;
|
||||
};
|
||||
@@ -186,10 +188,12 @@ tag_invoke(boost::json::value_to_tag<NoRippleCheckHandler::Input>, boost::json::
|
||||
void
|
||||
tag_invoke(boost::json::value_from_tag, boost::json::value& jv, NoRippleCheckHandler::Output const& output)
|
||||
{
|
||||
using boost::json::value_from;
|
||||
|
||||
auto obj = boost::json::object{
|
||||
{JS(ledger_hash), output.ledgerHash},
|
||||
{JS(ledger_index), output.ledgerIndex},
|
||||
{"problems", output.problems},
|
||||
{"problems", value_from(output.problems)},
|
||||
{JS(validated), output.validated},
|
||||
};
|
||||
|
||||
|
||||
@@ -171,8 +171,10 @@ private:
|
||||
friend void
|
||||
tag_invoke(boost::json::value_from_tag, boost::json::value& jv, Output const& output)
|
||||
{
|
||||
using boost::json::value_from;
|
||||
|
||||
jv = {
|
||||
{JS(info), output.info},
|
||||
{JS(info), value_from(output.info)},
|
||||
{JS(validated), output.validated},
|
||||
};
|
||||
}
|
||||
@@ -180,6 +182,7 @@ private:
|
||||
friend void
|
||||
tag_invoke(boost::json::value_from_tag, boost::json::value& jv, InfoSection const& info)
|
||||
{
|
||||
using boost::json::value_from;
|
||||
using ripple::to_string;
|
||||
|
||||
jv = {
|
||||
@@ -188,8 +191,8 @@ private:
|
||||
{JS(time), to_string(std::chrono::floor<std::chrono::microseconds>(info.time))},
|
||||
{JS(uptime), info.uptime.count()},
|
||||
{"clio_version", info.clioVersion},
|
||||
{JS(validated_ledger), info.validatedLedger},
|
||||
{"cache", info.cache},
|
||||
{JS(validated_ledger), value_from(info.validatedLedger)},
|
||||
{"cache", value_from(info.cache)},
|
||||
};
|
||||
|
||||
if (info.isAmendmentBlocked)
|
||||
|
||||
@@ -31,7 +31,7 @@ TransactionEntryHandler::process(TransactionEntryHandler::Input input, Context c
|
||||
if (auto status = std::get_if<Status>(&lgrInfoOrStatus))
|
||||
return Error{*status};
|
||||
|
||||
auto const lgrInfo = std::get<ripple::LedgerInfo>(lgrInfoOrStatus);
|
||||
auto const lgrInfo = std::get<ripple::LedgerHeader>(lgrInfoOrStatus);
|
||||
auto const dbRet = sharedPtrBackend_->fetchTransaction(ripple::uint256{input.txHash.c_str()}, ctx.yield);
|
||||
// Note: transaction_entry is meant to only search a specified ledger for
|
||||
// the specified transaction. tx searches the entire range of history. For
|
||||
|
||||
@@ -41,7 +41,7 @@ Subscription::publish(std::shared_ptr<std::string> const& message)
|
||||
|
||||
boost::json::object
|
||||
getLedgerPubMessage(
|
||||
ripple::LedgerInfo const& lgrInfo,
|
||||
ripple::LedgerHeader const& lgrInfo,
|
||||
ripple::Fees const& fees,
|
||||
std::string const& ledgerRange,
|
||||
std::uint32_t txnCount)
|
||||
@@ -53,7 +53,8 @@ getLedgerPubMessage(
|
||||
pubMsg["ledger_hash"] = to_string(lgrInfo.hash);
|
||||
pubMsg["ledger_time"] = lgrInfo.closeTime.time_since_epoch().count();
|
||||
|
||||
pubMsg["fee_ref"] = RPC::toBoostJson(fees.units.jsonClipped());
|
||||
// deprecated?
|
||||
// pubMsg["fee_ref"] = RPC::toBoostJson(fees.units.jsonClipped());
|
||||
pubMsg["fee_base"] = RPC::toBoostJson(fees.base.jsonClipped());
|
||||
pubMsg["reserve_base"] = RPC::toBoostJson(fees.reserve.jsonClipped());
|
||||
pubMsg["reserve_inc"] = RPC::toBoostJson(fees.increment.jsonClipped());
|
||||
@@ -144,7 +145,7 @@ SubscriptionManager::unsubBookChanges(SessionPtrType session)
|
||||
|
||||
void
|
||||
SubscriptionManager::pubLedger(
|
||||
ripple::LedgerInfo const& lgrInfo,
|
||||
ripple::LedgerHeader const& lgrInfo,
|
||||
ripple::Fees const& fees,
|
||||
std::string const& ledgerRange,
|
||||
std::uint32_t txnCount)
|
||||
@@ -156,7 +157,7 @@ SubscriptionManager::pubLedger(
|
||||
}
|
||||
|
||||
void
|
||||
SubscriptionManager::pubTransaction(Backend::TransactionAndMetadata const& blobs, ripple::LedgerInfo const& lgrInfo)
|
||||
SubscriptionManager::pubTransaction(Backend::TransactionAndMetadata const& blobs, ripple::LedgerHeader const& lgrInfo)
|
||||
{
|
||||
auto [tx, meta] = RPC::deserializeTxPlusMeta(blobs, lgrInfo.seq);
|
||||
boost::json::object pubObj;
|
||||
@@ -244,7 +245,7 @@ SubscriptionManager::pubTransaction(Backend::TransactionAndMetadata const& blobs
|
||||
|
||||
void
|
||||
SubscriptionManager::pubBookChanges(
|
||||
ripple::LedgerInfo const& lgrInfo,
|
||||
ripple::LedgerHeader const& lgrInfo,
|
||||
std::vector<Backend::TransactionAndMetadata> const& transactions)
|
||||
{
|
||||
auto const json = RPC::computeBookChanges(lgrInfo, transactions);
|
||||
|
||||
@@ -24,13 +24,15 @@
|
||||
#include <log/Logger.h>
|
||||
#include <webserver/interface/ConnectionBase.h>
|
||||
|
||||
#include <ripple/protocol/LedgerHeader.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
using SessionPtrType = std::shared_ptr<Server::ConnectionBase>;
|
||||
|
||||
class Subscription
|
||||
{
|
||||
boost::asio::io_context::strand strand_;
|
||||
boost::asio::strand<boost::asio::io_context::executor_type> strand_;
|
||||
std::unordered_set<SessionPtrType> subscribers_ = {};
|
||||
std::atomic_uint64_t subCount_ = 0;
|
||||
|
||||
@@ -39,7 +41,7 @@ public:
|
||||
Subscription(Subscription&) = delete;
|
||||
Subscription(Subscription&&) = delete;
|
||||
|
||||
explicit Subscription(boost::asio::io_context& ioc) : strand_(ioc)
|
||||
explicit Subscription(boost::asio::io_context& ioc) : strand_(ioc.get_executor())
|
||||
{
|
||||
}
|
||||
|
||||
@@ -72,7 +74,7 @@ class SubscriptionMap
|
||||
{
|
||||
using subscribers = std::set<SessionPtrType>;
|
||||
|
||||
boost::asio::io_context::strand strand_;
|
||||
boost::asio::strand<boost::asio::io_context::executor_type> strand_;
|
||||
std::unordered_map<Key, subscribers> subscribers_ = {};
|
||||
std::atomic_uint64_t subCount_ = 0;
|
||||
|
||||
@@ -81,7 +83,7 @@ public:
|
||||
SubscriptionMap(SubscriptionMap&) = delete;
|
||||
SubscriptionMap(SubscriptionMap&&) = delete;
|
||||
|
||||
explicit SubscriptionMap(boost::asio::io_context& ioc) : strand_(ioc)
|
||||
explicit SubscriptionMap(boost::asio::io_context& ioc) : strand_(ioc.get_executor())
|
||||
{
|
||||
}
|
||||
|
||||
@@ -253,13 +255,15 @@ public:
|
||||
|
||||
void
|
||||
pubLedger(
|
||||
ripple::LedgerInfo const& lgrInfo,
|
||||
ripple::LedgerHeader const& lgrInfo,
|
||||
ripple::Fees const& fees,
|
||||
std::string const& ledgerRange,
|
||||
std::uint32_t txnCount);
|
||||
|
||||
void
|
||||
pubBookChanges(ripple::LedgerInfo const& lgrInfo, std::vector<Backend::TransactionAndMetadata> const& transactions);
|
||||
pubBookChanges(
|
||||
ripple::LedgerHeader const& lgrInfo,
|
||||
std::vector<Backend::TransactionAndMetadata> const& transactions);
|
||||
|
||||
void
|
||||
unsubLedger(SessionPtrType session);
|
||||
@@ -271,7 +275,7 @@ public:
|
||||
unsubTransactions(SessionPtrType session);
|
||||
|
||||
void
|
||||
pubTransaction(Backend::TransactionAndMetadata const& blobs, ripple::LedgerInfo const& lgrInfo);
|
||||
pubTransaction(Backend::TransactionAndMetadata const& blobs, ripple::LedgerHeader const& lgrInfo);
|
||||
|
||||
void
|
||||
subAccount(ripple::AccountID const& account, SessionPtrType const& session);
|
||||
|
||||
@@ -19,38 +19,26 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ripple/basics/Slice.h>
|
||||
#include <ripple/basics/StringUtilities.h>
|
||||
#include <ripple/protocol/LedgerHeader.h>
|
||||
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
namespace util {
|
||||
|
||||
inline ripple::LedgerInfo
|
||||
inline ripple::LedgerHeader
|
||||
deserializeHeader(ripple::Slice data)
|
||||
{
|
||||
ripple::SerialIter sit(data.data(), data.size());
|
||||
ripple::LedgerInfo info;
|
||||
|
||||
info.seq = sit.get32();
|
||||
info.drops = sit.get64();
|
||||
info.parentHash = sit.get256();
|
||||
info.txHash = sit.get256();
|
||||
info.accountHash = sit.get256();
|
||||
info.parentCloseTime = ripple::NetClock::time_point{ripple::NetClock::duration{sit.get32()}};
|
||||
info.closeTime = ripple::NetClock::time_point{ripple::NetClock::duration{sit.get32()}};
|
||||
info.closeTimeResolution = ripple::NetClock::duration{sit.get8()};
|
||||
info.closeFlags = sit.get8();
|
||||
info.hash = sit.get256();
|
||||
|
||||
return info;
|
||||
return ripple::deserializeHeader(data, /*hasHash=*/true);
|
||||
}
|
||||
|
||||
inline std::string
|
||||
toString(ripple::LedgerInfo const& info)
|
||||
toString(ripple::LedgerHeader const& info)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "LedgerInfo { Sequence : " << info.seq << " Hash : " << ripple::strHex(info.hash)
|
||||
ss << "LedgerHeader { Sequence : " << info.seq << " Hash : " << ripple::strHex(info.hash)
|
||||
<< " TxHash : " << strHex(info.txHash) << " AccountHash : " << ripple::strHex(info.accountHash)
|
||||
<< " ParentHash : " << strHex(info.parentHash) << " }";
|
||||
return ss.str();
|
||||
|
||||
Reference in New Issue
Block a user