mirror of
https://github.com/XRPLF/clio.git
synced 2025-12-06 17:27:58 +00:00
@@ -106,6 +106,8 @@ ClioApplication::run(bool const useNgWebServer)
|
||||
// Interface to the database
|
||||
auto backend = data::makeBackend(config_);
|
||||
|
||||
auto const amendmentCenter = std::make_shared<data::AmendmentCenter const>(backend);
|
||||
|
||||
{
|
||||
auto const migrationInspector = migration::makeMigrationInspector(config_, backend);
|
||||
// Check if any migration is blocking Clio server starting.
|
||||
@@ -117,7 +119,7 @@ ClioApplication::run(bool const useNgWebServer)
|
||||
}
|
||||
|
||||
// Manages clients subscribed to streams
|
||||
auto subscriptions = feed::SubscriptionManager::makeSubscriptionManager(config_, backend);
|
||||
auto subscriptions = feed::SubscriptionManager::makeSubscriptionManager(config_, backend, amendmentCenter);
|
||||
|
||||
// Tracks which ledgers have been validated by the network
|
||||
auto ledgers = etl::NetworkValidatedLedgers::makeValidatedLedgers();
|
||||
@@ -133,7 +135,7 @@ ClioApplication::run(bool const useNgWebServer)
|
||||
|
||||
auto workQueue = rpc::WorkQueue::makeWorkQueue(config_);
|
||||
auto counters = rpc::Counters::makeCounters(workQueue);
|
||||
auto const amendmentCenter = std::make_shared<data::AmendmentCenter const>(backend);
|
||||
|
||||
auto const handlerProvider = std::make_shared<rpc::impl::ProductionHandlerProvider const>(
|
||||
config_, backend, subscriptions, balancer, etl, amendmentCenter, counters
|
||||
);
|
||||
|
||||
@@ -134,6 +134,7 @@ struct Amendments {
|
||||
REGISTER(Credentials);
|
||||
REGISTER(DynamicNFT);
|
||||
REGISTER(PermissionedDomains);
|
||||
REGISTER(fixFrozenLPTokenTransfer);
|
||||
|
||||
// Obsolete but supported by libxrpl
|
||||
REGISTER(CryptoConditionsSuite);
|
||||
|
||||
@@ -191,7 +191,7 @@ SubscriptionManager::unsubBook(ripple::Book const& book, SubscriberSharedPtr con
|
||||
void
|
||||
SubscriptionManager::pubTransaction(data::TransactionAndMetadata const& txMeta, ripple::LedgerHeader const& lgrInfo)
|
||||
{
|
||||
transactionFeed_.pub(txMeta, lgrInfo, backend_);
|
||||
transactionFeed_.pub(txMeta, lgrInfo, backend_, amendmentCenter_);
|
||||
}
|
||||
|
||||
boost::json::object
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "data/AmendmentCenterInterface.hpp"
|
||||
#include "data/BackendInterface.hpp"
|
||||
#include "data/Types.hpp"
|
||||
#include "feed/SubscriptionManagerInterface.hpp"
|
||||
@@ -60,6 +61,7 @@ namespace feed {
|
||||
*/
|
||||
class SubscriptionManager : public SubscriptionManagerInterface {
|
||||
std::shared_ptr<data::BackendInterface const> backend_;
|
||||
std::shared_ptr<data::AmendmentCenterInterface const> amendmentCenter_;
|
||||
util::async::AnyExecutionContext ctx_;
|
||||
impl::ForwardFeed manifestFeed_;
|
||||
impl::ForwardFeed validationsFeed_;
|
||||
@@ -74,12 +76,14 @@ public:
|
||||
*
|
||||
* @param config The configuration to use
|
||||
* @param backend The backend to use
|
||||
* @param amendmentCenter The amendmentCenter to use
|
||||
* @return A shared pointer to a new instance of SubscriptionManager
|
||||
*/
|
||||
static std::shared_ptr<SubscriptionManager>
|
||||
makeSubscriptionManager(
|
||||
util::config::ClioConfigDefinition const& config,
|
||||
std::shared_ptr<data::BackendInterface const> const& backend
|
||||
std::shared_ptr<data::BackendInterface const> const& backend,
|
||||
std::shared_ptr<data::AmendmentCenterInterface const> const& amendmentCenter
|
||||
)
|
||||
{
|
||||
auto const workersNum = config.get<uint64_t>("subscription_workers");
|
||||
@@ -87,7 +91,9 @@ public:
|
||||
util::Logger const logger{"Subscriptions"};
|
||||
LOG(logger.info()) << "Starting subscription manager with " << workersNum << " workers";
|
||||
|
||||
return std::make_shared<feed::SubscriptionManager>(util::async::PoolExecutionContext(workersNum), backend);
|
||||
return std::make_shared<feed::SubscriptionManager>(
|
||||
util::async::PoolExecutionContext(workersNum), backend, amendmentCenter
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,12 +101,15 @@ public:
|
||||
*
|
||||
* @param executor The executor to use to publish the feeds
|
||||
* @param backend The backend to use
|
||||
* @param amendmentCenter The amendmentCenter to use
|
||||
*/
|
||||
SubscriptionManager(
|
||||
util::async::AnyExecutionContext&& executor,
|
||||
std::shared_ptr<data::BackendInterface const> const& backend
|
||||
std::shared_ptr<data::BackendInterface const> const& backend,
|
||||
std::shared_ptr<data::AmendmentCenterInterface const> const& amendmentCenter
|
||||
)
|
||||
: backend_(backend)
|
||||
, amendmentCenter_(amendmentCenter)
|
||||
, ctx_(std::move(executor))
|
||||
, manifestFeed_(ctx_, "manifest")
|
||||
, validationsFeed_(ctx_, "validations")
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include "feed/impl/TransactionFeed.hpp"
|
||||
|
||||
#include "data/AmendmentCenterInterface.hpp"
|
||||
#include "data/BackendInterface.hpp"
|
||||
#include "data/Types.hpp"
|
||||
#include "feed/Types.hpp"
|
||||
@@ -174,7 +175,8 @@ void
|
||||
TransactionFeed::pub(
|
||||
data::TransactionAndMetadata const& txMeta,
|
||||
ripple::LedgerHeader const& lgrInfo,
|
||||
std::shared_ptr<data::BackendInterface const> const& backend
|
||||
std::shared_ptr<data::BackendInterface const> const& backend,
|
||||
std::shared_ptr<data::AmendmentCenterInterface const> const& amendmentCenter
|
||||
)
|
||||
{
|
||||
auto [tx, meta] = rpc::deserializeTxPlusMeta(txMeta, lgrInfo.seq);
|
||||
@@ -187,7 +189,7 @@ TransactionFeed::pub(
|
||||
if (account != amount.issue().account) {
|
||||
auto fetchFundsSynchronous = [&]() {
|
||||
data::synchronous([&](boost::asio::yield_context yield) {
|
||||
ownerFunds = rpc::accountFunds(*backend, lgrInfo.seq, amount, account, yield);
|
||||
ownerFunds = rpc::accountFunds(*backend, *amendmentCenter, lgrInfo.seq, amount, account, yield);
|
||||
});
|
||||
};
|
||||
data::retryOnTimeout(fetchFundsSynchronous);
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "data/AmendmentCenterInterface.hpp"
|
||||
#include "data/BackendInterface.hpp"
|
||||
#include "data/Types.hpp"
|
||||
#include "feed/Types.hpp"
|
||||
@@ -180,7 +181,8 @@ public:
|
||||
void
|
||||
pub(data::TransactionAndMetadata const& txMeta,
|
||||
ripple::LedgerHeader const& lgrInfo,
|
||||
std::shared_ptr<data::BackendInterface const> const& backend);
|
||||
std::shared_ptr<data::BackendInterface const> const& backend,
|
||||
std::shared_ptr<data::AmendmentCenterInterface const> const& amendmentCenter);
|
||||
|
||||
/**
|
||||
* @brief Get the number of subscribers of the transaction feed.
|
||||
|
||||
@@ -38,6 +38,7 @@ namespace rpc {
|
||||
std::pair<ripple::STAmount, ripple::STAmount>
|
||||
getAmmPoolHolds(
|
||||
BackendInterface const& backend,
|
||||
data::AmendmentCenterInterface const& amendmentCenter,
|
||||
std::uint32_t sequence,
|
||||
ripple::AccountID const& ammAccountID,
|
||||
ripple::Issue const& issue1,
|
||||
@@ -46,10 +47,12 @@ getAmmPoolHolds(
|
||||
boost::asio::yield_context yield
|
||||
)
|
||||
{
|
||||
auto const assetInBalance =
|
||||
accountHolds(backend, sequence, ammAccountID, issue1.currency, issue1.account, freezeHandling, yield);
|
||||
auto const assetOutBalance =
|
||||
accountHolds(backend, sequence, ammAccountID, issue2.currency, issue2.account, freezeHandling, yield);
|
||||
auto const assetInBalance = accountHolds(
|
||||
backend, amendmentCenter, sequence, ammAccountID, issue1.currency, issue1.account, freezeHandling, yield
|
||||
);
|
||||
auto const assetOutBalance = accountHolds(
|
||||
backend, amendmentCenter, sequence, ammAccountID, issue2.currency, issue2.account, freezeHandling, yield
|
||||
);
|
||||
return std::make_pair(assetInBalance, assetOutBalance);
|
||||
}
|
||||
|
||||
@@ -65,7 +68,9 @@ getAmmLpHolds(
|
||||
)
|
||||
{
|
||||
auto const lptCurrency = ammLPTCurrency(cur1, cur2);
|
||||
return accountHolds(backend, sequence, lpAccount, lptCurrency, ammAccount, true, yield);
|
||||
|
||||
// not using accountHolds because we don't need to check if the associated tokens of the LP are frozen
|
||||
return ammAccountHolds(backend, sequence, lpAccount, lptCurrency, ammAccount, true, yield);
|
||||
}
|
||||
|
||||
ripple::STAmount
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "data/AmendmentCenterInterface.hpp"
|
||||
#include "data/BackendInterface.hpp"
|
||||
|
||||
#include <boost/asio/spawn.hpp>
|
||||
@@ -37,6 +38,7 @@ namespace rpc {
|
||||
* @brief getAmmPoolHolds returns the balances of the amm asset pair
|
||||
*
|
||||
* @param backend The backend to use
|
||||
* @param amendmentCenter The amendmentCenter to use
|
||||
* @param sequence The sequence number to use
|
||||
* @param ammAccountID The amm account
|
||||
* @param issue1 The first issue
|
||||
@@ -48,6 +50,7 @@ namespace rpc {
|
||||
std::pair<ripple::STAmount, ripple::STAmount>
|
||||
getAmmPoolHolds(
|
||||
BackendInterface const& backend,
|
||||
data::AmendmentCenterInterface const& amendmentCenter,
|
||||
std::uint32_t sequence,
|
||||
ripple::AccountID const& ammAccountID,
|
||||
ripple::Issue const& issue1,
|
||||
|
||||
@@ -19,12 +19,15 @@
|
||||
|
||||
#include "rpc/RPCHelpers.hpp"
|
||||
|
||||
#include "data/AmendmentCenter.hpp"
|
||||
#include "data/AmendmentCenterInterface.hpp"
|
||||
#include "data/BackendInterface.hpp"
|
||||
#include "data/Types.hpp"
|
||||
#include "rpc/Errors.hpp"
|
||||
#include "rpc/JS.hpp"
|
||||
#include "rpc/common/Types.hpp"
|
||||
#include "util/AccountUtils.hpp"
|
||||
#include "util/Assert.hpp"
|
||||
#include "util/Profiler.hpp"
|
||||
#include "util/log/Logger.hpp"
|
||||
#include "web/Context.hpp"
|
||||
@@ -943,6 +946,20 @@ isFrozen(
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
isLPTokenFrozen(
|
||||
BackendInterface const& backend,
|
||||
std::uint32_t sequence,
|
||||
ripple::AccountID const& account,
|
||||
ripple::Issue const& asset,
|
||||
ripple::Issue const& asset2,
|
||||
boost::asio::yield_context yield
|
||||
)
|
||||
{
|
||||
return isFrozen(backend, sequence, account, asset.currency, asset.account, yield) ||
|
||||
isFrozen(backend, sequence, account, asset2.currency, asset2.account, yield);
|
||||
}
|
||||
|
||||
ripple::XRPAmount
|
||||
xrpLiquid(
|
||||
BackendInterface const& backend,
|
||||
@@ -981,6 +998,7 @@ xrpLiquid(
|
||||
ripple::STAmount
|
||||
accountFunds(
|
||||
BackendInterface const& backend,
|
||||
data::AmendmentCenterInterface const& amendmentCenter,
|
||||
std::uint32_t const sequence,
|
||||
ripple::STAmount const& amount,
|
||||
ripple::AccountID const& id,
|
||||
@@ -991,11 +1009,11 @@ accountFunds(
|
||||
return amount;
|
||||
}
|
||||
|
||||
return accountHolds(backend, sequence, id, amount.getCurrency(), amount.getIssuer(), true, yield);
|
||||
return accountHolds(backend, amendmentCenter, sequence, id, amount.getCurrency(), amount.getIssuer(), true, yield);
|
||||
}
|
||||
|
||||
ripple::STAmount
|
||||
accountHolds(
|
||||
ammAccountHolds(
|
||||
BackendInterface const& backend,
|
||||
std::uint32_t sequence,
|
||||
ripple::AccountID const& account,
|
||||
@@ -1006,6 +1024,7 @@ accountHolds(
|
||||
)
|
||||
{
|
||||
ripple::STAmount amount;
|
||||
ASSERT(!ripple::isXRP(currency), "LPToken currency can never be XRP");
|
||||
if (ripple::isXRP(currency))
|
||||
return {xrpLiquid(backend, sequence, account, yield)};
|
||||
|
||||
@@ -1036,6 +1055,91 @@ accountHolds(
|
||||
return amount;
|
||||
}
|
||||
|
||||
ripple::STAmount
|
||||
accountHolds(
|
||||
BackendInterface const& backend,
|
||||
data::AmendmentCenterInterface const& amendmentCenter,
|
||||
std::uint32_t sequence,
|
||||
ripple::AccountID const& account,
|
||||
ripple::Currency const& currency,
|
||||
ripple::AccountID const& issuer,
|
||||
bool const zeroIfFrozen,
|
||||
boost::asio::yield_context yield
|
||||
)
|
||||
{
|
||||
ripple::STAmount amount;
|
||||
if (ripple::isXRP(currency))
|
||||
return {xrpLiquid(backend, sequence, account, yield)};
|
||||
|
||||
auto const key = ripple::keylet::line(account, issuer, currency).key;
|
||||
auto const blob = backend.fetchLedgerObject(key, sequence, yield);
|
||||
|
||||
if (!blob) {
|
||||
amount.setIssue(ripple::Issue(currency, issuer));
|
||||
amount.clear();
|
||||
return amount;
|
||||
}
|
||||
|
||||
auto const allowBalance = [&]() {
|
||||
if (!zeroIfFrozen)
|
||||
return true;
|
||||
|
||||
if (isFrozen(backend, sequence, account, currency, issuer, yield))
|
||||
return false;
|
||||
|
||||
if (amendmentCenter.isEnabled(yield, data::Amendments::fixFrozenLPTokenTransfer, sequence)) {
|
||||
auto const issuerBlob = backend.fetchLedgerObject(ripple::keylet::account(issuer).key, sequence, yield);
|
||||
|
||||
if (!issuerBlob)
|
||||
return false;
|
||||
|
||||
ripple::SLE const issuerSle{
|
||||
ripple::SerialIter{issuerBlob->data(), issuerBlob->size()}, ripple::keylet::account(issuer).key
|
||||
};
|
||||
|
||||
// if the issuer is an amm account, then currency is lptoken, so we will need to check if the
|
||||
// assets in the pool are frozen as well
|
||||
if (issuerSle.isFieldPresent(ripple::sfAMMID)) {
|
||||
auto const ammKeylet = ripple::keylet::amm(issuerSle[ripple::sfAMMID]);
|
||||
auto const ammBlob = backend.fetchLedgerObject(ammKeylet.key, sequence, yield);
|
||||
|
||||
if (!ammBlob)
|
||||
return false;
|
||||
|
||||
ripple::SLE const ammSle{ripple::SerialIter{ammBlob->data(), ammBlob->size()}, ammKeylet.key};
|
||||
|
||||
return !isLPTokenFrozen(
|
||||
backend,
|
||||
sequence,
|
||||
account,
|
||||
ammSle[ripple::sfAsset].get<ripple::Issue>(),
|
||||
ammSle[ripple::sfAsset2].get<ripple::Issue>(),
|
||||
yield
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}();
|
||||
|
||||
if (allowBalance) {
|
||||
ripple::SerialIter it{blob->data(), blob->size()};
|
||||
ripple::SLE const sle{it, key};
|
||||
|
||||
amount = sle.getFieldAmount(ripple::sfBalance);
|
||||
if (account > issuer) {
|
||||
// Put balance in account terms.
|
||||
amount.negate();
|
||||
}
|
||||
amount.setIssuer(issuer);
|
||||
} else {
|
||||
amount.setIssue(ripple::Issue(currency, issuer));
|
||||
amount.clear();
|
||||
}
|
||||
|
||||
return amount;
|
||||
}
|
||||
|
||||
ripple::Rate
|
||||
transferRate(
|
||||
BackendInterface const& backend,
|
||||
@@ -1064,6 +1168,7 @@ postProcessOrderBook(
|
||||
ripple::Book const& book,
|
||||
ripple::AccountID const& takerID,
|
||||
data::BackendInterface const& backend,
|
||||
data::AmendmentCenterInterface const& amendmentCenter,
|
||||
std::uint32_t const ledgerSequence,
|
||||
boost::asio::yield_context yield
|
||||
)
|
||||
@@ -1106,7 +1211,14 @@ postProcessOrderBook(
|
||||
firstOwnerOffer = false;
|
||||
} else {
|
||||
saOwnerFunds = accountHolds(
|
||||
backend, ledgerSequence, uOfferOwnerID, book.out.currency, book.out.account, true, yield
|
||||
backend,
|
||||
amendmentCenter,
|
||||
ledgerSequence,
|
||||
uOfferOwnerID,
|
||||
book.out.currency,
|
||||
book.out.account,
|
||||
true,
|
||||
yield
|
||||
);
|
||||
|
||||
if (saOwnerFunds < beast::zero)
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
* This file contains a variety of utility functions used when executing the handlers.
|
||||
*/
|
||||
|
||||
#include "data/AmendmentCenterInterface.hpp"
|
||||
#include "data/BackendInterface.hpp"
|
||||
#include "data/Types.hpp"
|
||||
#include "rpc/Errors.hpp"
|
||||
@@ -427,10 +428,32 @@ isFrozen(
|
||||
boost::asio::yield_context yield
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Whether the account that owns a LPToken is frozen for the assets in the pool
|
||||
*
|
||||
* @param backend The backend to use
|
||||
* @param sequence The sequence
|
||||
* @param account The account
|
||||
* @param asset The first asset in the pool
|
||||
* @param asset2 The second asset in the pool
|
||||
* @param yield The coroutine context
|
||||
* @return true if account is frozen for one of the assets
|
||||
*/
|
||||
bool
|
||||
isLPTokenFrozen(
|
||||
BackendInterface const& backend,
|
||||
std::uint32_t sequence,
|
||||
ripple::AccountID const& account,
|
||||
ripple::Issue const& asset,
|
||||
ripple::Issue const& asset2,
|
||||
boost::asio::yield_context yield
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Get the account funds
|
||||
*
|
||||
* @param backend The backend to use
|
||||
* @param amendmentCenter The amendmentCenter to use
|
||||
* @param sequence The sequence
|
||||
* @param amount The amount
|
||||
* @param id The account ID
|
||||
@@ -440,6 +463,7 @@ isFrozen(
|
||||
ripple::STAmount
|
||||
accountFunds(
|
||||
BackendInterface const& backend,
|
||||
data::AmendmentCenterInterface const& amendmentCenter,
|
||||
std::uint32_t sequence,
|
||||
ripple::STAmount const& amount,
|
||||
ripple::AccountID const& id,
|
||||
@@ -450,6 +474,7 @@ accountFunds(
|
||||
* @brief Get the amount that an account holds
|
||||
*
|
||||
* @param backend The backend to use
|
||||
* @param amendmentCenter The amendmentCenter to use
|
||||
* @param sequence The sequence
|
||||
* @param account The account
|
||||
* @param currency The currency
|
||||
@@ -461,6 +486,7 @@ accountFunds(
|
||||
ripple::STAmount
|
||||
accountHolds(
|
||||
BackendInterface const& backend,
|
||||
data::AmendmentCenterInterface const& amendmentCenter,
|
||||
std::uint32_t sequence,
|
||||
ripple::AccountID const& account,
|
||||
ripple::Currency const& currency,
|
||||
@@ -469,6 +495,29 @@ accountHolds(
|
||||
boost::asio::yield_context yield
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Get the amount that an LPToken owner holds
|
||||
*
|
||||
* @param backend The backend to use
|
||||
* @param sequence The sequence
|
||||
* @param account The account
|
||||
* @param currency The currency
|
||||
* @param issuer The issuer
|
||||
* @param zeroIfFrozen Whether to return zero if frozen
|
||||
* @param yield The coroutine context
|
||||
* @return The amount account holds
|
||||
*/
|
||||
ripple::STAmount
|
||||
ammAccountHolds(
|
||||
BackendInterface const& backend,
|
||||
std::uint32_t sequence,
|
||||
ripple::AccountID const& account,
|
||||
ripple::Currency const& currency,
|
||||
ripple::AccountID const& issuer,
|
||||
bool const zeroIfFrozen,
|
||||
boost::asio::yield_context yield
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Get the transfer rate
|
||||
*
|
||||
@@ -510,6 +559,7 @@ xrpLiquid(
|
||||
* @param book The book
|
||||
* @param takerID The taker ID
|
||||
* @param backend The backend to use
|
||||
* @param amendmentCenter The amendmentCenter to use
|
||||
* @param ledgerSequence The ledger sequence
|
||||
* @param yield The coroutine context
|
||||
* @return The post processed order book
|
||||
@@ -520,6 +570,7 @@ postProcessOrderBook(
|
||||
ripple::Book const& book,
|
||||
ripple::AccountID const& takerID,
|
||||
data::BackendInterface const& backend,
|
||||
data::AmendmentCenterInterface const& amendmentCenter,
|
||||
std::uint32_t ledgerSequence,
|
||||
boost::asio::yield_context yield
|
||||
);
|
||||
|
||||
@@ -86,14 +86,14 @@ ProductionHandlerProvider::ProductionHandlerProvider(
|
||||
{"account_objects", {.handler = AccountObjectsHandler{backend}}},
|
||||
{"account_offers", {.handler = AccountOffersHandler{backend}}},
|
||||
{"account_tx", {.handler = AccountTxHandler{backend}}},
|
||||
{"amm_info", {.handler = AMMInfoHandler{backend}}},
|
||||
{"amm_info", {.handler = AMMInfoHandler{backend, amendmentCenter}}},
|
||||
{"book_changes", {.handler = BookChangesHandler{backend}}},
|
||||
{"book_offers", {.handler = BookOffersHandler{backend}}},
|
||||
{"book_offers", {.handler = BookOffersHandler{backend, amendmentCenter}}},
|
||||
{"deposit_authorized", {.handler = DepositAuthorizedHandler{backend}}},
|
||||
{"feature", {.handler = FeatureHandler{backend, amendmentCenter}}},
|
||||
{"gateway_balances", {.handler = GatewayBalancesHandler{backend}}},
|
||||
{"get_aggregate_price", {.handler = GetAggregatePriceHandler{backend}}},
|
||||
{"ledger", {.handler = LedgerHandler{backend}}},
|
||||
{"ledger", {.handler = LedgerHandler{backend, amendmentCenter}}},
|
||||
{"ledger_data", {.handler = LedgerDataHandler{backend}}},
|
||||
{"ledger_entry", {.handler = LedgerEntryHandler{backend}}},
|
||||
{"ledger_index", {.handler = LedgerIndexHandler{backend}, .isClioOnly = true}}, // clio only
|
||||
@@ -110,7 +110,7 @@ ProductionHandlerProvider::ProductionHandlerProvider(
|
||||
{"server_info", {.handler = ServerInfoHandler{backend, subscriptionManager, balancer, etl, counters}}},
|
||||
{"transaction_entry", {.handler = TransactionEntryHandler{backend}}},
|
||||
{"tx", {.handler = TxHandler{backend, etl}}},
|
||||
{"subscribe", {.handler = SubscribeHandler{backend, subscriptionManager}}},
|
||||
{"subscribe", {.handler = SubscribeHandler{backend, amendmentCenter, subscriptionManager}}},
|
||||
{"unsubscribe", {.handler = UnsubscribeHandler{subscriptionManager}}},
|
||||
{"version", {.handler = VersionHandler{config}}},
|
||||
}
|
||||
|
||||
@@ -149,8 +149,9 @@ AMMInfoHandler::process(AMMInfoHandler::Input input, Context const& ctx) const
|
||||
issue2 = amm[sfAsset2].get<Issue>();
|
||||
}
|
||||
|
||||
auto const [asset1Balance, asset2Balance] =
|
||||
getAmmPoolHolds(*sharedPtrBackend_, lgrInfo.seq, ammAccountID, issue1, issue2, false, ctx.yield);
|
||||
auto const [asset1Balance, asset2Balance] = getAmmPoolHolds(
|
||||
*sharedPtrBackend_, *amendmentCenter_, lgrInfo.seq, ammAccountID, issue1, issue2, false, ctx.yield
|
||||
);
|
||||
auto const lptAMMBalance = input.accountID
|
||||
? getAmmLpHolds(*sharedPtrBackend_, lgrInfo.seq, amm, *input.accountID, ctx.yield)
|
||||
: amm[sfLPTokenBalance];
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "data/AmendmentCenterInterface.hpp"
|
||||
#include "data/BackendInterface.hpp"
|
||||
#include "rpc/common/Specs.hpp"
|
||||
|
||||
@@ -42,6 +43,7 @@ namespace rpc {
|
||||
*/
|
||||
class AMMInfoHandler {
|
||||
std::shared_ptr<BackendInterface> sharedPtrBackend_;
|
||||
std::shared_ptr<data::AmendmentCenterInterface const> amendmentCenter_;
|
||||
|
||||
public:
|
||||
/**
|
||||
@@ -82,8 +84,13 @@ public:
|
||||
* @brief Construct a new AMMInfoHandler object
|
||||
*
|
||||
* @param sharedPtrBackend The backend to use
|
||||
* @param amendmentCenter The amendmentCenter to use
|
||||
*/
|
||||
AMMInfoHandler(std::shared_ptr<BackendInterface> const& sharedPtrBackend) : sharedPtrBackend_(sharedPtrBackend)
|
||||
AMMInfoHandler(
|
||||
std::shared_ptr<BackendInterface> const& sharedPtrBackend,
|
||||
std::shared_ptr<data::AmendmentCenterInterface const> const& amendmentCenter
|
||||
)
|
||||
: sharedPtrBackend_(sharedPtrBackend), amendmentCenter_{amendmentCenter}
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +72,13 @@ BookOffersHandler::process(Input input, Context const& ctx) const
|
||||
output.ledgerHash = ripple::strHex(lgrInfo.hash);
|
||||
output.ledgerIndex = lgrInfo.seq;
|
||||
output.offers = postProcessOrderBook(
|
||||
offers, book, input.taker ? *(input.taker) : beast::zero, *sharedPtrBackend_, lgrInfo.seq, ctx.yield
|
||||
offers,
|
||||
book,
|
||||
input.taker ? *(input.taker) : beast::zero,
|
||||
*sharedPtrBackend_,
|
||||
*amendmentCenter_,
|
||||
lgrInfo.seq,
|
||||
ctx.yield
|
||||
);
|
||||
|
||||
return output;
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "data/AmendmentCenterInterface.hpp"
|
||||
#include "data/BackendInterface.hpp"
|
||||
#include "rpc/Errors.hpp"
|
||||
#include "rpc/JS.hpp"
|
||||
@@ -51,6 +52,7 @@ namespace rpc {
|
||||
*/
|
||||
class BookOffersHandler {
|
||||
std::shared_ptr<BackendInterface> sharedPtrBackend_;
|
||||
std::shared_ptr<data::AmendmentCenterInterface const> amendmentCenter_;
|
||||
|
||||
public:
|
||||
static constexpr auto kLIMIT_MIN = 1;
|
||||
@@ -91,8 +93,13 @@ public:
|
||||
* @brief Construct a new BookOffersHandler object
|
||||
*
|
||||
* @param sharedPtrBackend The backend to use
|
||||
* @param amendmentCenter The amendmentCenter to use
|
||||
*/
|
||||
BookOffersHandler(std::shared_ptr<BackendInterface> const& sharedPtrBackend) : sharedPtrBackend_(sharedPtrBackend)
|
||||
BookOffersHandler(
|
||||
std::shared_ptr<BackendInterface> const& sharedPtrBackend,
|
||||
std::shared_ptr<data::AmendmentCenterInterface const> const& amendmentCenter
|
||||
)
|
||||
: sharedPtrBackend_(sharedPtrBackend), amendmentCenter_{amendmentCenter}
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -134,6 +134,7 @@ LedgerHandler::process(LedgerHandler::Input input, Context const& ctx) const
|
||||
if (account != amount.getIssuer()) {
|
||||
auto const ownerFunds = accountHolds(
|
||||
*sharedPtrBackend_,
|
||||
*amendmentCenter_,
|
||||
lgrInfo.seq,
|
||||
account,
|
||||
amount.getCurrency(),
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "data/AmendmentCenterInterface.hpp"
|
||||
#include "data/BackendInterface.hpp"
|
||||
#include "rpc/JS.hpp"
|
||||
#include "rpc/common/Checkers.hpp"
|
||||
@@ -45,6 +46,7 @@ namespace rpc {
|
||||
*/
|
||||
class LedgerHandler {
|
||||
std::shared_ptr<BackendInterface> sharedPtrBackend_;
|
||||
std::shared_ptr<data::AmendmentCenterInterface const> amendmentCenter_;
|
||||
|
||||
public:
|
||||
/**
|
||||
@@ -89,8 +91,13 @@ public:
|
||||
* @brief Construct a new LedgerHandler object
|
||||
*
|
||||
* @param sharedPtrBackend The backend to use
|
||||
* @param amendmentCenter The amendmentCenter to use
|
||||
*/
|
||||
LedgerHandler(std::shared_ptr<BackendInterface> const& sharedPtrBackend) : sharedPtrBackend_(sharedPtrBackend)
|
||||
LedgerHandler(
|
||||
std::shared_ptr<BackendInterface> const& sharedPtrBackend,
|
||||
std::shared_ptr<data::AmendmentCenterInterface const> amendmentCenter
|
||||
)
|
||||
: sharedPtrBackend_(sharedPtrBackend), amendmentCenter_(amendmentCenter)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -55,9 +55,10 @@ namespace rpc {
|
||||
|
||||
SubscribeHandler::SubscribeHandler(
|
||||
std::shared_ptr<BackendInterface> const& sharedPtrBackend,
|
||||
std::shared_ptr<data::AmendmentCenterInterface const> const& amendmentCenter,
|
||||
std::shared_ptr<feed::SubscriptionManagerInterface> const& subscriptions
|
||||
)
|
||||
: sharedPtrBackend_(sharedPtrBackend), subscriptions_(subscriptions)
|
||||
: sharedPtrBackend_(sharedPtrBackend), amendmentCenter_(amendmentCenter), subscriptions_(subscriptions)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -216,8 +217,9 @@ SubscribeHandler::subscribeToBooks(
|
||||
// https://github.com/XRPLF/xrpl-dev-portal/issues/1818
|
||||
auto const takerID = internalBook.taker ? accountFromStringStrict(*(internalBook.taker)) : beast::zero;
|
||||
|
||||
auto const orderBook =
|
||||
postProcessOrderBook(offers, book, *takerID, *sharedPtrBackend_, rng->maxSequence, yield);
|
||||
auto const orderBook = postProcessOrderBook(
|
||||
offers, book, *takerID, *sharedPtrBackend_, *amendmentCenter_, rng->maxSequence, yield
|
||||
);
|
||||
std::copy(orderBook.begin(), orderBook.end(), std::back_inserter(snapshots));
|
||||
};
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "data/AmendmentCenterInterface.hpp"
|
||||
#include "data/BackendInterface.hpp"
|
||||
#include "feed/SubscriptionManagerInterface.hpp"
|
||||
#include "feed/Types.hpp"
|
||||
@@ -53,6 +54,7 @@ namespace rpc {
|
||||
|
||||
class SubscribeHandler {
|
||||
std::shared_ptr<BackendInterface> sharedPtrBackend_;
|
||||
std::shared_ptr<data::AmendmentCenterInterface const> amendmentCenter_;
|
||||
std::shared_ptr<feed::SubscriptionManagerInterface> subscriptions_;
|
||||
|
||||
public:
|
||||
@@ -98,10 +100,12 @@ public:
|
||||
* @brief Construct a new BaseSubscribeHandler object
|
||||
*
|
||||
* @param sharedPtrBackend The backend to use
|
||||
* @param amendmentCenter The amendmentCenter to use
|
||||
* @param subscriptions The subscription manager to use
|
||||
*/
|
||||
SubscribeHandler(
|
||||
std::shared_ptr<BackendInterface> const& sharedPtrBackend,
|
||||
std::shared_ptr<data::AmendmentCenterInterface const> const& amendmentCenter,
|
||||
std::shared_ptr<feed::SubscriptionManagerInterface> const& subscriptions
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user