mirror of
https://github.com/XRPLF/rippled.git
synced 2026-06-02 08:17:13 +00:00
refactor: Decouple app/tx from Application and Config (#6227)
This change decouples app/tx from `Application` and `Config` to clear the way to moving transactors to `libxrpl`.
This commit is contained in:
@@ -83,6 +83,7 @@ test.csf > xrpl.protocol
|
||||
test.json > test.jtx
|
||||
test.json > xrpl.json
|
||||
test.jtx > xrpl.basics
|
||||
test.jtx > xrpl.core
|
||||
test.jtx > xrpld.app
|
||||
test.jtx > xrpld.core
|
||||
test.jtx > xrpld.rpc
|
||||
|
||||
33
include/xrpl/core/NetworkIDService.h
Normal file
33
include/xrpl/core/NetworkIDService.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
/** Service that provides access to the network ID.
|
||||
|
||||
This service provides read-only access to the network ID configured
|
||||
for this server. The network ID identifies which network (mainnet,
|
||||
testnet, devnet, or custom network) this server is configured to
|
||||
connect to.
|
||||
|
||||
Well-known network IDs:
|
||||
- 0: Mainnet
|
||||
- 1: Testnet
|
||||
- 2: Devnet
|
||||
- 1025+: Custom networks (require NetworkID field in transactions)
|
||||
*/
|
||||
class NetworkIDService
|
||||
{
|
||||
public:
|
||||
virtual ~NetworkIDService() = default;
|
||||
|
||||
/** Get the configured network ID
|
||||
*
|
||||
* @return The network ID this server is configured for
|
||||
*/
|
||||
virtual std::uint32_t
|
||||
getNetworkID() const noexcept = 0;
|
||||
};
|
||||
|
||||
} // namespace xrpl
|
||||
@@ -41,6 +41,7 @@ class LoadFeeTrack;
|
||||
class LoadManager;
|
||||
class ManifestCache;
|
||||
class NetworkOPs;
|
||||
class NetworkIDService;
|
||||
class OpenLedger;
|
||||
class OrderBookDB;
|
||||
class Overlay;
|
||||
@@ -99,6 +100,9 @@ public:
|
||||
virtual CachedSLEs&
|
||||
cachedSLEs() = 0;
|
||||
|
||||
virtual NetworkIDService&
|
||||
getNetworkIDService() = 0;
|
||||
|
||||
// Protocol and validation services
|
||||
virtual AmendmentTable&
|
||||
getAmendmentTable() = 0;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <test/jtx.h>
|
||||
#include <test/jtx/Env.h>
|
||||
|
||||
#include <xrpl/core/NetworkIDService.h>
|
||||
#include <xrpl/protocol/jss.h>
|
||||
|
||||
namespace xrpl {
|
||||
@@ -58,7 +59,7 @@ public:
|
||||
// test mainnet
|
||||
{
|
||||
test::jtx::Env env{*this, makeNetworkConfig(0)};
|
||||
BEAST_EXPECT(env.app().config().NETWORK_ID == 0);
|
||||
BEAST_EXPECT(env.app().getNetworkIDService().getNetworkID() == 0);
|
||||
|
||||
// try to submit a txn without network id, this should work
|
||||
Json::Value jv;
|
||||
@@ -81,7 +82,7 @@ public:
|
||||
// NetworkID
|
||||
{
|
||||
test::jtx::Env env{*this, makeNetworkConfig(1024)};
|
||||
BEAST_EXPECT(env.app().config().NETWORK_ID == 1024);
|
||||
BEAST_EXPECT(env.app().getNetworkIDService().getNetworkID() == 1024);
|
||||
|
||||
// try to submit a txn without network id, this should work
|
||||
Json::Value jv;
|
||||
@@ -101,7 +102,7 @@ public:
|
||||
// absent networkid
|
||||
{
|
||||
test::jtx::Env env{*this, makeNetworkConfig(1025)};
|
||||
BEAST_EXPECT(env.app().config().NETWORK_ID == 1025);
|
||||
BEAST_EXPECT(env.app().getNetworkIDService().getNetworkID() == 1025);
|
||||
{
|
||||
env.fund(XRP(200), alice);
|
||||
// try to submit a txn without network id, this should not work
|
||||
|
||||
@@ -38,12 +38,8 @@ public:
|
||||
{
|
||||
test::jtx::Env fully_canonical(*this, test::jtx::testable_amendments());
|
||||
|
||||
Validity valid = checkValidity(
|
||||
fully_canonical.app().getHashRouter(),
|
||||
tx,
|
||||
fully_canonical.current()->rules(),
|
||||
fully_canonical.app().config())
|
||||
.first;
|
||||
Validity valid =
|
||||
checkValidity(fully_canonical.app().getHashRouter(), tx, fully_canonical.current()->rules()).first;
|
||||
if (valid == Validity::Valid)
|
||||
fail("Non-Fully canonical signature was permitted");
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <xrpl/basics/Slice.h>
|
||||
#include <xrpl/basics/contract.h>
|
||||
#include <xrpl/basics/scope.h>
|
||||
#include <xrpl/core/NetworkIDService.h>
|
||||
#include <xrpl/json/to_string.h>
|
||||
#include <xrpl/net/HTTPClient.h>
|
||||
#include <xrpl/protocol/ErrorCodes.h>
|
||||
@@ -526,7 +527,7 @@ Env::autofill(JTx& jt)
|
||||
|
||||
if (jt.fill_netid)
|
||||
{
|
||||
uint32_t networkID = app().config().NETWORK_ID;
|
||||
uint32_t networkID = app().getNetworkIDService().getNetworkID();
|
||||
if (!jv.isMember(jss::NetworkID) && networkID > 1024)
|
||||
jv[jss::NetworkID] = std::to_string(networkID);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <xrpld/core/ConfigSections.h>
|
||||
|
||||
#include <xrpl/beast/unit_test.h>
|
||||
#include <xrpl/core/NetworkIDService.h>
|
||||
#include <xrpl/json/json_value.h>
|
||||
#include <xrpl/protocol/Feature.h>
|
||||
#include <xrpl/protocol/jss.h>
|
||||
@@ -106,7 +107,7 @@ public:
|
||||
BEAST_EXPECT(jv.isMember(jss::id) && jv[jss::id] == 5);
|
||||
}
|
||||
BEAST_EXPECT(jv[jss::result][jss::ledger_index] == 2);
|
||||
BEAST_EXPECT(jv[jss::result][jss::network_id] == env.app().config().NETWORK_ID);
|
||||
BEAST_EXPECT(jv[jss::result][jss::network_id] == env.app().getNetworkIDService().getNetworkID());
|
||||
}
|
||||
|
||||
{
|
||||
@@ -115,7 +116,8 @@ public:
|
||||
|
||||
// Check stream update
|
||||
BEAST_EXPECT(wsc->findMsg(5s, [&](auto const& jv) {
|
||||
return jv[jss::ledger_index] == 3 && jv[jss::network_id] == env.app().config().NETWORK_ID;
|
||||
return jv[jss::ledger_index] == 3 &&
|
||||
jv[jss::network_id] == env.app().getNetworkIDService().getNetworkID();
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -125,7 +127,8 @@ public:
|
||||
|
||||
// Check stream update
|
||||
BEAST_EXPECT(wsc->findMsg(5s, [&](auto const& jv) {
|
||||
return jv[jss::ledger_index] == 4 && jv[jss::network_id] == env.app().config().NETWORK_ID;
|
||||
return jv[jss::ledger_index] == 4 &&
|
||||
jv[jss::network_id] == env.app().getNetworkIDService().getNetworkID();
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -451,7 +454,7 @@ public:
|
||||
if (!jv.isMember(jss::validated_hash))
|
||||
return false;
|
||||
|
||||
uint32_t netID = env.app().config().NETWORK_ID;
|
||||
uint32_t netID = env.app().getNetworkIDService().getNetworkID();
|
||||
if (!jv.isMember(jss::network_id) || jv[jss::network_id] != netID)
|
||||
return false;
|
||||
|
||||
@@ -510,7 +513,7 @@ public:
|
||||
jv[jss::streams][0u] = "ledger";
|
||||
jr = env.rpc("json", "subscribe", to_string(jv))[jss::result];
|
||||
BEAST_EXPECT(jr[jss::status] == "success");
|
||||
BEAST_EXPECT(jr[jss::network_id] == env.app().config().NETWORK_ID);
|
||||
BEAST_EXPECT(jr[jss::network_id] == env.app().getNetworkIDService().getNetworkID());
|
||||
|
||||
jr = env.rpc("json", "unsubscribe", to_string(jv))[jss::result];
|
||||
BEAST_EXPECT(jr[jss::status] == "success");
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <xrpld/app/rdb/backend/SQLiteDatabase.h>
|
||||
#include <xrpld/rpc/CTID.h>
|
||||
|
||||
#include <xrpl/core/NetworkIDService.h>
|
||||
#include <xrpl/protocol/ErrorCodes.h>
|
||||
#include <xrpl/protocol/STBase.h>
|
||||
#include <xrpl/protocol/jss.h>
|
||||
@@ -247,7 +248,7 @@ class Transaction_test : public beast::unit_test::suite
|
||||
char const* EXCESSIVE = RPC::get_error_info(rpcEXCESSIVE_LGR_RANGE).token;
|
||||
|
||||
Env env{*this, makeNetworkConfig(11111)};
|
||||
uint32_t netID = env.app().config().NETWORK_ID;
|
||||
uint32_t netID = env.app().getNetworkIDService().getNetworkID();
|
||||
|
||||
auto const alice = Account("alice");
|
||||
env.fund(XRP(1000), alice);
|
||||
@@ -520,7 +521,7 @@ class Transaction_test : public beast::unit_test::suite
|
||||
for (uint32_t netID : {11111, 65535, 65536})
|
||||
{
|
||||
Env env{*this, makeNetworkConfig(netID)};
|
||||
BEAST_EXPECT(netID == env.app().config().NETWORK_ID);
|
||||
BEAST_EXPECT(netID == env.app().getNetworkIDService().getNetworkID());
|
||||
|
||||
auto const alice = Account("alice");
|
||||
auto const bob = Account("bob");
|
||||
@@ -550,7 +551,7 @@ class Transaction_test : public beast::unit_test::suite
|
||||
// test querying with mixed case ctid
|
||||
{
|
||||
Env env{*this, makeNetworkConfig(11111)};
|
||||
std::uint32_t const netID = env.app().config().NETWORK_ID;
|
||||
std::uint32_t const netID = env.app().getNetworkIDService().getNetworkID();
|
||||
|
||||
Account const alice = Account("alice");
|
||||
Account const bob = Account("bob");
|
||||
@@ -591,7 +592,7 @@ class Transaction_test : public beast::unit_test::suite
|
||||
for (uint32_t netID : {2, 1024, 65535, 65536})
|
||||
{
|
||||
Env env{*this, makeNetworkConfig(netID)};
|
||||
BEAST_EXPECT(netID == env.app().config().NETWORK_ID);
|
||||
BEAST_EXPECT(netID == env.app().getNetworkIDService().getNetworkID());
|
||||
|
||||
auto const alice = Account("alice");
|
||||
auto const bob = Account("bob");
|
||||
@@ -623,7 +624,7 @@ class Transaction_test : public beast::unit_test::suite
|
||||
// test the wrong network ID was submitted
|
||||
{
|
||||
Env env{*this, makeNetworkConfig(21337)};
|
||||
uint32_t netID = env.app().config().NETWORK_ID;
|
||||
uint32_t netID = env.app().getNetworkIDService().getNetworkID();
|
||||
|
||||
auto const alice = Account("alice");
|
||||
auto const bob = Account("bob");
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <xrpld/app/ledger/Ledger.h>
|
||||
#include <xrpld/app/ledger/LedgerReplay.h>
|
||||
#include <xrpld/app/ledger/OpenLedger.h>
|
||||
#include <xrpld/app/main/Application.h>
|
||||
#include <xrpld/app/misc/CanonicalTXSet.h>
|
||||
#include <xrpld/app/tx/apply.h>
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <xrpld/app/paths/PathRequests.h>
|
||||
#include <xrpld/app/rdb/backend/SQLiteDatabase.h>
|
||||
#include <xrpld/app/tx/apply.h>
|
||||
#include <xrpld/core/NetworkIDServiceImpl.h>
|
||||
#include <xrpld/overlay/Cluster.h>
|
||||
#include <xrpld/overlay/PeerSet.h>
|
||||
#include <xrpld/overlay/make_Overlay.h>
|
||||
@@ -158,6 +159,7 @@ public:
|
||||
|
||||
NodeCache m_tempNodeCache;
|
||||
CachedSLEs cachedSLEs_;
|
||||
std::unique_ptr<NetworkIDService> networkIDService_;
|
||||
std::optional<std::pair<PublicKey, SecretKey>> nodeIdentity_;
|
||||
ValidatorKeys const validatorKeys_;
|
||||
|
||||
@@ -290,6 +292,8 @@ public:
|
||||
|
||||
, cachedSLEs_("Cached SLEs", 0, std::chrono::minutes(1), stopwatch(), logs_->journal("CachedSLEs"))
|
||||
|
||||
, networkIDService_(std::make_unique<NetworkIDServiceImpl>(config_->NETWORK_ID))
|
||||
|
||||
, validatorKeys_(*config_, m_journal)
|
||||
|
||||
, m_resourceManager(Resource::make_Manager(m_collectorManager->collector(), logs_->journal("Resource")))
|
||||
@@ -632,6 +636,12 @@ public:
|
||||
return cachedSLEs_;
|
||||
}
|
||||
|
||||
NetworkIDService&
|
||||
getNetworkIDService() override
|
||||
{
|
||||
return *networkIDService_;
|
||||
}
|
||||
|
||||
AmendmentTable&
|
||||
getAmendmentTable() override
|
||||
{
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include <xrpl/basics/scope.h>
|
||||
#include <xrpl/beast/utility/rngfill.h>
|
||||
#include <xrpl/core/HashRouter.h>
|
||||
#include <xrpl/core/NetworkIDService.h>
|
||||
#include <xrpl/core/PerfLog.h>
|
||||
#include <xrpl/crypto/RFC1751.h>
|
||||
#include <xrpl/crypto/csprng.h>
|
||||
@@ -1101,8 +1102,8 @@ NetworkOPsImp::submitTransaction(std::shared_ptr<STTx const> const& iTrans)
|
||||
|
||||
try
|
||||
{
|
||||
auto const [validity, reason] = checkValidity(
|
||||
registry_.getHashRouter(), *trans, m_ledgerMaster.getValidatedRules(), registry_.app().config());
|
||||
auto const [validity, reason] =
|
||||
checkValidity(registry_.getHashRouter(), *trans, m_ledgerMaster.getValidatedRules());
|
||||
|
||||
if (validity != Validity::Valid)
|
||||
{
|
||||
@@ -1158,8 +1159,7 @@ NetworkOPsImp::preProcessTransaction(std::shared_ptr<Transaction>& transaction)
|
||||
// NOTE ximinez - I think this check is redundant,
|
||||
// but I'm not 100% sure yet.
|
||||
// If so, only cost is looking up HashRouter flags.
|
||||
auto const [validity, reason] =
|
||||
checkValidity(registry_.getHashRouter(), sttx, view->rules(), registry_.app().config());
|
||||
auto const [validity, reason] = checkValidity(registry_.getHashRouter(), sttx, view->rules());
|
||||
XRPL_ASSERT(validity == Validity::Valid, "xrpl::NetworkOPsImp::processTransaction : valid validity");
|
||||
|
||||
// Not concerned with local checks at this point.
|
||||
@@ -2195,7 +2195,7 @@ NetworkOPsImp::pubValidation(std::shared_ptr<STValidation> const& val)
|
||||
jvObj[jss::flags] = val->getFlags();
|
||||
jvObj[jss::signing_time] = *(*val)[~sfSigningTime];
|
||||
jvObj[jss::data] = strHex(val->getSerializer().slice());
|
||||
jvObj[jss::network_id] = registry_.app().config().NETWORK_ID;
|
||||
jvObj[jss::network_id] = registry_.getNetworkIDService().getNetworkID();
|
||||
|
||||
if (auto version = (*val)[~sfServerVersion])
|
||||
jvObj[jss::server_version] = std::to_string(*version);
|
||||
@@ -2844,7 +2844,7 @@ NetworkOPsImp::pubLedger(std::shared_ptr<ReadView const> const& lpAccepted)
|
||||
jvObj[jss::ledger_hash] = to_string(lpAccepted->header().hash);
|
||||
jvObj[jss::ledger_time] = Json::Value::UInt(lpAccepted->header().closeTime.time_since_epoch().count());
|
||||
|
||||
jvObj[jss::network_id] = registry_.app().config().NETWORK_ID;
|
||||
jvObj[jss::network_id] = registry_.getNetworkIDService().getNetworkID();
|
||||
|
||||
if (!lpAccepted->rules().enabled(featureXRPFees))
|
||||
jvObj[jss::fee_ref] = Config::FEE_UNITS_DEPRECATED;
|
||||
@@ -2987,7 +2987,7 @@ NetworkOPsImp::transJson(
|
||||
lookup.second && lookup.second->isFieldPresent(sfTransactionIndex))
|
||||
{
|
||||
uint32_t const txnSeq = lookup.second->getFieldU32(sfTransactionIndex);
|
||||
uint32_t netID = registry_.app().config().NETWORK_ID;
|
||||
uint32_t netID = registry_.getNetworkIDService().getNetworkID();
|
||||
if (transaction->isFieldPresent(sfNetworkID))
|
||||
netID = transaction->getFieldU32(sfNetworkID);
|
||||
|
||||
@@ -3817,7 +3817,7 @@ NetworkOPsImp::subLedger(InfoSub::ref isrListener, Json::Value& jvResult)
|
||||
jvResult[jss::fee_base] = lpClosed->fees().base.jsonClipped();
|
||||
jvResult[jss::reserve_base] = lpClosed->fees().reserve.jsonClipped();
|
||||
jvResult[jss::reserve_inc] = lpClosed->fees().increment.jsonClipped();
|
||||
jvResult[jss::network_id] = registry_.app().config().NETWORK_ID;
|
||||
jvResult[jss::network_id] = registry_.getNetworkIDService().getNetworkID();
|
||||
}
|
||||
|
||||
if ((mMode >= OperatingMode::SYNCING) && !isNeedNetworkLedger())
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <xrpld/app/misc/Transaction.h>
|
||||
#include <xrpld/app/misc/detail/AccountTxPaging.h>
|
||||
|
||||
#include <xrpl/core/NetworkIDService.h>
|
||||
#include <xrpl/protocol/Serializer.h>
|
||||
|
||||
namespace xrpl {
|
||||
@@ -30,7 +31,7 @@ convertBlobsToTxResult(
|
||||
Transaction::sqlTransactionStatus(status),
|
||||
ledger_index,
|
||||
metaset->getAsObject().getFieldU32(sfTransactionIndex),
|
||||
app.config().NETWORK_ID);
|
||||
app.getNetworkIDService().getNetworkID());
|
||||
else
|
||||
tr->setStatus(Transaction::sqlTransactionStatus(status), ledger_index);
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#ifndef XRPLD_APP_MISC_SETUP_HASHROUTER_H_INCLUDED
|
||||
#define XRPLD_APP_MISC_SETUP_HASHROUTER_H_INCLUDED
|
||||
#pragma once
|
||||
|
||||
#include <xrpl/core/HashRouter.h>
|
||||
|
||||
@@ -13,5 +12,3 @@ HashRouter::Setup
|
||||
setup_HashRouter(Config const& config);
|
||||
|
||||
} // namespace xrpl
|
||||
|
||||
#endif
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include <xrpl/basics/BasicConfig.h>
|
||||
#include <xrpl/basics/StringUtilities.h>
|
||||
#include <xrpl/core/NetworkIDService.h>
|
||||
#include <xrpl/json/to_string.h>
|
||||
#include <xrpl/rdb/DatabaseCon.h>
|
||||
#include <xrpl/rdb/RelationalDatabase.h>
|
||||
@@ -306,7 +307,7 @@ saveValidatedLedger(
|
||||
acceptedLedgerTx->getTxn()->getMetaSQL(seq, acceptedLedgerTx->getEscMeta()) + ";");
|
||||
|
||||
app.getMasterTransaction().inLedger(
|
||||
transactionID, seq, acceptedLedgerTx->getTxnSeq(), app.config().NETWORK_ID);
|
||||
transactionID, seq, acceptedLedgerTx->getTxnSeq(), app.getNetworkIDService().getNetworkID());
|
||||
}
|
||||
|
||||
tr.commit();
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
class Application;
|
||||
class HashRouter;
|
||||
class ServiceRegistry;
|
||||
|
||||
/** Describes the pre-processing validity of a transaction.
|
||||
|
||||
@@ -41,7 +41,7 @@ enum class Validity {
|
||||
@see Validity
|
||||
*/
|
||||
std::pair<Validity, std::string>
|
||||
checkValidity(HashRouter& router, STTx const& tx, Rules const& rules, Config const& config);
|
||||
checkValidity(HashRouter& router, STTx const& tx, Rules const& rules);
|
||||
|
||||
/** Sets the validity of a given transaction in the cache.
|
||||
|
||||
@@ -97,7 +97,7 @@ forceValidity(HashRouter& router, uint256 const& txid, Validity validity);
|
||||
whether or not the transaction was applied.
|
||||
*/
|
||||
ApplyResult
|
||||
apply(Application& app, OpenView& view, STTx const& tx, ApplyFlags flags, beast::Journal journal);
|
||||
apply(ServiceRegistry& registry, OpenView& view, STTx const& tx, ApplyFlags flags, beast::Journal journal);
|
||||
|
||||
/** Enum class for return value from `applyTransaction`
|
||||
|
||||
@@ -121,7 +121,7 @@ enum class ApplyTransactionResult {
|
||||
*/
|
||||
ApplyTransactionResult
|
||||
applyTransaction(
|
||||
Application& app,
|
||||
ServiceRegistry& registry,
|
||||
OpenView& view,
|
||||
STTx const& tx,
|
||||
bool retryAssured,
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
class Application;
|
||||
class ServiceRegistry;
|
||||
class STTx;
|
||||
class TxQ;
|
||||
|
||||
@@ -240,11 +240,11 @@ public:
|
||||
*/
|
||||
/** @{ */
|
||||
PreflightResult
|
||||
preflight(Application& app, Rules const& rules, STTx const& tx, ApplyFlags flags, beast::Journal j);
|
||||
preflight(ServiceRegistry& registry, Rules const& rules, STTx const& tx, ApplyFlags flags, beast::Journal j);
|
||||
|
||||
PreflightResult
|
||||
preflight(
|
||||
Application& app,
|
||||
ServiceRegistry& registry,
|
||||
Rules const& rules,
|
||||
uint256 const& parentBatchId,
|
||||
STTx const& tx,
|
||||
@@ -281,7 +281,7 @@ preflight(
|
||||
this transaction.
|
||||
*/
|
||||
PreclaimResult
|
||||
preclaim(PreflightResult const& preflightResult, Application& app, OpenView const& view);
|
||||
preclaim(PreflightResult const& preflightResult, ServiceRegistry& registry, OpenView const& view);
|
||||
|
||||
/** Compute only the expected base fee for a transaction.
|
||||
|
||||
@@ -323,7 +323,7 @@ calculateDefaultBaseFee(ReadView const& view, STTx const& tx);
|
||||
|
||||
@param preclaimResult The result of a previous
|
||||
call to `preclaim` for the transaction.
|
||||
@param app The current running `Application`.
|
||||
@param registry The service registry.
|
||||
@param view The open ledger that the transaction
|
||||
will attempt to be applied to.
|
||||
|
||||
@@ -333,6 +333,6 @@ calculateDefaultBaseFee(ReadView const& view, STTx const& tx);
|
||||
whether or not the transaction was applied.
|
||||
*/
|
||||
ApplyResult
|
||||
doApply(PreclaimResult const& preclaimResult, Application& app, OpenView& view);
|
||||
doApply(PreclaimResult const& preclaimResult, ServiceRegistry& registry, OpenView& view);
|
||||
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -272,7 +272,7 @@ applyCreate(ApplyContext& ctx_, Sandbox& sb, AccountID const& account_, beast::J
|
||||
Book const book{issueIn, issueOut, std::nullopt};
|
||||
auto const dir = keylet::quality(keylet::book(book), uRate);
|
||||
if (auto const bookExisted = static_cast<bool>(sb.read(dir)); !bookExisted)
|
||||
ctx_.app.getOrderBookDB().addOrderBook(book);
|
||||
ctx_.registry.getOrderBookDB().addOrderBook(book);
|
||||
};
|
||||
addOrderBook(amount.issue(), amount2.issue(), getRate(amount2, amount));
|
||||
addOrderBook(amount2.issue(), amount.issue(), getRate(amount, amount2));
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
namespace xrpl {
|
||||
|
||||
ApplyContext::ApplyContext(
|
||||
Application& app_,
|
||||
ServiceRegistry& registry_,
|
||||
OpenView& base,
|
||||
std::optional<uint256 const> const& parentBatchId,
|
||||
STTx const& tx_,
|
||||
@@ -16,7 +16,7 @@ ApplyContext::ApplyContext(
|
||||
XRPAmount baseFee_,
|
||||
ApplyFlags flags,
|
||||
beast::Journal journal_)
|
||||
: app(app_)
|
||||
: registry(registry_)
|
||||
, tx(tx_)
|
||||
, preclaimResult(preclaimResult_)
|
||||
, baseFee(baseFee_)
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <xrpld/app/main/Application.h>
|
||||
#include <xrpld/core/Config.h>
|
||||
|
||||
#include <xrpl/beast/utility/Journal.h>
|
||||
#include <xrpl/core/ServiceRegistry.h>
|
||||
#include <xrpl/ledger/ApplyViewImpl.h>
|
||||
#include <xrpl/protocol/STTx.h>
|
||||
#include <xrpl/protocol/XRPAmount.h>
|
||||
@@ -17,7 +15,7 @@ class ApplyContext
|
||||
{
|
||||
public:
|
||||
explicit ApplyContext(
|
||||
Application& app,
|
||||
ServiceRegistry& registry,
|
||||
OpenView& base,
|
||||
std::optional<uint256 const> const& parentBatchId,
|
||||
STTx const& tx,
|
||||
@@ -27,19 +25,19 @@ public:
|
||||
beast::Journal journal = beast::Journal{beast::Journal::getNullSink()});
|
||||
|
||||
explicit ApplyContext(
|
||||
Application& app,
|
||||
ServiceRegistry& registry,
|
||||
OpenView& base,
|
||||
STTx const& tx,
|
||||
TER preclaimResult,
|
||||
XRPAmount baseFee,
|
||||
ApplyFlags flags,
|
||||
beast::Journal journal = beast::Journal{beast::Journal::getNullSink()})
|
||||
: ApplyContext(app, base, std::nullopt, tx, preclaimResult, baseFee, flags, journal)
|
||||
: ApplyContext(registry, base, std::nullopt, tx, preclaimResult, baseFee, flags, journal)
|
||||
{
|
||||
XRPL_ASSERT((flags & tapBATCH) == 0, "Batch apply flag should not be set");
|
||||
}
|
||||
|
||||
Application& app;
|
||||
ServiceRegistry& registry;
|
||||
STTx const& tx;
|
||||
TER const preclaimResult;
|
||||
XRPAmount const baseFee;
|
||||
|
||||
@@ -296,7 +296,7 @@ Batch::preflight(PreflightContext const& ctx)
|
||||
}
|
||||
|
||||
auto const innerAccount = stx.getAccountID(sfAccount);
|
||||
if (auto const preflightResult = xrpl::preflight(ctx.app, ctx.rules, parentBatchId, stx, tapBATCH, ctx.j);
|
||||
if (auto const preflightResult = xrpl::preflight(ctx.registry, ctx.rules, parentBatchId, stx, tapBATCH, ctx.j);
|
||||
preflightResult.ter != tesSUCCESS)
|
||||
{
|
||||
JLOG(ctx.j.debug()) << "BatchTrace[" << parentBatchId << "]: "
|
||||
|
||||
@@ -62,7 +62,7 @@ CancelCheck::doApply()
|
||||
|
||||
AccountID const srcId{sleCheck->getAccountID(sfAccount)};
|
||||
AccountID const dstId{sleCheck->getAccountID(sfDestination)};
|
||||
auto viewJ = ctx_.app.journal("View");
|
||||
auto viewJ = ctx_.registry.journal("View");
|
||||
|
||||
// If the check is not written to self (and it shouldn't be), remove the
|
||||
// check from the destination account root.
|
||||
|
||||
@@ -54,7 +54,7 @@ CancelOffer::doApply()
|
||||
if (auto sleOffer = view().peek(keylet::offer(account_, offerSequence)))
|
||||
{
|
||||
JLOG(j_.debug()) << "Trying to cancel offer #" << offerSequence;
|
||||
return offerDelete(view(), sleOffer, ctx_.app.journal("View"));
|
||||
return offerDelete(view(), sleOffer, ctx_.registry.journal("View"));
|
||||
}
|
||||
|
||||
JLOG(j_.debug()) << "Offer #" << offerSequence << " can't be found.";
|
||||
|
||||
@@ -228,7 +228,7 @@ CashCheck::doApply()
|
||||
//
|
||||
// If it is not a check to self (as should be the case), then there's
|
||||
// work to do...
|
||||
auto viewJ = ctx_.app.journal("View");
|
||||
auto viewJ = ctx_.registry.journal("View");
|
||||
auto const optDeliverMin = ctx_.tx[~sfDeliverMin];
|
||||
|
||||
if (srcId != account_)
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#include <xrpld/app/ledger/Ledger.h>
|
||||
#include <xrpld/app/main/Application.h>
|
||||
#include <xrpld/app/misc/AmendmentTable.h>
|
||||
#include <xrpld/app/tx/detail/Change.h>
|
||||
|
||||
@@ -195,7 +193,7 @@ Change::applyAmendment()
|
||||
entry[sfAmendment] = amendment;
|
||||
entry[sfCloseTime] = view().parentCloseTime().time_since_epoch().count();
|
||||
|
||||
if (!ctx_.app.getAmendmentTable().isSupported(amendment))
|
||||
if (!ctx_.registry.getAmendmentTable().isSupported(amendment))
|
||||
{
|
||||
JLOG(j_.warn()) << "Unsupported amendment " << amendment << " received a majority.";
|
||||
}
|
||||
@@ -206,12 +204,12 @@ Change::applyAmendment()
|
||||
amendments.push_back(amendment);
|
||||
amendmentObject->setFieldV256(sfAmendments, amendments);
|
||||
|
||||
ctx_.app.getAmendmentTable().enable(amendment);
|
||||
ctx_.registry.getAmendmentTable().enable(amendment);
|
||||
|
||||
if (!ctx_.app.getAmendmentTable().isSupported(amendment))
|
||||
if (!ctx_.registry.getAmendmentTable().isSupported(amendment))
|
||||
{
|
||||
JLOG(j_.error()) << "Unsupported amendment " << amendment << " activated: server blocked.";
|
||||
ctx_.app.getOPs().setAmendmentBlocked();
|
||||
ctx_.registry.getOPs().setAmendmentBlocked();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -164,7 +164,7 @@ CreateCheck::doApply()
|
||||
|
||||
view().insert(sleCheck);
|
||||
|
||||
auto viewJ = ctx_.app.journal("View");
|
||||
auto viewJ = ctx_.registry.journal("View");
|
||||
// If it's not a self-send (and it shouldn't be), add Check to the
|
||||
// destination's owner directory.
|
||||
if (dstAccountId != account_)
|
||||
|
||||
@@ -144,7 +144,7 @@ CreateOffer::preclaim(PreclaimContext const& ctx)
|
||||
|
||||
std::uint32_t const uAccountSequence = sleCreator->getFieldU32(sfSequence);
|
||||
|
||||
auto viewJ = ctx.app.journal("View");
|
||||
auto viewJ = ctx.registry.journal("View");
|
||||
|
||||
if (isGlobalFrozen(ctx.view, uPaysIssuerID) || isGlobalFrozen(ctx.view, uGetsIssuerID))
|
||||
{
|
||||
@@ -489,7 +489,7 @@ CreateOffer::applyHybrid(
|
||||
bookArr.push_back(std::move(bookInfo));
|
||||
|
||||
if (!bookExists)
|
||||
ctx_.app.getOrderBookDB().addOrderBook(book);
|
||||
ctx_.registry.getOrderBookDB().addOrderBook(book);
|
||||
|
||||
sleOffer->setFieldArray(sfAdditionalBooks, bookArr);
|
||||
return tesSUCCESS;
|
||||
@@ -523,7 +523,7 @@ CreateOffer::applyGuts(Sandbox& sb, Sandbox& sbCancel)
|
||||
// end up on the books.
|
||||
auto uRate = getRate(saTakerGets, saTakerPays);
|
||||
|
||||
auto viewJ = ctx_.app.journal("View");
|
||||
auto viewJ = ctx_.registry.journal("View");
|
||||
|
||||
TER result = tesSUCCESS;
|
||||
|
||||
@@ -825,7 +825,7 @@ CreateOffer::applyGuts(Sandbox& sb, Sandbox& sbCancel)
|
||||
sb.insert(sleOffer);
|
||||
|
||||
if (!bookExisted)
|
||||
ctx_.app.getOrderBookDB().addOrderBook(book);
|
||||
ctx_.registry.getOrderBookDB().addOrderBook(book);
|
||||
|
||||
JLOG(j_.debug()) << "final result: success";
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ CreateTicket::doApply()
|
||||
return tecINSUFFICIENT_RESERVE;
|
||||
}
|
||||
|
||||
beast::Journal viewJ{ctx_.app.journal("View")};
|
||||
beast::Journal viewJ{ctx_.registry.journal("View")};
|
||||
|
||||
// The starting ticket sequence is the same as the current account
|
||||
// root sequence. Before we got here to doApply(), the transaction
|
||||
|
||||
@@ -51,7 +51,7 @@ DeleteAccount::calculateBaseFee(ReadView const& view, STTx const& tx)
|
||||
namespace {
|
||||
// Define a function pointer type that can be used to delete ledger node types.
|
||||
using DeleterFuncPtr = TER (*)(
|
||||
Application& app,
|
||||
ServiceRegistry& registry,
|
||||
ApplyView& view,
|
||||
AccountID const& account,
|
||||
uint256 const& delIndex,
|
||||
@@ -61,7 +61,7 @@ using DeleterFuncPtr = TER (*)(
|
||||
// Local function definitions that provides signature compatibility.
|
||||
TER
|
||||
offerDelete(
|
||||
Application& app,
|
||||
ServiceRegistry&,
|
||||
ApplyView& view,
|
||||
AccountID const& account,
|
||||
uint256 const& delIndex,
|
||||
@@ -73,19 +73,19 @@ offerDelete(
|
||||
|
||||
TER
|
||||
removeSignersFromLedger(
|
||||
Application& app,
|
||||
ServiceRegistry& registry,
|
||||
ApplyView& view,
|
||||
AccountID const& account,
|
||||
uint256 const& delIndex,
|
||||
std::shared_ptr<SLE> const& sleDel,
|
||||
beast::Journal j)
|
||||
{
|
||||
return SetSignerList::removeFromLedger(app, view, account, j);
|
||||
return SetSignerList::removeFromLedger(registry, view, account, j);
|
||||
}
|
||||
|
||||
TER
|
||||
removeTicketFromLedger(
|
||||
Application&,
|
||||
ServiceRegistry&,
|
||||
ApplyView& view,
|
||||
AccountID const& account,
|
||||
uint256 const& delIndex,
|
||||
@@ -97,7 +97,7 @@ removeTicketFromLedger(
|
||||
|
||||
TER
|
||||
removeDepositPreauthFromLedger(
|
||||
Application&,
|
||||
ServiceRegistry&,
|
||||
ApplyView& view,
|
||||
AccountID const&,
|
||||
uint256 const& delIndex,
|
||||
@@ -109,7 +109,7 @@ removeDepositPreauthFromLedger(
|
||||
|
||||
TER
|
||||
removeNFTokenOfferFromLedger(
|
||||
Application& app,
|
||||
ServiceRegistry&,
|
||||
ApplyView& view,
|
||||
AccountID const& account,
|
||||
uint256 const& delIndex,
|
||||
@@ -124,7 +124,7 @@ removeNFTokenOfferFromLedger(
|
||||
|
||||
TER
|
||||
removeDIDFromLedger(
|
||||
Application& app,
|
||||
ServiceRegistry&,
|
||||
ApplyView& view,
|
||||
AccountID const& account,
|
||||
uint256 const& delIndex,
|
||||
@@ -136,7 +136,7 @@ removeDIDFromLedger(
|
||||
|
||||
TER
|
||||
removeOracleFromLedger(
|
||||
Application&,
|
||||
ServiceRegistry&,
|
||||
ApplyView& view,
|
||||
AccountID const& account,
|
||||
uint256 const&,
|
||||
@@ -148,7 +148,7 @@ removeOracleFromLedger(
|
||||
|
||||
TER
|
||||
removeCredentialFromLedger(
|
||||
Application&,
|
||||
ServiceRegistry&,
|
||||
ApplyView& view,
|
||||
AccountID const&,
|
||||
uint256 const&,
|
||||
@@ -160,7 +160,7 @@ removeCredentialFromLedger(
|
||||
|
||||
TER
|
||||
removeDelegateFromLedger(
|
||||
Application& app,
|
||||
ServiceRegistry&,
|
||||
ApplyView& view,
|
||||
AccountID const& account,
|
||||
uint256 const& delIndex,
|
||||
@@ -351,7 +351,7 @@ DeleteAccount::doApply()
|
||||
std::shared_ptr<SLE>& sleItem) -> std::pair<TER, SkipEntry> {
|
||||
if (auto deleter = nonObligationDeleter(nodeType))
|
||||
{
|
||||
TER const result{deleter(ctx_.app, view(), account_, dirEntry, sleItem, j_)};
|
||||
TER const result{deleter(ctx_.registry, view(), account_, dirEntry, sleItem, j_)};
|
||||
|
||||
return {result, SkipEntry::No};
|
||||
}
|
||||
|
||||
@@ -544,7 +544,7 @@ EscrowFinish::preflightSigValidated(PreflightContext const& ctx)
|
||||
|
||||
if (cb && fb)
|
||||
{
|
||||
auto& router = ctx.app.getHashRouter();
|
||||
auto& router = ctx.registry.getHashRouter();
|
||||
|
||||
auto const id = ctx.tx.getTransactionID();
|
||||
auto const flags = router.getFlags(id);
|
||||
@@ -900,7 +900,7 @@ EscrowFinish::doApply()
|
||||
// Check cryptocondition fulfillment
|
||||
{
|
||||
auto const id = ctx_.tx.getTransactionID();
|
||||
auto flags = ctx_.app.getHashRouter().getFlags(id);
|
||||
auto flags = ctx_.registry.getHashRouter().getFlags(id);
|
||||
|
||||
auto const cb = ctx_.tx[~sfCondition];
|
||||
|
||||
@@ -920,7 +920,7 @@ EscrowFinish::doApply()
|
||||
else
|
||||
flags = SF_CF_INVALID;
|
||||
|
||||
ctx_.app.getHashRouter().setFlags(id, flags);
|
||||
ctx_.registry.getHashRouter().setFlags(id, flags);
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
|
||||
@@ -310,7 +310,7 @@ PayChanFund::doApply()
|
||||
auto const cancelAfter = (*slep)[~sfCancelAfter];
|
||||
auto const closeTime = ctx_.view().header().parentCloseTime.time_since_epoch().count();
|
||||
if ((cancelAfter && closeTime >= *cancelAfter) || (expiration && closeTime >= *expiration))
|
||||
return closeChannel(slep, ctx_.view(), k.key, ctx_.app.journal("View"));
|
||||
return closeChannel(slep, ctx_.view(), k.key, ctx_.registry.journal("View"));
|
||||
}
|
||||
|
||||
if (src != txAccount)
|
||||
@@ -456,7 +456,7 @@ PayChanClaim::doApply()
|
||||
auto const cancelAfter = (*slep)[~sfCancelAfter];
|
||||
auto const closeTime = ctx_.view().header().parentCloseTime.time_since_epoch().count();
|
||||
if ((cancelAfter && closeTime >= *cancelAfter) || (curExpiration && closeTime >= *curExpiration))
|
||||
return closeChannel(slep, ctx_.view(), k.key, ctx_.app.journal("View"));
|
||||
return closeChannel(slep, ctx_.view(), k.key, ctx_.registry.journal("View"));
|
||||
}
|
||||
|
||||
if (txAccount != src && txAccount != dst)
|
||||
@@ -513,7 +513,7 @@ PayChanClaim::doApply()
|
||||
{
|
||||
// Channel will close immediately if dry or the receiver closes
|
||||
if (dst == txAccount || (*slep)[sfBalance] == (*slep)[sfAmount])
|
||||
return closeChannel(slep, ctx_.view(), k.key, ctx_.app.journal("View"));
|
||||
return closeChannel(slep, ctx_.view(), k.key, ctx_.registry.journal("View"));
|
||||
|
||||
auto const settleExpiration =
|
||||
ctx_.view().header().parentCloseTime.time_since_epoch().count() + (*slep)[sfSettleDelay];
|
||||
|
||||
@@ -414,7 +414,7 @@ Payment::doApply()
|
||||
account_,
|
||||
ctx_.tx.getFieldPathSet(sfPaths),
|
||||
ctx_.tx[~sfDomainID],
|
||||
ctx_.app.logs(),
|
||||
ctx_.registry.logs(),
|
||||
&rcInput);
|
||||
// VFALCO NOTE We might not need to apply, depending
|
||||
// on the TER. But always applying *should*
|
||||
|
||||
@@ -47,7 +47,7 @@ SetRegularKey::doApply()
|
||||
if (!sle)
|
||||
return tefINTERNAL; // LCOV_EXCL_LINE
|
||||
|
||||
if (!minimumFee(ctx_.app, ctx_.baseFee, view().fees(), view().flags()))
|
||||
if (!minimumFee(ctx_.registry, ctx_.baseFee, view().fees(), view().flags()))
|
||||
sle->setFlag(lsfPasswordSpent);
|
||||
|
||||
if (ctx_.tx.isFieldPresent(sfRegularKey))
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include <xrpld/app/ledger/Ledger.h>
|
||||
#include <xrpld/app/tx/detail/SetSignerList.h>
|
||||
|
||||
#include <xrpl/basics/Log.h>
|
||||
#include <xrpl/ledger/ApplyView.h>
|
||||
#include <xrpl/ledger/View.h>
|
||||
#include <xrpl/protocol/Feature.h>
|
||||
#include <xrpl/protocol/Indexes.h>
|
||||
#include <xrpl/protocol/STArray.h>
|
||||
@@ -151,7 +151,7 @@ signerCountBasedOwnerCountDelta(std::size_t entryCount, Rules const& rules)
|
||||
|
||||
static TER
|
||||
removeSignersFromLedger(
|
||||
Application& app,
|
||||
ServiceRegistry& registry,
|
||||
ApplyView& view,
|
||||
Keylet const& accountKeylet,
|
||||
Keylet const& ownerDirKeylet,
|
||||
@@ -187,7 +187,7 @@ removeSignersFromLedger(
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
adjustOwnerCount(view, view.peek(accountKeylet), removeFromOwnerCount, app.journal("View"));
|
||||
adjustOwnerCount(view, view.peek(accountKeylet), removeFromOwnerCount, registry.journal("View"));
|
||||
|
||||
view.erase(signers);
|
||||
|
||||
@@ -195,13 +195,13 @@ removeSignersFromLedger(
|
||||
}
|
||||
|
||||
TER
|
||||
SetSignerList::removeFromLedger(Application& app, ApplyView& view, AccountID const& account, beast::Journal j)
|
||||
SetSignerList::removeFromLedger(ServiceRegistry& registry, ApplyView& view, AccountID const& account, beast::Journal j)
|
||||
{
|
||||
auto const accountKeylet = keylet::account(account);
|
||||
auto const ownerDirKeylet = keylet::ownerDir(account);
|
||||
auto const signerListKeylet = keylet::signers(account);
|
||||
|
||||
return removeSignersFromLedger(app, view, accountKeylet, ownerDirKeylet, signerListKeylet, j);
|
||||
return removeSignersFromLedger(registry, view, accountKeylet, ownerDirKeylet, signerListKeylet, j);
|
||||
}
|
||||
|
||||
NotTEC
|
||||
@@ -273,7 +273,8 @@ SetSignerList::replaceSignerList()
|
||||
// This may be either a create or a replace. Preemptively remove any
|
||||
// old signer list. May reduce the reserve, so this is done before
|
||||
// checking the reserve.
|
||||
if (TER const ter = removeSignersFromLedger(ctx_.app, view(), accountKeylet, ownerDirKeylet, signerListKeylet, j_))
|
||||
if (TER const ter =
|
||||
removeSignersFromLedger(ctx_.registry, view(), accountKeylet, ownerDirKeylet, signerListKeylet, j_))
|
||||
return ter;
|
||||
|
||||
auto const sle = view().peek(accountKeylet);
|
||||
@@ -299,7 +300,7 @@ SetSignerList::replaceSignerList()
|
||||
view().insert(signerList);
|
||||
writeSignersToSLE(signerList, flags);
|
||||
|
||||
auto viewJ = ctx_.app.journal("View");
|
||||
auto viewJ = ctx_.registry.journal("View");
|
||||
// Add the signer list to the account's directory.
|
||||
auto const page = ctx_.view().dirInsert(ownerDirKeylet, signerListKeylet, describeOwnerDir(account_));
|
||||
|
||||
@@ -332,7 +333,7 @@ SetSignerList::destroySignerList()
|
||||
|
||||
auto const ownerDirKeylet = keylet::ownerDir(account_);
|
||||
auto const signerListKeylet = keylet::signers(account_);
|
||||
return removeSignersFromLedger(ctx_.app, view(), accountKeylet, ownerDirKeylet, signerListKeylet, j_);
|
||||
return removeSignersFromLedger(ctx_.registry, view(), accountKeylet, ownerDirKeylet, signerListKeylet, j_);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
|
||||
// Interface used by DeleteAccount
|
||||
static TER
|
||||
removeFromLedger(Application& app, ApplyView& view, AccountID const& account, beast::Journal j);
|
||||
removeFromLedger(ServiceRegistry& registry, ApplyView& view, AccountID const& account, beast::Journal j);
|
||||
|
||||
private:
|
||||
static std::tuple<NotTEC, std::uint32_t, std::vector<SignerEntries::SignerEntry>, Operation>
|
||||
|
||||
@@ -352,7 +352,7 @@ SetTrust::doApply()
|
||||
bool const bSetDeepFreeze = (uTxFlags & tfSetDeepFreeze);
|
||||
bool const bClearDeepFreeze = (uTxFlags & tfClearDeepFreeze);
|
||||
|
||||
auto viewJ = ctx_.app.journal("View");
|
||||
auto viewJ = ctx_.registry.journal("View");
|
||||
|
||||
SLE::pointer sleDst = view().peek(keylet::account(uDstAccountID));
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include <xrpl/basics/Log.h>
|
||||
#include <xrpl/basics/contract.h>
|
||||
#include <xrpl/core/NetworkIDService.h>
|
||||
#include <xrpl/json/to_string.h>
|
||||
#include <xrpl/ledger/CredentialHelpers.h>
|
||||
#include <xrpl/ledger/View.h>
|
||||
@@ -32,7 +33,7 @@ preflight0(PreflightContext const& ctx, std::uint32_t flagMask)
|
||||
|
||||
if (!isPseudoTx(ctx.tx) || ctx.tx.isFieldPresent(sfNetworkID))
|
||||
{
|
||||
uint32_t nodeNID = ctx.app.config().NETWORK_ID;
|
||||
uint32_t nodeNID = ctx.registry.getNetworkIDService().getNetworkID();
|
||||
std::optional<uint32_t> txNID = ctx.tx[~sfNetworkID];
|
||||
|
||||
if (nodeNID <= 1024)
|
||||
@@ -204,7 +205,7 @@ Transactor::preflight2(PreflightContext const& ctx)
|
||||
// Do not add any checks after this point that are relevant for
|
||||
// batch inner transactions. They will be skipped.
|
||||
|
||||
auto const sigValid = checkValidity(ctx.app.getHashRouter(), ctx.tx, ctx.rules, ctx.app.config());
|
||||
auto const sigValid = checkValidity(ctx.registry.getHashRouter(), ctx.tx, ctx.rules);
|
||||
if (sigValid.first == Validity::SigBad)
|
||||
{ // LCOV_EXCL_START
|
||||
JLOG(ctx.j.debug()) << "preflight2: bad signature. " << sigValid.second;
|
||||
@@ -303,9 +304,9 @@ Transactor::calculateOwnerReserveFee(ReadView const& view, STTx const& tx)
|
||||
}
|
||||
|
||||
XRPAmount
|
||||
Transactor::minimumFee(Application& app, XRPAmount baseFee, Fees const& fees, ApplyFlags flags)
|
||||
Transactor::minimumFee(ServiceRegistry& registry, XRPAmount baseFee, Fees const& fees, ApplyFlags flags)
|
||||
{
|
||||
return scaleFeeLoad(baseFee, app.getFeeTrack(), fees, flags & tapUNLIMITED);
|
||||
return scaleFeeLoad(baseFee, registry.getFeeTrack(), fees, flags & tapUNLIMITED);
|
||||
}
|
||||
|
||||
TER
|
||||
@@ -331,7 +332,7 @@ Transactor::checkFee(PreclaimContext const& ctx, XRPAmount baseFee)
|
||||
// Only check fee is sufficient when the ledger is open.
|
||||
if (ctx.view.open())
|
||||
{
|
||||
auto const feeDue = minimumFee(ctx.app, baseFee, ctx.view.fees(), ctx.flags);
|
||||
auto const feeDue = minimumFee(ctx.registry, baseFee, ctx.view.fees(), ctx.flags);
|
||||
|
||||
if (feePaid < feeDue)
|
||||
{
|
||||
@@ -1071,7 +1072,7 @@ Transactor::operator()()
|
||||
}
|
||||
#endif
|
||||
|
||||
if (auto const& trap = ctx_.app.trapTxID(); trap && *trap == ctx_.tx.getTransactionID())
|
||||
if (auto const& trap = ctx_.registry.trapTxID(); trap && *trap == ctx_.tx.getTransactionID())
|
||||
{
|
||||
trapTransaction(*trap);
|
||||
}
|
||||
@@ -1172,16 +1173,16 @@ Transactor::operator()()
|
||||
|
||||
// If necessary, remove any offers found unfunded during processing
|
||||
if ((result == tecOVERSIZE) || (result == tecKILLED))
|
||||
removeUnfundedOffers(view(), removedOffers, ctx_.app.journal("View"));
|
||||
removeUnfundedOffers(view(), removedOffers, ctx_.registry.journal("View"));
|
||||
|
||||
if (result == tecEXPIRED)
|
||||
removeExpiredNFTokenOffers(view(), expiredNFTokenOffers, ctx_.app.journal("View"));
|
||||
removeExpiredNFTokenOffers(view(), expiredNFTokenOffers, ctx_.registry.journal("View"));
|
||||
|
||||
if (result == tecINCOMPLETE)
|
||||
removeDeletedTrustLines(view(), removedTrustLines, ctx_.app.journal("View"));
|
||||
removeDeletedTrustLines(view(), removedTrustLines, ctx_.registry.journal("View"));
|
||||
|
||||
if (result == tecEXPIRED)
|
||||
removeExpiredCredentials(view(), expiredCredentials, ctx_.app.journal("View"));
|
||||
removeExpiredCredentials(view(), expiredCredentials, ctx_.registry.journal("View"));
|
||||
|
||||
applied = isTecClaim(result);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace xrpl {
|
||||
struct PreflightContext
|
||||
{
|
||||
public:
|
||||
Application& app;
|
||||
ServiceRegistry& registry;
|
||||
STTx const& tx;
|
||||
Rules const rules;
|
||||
ApplyFlags flags;
|
||||
@@ -22,24 +22,24 @@ public:
|
||||
beast::Journal const j;
|
||||
|
||||
PreflightContext(
|
||||
Application& app_,
|
||||
ServiceRegistry& registry_,
|
||||
STTx const& tx_,
|
||||
uint256 parentBatchId_,
|
||||
Rules const& rules_,
|
||||
ApplyFlags flags_,
|
||||
beast::Journal j_ = beast::Journal{beast::Journal::getNullSink()})
|
||||
: app(app_), tx(tx_), rules(rules_), flags(flags_), parentBatchId(parentBatchId_), j(j_)
|
||||
: registry(registry_), tx(tx_), rules(rules_), flags(flags_), parentBatchId(parentBatchId_), j(j_)
|
||||
{
|
||||
XRPL_ASSERT((flags_ & tapBATCH) == tapBATCH, "Batch apply flag should be set");
|
||||
}
|
||||
|
||||
PreflightContext(
|
||||
Application& app_,
|
||||
ServiceRegistry& registry_,
|
||||
STTx const& tx_,
|
||||
Rules const& rules_,
|
||||
ApplyFlags flags_,
|
||||
beast::Journal j_ = beast::Journal{beast::Journal::getNullSink()})
|
||||
: app(app_), tx(tx_), rules(rules_), flags(flags_), j(j_)
|
||||
: registry(registry_), tx(tx_), rules(rules_), flags(flags_), j(j_)
|
||||
{
|
||||
XRPL_ASSERT((flags_ & tapBATCH) == 0, "Batch apply flag should not be set");
|
||||
}
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
struct PreclaimContext
|
||||
{
|
||||
public:
|
||||
Application& app;
|
||||
ServiceRegistry& registry;
|
||||
ReadView const& view;
|
||||
TER preflightResult;
|
||||
ApplyFlags flags;
|
||||
@@ -61,14 +61,14 @@ public:
|
||||
beast::Journal const j;
|
||||
|
||||
PreclaimContext(
|
||||
Application& app_,
|
||||
ServiceRegistry& registry_,
|
||||
ReadView const& view_,
|
||||
TER preflightResult_,
|
||||
STTx const& tx_,
|
||||
ApplyFlags flags_,
|
||||
std::optional<uint256> parentBatchId_,
|
||||
beast::Journal j_ = beast::Journal{beast::Journal::getNullSink()})
|
||||
: app(app_)
|
||||
: registry(registry_)
|
||||
, view(view_)
|
||||
, preflightResult(preflightResult_)
|
||||
, flags(flags_)
|
||||
@@ -82,13 +82,13 @@ public:
|
||||
}
|
||||
|
||||
PreclaimContext(
|
||||
Application& app_,
|
||||
ServiceRegistry& registry_,
|
||||
ReadView const& view_,
|
||||
TER preflightResult_,
|
||||
STTx const& tx_,
|
||||
ApplyFlags flags_,
|
||||
beast::Journal j_ = beast::Journal{beast::Journal::getNullSink()})
|
||||
: PreclaimContext(app_, view_, preflightResult_, tx_, flags_, std::nullopt, j_)
|
||||
: PreclaimContext(registry_, view_, preflightResult_, tx_, flags_, std::nullopt, j_)
|
||||
{
|
||||
XRPL_ASSERT((flags_ & tapBATCH) == 0, "Batch apply flag should not be set");
|
||||
}
|
||||
@@ -225,14 +225,14 @@ protected:
|
||||
/** Compute the minimum fee required to process a transaction
|
||||
with a given baseFee based on the current server load.
|
||||
|
||||
@param app The application hosting the server
|
||||
@param registry The service registry.
|
||||
@param baseFee The base fee of a candidate transaction
|
||||
@see xrpl::calculateBaseFee
|
||||
@param fees Fee settings from the current ledger
|
||||
@param flags Transaction processing fees
|
||||
*/
|
||||
static XRPAmount
|
||||
minimumFee(Application& app, XRPAmount baseFee, Fees const& fees, ApplyFlags flags);
|
||||
minimumFee(ServiceRegistry& registry, XRPAmount baseFee, Fees const& fees, ApplyFlags flags);
|
||||
|
||||
// Returns the fee in fee units, not scaled for load.
|
||||
static XRPAmount
|
||||
|
||||
@@ -19,7 +19,7 @@ constexpr HashRouterFlags SF_LOCALGOOD = HashRouterFlags::PRIVATE4; // Local ch
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
std::pair<Validity, std::string>
|
||||
checkValidity(HashRouter& router, STTx const& tx, Rules const& rules, Config const& config)
|
||||
checkValidity(HashRouter& router, STTx const& tx, Rules const& rules)
|
||||
{
|
||||
auto const id = tx.getTransactionID();
|
||||
auto const flags = router.getFlags(id);
|
||||
@@ -108,32 +108,33 @@ forceValidity(HashRouter& router, uint256 const& txid, Validity validity)
|
||||
|
||||
template <typename PreflightChecks>
|
||||
ApplyResult
|
||||
apply(Application& app, OpenView& view, PreflightChecks&& preflightChecks)
|
||||
apply(ServiceRegistry& registry, OpenView& view, PreflightChecks&& preflightChecks)
|
||||
{
|
||||
NumberSO stNumberSO{view.rules().enabled(fixUniversalNumber)};
|
||||
return doApply(preclaim(preflightChecks(), app, view), app, view);
|
||||
return doApply(preclaim(preflightChecks(), registry, view), registry, view);
|
||||
}
|
||||
|
||||
ApplyResult
|
||||
apply(Application& app, OpenView& view, STTx const& tx, ApplyFlags flags, beast::Journal j)
|
||||
apply(ServiceRegistry& registry, OpenView& view, STTx const& tx, ApplyFlags flags, beast::Journal j)
|
||||
{
|
||||
return apply(app, view, [&]() mutable { return preflight(app, view.rules(), tx, flags, j); });
|
||||
return apply(registry, view, [&]() mutable { return preflight(registry, view.rules(), tx, flags, j); });
|
||||
}
|
||||
|
||||
ApplyResult
|
||||
apply(
|
||||
Application& app,
|
||||
ServiceRegistry& registry,
|
||||
OpenView& view,
|
||||
uint256 const& parentBatchId,
|
||||
STTx const& tx,
|
||||
ApplyFlags flags,
|
||||
beast::Journal j)
|
||||
{
|
||||
return apply(app, view, [&]() mutable { return preflight(app, view.rules(), parentBatchId, tx, flags, j); });
|
||||
return apply(
|
||||
registry, view, [&]() mutable { return preflight(registry, view.rules(), parentBatchId, tx, flags, j); });
|
||||
}
|
||||
|
||||
static bool
|
||||
applyBatchTransactions(Application& app, OpenView& batchView, STTx const& batchTxn, beast::Journal j)
|
||||
applyBatchTransactions(ServiceRegistry& registry, OpenView& batchView, STTx const& batchTxn, beast::Journal j)
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
batchTxn.getTxnType() == ttBATCH && batchTxn.getFieldArray(sfRawTransactions).size() != 0,
|
||||
@@ -142,10 +143,10 @@ applyBatchTransactions(Application& app, OpenView& batchView, STTx const& batchT
|
||||
auto const parentBatchId = batchTxn.getTransactionID();
|
||||
auto const mode = batchTxn.getFlags();
|
||||
|
||||
auto applyOneTransaction = [&app, &j, &parentBatchId, &batchView](STTx&& tx) {
|
||||
auto applyOneTransaction = [®istry, &j, &parentBatchId, &batchView](STTx&& tx) {
|
||||
OpenView perTxBatchView(batch_view, batchView);
|
||||
|
||||
auto const ret = apply(app, perTxBatchView, parentBatchId, tx, tapBATCH, j);
|
||||
auto const ret = apply(registry, perTxBatchView, parentBatchId, tx, tapBATCH, j);
|
||||
XRPL_ASSERT(
|
||||
ret.applied == (isTesSuccess(ret.ter) || isTecClaim(ret.ter)), "Inner transaction should not be applied");
|
||||
|
||||
@@ -189,7 +190,7 @@ applyBatchTransactions(Application& app, OpenView& batchView, STTx const& batchT
|
||||
|
||||
ApplyTransactionResult
|
||||
applyTransaction(
|
||||
Application& app,
|
||||
ServiceRegistry& registry,
|
||||
OpenView& view,
|
||||
STTx const& txn,
|
||||
bool retryAssured,
|
||||
@@ -204,7 +205,7 @@ applyTransaction(
|
||||
|
||||
try
|
||||
{
|
||||
auto const result = apply(app, view, txn, flags, j);
|
||||
auto const result = apply(registry, view, txn, flags, j);
|
||||
|
||||
if (result.applied)
|
||||
{
|
||||
@@ -216,7 +217,7 @@ applyTransaction(
|
||||
{
|
||||
OpenView wholeBatchView(batch_view, view);
|
||||
|
||||
if (applyBatchTransactions(app, wholeBatchView, txn, j))
|
||||
if (applyBatchTransactions(registry, wholeBatchView, txn, j))
|
||||
wholeBatchView.apply(view);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
// DO NOT INCLUDE TRANSACTOR HEADER FILES HERE.
|
||||
// See the instructions at the top of transactions.macro instead.
|
||||
|
||||
#include <xrpl/core/ServiceRegistry.h>
|
||||
#include <xrpl/protocol/TxFormats.h>
|
||||
|
||||
#include <stdexcept>
|
||||
@@ -292,9 +293,9 @@ invoke_apply(ApplyContext& ctx)
|
||||
}
|
||||
|
||||
PreflightResult
|
||||
preflight(Application& app, Rules const& rules, STTx const& tx, ApplyFlags flags, beast::Journal j)
|
||||
preflight(ServiceRegistry& registry, Rules const& rules, STTx const& tx, ApplyFlags flags, beast::Journal j)
|
||||
{
|
||||
PreflightContext const pfCtx(app, tx, rules, flags, j);
|
||||
PreflightContext const pfCtx(registry, tx, rules, flags, j);
|
||||
try
|
||||
{
|
||||
return {pfCtx, invoke_preflight(pfCtx)};
|
||||
@@ -308,14 +309,14 @@ preflight(Application& app, Rules const& rules, STTx const& tx, ApplyFlags flags
|
||||
|
||||
PreflightResult
|
||||
preflight(
|
||||
Application& app,
|
||||
ServiceRegistry& registry,
|
||||
Rules const& rules,
|
||||
uint256 const& parentBatchId,
|
||||
STTx const& tx,
|
||||
ApplyFlags flags,
|
||||
beast::Journal j)
|
||||
{
|
||||
PreflightContext const pfCtx(app, tx, parentBatchId, rules, flags, j);
|
||||
PreflightContext const pfCtx(registry, tx, parentBatchId, rules, flags, j);
|
||||
try
|
||||
{
|
||||
return {pfCtx, invoke_preflight(pfCtx)};
|
||||
@@ -328,7 +329,7 @@ preflight(
|
||||
}
|
||||
|
||||
PreclaimResult
|
||||
preclaim(PreflightResult const& preflightResult, Application& app, OpenView const& view)
|
||||
preclaim(PreflightResult const& preflightResult, ServiceRegistry& registry, OpenView const& view)
|
||||
{
|
||||
std::optional<PreclaimContext const> ctx;
|
||||
if (preflightResult.rules != view.rules())
|
||||
@@ -336,18 +337,18 @@ preclaim(PreflightResult const& preflightResult, Application& app, OpenView cons
|
||||
auto secondFlight = [&]() {
|
||||
if (preflightResult.parentBatchId)
|
||||
return preflight(
|
||||
app,
|
||||
registry,
|
||||
view.rules(),
|
||||
preflightResult.parentBatchId.value(),
|
||||
preflightResult.tx,
|
||||
preflightResult.flags,
|
||||
preflightResult.j);
|
||||
|
||||
return preflight(app, view.rules(), preflightResult.tx, preflightResult.flags, preflightResult.j);
|
||||
return preflight(registry, view.rules(), preflightResult.tx, preflightResult.flags, preflightResult.j);
|
||||
}();
|
||||
|
||||
ctx.emplace(
|
||||
app,
|
||||
registry,
|
||||
view,
|
||||
secondFlight.ter,
|
||||
secondFlight.tx,
|
||||
@@ -358,7 +359,7 @@ preclaim(PreflightResult const& preflightResult, Application& app, OpenView cons
|
||||
else
|
||||
{
|
||||
ctx.emplace(
|
||||
app,
|
||||
registry,
|
||||
view,
|
||||
preflightResult.ter,
|
||||
preflightResult.tx,
|
||||
@@ -393,7 +394,7 @@ calculateDefaultBaseFee(ReadView const& view, STTx const& tx)
|
||||
}
|
||||
|
||||
ApplyResult
|
||||
doApply(PreclaimResult const& preclaimResult, Application& app, OpenView& view)
|
||||
doApply(PreclaimResult const& preclaimResult, ServiceRegistry& registry, OpenView& view)
|
||||
{
|
||||
if (preclaimResult.view.seq() != view.seq())
|
||||
{
|
||||
@@ -406,7 +407,7 @@ doApply(PreclaimResult const& preclaimResult, Application& app, OpenView& view)
|
||||
if (!preclaimResult.likelyToClaimFee)
|
||||
return {preclaimResult.ter, false};
|
||||
ApplyContext ctx(
|
||||
app,
|
||||
registry,
|
||||
view,
|
||||
preclaimResult.parentBatchId,
|
||||
preclaimResult.tx,
|
||||
|
||||
32
src/xrpld/core/NetworkIDServiceImpl.h
Normal file
32
src/xrpld/core/NetworkIDServiceImpl.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
#include <xrpl/core/NetworkIDService.h>
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
// Forward declaration
|
||||
class Config;
|
||||
|
||||
/** Implementation of NetworkIDService that reads from Config.
|
||||
|
||||
This class provides a NetworkIDService interface that wraps
|
||||
the network ID from the application Config. It caches the
|
||||
network ID at construction time.
|
||||
*/
|
||||
class NetworkIDServiceImpl final : public NetworkIDService
|
||||
{
|
||||
public:
|
||||
explicit NetworkIDServiceImpl(std::uint32_t networkID);
|
||||
|
||||
~NetworkIDServiceImpl() override = default;
|
||||
|
||||
std::uint32_t
|
||||
getNetworkID() const noexcept override;
|
||||
|
||||
private:
|
||||
std::uint32_t networkID_;
|
||||
};
|
||||
|
||||
} // namespace xrpl
|
||||
16
src/xrpld/core/detail/NetworkIDServiceImpl.cpp
Normal file
16
src/xrpld/core/detail/NetworkIDServiceImpl.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#include <xrpld/core/Config.h>
|
||||
#include <xrpld/core/NetworkIDServiceImpl.h>
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
NetworkIDServiceImpl::NetworkIDServiceImpl(std::uint32_t networkID) : networkID_(networkID)
|
||||
{
|
||||
}
|
||||
|
||||
std::uint32_t
|
||||
NetworkIDServiceImpl::getNetworkID() const noexcept
|
||||
{
|
||||
return networkID_;
|
||||
}
|
||||
|
||||
} // namespace xrpl
|
||||
@@ -2722,8 +2722,8 @@ PeerImp::checkTransaction(
|
||||
if (checkSignature)
|
||||
{
|
||||
// Check the signature before handing off to the job queue.
|
||||
if (auto [valid, validReason] = checkValidity(
|
||||
app_.getHashRouter(), *stx, app_.getLedgerMaster().getValidatedRules(), app_.config());
|
||||
if (auto [valid, validReason] =
|
||||
checkValidity(app_.getHashRouter(), *stx, app_.getLedgerMaster().getValidatedRules());
|
||||
valid != Validity::Valid)
|
||||
{
|
||||
if (!validReason.empty())
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
#include <xrpl/basics/Log.h>
|
||||
#include <xrpl/basics/mulDiv.h>
|
||||
#include <xrpl/core/NetworkIDService.h>
|
||||
#include <xrpl/json/json_writer.h>
|
||||
#include <xrpl/protocol/ErrorCodes.h>
|
||||
#include <xrpl/protocol/InnerObjectFormats.h>
|
||||
@@ -466,7 +467,7 @@ transactionPreProcessImpl(
|
||||
|
||||
if (!tx_json.isMember(jss::NetworkID))
|
||||
{
|
||||
auto const networkId = app.config().NETWORK_ID;
|
||||
auto const networkId = app.getNetworkIDService().getNetworkID();
|
||||
if (networkId > 1024)
|
||||
tx_json[jss::NetworkID] = to_string(networkId);
|
||||
}
|
||||
@@ -637,7 +638,7 @@ transactionConstructImpl(std::shared_ptr<STTx const> const& stTx, Rules const& r
|
||||
auto sttxNew = std::make_shared<STTx const>(sit);
|
||||
if (!app.checkSigs())
|
||||
forceValidity(app.getHashRouter(), sttxNew->getTransactionID(), Validity::SigGoodOnly);
|
||||
if (checkValidity(app.getHashRouter(), *sttxNew, rules, app.config()).first != Validity::Valid)
|
||||
if (checkValidity(app.getHashRouter(), *sttxNew, rules).first != Validity::Valid)
|
||||
{
|
||||
ret.first = RPC::make_error(rpcINTERNAL, "Invalid signature.");
|
||||
return ret;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <xrpld/rpc/detail/TransactionSign.h>
|
||||
|
||||
#include <xrpl/core/HashRouter.h>
|
||||
#include <xrpl/core/NetworkIDService.h>
|
||||
#include <xrpl/protocol/ErrorCodes.h>
|
||||
#include <xrpl/protocol/NFTSyntheticSerializer.h>
|
||||
#include <xrpl/protocol/RPCErr.h>
|
||||
@@ -128,7 +129,7 @@ autofillTx(Json::Value& tx_json, RPC::JsonContext& context)
|
||||
|
||||
if (!tx_json.isMember(jss::NetworkID))
|
||||
{
|
||||
auto const networkId = context.app.config().NETWORK_ID;
|
||||
auto const networkId = context.app.getNetworkIDService().getNetworkID();
|
||||
if (networkId > 1024)
|
||||
tx_json[jss::NetworkID] = to_string(networkId);
|
||||
}
|
||||
|
||||
@@ -76,8 +76,8 @@ doSubmit(RPC::JsonContext& context)
|
||||
{
|
||||
if (!context.app.checkSigs())
|
||||
forceValidity(context.app.getHashRouter(), stTx->getTransactionID(), Validity::SigGoodOnly);
|
||||
auto [validity, reason] = checkValidity(
|
||||
context.app.getHashRouter(), *stTx, context.ledgerMaster.getCurrentLedger()->rules(), context.app.config());
|
||||
auto [validity, reason] =
|
||||
checkValidity(context.app.getHashRouter(), *stTx, context.ledgerMaster.getCurrentLedger()->rules());
|
||||
if (validity != Validity::Valid)
|
||||
{
|
||||
jvResult[jss::error] = "invalidTransaction";
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <xrpld/rpc/Status.h>
|
||||
|
||||
#include <xrpl/basics/ToString.h>
|
||||
#include <xrpl/core/NetworkIDService.h>
|
||||
#include <xrpl/protocol/ErrorCodes.h>
|
||||
#include <xrpl/protocol/NFTSyntheticSerializer.h>
|
||||
#include <xrpl/protocol/RPCErr.h>
|
||||
@@ -147,7 +148,7 @@ doTxHelp(RPC::Context& context, TxArgs args)
|
||||
{
|
||||
uint32_t lgrSeq = ledger->header().seq;
|
||||
uint32_t txnIdx = meta->getAsObject().getFieldU32(sfTransactionIndex);
|
||||
uint32_t netID = context.app.config().NETWORK_ID;
|
||||
uint32_t netID = context.app.getNetworkIDService().getNetworkID();
|
||||
|
||||
if (txnIdx <= 0xFFFFU && netID < 0xFFFFU && lgrSeq < 0x0FFF'FFFFUL)
|
||||
result.ctid = RPC::encodeCTID(lgrSeq, (uint32_t)txnIdx, (uint32_t)netID);
|
||||
@@ -267,7 +268,7 @@ doTxJson(RPC::JsonContext& context)
|
||||
return rpcError(rpcINVALID_PARAMS);
|
||||
|
||||
auto const [lgr_seq, txn_idx, net_id] = *ctid;
|
||||
if (net_id != context.app.config().NETWORK_ID)
|
||||
if (net_id != context.app.getNetworkIDService().getNetworkID())
|
||||
{
|
||||
std::stringstream out;
|
||||
out << "Wrong network. You should submit this request to a node "
|
||||
|
||||
Reference in New Issue
Block a user