mirror of
https://github.com/XRPLF/rippled.git
synced 2026-07-24 07:30:30 +00:00
refactor: Address PR comments after the modularisation PRs (#6389)
Signed-off-by: JCW <a1q123456@users.noreply.github.com> Co-authored-by: Bart <bthomee@users.noreply.github.com>
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
enum class StartUpType { FRESH, NORMAL, LOAD, LOAD_FILE, REPLAY, NETWORK };
|
||||
enum class StartUpType { Fresh, Normal, Load, LoadFile, Replay, Network };
|
||||
|
||||
inline std::ostream&
|
||||
operator<<(std::ostream& os, StartUpType const& type)
|
||||
|
||||
@@ -76,16 +76,33 @@ public:
|
||||
@return true if a book from this issue to XRP exists
|
||||
*/
|
||||
virtual bool
|
||||
isBookToXRP(Issue const& issue, std::optional<Domain> domain = std::nullopt) = 0;
|
||||
isBookToXRP(Issue const& issue, std::optional<Domain> const& domain = std::nullopt) = 0;
|
||||
|
||||
/**
|
||||
* Process a transaction for order book tracking.
|
||||
* @param ledger The ledger the transaction was applied to
|
||||
* @param alTx The transaction to process
|
||||
* @param jvObj The JSON object of the transaction
|
||||
*/
|
||||
virtual void
|
||||
processTxn(
|
||||
std::shared_ptr<ReadView const> const& ledger,
|
||||
AcceptedLedgerTx const& alTx,
|
||||
MultiApiJson const& jvObj) = 0;
|
||||
|
||||
/**
|
||||
* Get the book listeners for a book.
|
||||
* @param book The book to get the listeners for
|
||||
* @return The book listeners for the book
|
||||
*/
|
||||
virtual BookListeners::pointer
|
||||
getBookListeners(Book const&) = 0;
|
||||
|
||||
/**
|
||||
* Create a new book listeners for a book.
|
||||
* @param book The book to create the listeners for
|
||||
* @return The new book listeners for the book
|
||||
*/
|
||||
virtual BookListeners::pointer
|
||||
makeBookListeners(Book const&) = 0;
|
||||
};
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
enum class TxSearched { all, some, unknown };
|
||||
enum class TxSearched { All, Some, Unknown };
|
||||
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public:
|
||||
{
|
||||
explicit Setup() = default;
|
||||
|
||||
StartUpType startUp = StartUpType::NORMAL;
|
||||
StartUpType startUp = StartUpType::Normal;
|
||||
bool standAlone = false;
|
||||
boost::filesystem::path dataDir;
|
||||
// Indicates whether or not to return the `globalPragma`
|
||||
@@ -107,9 +107,8 @@ public:
|
||||
beast::Journal journal)
|
||||
// Use temporary files or regular DB files?
|
||||
: DatabaseCon(
|
||||
setup.standAlone && setup.startUp != StartUpType::LOAD &&
|
||||
setup.startUp != StartUpType::LOAD_FILE &&
|
||||
setup.startUp != StartUpType::REPLAY
|
||||
setup.standAlone && setup.startUp != StartUpType::Load &&
|
||||
setup.startUp != StartUpType::LoadFile && setup.startUp != StartUpType::Replay
|
||||
? ""
|
||||
: (setup.dataDir / dbName),
|
||||
setup.commonPragma(),
|
||||
|
||||
@@ -49,8 +49,9 @@ public:
|
||||
struct AccountTxOptions
|
||||
{
|
||||
AccountID const& account;
|
||||
std::uint32_t minLedger;
|
||||
std::uint32_t maxLedger;
|
||||
/// Ledger sequence range to search. A value of 0 for min or max
|
||||
/// means unbounded in that direction (no constraint applied).
|
||||
LedgerRange ledgerRange;
|
||||
std::uint32_t offset;
|
||||
std::uint32_t limit;
|
||||
bool bUnlimited;
|
||||
@@ -59,8 +60,7 @@ public:
|
||||
struct AccountTxPageOptions
|
||||
{
|
||||
AccountID const& account;
|
||||
std::uint32_t minLedger;
|
||||
std::uint32_t maxLedger;
|
||||
LedgerRange ledgerRange;
|
||||
std::optional<AccountTxMarker> marker;
|
||||
std::uint32_t limit;
|
||||
bool bAdmin;
|
||||
@@ -247,7 +247,7 @@ public:
|
||||
* @return Struct CountMinMax which contains the minimum sequence,
|
||||
* maximum sequence and number of ledgers.
|
||||
*/
|
||||
virtual struct CountMinMax
|
||||
virtual CountMinMax
|
||||
getLedgerCountMinMax() = 0;
|
||||
|
||||
/**
|
||||
@@ -405,10 +405,10 @@ public:
|
||||
* @param id Hash of the transaction.
|
||||
* @param range Range of ledgers to check, if present.
|
||||
* @param ec Default error code value.
|
||||
* @return Transaction and its metadata if found, otherwise TxSearched::all
|
||||
* @return Transaction and its metadata if found, otherwise TxSearched::All
|
||||
* if a range is provided and all ledgers from the range are present
|
||||
* in the database, TxSearched::some if a range is provided and not
|
||||
* all ledgers are present, TxSearched::unknown if the range is not
|
||||
* in the database, TxSearched::Some if a range is provided and not
|
||||
* all ledgers are present, TxSearched::Unknown if the range is not
|
||||
* provided or a deserializing error occurred. In the last case the
|
||||
* error code is returned via the ec parameter, in other cases the
|
||||
* default error code is not changed.
|
||||
@@ -455,9 +455,10 @@ public:
|
||||
closeTransactionDB() = 0;
|
||||
};
|
||||
|
||||
template <class T, class C>
|
||||
template <typename T, typename C>
|
||||
T
|
||||
rangeCheckedCast(C c)
|
||||
requires(std::is_arithmetic_v<T> && std::is_arithmetic_v<C> && std::convertible_to<C, T>)
|
||||
{
|
||||
if ((c > std::numeric_limits<T>::max()) || (!std::numeric_limits<T>::is_signed && c < 0) ||
|
||||
(std::numeric_limits<T>::is_signed && std::numeric_limits<C>::is_signed &&
|
||||
|
||||
@@ -37,7 +37,7 @@ public:
|
||||
XRPL_ASSERT((flags & tapBATCH) == 0, "Batch apply flag should not be set");
|
||||
}
|
||||
|
||||
ServiceRegistry& registry;
|
||||
std::reference_wrapper<ServiceRegistry> registry;
|
||||
STTx const& tx;
|
||||
TER const preclaimResult;
|
||||
XRPAmount const baseFee;
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace xrpl {
|
||||
struct PreflightContext
|
||||
{
|
||||
public:
|
||||
ServiceRegistry& registry;
|
||||
std::reference_wrapper<ServiceRegistry> registry;
|
||||
STTx const& tx;
|
||||
Rules const rules;
|
||||
ApplyFlags flags;
|
||||
@@ -56,7 +56,7 @@ public:
|
||||
struct PreclaimContext
|
||||
{
|
||||
public:
|
||||
ServiceRegistry& registry;
|
||||
std::reference_wrapper<ServiceRegistry> registry;
|
||||
ReadView const& view;
|
||||
TER preflightResult;
|
||||
ApplyFlags flags;
|
||||
|
||||
@@ -29,7 +29,7 @@ public:
|
||||
auto it = checkpointers_.find(id);
|
||||
if (it != checkpointers_.end())
|
||||
return it->second;
|
||||
return {};
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -34,7 +34,7 @@ preflight0(PreflightContext const& ctx, std::uint32_t flagMask)
|
||||
|
||||
if (!isPseudoTx(ctx.tx) || ctx.tx.isFieldPresent(sfNetworkID))
|
||||
{
|
||||
uint32_t nodeNID = ctx.registry.getNetworkIDService().getNetworkID();
|
||||
uint32_t nodeNID = ctx.registry.get().getNetworkIDService().getNetworkID();
|
||||
std::optional<uint32_t> txNID = ctx.tx[~sfNetworkID];
|
||||
|
||||
if (nodeNID <= 1024)
|
||||
@@ -211,7 +211,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.registry.getHashRouter(), ctx.tx, ctx.rules);
|
||||
auto const sigValid = checkValidity(ctx.registry.get().getHashRouter(), ctx.tx, ctx.rules);
|
||||
if (sigValid.first == Validity::SigBad)
|
||||
{ // LCOV_EXCL_START
|
||||
JLOG(ctx.j.debug()) << "preflight2: bad signature. " << sigValid.second;
|
||||
@@ -1095,7 +1095,8 @@ Transactor::operator()()
|
||||
}
|
||||
#endif
|
||||
|
||||
if (auto const& trap = ctx_.registry.getTrapTxID(); trap && *trap == ctx_.tx.getTransactionID())
|
||||
if (auto const& trap = ctx_.registry.get().getTrapTxID();
|
||||
trap && *trap == ctx_.tx.getTransactionID())
|
||||
{
|
||||
trapTransaction(*trap);
|
||||
}
|
||||
@@ -1198,23 +1199,25 @@ Transactor::operator()()
|
||||
// If necessary, remove any offers found unfunded during processing
|
||||
if ((result == tecOVERSIZE) || (result == tecKILLED))
|
||||
{
|
||||
removeUnfundedOffers(view(), removedOffers, ctx_.registry.getJournal("View"));
|
||||
removeUnfundedOffers(view(), removedOffers, ctx_.registry.get().getJournal("View"));
|
||||
}
|
||||
|
||||
if (result == tecEXPIRED)
|
||||
{
|
||||
removeExpiredNFTokenOffers(
|
||||
view(), expiredNFTokenOffers, ctx_.registry.getJournal("View"));
|
||||
view(), expiredNFTokenOffers, ctx_.registry.get().getJournal("View"));
|
||||
}
|
||||
|
||||
if (result == tecINCOMPLETE)
|
||||
{
|
||||
removeDeletedTrustLines(view(), removedTrustLines, ctx_.registry.getJournal("View"));
|
||||
removeDeletedTrustLines(
|
||||
view(), removedTrustLines, ctx_.registry.get().getJournal("View"));
|
||||
}
|
||||
|
||||
if (result == tecEXPIRED)
|
||||
{
|
||||
removeExpiredCredentials(view(), expiredCredentials, ctx_.registry.getJournal("View"));
|
||||
removeExpiredCredentials(
|
||||
view(), expiredCredentials, ctx_.registry.get().getJournal("View"));
|
||||
}
|
||||
|
||||
applied = isTecClaim(result);
|
||||
|
||||
@@ -314,7 +314,7 @@ SignerListSet::replaceSignerList()
|
||||
view().insert(signerList);
|
||||
writeSignersToSLE(signerList, flags);
|
||||
|
||||
auto viewJ = ctx_.registry.getJournal("View");
|
||||
auto viewJ = ctx_.registry.get().getJournal("View");
|
||||
// Add the signer list to the account's directory.
|
||||
auto const page =
|
||||
ctx_.view().dirInsert(ownerDirKeylet, signerListKeylet, describeOwnerDir(account_));
|
||||
|
||||
@@ -57,7 +57,7 @@ CheckCancel::doApply()
|
||||
|
||||
AccountID const srcId{sleCheck->getAccountID(sfAccount)};
|
||||
AccountID const dstId{sleCheck->getAccountID(sfDestination)};
|
||||
auto viewJ = ctx_.registry.getJournal("View");
|
||||
auto viewJ = ctx_.registry.get().getJournal("View");
|
||||
|
||||
// If the check is not written to self (and it shouldn't be), remove the
|
||||
// check from the destination account root.
|
||||
|
||||
@@ -232,7 +232,7 @@ CheckCash::doApply()
|
||||
//
|
||||
// If it is not a check to self (as should be the case), then there's
|
||||
// work to do...
|
||||
auto viewJ = ctx_.registry.getJournal("View");
|
||||
auto viewJ = ctx_.registry.get().getJournal("View");
|
||||
auto const optDeliverMin = ctx_.tx[~sfDeliverMin];
|
||||
|
||||
if (srcId != account_)
|
||||
|
||||
@@ -168,7 +168,7 @@ CheckCreate::doApply()
|
||||
|
||||
view().insert(sleCheck);
|
||||
|
||||
auto viewJ = ctx_.registry.getJournal("View");
|
||||
auto viewJ = ctx_.registry.get().getJournal("View");
|
||||
// If it's not a self-send (and it shouldn't be), add Check to the
|
||||
// destination's owner directory.
|
||||
if (dstAccountId != account_)
|
||||
|
||||
@@ -281,7 +281,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_.registry.getOrderBookDB().addOrderBook(book);
|
||||
ctx_.registry.get().getOrderBookDB().addOrderBook(book);
|
||||
};
|
||||
addOrderBook(amount.issue(), amount2.issue(), getRate(amount2, amount));
|
||||
addOrderBook(amount2.issue(), amount.issue(), getRate(amount, amount2));
|
||||
|
||||
@@ -53,7 +53,7 @@ OfferCancel::doApply()
|
||||
if (auto sleOffer = view().peek(keylet::offer(account_, offerSequence)))
|
||||
{
|
||||
JLOG(j_.debug()) << "Trying to cancel offer #" << offerSequence;
|
||||
return offerDelete(view(), sleOffer, ctx_.registry.getJournal("View"));
|
||||
return offerDelete(view(), sleOffer, ctx_.registry.get().getJournal("View"));
|
||||
}
|
||||
|
||||
JLOG(j_.debug()) << "Offer #" << offerSequence << " can't be found.";
|
||||
|
||||
@@ -144,7 +144,7 @@ OfferCreate::preclaim(PreclaimContext const& ctx)
|
||||
|
||||
std::uint32_t const uAccountSequence = sleCreator->getFieldU32(sfSequence);
|
||||
|
||||
auto viewJ = ctx.registry.getJournal("View");
|
||||
auto viewJ = ctx.registry.get().getJournal("View");
|
||||
|
||||
if (isGlobalFrozen(ctx.view, uPaysIssuerID) || isGlobalFrozen(ctx.view, uGetsIssuerID))
|
||||
{
|
||||
@@ -502,7 +502,7 @@ OfferCreate::applyHybrid(
|
||||
bookArr.push_back(std::move(bookInfo));
|
||||
|
||||
if (!bookExists)
|
||||
ctx_.registry.getOrderBookDB().addOrderBook(book);
|
||||
ctx_.registry.get().getOrderBookDB().addOrderBook(book);
|
||||
|
||||
sleOffer->setFieldArray(sfAdditionalBooks, bookArr);
|
||||
return tesSUCCESS;
|
||||
@@ -536,7 +536,7 @@ OfferCreate::applyGuts(Sandbox& sb, Sandbox& sbCancel)
|
||||
// end up on the books.
|
||||
auto uRate = getRate(saTakerGets, saTakerPays);
|
||||
|
||||
auto viewJ = ctx_.registry.getJournal("View");
|
||||
auto viewJ = ctx_.registry.get().getJournal("View");
|
||||
|
||||
TER result = tesSUCCESS;
|
||||
|
||||
@@ -846,7 +846,7 @@ OfferCreate::applyGuts(Sandbox& sb, Sandbox& sbCancel)
|
||||
sb.insert(sleOffer);
|
||||
|
||||
if (!bookExisted)
|
||||
ctx_.registry.getOrderBookDB().addOrderBook(book);
|
||||
ctx_.registry.get().getOrderBookDB().addOrderBook(book);
|
||||
|
||||
JLOG(j_.debug()) << "final result: success";
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ EscrowFinish::preflightSigValidated(PreflightContext const& ctx)
|
||||
|
||||
if (cb && fb)
|
||||
{
|
||||
auto& router = ctx.registry.getHashRouter();
|
||||
auto& router = ctx.registry.get().getHashRouter();
|
||||
|
||||
auto const id = ctx.tx.getTransactionID();
|
||||
auto const flags = router.getFlags(id);
|
||||
@@ -237,7 +237,7 @@ EscrowFinish::doApply()
|
||||
// Check cryptocondition fulfillment
|
||||
{
|
||||
auto const id = ctx_.tx.getTransactionID();
|
||||
auto flags = ctx_.registry.getHashRouter().getFlags(id);
|
||||
auto flags = ctx_.registry.get().getHashRouter().getFlags(id);
|
||||
|
||||
auto const cb = ctx_.tx[~sfCondition];
|
||||
|
||||
@@ -261,7 +261,7 @@ EscrowFinish::doApply()
|
||||
flags = SF_CF_INVALID;
|
||||
}
|
||||
|
||||
ctx_.registry.getHashRouter().setFlags(id, flags);
|
||||
ctx_.registry.get().getHashRouter().setFlags(id, flags);
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ PaymentChannelClaim::doApply()
|
||||
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_.registry.getJournal("View"));
|
||||
return closeChannel(slep, ctx_.view(), k.key, ctx_.registry.get().getJournal("View"));
|
||||
}
|
||||
|
||||
if (txAccount != src && txAccount != dst)
|
||||
@@ -169,7 +169,7 @@ PaymentChannelClaim::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_.registry.getJournal("View"));
|
||||
return closeChannel(slep, ctx_.view(), k.key, ctx_.registry.get().getJournal("View"));
|
||||
|
||||
auto const settleExpiration =
|
||||
ctx_.view().header().parentCloseTime.time_since_epoch().count() +
|
||||
|
||||
@@ -38,7 +38,7 @@ PaymentChannelFund::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_.registry.getJournal("View"));
|
||||
return closeChannel(slep, ctx_.view(), k.key, ctx_.registry.get().getJournal("View"));
|
||||
}
|
||||
|
||||
if (src != txAccount)
|
||||
|
||||
@@ -200,7 +200,7 @@ Change::applyAmendment()
|
||||
entry[sfAmendment] = amendment;
|
||||
entry[sfCloseTime] = view().parentCloseTime().time_since_epoch().count();
|
||||
|
||||
if (!ctx_.registry.getAmendmentTable().isSupported(amendment))
|
||||
if (!ctx_.registry.get().getAmendmentTable().isSupported(amendment))
|
||||
{
|
||||
JLOG(j_.warn()) << "Unsupported amendment " << amendment << " received a majority.";
|
||||
}
|
||||
@@ -211,13 +211,13 @@ Change::applyAmendment()
|
||||
amendments.push_back(amendment);
|
||||
amendmentObject->setFieldV256(sfAmendments, amendments);
|
||||
|
||||
ctx_.registry.getAmendmentTable().enable(amendment);
|
||||
ctx_.registry.get().getAmendmentTable().enable(amendment);
|
||||
|
||||
if (!ctx_.registry.getAmendmentTable().isSupported(amendment))
|
||||
if (!ctx_.registry.get().getAmendmentTable().isSupported(amendment))
|
||||
{
|
||||
JLOG(j_.error()) << "Unsupported amendment " << amendment
|
||||
<< " activated: server blocked.";
|
||||
ctx_.registry.getOPs().setAmendmentBlocked();
|
||||
ctx_.registry.get().getOPs().setAmendmentBlocked();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ TicketCreate::doApply()
|
||||
return tecINSUFFICIENT_RESERVE;
|
||||
}
|
||||
|
||||
beast::Journal viewJ{ctx_.registry.getJournal("View")};
|
||||
beast::Journal viewJ{ctx_.registry.get().getJournal("View")};
|
||||
|
||||
// The starting ticket sequence is the same as the current account
|
||||
// root sequence. Before we got here to doApply(), the transaction
|
||||
|
||||
@@ -366,7 +366,7 @@ TrustSet::doApply()
|
||||
bool const bSetDeepFreeze = (uTxFlags & tfSetDeepFreeze) != 0u;
|
||||
bool const bClearDeepFreeze = (uTxFlags & tfClearDeepFreeze) != 0u;
|
||||
|
||||
auto viewJ = ctx_.registry.getJournal("View");
|
||||
auto viewJ = ctx_.registry.get().getJournal("View");
|
||||
|
||||
SLE::pointer sleDst = view().peek(keylet::account(uDstAccountID));
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ class LedgerLoad_test : public beast::unit_test::suite
|
||||
// create a new env with the ledger file specified for startup
|
||||
Env env(
|
||||
*this,
|
||||
envconfig(ledgerConfig, sd.dbPath, sd.ledgerFile, StartUpType::LOAD_FILE, std::nullopt),
|
||||
envconfig(ledgerConfig, sd.dbPath, sd.ledgerFile, StartUpType::LoadFile, std::nullopt),
|
||||
nullptr,
|
||||
beast::severities::kDisabled);
|
||||
auto jrb = env.rpc("ledger", "current", "full")[jss::result];
|
||||
@@ -129,7 +129,7 @@ class LedgerLoad_test : public beast::unit_test::suite
|
||||
except([&] {
|
||||
Env env(
|
||||
*this,
|
||||
envconfig(ledgerConfig, sd.dbPath, "", StartUpType::LOAD_FILE, std::nullopt),
|
||||
envconfig(ledgerConfig, sd.dbPath, "", StartUpType::LoadFile, std::nullopt),
|
||||
nullptr,
|
||||
beast::severities::kDisabled);
|
||||
});
|
||||
@@ -139,7 +139,7 @@ class LedgerLoad_test : public beast::unit_test::suite
|
||||
Env env(
|
||||
*this,
|
||||
envconfig(
|
||||
ledgerConfig, sd.dbPath, "badfile.json", StartUpType::LOAD_FILE, std::nullopt),
|
||||
ledgerConfig, sd.dbPath, "badfile.json", StartUpType::LoadFile, std::nullopt),
|
||||
nullptr,
|
||||
beast::severities::kDisabled);
|
||||
});
|
||||
@@ -164,7 +164,7 @@ class LedgerLoad_test : public beast::unit_test::suite
|
||||
ledgerConfig,
|
||||
sd.dbPath,
|
||||
ledgerFileCorrupt.string(),
|
||||
StartUpType::LOAD_FILE,
|
||||
StartUpType::LoadFile,
|
||||
std::nullopt),
|
||||
nullptr,
|
||||
beast::severities::kDisabled);
|
||||
@@ -182,7 +182,7 @@ class LedgerLoad_test : public beast::unit_test::suite
|
||||
boost::erase_all(ledgerHash, "\"");
|
||||
Env env(
|
||||
*this,
|
||||
envconfig(ledgerConfig, sd.dbPath, ledgerHash, StartUpType::LOAD, std::nullopt),
|
||||
envconfig(ledgerConfig, sd.dbPath, ledgerHash, StartUpType::Load, std::nullopt),
|
||||
nullptr,
|
||||
beast::severities::kDisabled);
|
||||
auto jrb = env.rpc("ledger", "current", "full")[jss::result];
|
||||
@@ -203,7 +203,7 @@ class LedgerLoad_test : public beast::unit_test::suite
|
||||
boost::erase_all(ledgerHash, "\"");
|
||||
Env env(
|
||||
*this,
|
||||
envconfig(ledgerConfig, sd.dbPath, ledgerHash, StartUpType::REPLAY, std::nullopt),
|
||||
envconfig(ledgerConfig, sd.dbPath, ledgerHash, StartUpType::Replay, std::nullopt),
|
||||
nullptr,
|
||||
beast::severities::kDisabled);
|
||||
auto const jrb = env.rpc("ledger", "current", "full")[jss::result];
|
||||
@@ -229,7 +229,7 @@ class LedgerLoad_test : public beast::unit_test::suite
|
||||
boost::erase_all(ledgerHash, "\"");
|
||||
Env env(
|
||||
*this,
|
||||
envconfig(ledgerConfig, sd.dbPath, ledgerHash, StartUpType::REPLAY, sd.trapTxHash),
|
||||
envconfig(ledgerConfig, sd.dbPath, ledgerHash, StartUpType::Replay, sd.trapTxHash),
|
||||
nullptr,
|
||||
beast::severities::kDisabled);
|
||||
auto const jrb = env.rpc("ledger", "current", "full")[jss::result];
|
||||
@@ -259,7 +259,7 @@ class LedgerLoad_test : public beast::unit_test::suite
|
||||
// replay when trapTxHash is set to an invalid transaction
|
||||
Env env(
|
||||
*this,
|
||||
envconfig(ledgerConfig, sd.dbPath, ledgerHash, StartUpType::REPLAY, ~sd.trapTxHash),
|
||||
envconfig(ledgerConfig, sd.dbPath, ledgerHash, StartUpType::Replay, ~sd.trapTxHash),
|
||||
nullptr,
|
||||
beast::severities::kDisabled);
|
||||
BEAST_EXPECT(false);
|
||||
@@ -283,7 +283,7 @@ class LedgerLoad_test : public beast::unit_test::suite
|
||||
// create a new env with the ledger "latest" specified for startup
|
||||
Env env(
|
||||
*this,
|
||||
envconfig(ledgerConfig, sd.dbPath, "latest", StartUpType::LOAD, std::nullopt),
|
||||
envconfig(ledgerConfig, sd.dbPath, "latest", StartUpType::Load, std::nullopt),
|
||||
nullptr,
|
||||
beast::severities::kDisabled);
|
||||
auto jrb = env.rpc("ledger", "current", "full")[jss::result];
|
||||
@@ -301,7 +301,7 @@ class LedgerLoad_test : public beast::unit_test::suite
|
||||
// create a new env with specific ledger index at startup
|
||||
Env env(
|
||||
*this,
|
||||
envconfig(ledgerConfig, sd.dbPath, "43", StartUpType::LOAD, std::nullopt),
|
||||
envconfig(ledgerConfig, sd.dbPath, "43", StartUpType::Load, std::nullopt),
|
||||
nullptr,
|
||||
beast::severities::kDisabled);
|
||||
auto jrb = env.rpc("ledger", "current", "full")[jss::result];
|
||||
|
||||
@@ -2189,7 +2189,7 @@ class LedgerEntry_test : public beast::unit_test::suite
|
||||
Account const bob{"bob"};
|
||||
|
||||
Env env{*this, envconfig([](auto cfg) {
|
||||
cfg->START_UP = StartUpType::FRESH;
|
||||
cfg->START_UP = StartUpType::Fresh;
|
||||
return cfg;
|
||||
})};
|
||||
|
||||
@@ -2382,7 +2382,7 @@ class LedgerEntry_test : public beast::unit_test::suite
|
||||
Account const bob{"bob"};
|
||||
|
||||
Env env{*this, envconfig([](auto cfg) {
|
||||
cfg->START_UP = StartUpType::FRESH;
|
||||
cfg->START_UP = StartUpType::Fresh;
|
||||
return cfg;
|
||||
})};
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ make_OrderBookDB(ServiceRegistry& registry, OrderBookDBConfig const& config)
|
||||
void
|
||||
OrderBookDBImpl::setup(std::shared_ptr<ReadView const> const& ledger)
|
||||
{
|
||||
if (!standalone_ && registry_.getOPs().isNeedNetworkLedger())
|
||||
if (!standalone_ && registry_.get().getOPs().isNeedNetworkLedger())
|
||||
{
|
||||
JLOG(j_.warn()) << "Eliding full order book update: no ledger";
|
||||
return;
|
||||
@@ -56,7 +56,7 @@ OrderBookDBImpl::setup(std::shared_ptr<ReadView const> const& ledger)
|
||||
}
|
||||
else
|
||||
{
|
||||
registry_.getJobQueue().addJob(
|
||||
registry_.get().getJobQueue().addJob(
|
||||
jtUPDATE_PF, "OBUpd" + std::to_string(ledger->seq()), [this, ledger]() {
|
||||
update(ledger);
|
||||
});
|
||||
@@ -95,7 +95,7 @@ OrderBookDBImpl::update(std::shared_ptr<ReadView const> const& ledger)
|
||||
{
|
||||
for (auto& sle : ledger->sles)
|
||||
{
|
||||
if (registry_.isStopping())
|
||||
if (registry_.get().isStopping())
|
||||
{
|
||||
JLOG(j_.info()) << "Update halted because the process is stopping";
|
||||
seq_.store(0);
|
||||
@@ -167,7 +167,7 @@ OrderBookDBImpl::update(std::shared_ptr<ReadView const> const& ledger)
|
||||
xrpDomainBooks_.swap(xrpDomainBooks);
|
||||
}
|
||||
|
||||
registry_.getLedgerMaster().newOrderBookDB();
|
||||
registry_.get().getLedgerMaster().newOrderBookDB();
|
||||
}
|
||||
|
||||
void
|
||||
@@ -249,7 +249,7 @@ OrderBookDBImpl::getBookSize(Issue const& issue, std::optional<uint256> const& d
|
||||
}
|
||||
|
||||
bool
|
||||
OrderBookDBImpl::isBookToXRP(Issue const& issue, std::optional<Domain> domain)
|
||||
OrderBookDBImpl::isBookToXRP(Issue const& issue, std::optional<Domain> const& domain)
|
||||
{
|
||||
std::lock_guard sl(mLock);
|
||||
if (domain)
|
||||
|
||||
@@ -48,7 +48,7 @@ public:
|
||||
getBookSize(Issue const& issue, std::optional<Domain> const& domain = std::nullopt) override;
|
||||
|
||||
bool
|
||||
isBookToXRP(Issue const& issue, std::optional<Domain> domain = std::nullopt) override;
|
||||
isBookToXRP(Issue const& issue, std::optional<Domain> const& domain = std::nullopt) override;
|
||||
|
||||
// OrderBookDBImpl-specific methods
|
||||
void
|
||||
@@ -67,7 +67,7 @@ public:
|
||||
makeBookListeners(Book const&) override;
|
||||
|
||||
private:
|
||||
ServiceRegistry& registry_;
|
||||
std::reference_wrapper<ServiceRegistry> registry_;
|
||||
int const pathSearchMax_;
|
||||
bool const standalone_;
|
||||
|
||||
|
||||
@@ -782,8 +782,7 @@ public:
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
relationalDatabase_,
|
||||
"xrpl::ApplicationImp::getRelationalDatabase : non-null "
|
||||
"relational database");
|
||||
"xrpl::ApplicationImp::getRelationalDatabase : non-null relational database");
|
||||
return *relationalDatabase_;
|
||||
}
|
||||
|
||||
@@ -1214,22 +1213,22 @@ ApplicationImp::setup(boost::program_options::variables_map const& cmdline)
|
||||
|
||||
auto const startUp = config_->START_UP;
|
||||
JLOG(m_journal.debug()) << "startUp: " << startUp;
|
||||
if (startUp == StartUpType::FRESH)
|
||||
if (startUp == StartUpType::Fresh)
|
||||
{
|
||||
JLOG(m_journal.info()) << "Starting new Ledger";
|
||||
|
||||
startGenesisLedger();
|
||||
}
|
||||
else if (
|
||||
startUp == StartUpType::LOAD || startUp == StartUpType::LOAD_FILE ||
|
||||
startUp == StartUpType::REPLAY)
|
||||
startUp == StartUpType::Load || startUp == StartUpType::LoadFile ||
|
||||
startUp == StartUpType::Replay)
|
||||
{
|
||||
JLOG(m_journal.info()) << "Loading specified Ledger";
|
||||
|
||||
if (!loadOldLedger(
|
||||
config_->START_LEDGER,
|
||||
startUp == StartUpType::REPLAY,
|
||||
startUp == StartUpType::LOAD_FILE,
|
||||
startUp == StartUpType::Replay,
|
||||
startUp == StartUpType::LoadFile,
|
||||
config_->TRAP_TX_HASH))
|
||||
{
|
||||
JLOG(m_journal.error()) << "The specified ledger could not be loaded.";
|
||||
@@ -1245,7 +1244,7 @@ ApplicationImp::setup(boost::program_options::variables_map const& cmdline)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (startUp == StartUpType::NETWORK)
|
||||
else if (startUp == StartUpType::Network)
|
||||
{
|
||||
// This should probably become the default once we have a stable
|
||||
// network.
|
||||
@@ -1636,7 +1635,7 @@ ApplicationImp::fdRequired() const
|
||||
void
|
||||
ApplicationImp::startGenesisLedger()
|
||||
{
|
||||
std::vector<uint256> const initialAmendments = (config_->START_UP == StartUpType::FRESH)
|
||||
std::vector<uint256> const initialAmendments = (config_->START_UP == StartUpType::Fresh)
|
||||
? m_amendmentTable->getDesired()
|
||||
: std::vector<uint256>{};
|
||||
|
||||
|
||||
@@ -613,7 +613,7 @@ run(int argc, char** argv)
|
||||
|
||||
if (vm.contains("start"))
|
||||
{
|
||||
config->START_UP = StartUpType::FRESH;
|
||||
config->START_UP = StartUpType::Fresh;
|
||||
}
|
||||
|
||||
if (vm.contains("import"))
|
||||
@@ -624,7 +624,7 @@ run(int argc, char** argv)
|
||||
config->START_LEDGER = vm["ledger"].as<std::string>();
|
||||
if (vm.contains("replay"))
|
||||
{
|
||||
config->START_UP = StartUpType::REPLAY;
|
||||
config->START_UP = StartUpType::Replay;
|
||||
if (vm.contains("trap_tx_hash"))
|
||||
{
|
||||
uint256 tmp = {};
|
||||
@@ -644,17 +644,17 @@ run(int argc, char** argv)
|
||||
}
|
||||
else
|
||||
{
|
||||
config->START_UP = StartUpType::LOAD;
|
||||
config->START_UP = StartUpType::Load;
|
||||
}
|
||||
}
|
||||
else if (vm.contains("ledgerfile"))
|
||||
{
|
||||
config->START_LEDGER = vm["ledgerfile"].as<std::string>();
|
||||
config->START_UP = StartUpType::LOAD_FILE;
|
||||
config->START_UP = StartUpType::LoadFile;
|
||||
}
|
||||
else if (vm.contains("load") || config->FAST_LOAD)
|
||||
{
|
||||
config->START_UP = StartUpType::LOAD;
|
||||
config->START_UP = StartUpType::Load;
|
||||
}
|
||||
|
||||
if (vm.contains("trap_tx_hash") && !vm.contains("replay"))
|
||||
@@ -665,13 +665,13 @@ run(int argc, char** argv)
|
||||
|
||||
if (vm.contains("net") && !config->FAST_LOAD)
|
||||
{
|
||||
if ((config->START_UP == StartUpType::LOAD) || (config->START_UP == StartUpType::REPLAY))
|
||||
if ((config->START_UP == StartUpType::Load) || (config->START_UP == StartUpType::Replay))
|
||||
{
|
||||
std::cerr << "Net and load/replay options are incompatible" << std::endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
config->START_UP = StartUpType::NETWORK;
|
||||
config->START_UP = StartUpType::Network;
|
||||
}
|
||||
|
||||
if (vm.contains("valid"))
|
||||
|
||||
@@ -216,27 +216,27 @@ public:
|
||||
JobQueue& job_queue,
|
||||
LedgerMaster& ledgerMaster,
|
||||
ValidatorKeys const& validatorKeys,
|
||||
boost::asio::io_context& io_svc,
|
||||
boost::asio::io_context& ioCtx,
|
||||
beast::Journal journal,
|
||||
beast::insight::Collector::ptr const& collector)
|
||||
: registry_(registry)
|
||||
, m_journal(journal)
|
||||
, m_localTX(make_LocalTxs())
|
||||
, mMode(start_valid ? OperatingMode::FULL : OperatingMode::DISCONNECTED)
|
||||
, heartbeatTimer_(io_svc)
|
||||
, clusterTimer_(io_svc)
|
||||
, accountHistoryTxTimer_(io_svc)
|
||||
, heartbeatTimer_(ioCtx)
|
||||
, clusterTimer_(ioCtx)
|
||||
, accountHistoryTxTimer_(ioCtx)
|
||||
, mConsensus(
|
||||
registry_.getApp(),
|
||||
registry_.get().getApp(),
|
||||
make_FeeVote(
|
||||
setup_FeeVote(registry_.getApp().config().section("voting")),
|
||||
registry_.getJournal("FeeVote")),
|
||||
setup_FeeVote(registry_.get().getApp().config().section("voting")),
|
||||
registry_.get().getJournal("FeeVote")),
|
||||
ledgerMaster,
|
||||
*m_localTX,
|
||||
registry.getInboundTransactions(),
|
||||
beast::get_abstract_clock<std::chrono::steady_clock>(),
|
||||
validatorKeys,
|
||||
registry_.getJournal("LedgerConsensus"))
|
||||
registry_.get().getJournal("LedgerConsensus"))
|
||||
, validatorPK_(
|
||||
validatorKeys.keys ? validatorKeys.keys->publicKey : decltype(validatorPK_){})
|
||||
, validatorMasterPK_(
|
||||
@@ -690,7 +690,7 @@ private:
|
||||
void
|
||||
setAccountHistoryJobTimer(SubAccountHistoryInfoWeak subInfo);
|
||||
|
||||
ServiceRegistry& registry_;
|
||||
std::reference_wrapper<ServiceRegistry> registry_;
|
||||
beast::Journal m_journal;
|
||||
|
||||
std::unique_ptr<LocalTxs> m_localTX;
|
||||
@@ -877,7 +877,7 @@ NetworkOPsImp::getHostId(bool forAdmin)
|
||||
// For non-admin uses hash the node public key into a
|
||||
// single RFC1751 word:
|
||||
static std::string const shroudedHostId = [this]() {
|
||||
auto const& id = registry_.getApp().nodeIdentity();
|
||||
auto const& id = registry_.get().getApp().nodeIdentity();
|
||||
|
||||
return RFC1751::getWordFromBlob(id.first.data(), id.first.size());
|
||||
}();
|
||||
@@ -891,7 +891,7 @@ NetworkOPsImp::setStateTimer()
|
||||
setHeartbeatTimer();
|
||||
|
||||
// Only do this work if a cluster is configured
|
||||
if (registry_.getCluster().size() != 0)
|
||||
if (registry_.get().getCluster().size() != 0)
|
||||
setClusterTimer();
|
||||
}
|
||||
|
||||
@@ -969,13 +969,13 @@ NetworkOPsImp::processHeartbeatTimer()
|
||||
{
|
||||
RclConsensusLogger clog("Heartbeat Timer", mConsensus.validating(), m_journal);
|
||||
{
|
||||
std::unique_lock lock{registry_.getApp().getMasterMutex()};
|
||||
std::unique_lock lock{registry_.get().getApp().getMasterMutex()};
|
||||
|
||||
// VFALCO NOTE This is for diagnosing a crash on exit
|
||||
LoadManager& mgr(registry_.getLoadManager());
|
||||
LoadManager& mgr(registry_.get().getLoadManager());
|
||||
mgr.heartbeat();
|
||||
|
||||
std::size_t const numPeers = registry_.getOverlay().size();
|
||||
std::size_t const numPeers = registry_.get().getOverlay().size();
|
||||
|
||||
// do we have sufficient peers? If not, we are disconnected.
|
||||
if (numPeers < minPeerCount_)
|
||||
@@ -1031,7 +1031,7 @@ NetworkOPsImp::processHeartbeatTimer()
|
||||
CLOG(clog.ss()) << ". ";
|
||||
}
|
||||
|
||||
mConsensus.timerEntry(registry_.getTimeKeeper().closeTime(), clog.ss());
|
||||
mConsensus.timerEntry(registry_.get().getTimeKeeper().closeTime(), clog.ss());
|
||||
|
||||
CLOG(clog.ss()) << "consensus phase " << to_string(mLastConsensusPhase);
|
||||
ConsensusPhase const currPhase = mConsensus.phase();
|
||||
@@ -1049,17 +1049,18 @@ NetworkOPsImp::processHeartbeatTimer()
|
||||
void
|
||||
NetworkOPsImp::processClusterTimer()
|
||||
{
|
||||
if (registry_.getCluster().size() == 0)
|
||||
if (registry_.get().getCluster().size() == 0)
|
||||
return;
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
bool const update = registry_.getCluster().update(
|
||||
registry_.getApp().nodeIdentity().first,
|
||||
bool const update = registry_.get().getCluster().update(
|
||||
registry_.get().getApp().nodeIdentity().first,
|
||||
"",
|
||||
(m_ledgerMaster.getValidatedLedgerAge() <= 4min) ? registry_.getFeeTrack().getLocalFee()
|
||||
: 0,
|
||||
registry_.getTimeKeeper().now());
|
||||
(m_ledgerMaster.getValidatedLedgerAge() <= 4min)
|
||||
? registry_.get().getFeeTrack().getLocalFee()
|
||||
: 0,
|
||||
registry_.get().getTimeKeeper().now());
|
||||
|
||||
if (!update)
|
||||
{
|
||||
@@ -1069,7 +1070,7 @@ NetworkOPsImp::processClusterTimer()
|
||||
}
|
||||
|
||||
protocol::TMCluster cluster;
|
||||
registry_.getCluster().for_each([&cluster](ClusterNode const& node) {
|
||||
registry_.get().getCluster().for_each([&cluster](ClusterNode const& node) {
|
||||
protocol::TMClusterNode& n = *cluster.add_clusternodes();
|
||||
n.set_publickey(toBase58(TokenType::NodePublic, node.identity()));
|
||||
n.set_reporttime(node.getReportTime().time_since_epoch().count());
|
||||
@@ -1078,14 +1079,14 @@ NetworkOPsImp::processClusterTimer()
|
||||
n.set_nodename(node.name());
|
||||
});
|
||||
|
||||
Resource::Gossip gossip = registry_.getResourceManager().exportConsumers();
|
||||
Resource::Gossip gossip = registry_.get().getResourceManager().exportConsumers();
|
||||
for (auto& item : gossip.items)
|
||||
{
|
||||
protocol::TMLoadSource& node = *cluster.add_loadsources();
|
||||
node.set_name(to_string(item.address));
|
||||
node.set_cost(item.balance);
|
||||
}
|
||||
registry_.getOverlay().foreach(
|
||||
registry_.get().getOverlay().foreach(
|
||||
send_if(std::make_shared<Message>(cluster, protocol::mtCLUSTER), peer_in_cluster()));
|
||||
setClusterTimer();
|
||||
}
|
||||
@@ -1131,7 +1132,7 @@ NetworkOPsImp::submitTransaction(std::shared_ptr<STTx const> const& iTrans)
|
||||
auto const trans = sterilize(*iTrans);
|
||||
|
||||
auto const txid = trans->getTransactionID();
|
||||
auto const flags = registry_.getHashRouter().getFlags(txid);
|
||||
auto const flags = registry_.get().getHashRouter().getFlags(txid);
|
||||
|
||||
if ((flags & HashRouterFlags::BAD) != HashRouterFlags::UNDEFINED)
|
||||
{
|
||||
@@ -1141,8 +1142,8 @@ NetworkOPsImp::submitTransaction(std::shared_ptr<STTx const> const& iTrans)
|
||||
|
||||
try
|
||||
{
|
||||
auto const [validity, reason] =
|
||||
checkValidity(registry_.getHashRouter(), *trans, m_ledgerMaster.getValidatedRules());
|
||||
auto const [validity, reason] = checkValidity(
|
||||
registry_.get().getHashRouter(), *trans, m_ledgerMaster.getValidatedRules());
|
||||
|
||||
if (validity != Validity::Valid)
|
||||
{
|
||||
@@ -1159,7 +1160,7 @@ NetworkOPsImp::submitTransaction(std::shared_ptr<STTx const> const& iTrans)
|
||||
|
||||
std::string reason;
|
||||
|
||||
auto tx = std::make_shared<Transaction>(trans, reason, registry_.getApp());
|
||||
auto tx = std::make_shared<Transaction>(trans, reason, registry_.get().getApp());
|
||||
|
||||
m_job_queue.addJob(jtTRANSACTION, "SubmitTxn", [this, tx]() {
|
||||
auto t = tx;
|
||||
@@ -1170,7 +1171,7 @@ NetworkOPsImp::submitTransaction(std::shared_ptr<STTx const> const& iTrans)
|
||||
bool
|
||||
NetworkOPsImp::preProcessTransaction(std::shared_ptr<Transaction>& transaction)
|
||||
{
|
||||
auto const newFlags = registry_.getHashRouter().getFlags(transaction->getID());
|
||||
auto const newFlags = registry_.get().getHashRouter().getFlags(transaction->getID());
|
||||
|
||||
if ((newFlags & HashRouterFlags::BAD) != HashRouterFlags::UNDEFINED)
|
||||
{
|
||||
@@ -1191,14 +1192,15 @@ NetworkOPsImp::preProcessTransaction(std::shared_ptr<Transaction>& transaction)
|
||||
{
|
||||
transaction->setStatus(INVALID);
|
||||
transaction->setResult(temINVALID_FLAG);
|
||||
registry_.getHashRouter().setFlags(transaction->getID(), HashRouterFlags::BAD);
|
||||
registry_.get().getHashRouter().setFlags(transaction->getID(), HashRouterFlags::BAD);
|
||||
return false;
|
||||
}
|
||||
|
||||
// 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());
|
||||
auto const [validity, reason] =
|
||||
checkValidity(registry_.get().getHashRouter(), sttx, view->rules());
|
||||
XRPL_ASSERT(
|
||||
validity == Validity::Valid, "xrpl::NetworkOPsImp::processTransaction : valid validity");
|
||||
|
||||
@@ -1208,12 +1210,12 @@ NetworkOPsImp::preProcessTransaction(std::shared_ptr<Transaction>& transaction)
|
||||
JLOG(m_journal.info()) << "Transaction has bad signature: " << reason;
|
||||
transaction->setStatus(INVALID);
|
||||
transaction->setResult(temBAD_SIGNATURE);
|
||||
registry_.getHashRouter().setFlags(transaction->getID(), HashRouterFlags::BAD);
|
||||
registry_.get().getHashRouter().setFlags(transaction->getID(), HashRouterFlags::BAD);
|
||||
return false;
|
||||
}
|
||||
|
||||
// canonicalize can change our pointer
|
||||
registry_.getMasterTransaction().canonicalize(&transaction);
|
||||
registry_.get().getMasterTransaction().canonicalize(&transaction);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1320,7 +1322,7 @@ NetworkOPsImp::processTransactionSet(CanonicalTXSet const& set)
|
||||
for (auto const& [_, tx] : set)
|
||||
{
|
||||
std::string reason;
|
||||
auto transaction = std::make_shared<Transaction>(tx, reason, registry_.getApp());
|
||||
auto transaction = std::make_shared<Transaction>(tx, reason, registry_.get().getApp());
|
||||
|
||||
if (transaction->getStatus() == INVALID)
|
||||
{
|
||||
@@ -1328,7 +1330,7 @@ NetworkOPsImp::processTransactionSet(CanonicalTXSet const& set)
|
||||
{
|
||||
JLOG(m_journal.trace()) << "Exception checking transaction: " << reason;
|
||||
}
|
||||
registry_.getHashRouter().setFlags(tx->getTransactionID(), HashRouterFlags::BAD);
|
||||
registry_.get().getHashRouter().setFlags(tx->getTransactionID(), HashRouterFlags::BAD);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1406,13 +1408,12 @@ NetworkOPsImp::apply(std::unique_lock<std::mutex>& batchLock)
|
||||
batchLock.unlock();
|
||||
|
||||
{
|
||||
std::unique_lock masterLock{registry_.getApp().getMasterMutex(), std::defer_lock};
|
||||
std::unique_lock masterLock{registry_.get().getApp().getMasterMutex(), std::defer_lock};
|
||||
bool changed = false;
|
||||
{
|
||||
std::unique_lock ledgerLock{m_ledgerMaster.peekMutex(), std::defer_lock};
|
||||
std::lock(masterLock, ledgerLock);
|
||||
|
||||
registry_.getOpenLedger().modify([&](OpenView& view, beast::Journal j) {
|
||||
registry_.get().getOpenLedger().modify([&](OpenView& view, beast::Journal j) {
|
||||
for (TransactionStatus& e : transactions)
|
||||
{
|
||||
// we check before adding to the batch
|
||||
@@ -1423,8 +1424,8 @@ NetworkOPsImp::apply(std::unique_lock<std::mutex>& batchLock)
|
||||
if (e.failType == FailHard::yes)
|
||||
flags |= tapFAIL_HARD;
|
||||
|
||||
auto const result = registry_.getTxQ().apply(
|
||||
registry_.getApp(), view, e.transaction->getSTransaction(), flags, j);
|
||||
auto const result = registry_.get().getTxQ().apply(
|
||||
registry_.get().getApp(), view, e.transaction->getSTransaction(), flags, j);
|
||||
e.result = result.ter;
|
||||
e.applied = result.applied;
|
||||
changed = changed || result.applied;
|
||||
@@ -1439,7 +1440,7 @@ NetworkOPsImp::apply(std::unique_lock<std::mutex>& batchLock)
|
||||
if (auto const l = m_ledgerMaster.getValidatedLedger())
|
||||
validatedLedgerIndex = l->header().seq;
|
||||
|
||||
auto newOL = registry_.getOpenLedger().current();
|
||||
auto newOL = registry_.get().getOpenLedger().current();
|
||||
for (TransactionStatus& e : transactions)
|
||||
{
|
||||
e.transaction->clearSubmitResult();
|
||||
@@ -1453,7 +1454,10 @@ NetworkOPsImp::apply(std::unique_lock<std::mutex>& batchLock)
|
||||
e.transaction->setResult(e.result);
|
||||
|
||||
if (isTemMalformed(e.result))
|
||||
registry_.getHashRouter().setFlags(e.transaction->getID(), HashRouterFlags::BAD);
|
||||
{
|
||||
registry_.get().getHashRouter().setFlags(
|
||||
e.transaction->getID(), HashRouterFlags::BAD);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
if (!isTesSuccess(e.result))
|
||||
@@ -1488,7 +1492,7 @@ NetworkOPsImp::apply(std::unique_lock<std::mutex>& batchLock)
|
||||
batchLock.lock();
|
||||
std::string reason;
|
||||
auto const trans = sterilize(*txNext);
|
||||
auto t = std::make_shared<Transaction>(trans, reason, registry_.getApp());
|
||||
auto t = std::make_shared<Transaction>(trans, reason, registry_.get().getApp());
|
||||
if (t->getApplying())
|
||||
break;
|
||||
submit_held.emplace_back(t, false, false, FailHard::no);
|
||||
@@ -1542,7 +1546,7 @@ NetworkOPsImp::apply(std::unique_lock<std::mutex>& batchLock)
|
||||
// up!)
|
||||
//
|
||||
if (e.local || (ledgersLeft && ledgersLeft <= LocalTxs::holdLedgers) ||
|
||||
registry_.getHashRouter().setFlags(
|
||||
registry_.get().getHashRouter().setFlags(
|
||||
e.transaction->getID(), HashRouterFlags::HELD))
|
||||
{
|
||||
// transaction should be held
|
||||
@@ -1579,7 +1583,8 @@ NetworkOPsImp::apply(std::unique_lock<std::mutex>& batchLock)
|
||||
(e.result == terQUEUED)) &&
|
||||
!enforceFailHard)
|
||||
{
|
||||
auto const toSkip = registry_.getHashRouter().shouldRelay(e.transaction->getID());
|
||||
auto const toSkip =
|
||||
registry_.get().getHashRouter().shouldRelay(e.transaction->getID());
|
||||
if (auto const sttx = *(e.transaction->getSTransaction()); toSkip &&
|
||||
// Skip relaying if it's an inner batch txn. The flag should
|
||||
// only be set if the Batch feature is enabled. If Batch is
|
||||
@@ -1594,18 +1599,19 @@ NetworkOPsImp::apply(std::unique_lock<std::mutex>& batchLock)
|
||||
tx.set_rawtransaction(s.data(), s.size());
|
||||
tx.set_status(protocol::tsCURRENT);
|
||||
tx.set_receivetimestamp(
|
||||
registry_.getTimeKeeper().now().time_since_epoch().count());
|
||||
registry_.get().getTimeKeeper().now().time_since_epoch().count());
|
||||
tx.set_deferred(e.result == terQUEUED);
|
||||
// FIXME: This should be when we received it
|
||||
registry_.getOverlay().relay(e.transaction->getID(), tx, *toSkip);
|
||||
registry_.get().getOverlay().relay(e.transaction->getID(), tx, *toSkip);
|
||||
e.transaction->setBroadcast();
|
||||
}
|
||||
}
|
||||
|
||||
if (validatedLedgerIndex)
|
||||
{
|
||||
auto [fee, accountSeq, availableSeq] = registry_.getTxQ().getTxRequiredFeeAndSeq(
|
||||
*newOL, e.transaction->getSTransaction());
|
||||
auto [fee, accountSeq, availableSeq] =
|
||||
registry_.get().getTxQ().getTxRequiredFeeAndSeq(
|
||||
*newOL, e.transaction->getSTransaction());
|
||||
e.transaction->setCurrentLedgerState(
|
||||
*validatedLedgerIndex, fee, accountSeq, availableSeq);
|
||||
}
|
||||
@@ -1783,7 +1789,7 @@ NetworkOPsImp::checkLastClosedLedger(Overlay::PeerSequence const& peerList, uint
|
||||
//-------------------------------------------------------------------------
|
||||
// Determine preferred last closed ledger
|
||||
|
||||
auto& validations = registry_.getValidations();
|
||||
auto& validations = registry_.get().getValidations();
|
||||
JLOG(m_journal.debug()) << "ValidationTrie " << Json::Compact(validations.getJsonTrie());
|
||||
|
||||
// Will rely on peer LCL if no trusted validations exist
|
||||
@@ -1831,7 +1837,7 @@ NetworkOPsImp::checkLastClosedLedger(Overlay::PeerSequence const& peerList, uint
|
||||
|
||||
if (!consensus)
|
||||
{
|
||||
consensus = registry_.getInboundLedgers().acquire(
|
||||
consensus = registry_.get().getInboundLedgers().acquire(
|
||||
closedLedger, 0, InboundLedger::Reason::CONSENSUS);
|
||||
}
|
||||
|
||||
@@ -1874,7 +1880,7 @@ NetworkOPsImp::switchLastClosedLedger(std::shared_ptr<Ledger const> const& newLC
|
||||
clearNeedNetworkLedger();
|
||||
|
||||
// Update fee computations.
|
||||
registry_.getTxQ().processClosedLedger(registry_.getApp(), *newLCL, true);
|
||||
registry_.get().getTxQ().processClosedLedger(registry_.get().getApp(), *newLCL, true);
|
||||
|
||||
// Caller must own master lock
|
||||
{
|
||||
@@ -1882,18 +1888,18 @@ NetworkOPsImp::switchLastClosedLedger(std::shared_ptr<Ledger const> const& newLC
|
||||
// open ledger. Then apply local tx.
|
||||
|
||||
auto retries = m_localTX->getTxSet();
|
||||
auto const lastVal = registry_.getLedgerMaster().getValidatedLedger();
|
||||
auto const lastVal = registry_.get().getLedgerMaster().getValidatedLedger();
|
||||
std::optional<Rules> rules;
|
||||
if (lastVal)
|
||||
{
|
||||
rules = makeRulesGivenLedger(*lastVal, registry_.getApp().config().features);
|
||||
rules = makeRulesGivenLedger(*lastVal, registry_.get().getApp().config().features);
|
||||
}
|
||||
else
|
||||
{
|
||||
rules.emplace(registry_.getApp().config().features);
|
||||
rules.emplace(registry_.get().getApp().config().features);
|
||||
}
|
||||
registry_.getOpenLedger().accept(
|
||||
registry_.getApp(),
|
||||
registry_.get().getOpenLedger().accept(
|
||||
registry_.get().getApp(),
|
||||
*rules,
|
||||
newLCL,
|
||||
OrderedTxs({}),
|
||||
@@ -1903,7 +1909,7 @@ NetworkOPsImp::switchLastClosedLedger(std::shared_ptr<Ledger const> const& newLC
|
||||
"jump",
|
||||
[&](OpenView& view, beast::Journal j) {
|
||||
// Stuff the ledger with transactions from the queue.
|
||||
return registry_.getTxQ().accept(registry_.getApp(), view);
|
||||
return registry_.get().getTxQ().accept(registry_.get().getApp(), view);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1912,12 +1918,11 @@ NetworkOPsImp::switchLastClosedLedger(std::shared_ptr<Ledger const> const& newLC
|
||||
protocol::TMStatusChange s;
|
||||
s.set_newevent(protocol::neSWITCHED_LEDGER);
|
||||
s.set_ledgerseq(newLCL->header().seq);
|
||||
s.set_networktime(registry_.getTimeKeeper().now().time_since_epoch().count());
|
||||
s.set_networktime(registry_.get().getTimeKeeper().now().time_since_epoch().count());
|
||||
s.set_ledgerhashprevious(
|
||||
newLCL->header().parentHash.begin(), newLCL->header().parentHash.size());
|
||||
s.set_ledgerhash(newLCL->header().hash.begin(), newLCL->header().hash.size());
|
||||
|
||||
registry_.getOverlay().foreach(
|
||||
registry_.get().getOverlay().foreach(
|
||||
send_always(std::make_shared<Message>(s, protocol::mtSTATUS_CHANGE)));
|
||||
}
|
||||
|
||||
@@ -1958,24 +1963,24 @@ NetworkOPsImp::beginConsensus(
|
||||
"xrpl::NetworkOPsImp::beginConsensus : closedLedger parent matches "
|
||||
"hash");
|
||||
|
||||
registry_.getValidators().setNegativeUNL(prevLedger->negativeUNL());
|
||||
TrustChanges const changes = registry_.getValidators().updateTrusted(
|
||||
registry_.getValidations().getCurrentNodeIDs(),
|
||||
registry_.get().getValidators().setNegativeUNL(prevLedger->negativeUNL());
|
||||
TrustChanges const changes = registry_.get().getValidators().updateTrusted(
|
||||
registry_.get().getValidations().getCurrentNodeIDs(),
|
||||
closingInfo.parentCloseTime,
|
||||
*this,
|
||||
registry_.getOverlay(),
|
||||
registry_.getHashRouter());
|
||||
registry_.get().getOverlay(),
|
||||
registry_.get().getHashRouter());
|
||||
|
||||
if (!changes.added.empty() || !changes.removed.empty())
|
||||
{
|
||||
registry_.getValidations().trustChanged(changes.added, changes.removed);
|
||||
registry_.get().getValidations().trustChanged(changes.added, changes.removed);
|
||||
// Update the AmendmentTable so it tracks the current validators.
|
||||
registry_.getAmendmentTable().trustChanged(
|
||||
registry_.getValidators().getQuorumKeys().second);
|
||||
registry_.get().getAmendmentTable().trustChanged(
|
||||
registry_.get().getValidators().getQuorumKeys().second);
|
||||
}
|
||||
|
||||
mConsensus.startRound(
|
||||
registry_.getTimeKeeper().closeTime(),
|
||||
registry_.get().getTimeKeeper().closeTime(),
|
||||
networkClosed,
|
||||
prevLedger,
|
||||
changes.removed,
|
||||
@@ -2015,34 +2020,30 @@ NetworkOPsImp::processTrustedProposal(RCLCxPeerPos peerPos)
|
||||
return false;
|
||||
}
|
||||
|
||||
return mConsensus.peerProposal(registry_.getTimeKeeper().closeTime(), peerPos);
|
||||
return mConsensus.peerProposal(registry_.get().getTimeKeeper().closeTime(), peerPos);
|
||||
}
|
||||
|
||||
void
|
||||
NetworkOPsImp::mapComplete(std::shared_ptr<SHAMap> const& map, bool fromAcquire)
|
||||
{
|
||||
// We now have an additional transaction set
|
||||
// either created locally during the consensus process
|
||||
// or acquired from a peer
|
||||
|
||||
// Inform peers we have this set
|
||||
protocol::TMHaveTransactionSet msg;
|
||||
msg.set_hash(map->getHash().as_uint256().begin(), 256 / 8);
|
||||
msg.set_status(protocol::tsHAVE);
|
||||
registry_.getOverlay().foreach(
|
||||
registry_.get().getOverlay().foreach(
|
||||
send_always(std::make_shared<Message>(msg, protocol::mtHAVE_SET)));
|
||||
|
||||
// We acquired it because consensus asked us to
|
||||
if (fromAcquire)
|
||||
mConsensus.gotTxSet(registry_.getTimeKeeper().closeTime(), RCLTxSet{map});
|
||||
mConsensus.gotTxSet(registry_.get().getTimeKeeper().closeTime(), RCLTxSet{map});
|
||||
}
|
||||
|
||||
void
|
||||
NetworkOPsImp::endConsensus(std::unique_ptr<std::stringstream> const& clog)
|
||||
{
|
||||
uint256 deadLedger = m_ledgerMaster.getClosedLedger()->header().parentHash;
|
||||
|
||||
for (auto const& it : registry_.getOverlay().getActivePeers())
|
||||
for (auto const& it : registry_.get().getOverlay().getActivePeers())
|
||||
{
|
||||
if (it && (it->getClosedLedgerHash() == deadLedger))
|
||||
{
|
||||
@@ -2053,7 +2054,7 @@ NetworkOPsImp::endConsensus(std::unique_ptr<std::stringstream> const& clog)
|
||||
|
||||
uint256 networkClosed;
|
||||
bool ledgerChange =
|
||||
checkLastClosedLedger(registry_.getOverlay().getActivePeers(), networkClosed);
|
||||
checkLastClosedLedger(registry_.get().getOverlay().getActivePeers(), networkClosed);
|
||||
|
||||
if (networkClosed.isZero())
|
||||
{
|
||||
@@ -2083,7 +2084,7 @@ NetworkOPsImp::endConsensus(std::unique_ptr<std::stringstream> const& clog)
|
||||
// Note: Do not go to FULL if we don't have the previous ledger
|
||||
// check if the ledger is bad enough to go to CONNECTED -- TODO
|
||||
auto current = m_ledgerMaster.getCurrentLedger();
|
||||
if (registry_.getTimeKeeper().now() <
|
||||
if (registry_.get().getTimeKeeper().now() <
|
||||
(current->header().parentCloseTime + 2 * current->header().closeTimeResolution))
|
||||
{
|
||||
setMode(OperatingMode::FULL);
|
||||
@@ -2191,9 +2192,9 @@ NetworkOPsImp::pubServer()
|
||||
Json::Value jvObj(Json::objectValue);
|
||||
|
||||
ServerFeeSummary f{
|
||||
registry_.getOpenLedger().current()->fees().base,
|
||||
registry_.getTxQ().getMetrics(*registry_.getOpenLedger().current()),
|
||||
registry_.getFeeTrack()};
|
||||
registry_.get().getOpenLedger().current()->fees().base,
|
||||
registry_.get().getTxQ().getMetrics(*registry_.get().getOpenLedger().current()),
|
||||
registry_.get().getFeeTrack()};
|
||||
|
||||
jvObj[jss::type] = "serverStatus";
|
||||
jvObj[jss::server_status] = strOperatingMode();
|
||||
@@ -2287,7 +2288,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_.getNetworkIDService().getNetworkID();
|
||||
jvObj[jss::network_id] = registry_.get().getNetworkIDService().getNetworkID();
|
||||
|
||||
if (auto version = (*val)[~sfServerVersion])
|
||||
jvObj[jss::server_version] = std::to_string(*version);
|
||||
@@ -2298,7 +2299,7 @@ NetworkOPsImp::pubValidation(std::shared_ptr<STValidation> const& val)
|
||||
if (auto hash = (*val)[~sfValidatedHash])
|
||||
jvObj[jss::validated_hash] = strHex(*hash);
|
||||
|
||||
auto const masterKey = registry_.getValidatorManifests().getMasterKey(signerPublic);
|
||||
auto const masterKey = registry_.get().getValidatorManifests().getMasterKey(signerPublic);
|
||||
|
||||
if (masterKey != signerPublic)
|
||||
jvObj[jss::master_key] = toBase58(TokenType::NodePublic, masterKey);
|
||||
@@ -2407,12 +2408,12 @@ NetworkOPsImp::setMode(OperatingMode om)
|
||||
using namespace std::chrono_literals;
|
||||
if (om == OperatingMode::CONNECTED)
|
||||
{
|
||||
if (registry_.getLedgerMaster().getValidatedLedgerAge() < 1min)
|
||||
if (registry_.get().getLedgerMaster().getValidatedLedgerAge() < 1min)
|
||||
om = OperatingMode::SYNCING;
|
||||
}
|
||||
else if (om == OperatingMode::SYNCING)
|
||||
{
|
||||
if (registry_.getLedgerMaster().getValidatedLedgerAge() >= 1min)
|
||||
if (registry_.get().getLedgerMaster().getValidatedLedgerAge() >= 1min)
|
||||
om = OperatingMode::CONNECTED;
|
||||
}
|
||||
|
||||
@@ -2448,7 +2449,7 @@ NetworkOPsImp::recvValidation(std::shared_ptr<STValidation> const& val, std::str
|
||||
pendingValidations_.insert(val->getLedgerHash());
|
||||
}
|
||||
scope_unlock unlock(lock);
|
||||
handleNewValidation(registry_.getApp(), val, source, bypassAccept, m_journal);
|
||||
handleNewValidation(registry_.get().getApp(), val, source, bypassAccept, m_journal);
|
||||
}
|
||||
catch (std::exception const& e)
|
||||
{
|
||||
@@ -2471,7 +2472,7 @@ NetworkOPsImp::recvValidation(std::shared_ptr<STValidation> const& val, std::str
|
||||
JLOG(m_journal.debug()) << [this, &val]() -> auto {
|
||||
std::stringstream ss;
|
||||
ss << "VALIDATION: " << val->render() << " master_key: ";
|
||||
auto master = registry_.getValidators().getTrustedKey(val->getSignerPublic());
|
||||
auto master = registry_.get().getValidators().getTrustedKey(val->getSignerPublic());
|
||||
if (master)
|
||||
{
|
||||
ss << toBase58(TokenType::NodePublic, *master);
|
||||
@@ -2485,7 +2486,7 @@ NetworkOPsImp::recvValidation(std::shared_ptr<STValidation> const& val, std::str
|
||||
|
||||
// We will always relay trusted validations; if configured, we will
|
||||
// also relay all untrusted validations.
|
||||
return registry_.getApp().config().RELAY_UNTRUSTED_VALIDATIONS == 1 || val->isTrusted();
|
||||
return registry_.get().getApp().config().RELAY_UNTRUSTED_VALIDATIONS == 1 || val->isTrusted();
|
||||
}
|
||||
|
||||
Json::Value
|
||||
@@ -2527,7 +2528,8 @@ NetworkOPsImp::getServerInfo(bool human, bool admin, bool counters)
|
||||
"One or more unsupported amendments have reached majority. "
|
||||
"Upgrade to the latest version before they are activated "
|
||||
"to avoid being amendment blocked.";
|
||||
if (auto const expected = registry_.getAmendmentTable().firstUnsupportedExpected())
|
||||
if (auto const expected =
|
||||
registry_.get().getAmendmentTable().firstUnsupportedExpected())
|
||||
{
|
||||
auto& d = w[jss::details] = Json::objectValue;
|
||||
d[jss::expected_date] = expected->time_since_epoch().count();
|
||||
@@ -2544,8 +2546,8 @@ NetworkOPsImp::getServerInfo(bool human, bool admin, bool counters)
|
||||
info[jss::hostid] = getHostId(admin);
|
||||
|
||||
// domain: if configured with a domain, report it:
|
||||
if (!registry_.getApp().config().SERVER_DOMAIN.empty())
|
||||
info[jss::server_domain] = registry_.getApp().config().SERVER_DOMAIN;
|
||||
if (!registry_.get().getApp().config().SERVER_DOMAIN.empty())
|
||||
info[jss::server_domain] = registry_.get().getApp().config().SERVER_DOMAIN;
|
||||
|
||||
info[jss::build_version] = BuildInfo::getVersionString();
|
||||
|
||||
@@ -2557,14 +2559,15 @@ NetworkOPsImp::getServerInfo(bool human, bool admin, bool counters)
|
||||
if (needNetworkLedger_)
|
||||
info[jss::network_ledger] = "waiting";
|
||||
|
||||
info[jss::validation_quorum] = static_cast<Json::UInt>(registry_.getValidators().quorum());
|
||||
info[jss::validation_quorum] =
|
||||
static_cast<Json::UInt>(registry_.get().getValidators().quorum());
|
||||
|
||||
if (admin)
|
||||
{
|
||||
// Note: By default the node size is "tiny". When parsing it's an error if the final
|
||||
// NODE_SIZE is over 4 so below code should be safe.
|
||||
// NOLINTNEXTLINE(bugprone-switch-missing-default-case)
|
||||
switch (registry_.getApp().config().NODE_SIZE)
|
||||
switch (registry_.get().getApp().config().NODE_SIZE)
|
||||
{
|
||||
case 0:
|
||||
info[jss::node_size] = "tiny";
|
||||
@@ -2583,7 +2586,7 @@ NetworkOPsImp::getServerInfo(bool human, bool admin, bool counters)
|
||||
break;
|
||||
}
|
||||
|
||||
auto when = registry_.getValidators().expires();
|
||||
auto when = registry_.get().getValidators().expires();
|
||||
|
||||
if (!human)
|
||||
{
|
||||
@@ -2601,7 +2604,7 @@ NetworkOPsImp::getServerInfo(bool human, bool admin, bool counters)
|
||||
{
|
||||
auto& x = (info[jss::validator_list] = Json::objectValue);
|
||||
|
||||
x[jss::count] = static_cast<Json::UInt>(registry_.getValidators().count());
|
||||
x[jss::count] = static_cast<Json::UInt>(registry_.get().getValidators().count());
|
||||
|
||||
if (when)
|
||||
{
|
||||
@@ -2614,7 +2617,7 @@ NetworkOPsImp::getServerInfo(bool human, bool admin, bool counters)
|
||||
{
|
||||
x[jss::expiration] = to_string(*when);
|
||||
|
||||
if (*when > registry_.getTimeKeeper().now())
|
||||
if (*when > registry_.get().getTimeKeeper().now())
|
||||
{
|
||||
x[jss::status] = "active";
|
||||
}
|
||||
@@ -2640,12 +2643,13 @@ NetworkOPsImp::getServerInfo(bool human, bool admin, bool counters)
|
||||
x[jss::branch] = xrpl::git::getBuildBranch();
|
||||
}
|
||||
}
|
||||
info[jss::io_latency_ms] = static_cast<Json::UInt>(registry_.getApp().getIOLatency().count());
|
||||
info[jss::io_latency_ms] =
|
||||
static_cast<Json::UInt>(registry_.get().getApp().getIOLatency().count());
|
||||
|
||||
if (admin)
|
||||
{
|
||||
if (auto const localPubKey = registry_.getValidators().localPublicKey();
|
||||
localPubKey && registry_.getApp().getValidationPublicKey())
|
||||
if (auto const localPubKey = registry_.get().getValidators().localPublicKey();
|
||||
localPubKey && registry_.get().getApp().getValidationPublicKey())
|
||||
{
|
||||
info[jss::pubkey_validator] = toBase58(TokenType::NodePublic, localPubKey.value());
|
||||
}
|
||||
@@ -2657,18 +2661,18 @@ NetworkOPsImp::getServerInfo(bool human, bool admin, bool counters)
|
||||
|
||||
if (counters)
|
||||
{
|
||||
info[jss::counters] = registry_.getPerfLog().countersJson();
|
||||
info[jss::counters] = registry_.get().getPerfLog().countersJson();
|
||||
|
||||
Json::Value nodestore(Json::objectValue);
|
||||
registry_.getNodeStore().getCountsJson(nodestore);
|
||||
registry_.get().getNodeStore().getCountsJson(nodestore);
|
||||
info[jss::counters][jss::nodestore] = nodestore;
|
||||
info[jss::current_activities] = registry_.getPerfLog().currentJson();
|
||||
info[jss::current_activities] = registry_.get().getPerfLog().currentJson();
|
||||
}
|
||||
|
||||
info[jss::pubkey_node] =
|
||||
toBase58(TokenType::NodePublic, registry_.getApp().nodeIdentity().first);
|
||||
toBase58(TokenType::NodePublic, registry_.get().getApp().nodeIdentity().first);
|
||||
|
||||
info[jss::complete_ledgers] = registry_.getLedgerMaster().getCompleteLedgers();
|
||||
info[jss::complete_ledgers] = registry_.get().getLedgerMaster().getCompleteLedgers();
|
||||
|
||||
if (amendmentBlocked_)
|
||||
info[jss::amendment_blocked] = true;
|
||||
@@ -2678,7 +2682,7 @@ NetworkOPsImp::getServerInfo(bool human, bool admin, bool counters)
|
||||
if (fp != 0)
|
||||
info[jss::fetch_pack] = Json::UInt(fp);
|
||||
|
||||
info[jss::peers] = Json::UInt(registry_.getOverlay().size());
|
||||
info[jss::peers] = Json::UInt(registry_.get().getOverlay().size());
|
||||
|
||||
Json::Value lastClose = Json::objectValue;
|
||||
lastClose[jss::proposers] = Json::UInt(mConsensus.prevProposers());
|
||||
@@ -2700,14 +2704,14 @@ NetworkOPsImp::getServerInfo(bool human, bool admin, bool counters)
|
||||
if (admin)
|
||||
info[jss::load] = m_job_queue.getJson();
|
||||
|
||||
if (auto const netid = registry_.getOverlay().networkID())
|
||||
if (auto const netid = registry_.get().getOverlay().networkID())
|
||||
info[jss::network_id] = static_cast<Json::UInt>(*netid);
|
||||
|
||||
auto const escalationMetrics =
|
||||
registry_.getTxQ().getMetrics(*registry_.getOpenLedger().current());
|
||||
registry_.get().getTxQ().getMetrics(*registry_.get().getOpenLedger().current());
|
||||
|
||||
auto const loadFactorServer = registry_.getFeeTrack().getLoadFactor();
|
||||
auto const loadBaseServer = registry_.getFeeTrack().getLoadBase();
|
||||
auto const loadFactorServer = registry_.get().getFeeTrack().getLoadFactor();
|
||||
auto const loadBaseServer = registry_.get().getFeeTrack().getLoadBase();
|
||||
/* Scale the escalated fee level to unitless "load factor".
|
||||
In practice, this just strips the units, but it will continue
|
||||
to work correctly if either base value ever changes. */
|
||||
@@ -2744,13 +2748,13 @@ NetworkOPsImp::getServerInfo(bool human, bool admin, bool counters)
|
||||
|
||||
if (admin)
|
||||
{
|
||||
std::uint32_t fee = registry_.getFeeTrack().getLocalFee();
|
||||
std::uint32_t fee = registry_.get().getFeeTrack().getLocalFee();
|
||||
if (fee != loadBaseServer)
|
||||
info[jss::load_factor_local] = static_cast<double>(fee) / loadBaseServer;
|
||||
fee = registry_.getFeeTrack().getRemoteFee();
|
||||
fee = registry_.get().getFeeTrack().getRemoteFee();
|
||||
if (fee != loadBaseServer)
|
||||
info[jss::load_factor_net] = static_cast<double>(fee) / loadBaseServer;
|
||||
fee = registry_.getFeeTrack().getClusterFee();
|
||||
fee = registry_.get().getFeeTrack().getClusterFee();
|
||||
if (fee != loadBaseServer)
|
||||
info[jss::load_factor_cluster] = static_cast<double>(fee) / loadBaseServer;
|
||||
}
|
||||
@@ -2802,7 +2806,7 @@ NetworkOPsImp::getServerInfo(bool human, bool admin, bool counters)
|
||||
l[jss::reserve_base_xrp] = lpClosed->fees().reserve.decimalXRP();
|
||||
l[jss::reserve_inc_xrp] = lpClosed->fees().increment.decimalXRP();
|
||||
|
||||
if (auto const closeOffset = registry_.getTimeKeeper().closeOffset();
|
||||
if (auto const closeOffset = registry_.get().getTimeKeeper().closeOffset();
|
||||
std::abs(closeOffset.count()) >= 60)
|
||||
l[jss::close_time_offset] = static_cast<std::uint32_t>(closeOffset.count());
|
||||
|
||||
@@ -2815,7 +2819,7 @@ NetworkOPsImp::getServerInfo(bool human, bool admin, bool counters)
|
||||
else
|
||||
{
|
||||
auto lCloseTime = lpClosed->header().closeTime;
|
||||
auto closeTime = registry_.getTimeKeeper().closeTime();
|
||||
auto closeTime = registry_.get().getTimeKeeper().closeTime();
|
||||
if (lCloseTime <= closeTime)
|
||||
{
|
||||
using namespace std::chrono_literals;
|
||||
@@ -2847,10 +2851,11 @@ NetworkOPsImp::getServerInfo(bool human, bool admin, bool counters)
|
||||
|
||||
accounting_.json(info);
|
||||
info[jss::uptime] = UptimeClock::now().time_since_epoch().count();
|
||||
info[jss::jq_trans_overflow] = std::to_string(registry_.getOverlay().getJqTransOverflow());
|
||||
info[jss::peer_disconnects] = std::to_string(registry_.getOverlay().getPeerDisconnect());
|
||||
info[jss::jq_trans_overflow] =
|
||||
std::to_string(registry_.get().getOverlay().getJqTransOverflow());
|
||||
info[jss::peer_disconnects] = std::to_string(registry_.get().getOverlay().getPeerDisconnect());
|
||||
info[jss::peer_disconnects_resources] =
|
||||
std::to_string(registry_.getOverlay().getPeerDisconnectCharges());
|
||||
std::to_string(registry_.get().getOverlay().getPeerDisconnectCharges());
|
||||
|
||||
// This array must be sorted in increasing order.
|
||||
static constexpr std::array<std::string_view, 7> protocols{
|
||||
@@ -2858,7 +2863,7 @@ NetworkOPsImp::getServerInfo(bool human, bool admin, bool counters)
|
||||
static_assert(std::is_sorted(std::begin(protocols), std::end(protocols)));
|
||||
{
|
||||
Json::Value ports{Json::arrayValue};
|
||||
for (auto const& port : registry_.getServerHandler().setup().ports)
|
||||
for (auto const& port : registry_.get().getServerHandler().setup().ports)
|
||||
{
|
||||
// Don't publish admin ports for non-admin users
|
||||
if (!admin &&
|
||||
@@ -2882,9 +2887,9 @@ NetworkOPsImp::getServerInfo(bool human, bool admin, bool counters)
|
||||
}
|
||||
}
|
||||
|
||||
if (registry_.getApp().config().exists(SECTION_PORT_GRPC))
|
||||
if (registry_.get().getApp().config().exists(SECTION_PORT_GRPC))
|
||||
{
|
||||
auto const& grpcSection = registry_.getApp().config().section(SECTION_PORT_GRPC);
|
||||
auto const& grpcSection = registry_.get().getApp().config().section(SECTION_PORT_GRPC);
|
||||
auto const optPort = grpcSection.get("port");
|
||||
if (optPort && grpcSection.get("ip"))
|
||||
{
|
||||
@@ -2903,13 +2908,13 @@ NetworkOPsImp::getServerInfo(bool human, bool admin, bool counters)
|
||||
void
|
||||
NetworkOPsImp::clearLedgerFetch()
|
||||
{
|
||||
registry_.getInboundLedgers().clearFailures();
|
||||
registry_.get().getInboundLedgers().clearFailures();
|
||||
}
|
||||
|
||||
Json::Value
|
||||
NetworkOPsImp::getLedgerFetchInfo()
|
||||
{
|
||||
return registry_.getInboundLedgers().getInfo();
|
||||
return registry_.get().getInboundLedgers().getInfo();
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2959,11 +2964,11 @@ NetworkOPsImp::pubLedger(std::shared_ptr<ReadView const> const& lpAccepted)
|
||||
// Holes are filled across connection loss or other catastrophe
|
||||
|
||||
std::shared_ptr<AcceptedLedger> alpAccepted =
|
||||
registry_.getAcceptedLedgerCache().fetch(lpAccepted->header().hash);
|
||||
registry_.get().getAcceptedLedgerCache().fetch(lpAccepted->header().hash);
|
||||
if (!alpAccepted)
|
||||
{
|
||||
alpAccepted = std::make_shared<AcceptedLedger>(lpAccepted);
|
||||
registry_.getAcceptedLedgerCache().canonicalize_replace_client(
|
||||
registry_.get().getAcceptedLedgerCache().canonicalize_replace_client(
|
||||
lpAccepted->header().hash, alpAccepted);
|
||||
}
|
||||
|
||||
@@ -2987,7 +2992,7 @@ NetworkOPsImp::pubLedger(std::shared_ptr<ReadView const> const& lpAccepted)
|
||||
jvObj[jss::ledger_time] =
|
||||
Json::Value::UInt(lpAccepted->header().closeTime.time_since_epoch().count());
|
||||
|
||||
jvObj[jss::network_id] = registry_.getNetworkIDService().getNetworkID();
|
||||
jvObj[jss::network_id] = registry_.get().getNetworkIDService().getNetworkID();
|
||||
|
||||
if (!lpAccepted->rules().enabled(featureXRPFees))
|
||||
jvObj[jss::fee_ref] = FEE_UNITS_DEPRECATED;
|
||||
@@ -2999,7 +3004,8 @@ NetworkOPsImp::pubLedger(std::shared_ptr<ReadView const> const& lpAccepted)
|
||||
|
||||
if (mMode >= OperatingMode::SYNCING)
|
||||
{
|
||||
jvObj[jss::validated_ledgers] = registry_.getLedgerMaster().getCompleteLedgers();
|
||||
jvObj[jss::validated_ledgers] =
|
||||
registry_.get().getLedgerMaster().getCompleteLedgers();
|
||||
}
|
||||
|
||||
auto it = mStreamMaps[sLedger].begin();
|
||||
@@ -3071,9 +3077,9 @@ void
|
||||
NetworkOPsImp::reportFeeChange()
|
||||
{
|
||||
ServerFeeSummary f{
|
||||
registry_.getOpenLedger().current()->fees().base,
|
||||
registry_.getTxQ().getMetrics(*registry_.getOpenLedger().current()),
|
||||
registry_.getFeeTrack()};
|
||||
registry_.get().getOpenLedger().current()->fees().base,
|
||||
registry_.get().getTxQ().getMetrics(*registry_.get().getOpenLedger().current()),
|
||||
registry_.get().getFeeTrack()};
|
||||
|
||||
// only schedule the job if something has changed
|
||||
if (f != mLastFeeSummary)
|
||||
@@ -3134,7 +3140,7 @@ NetworkOPsImp::transJson(
|
||||
lookup.second && lookup.second->isFieldPresent(sfTransactionIndex))
|
||||
{
|
||||
uint32_t const txnSeq = lookup.second->getFieldU32(sfTransactionIndex);
|
||||
uint32_t netID = registry_.getNetworkIDService().getNetworkID();
|
||||
uint32_t netID = registry_.get().getNetworkIDService().getNetworkID();
|
||||
if (transaction->isFieldPresent(sfNetworkID))
|
||||
netID = transaction->getFieldU32(sfNetworkID);
|
||||
|
||||
@@ -3174,7 +3180,7 @@ NetworkOPsImp::transJson(
|
||||
if (account != amount.issue().account)
|
||||
{
|
||||
auto const ownerFunds = accountFunds(
|
||||
*ledger, account, amount, fhIGNORE_FREEZE, registry_.getJournal("View"));
|
||||
*ledger, account, amount, fhIGNORE_FREEZE, registry_.get().getJournal("View"));
|
||||
jvObj[jss::transaction][jss::owner_funds] = ownerFunds.getText();
|
||||
}
|
||||
}
|
||||
@@ -3255,7 +3261,7 @@ NetworkOPsImp::pubValidatedTransaction(
|
||||
}
|
||||
|
||||
if (transaction.getResult() == tesSUCCESS)
|
||||
registry_.getOrderBookDB().processTxn(ledger, transaction, jvObj);
|
||||
registry_.get().getOrderBookDB().processTxn(ledger, transaction, jvObj);
|
||||
|
||||
pubAccountTransaction(ledger, transaction, last);
|
||||
}
|
||||
@@ -3562,7 +3568,7 @@ NetworkOPsImp::addAccountHistoryJob(SubAccountHistoryInfoWeak subInfo)
|
||||
static auto const databaseType = [&]() -> DatabaseType {
|
||||
// Use a dynamic_cast to return DatabaseType::None
|
||||
// on failure.
|
||||
if (dynamic_cast<SQLiteDatabase*>(®istry_.getRelationalDatabase()))
|
||||
if (dynamic_cast<SQLiteDatabase*>(®istry_.get().getRelationalDatabase()))
|
||||
{
|
||||
return DatabaseType::Sqlite;
|
||||
}
|
||||
@@ -3584,7 +3590,7 @@ NetworkOPsImp::addAccountHistoryJob(SubAccountHistoryInfoWeak subInfo)
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
registry_.getJobQueue().addJob(
|
||||
registry_.get().getJobQueue().addJob(
|
||||
jtCLIENT_ACCT_HIST, "HistTxStream", [this, dbType = databaseType, subInfo]() {
|
||||
auto const& accountId = subInfo.index_->accountId_;
|
||||
auto& lastLedgerSeq = subInfo.index_->historyLastLedgerSeq_;
|
||||
@@ -3665,11 +3671,10 @@ NetworkOPsImp::addAccountHistoryJob(SubAccountHistoryInfoWeak subInfo)
|
||||
switch (dbType)
|
||||
{
|
||||
case Sqlite: {
|
||||
auto db =
|
||||
safe_downcast<SQLiteDatabase*>(®istry_.getRelationalDatabase());
|
||||
auto& db = registry_.get().getRelationalDatabase();
|
||||
RelationalDatabase::AccountTxPageOptions options{
|
||||
accountId, minLedger, maxLedger, marker, 0, true};
|
||||
return db->newestAccountTxPage(options);
|
||||
accountId, {minLedger, maxLedger}, marker, 0, true};
|
||||
return db.newestAccountTxPage(options);
|
||||
}
|
||||
// LCOV_EXCL_START
|
||||
default: {
|
||||
@@ -3711,7 +3716,8 @@ NetworkOPsImp::addAccountHistoryJob(SubAccountHistoryInfoWeak subInfo)
|
||||
std::uint32_t validatedMin = UINT_MAX;
|
||||
std::uint32_t validatedMax = 0;
|
||||
auto haveSomeValidatedLedgers =
|
||||
registry_.getLedgerMaster().getValidatedRange(validatedMin, validatedMax);
|
||||
registry_.get().getLedgerMaster().getValidatedRange(
|
||||
validatedMin, validatedMax);
|
||||
|
||||
return haveSomeValidatedLedgers && validatedMin <= startLedgerSeq &&
|
||||
lastLedgerSeq <= validatedMax;
|
||||
@@ -3758,7 +3764,7 @@ NetworkOPsImp::addAccountHistoryJob(SubAccountHistoryInfoWeak subInfo)
|
||||
return;
|
||||
}
|
||||
auto curTxLedger =
|
||||
registry_.getLedgerMaster().getLedgerBySeq(tx->getLedger());
|
||||
registry_.get().getLedgerMaster().getLedgerBySeq(tx->getLedger());
|
||||
if (!curTxLedger)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
@@ -3904,7 +3910,7 @@ NetworkOPsImp::subAccountHistory(InfoSub::ref isrListener, AccountID const& acco
|
||||
simIterator->second.emplace(isrListener->getSeq(), ahi);
|
||||
}
|
||||
|
||||
auto const ledger = registry_.getLedgerMaster().getValidatedLedger();
|
||||
auto const ledger = registry_.get().getLedgerMaster().getValidatedLedger();
|
||||
if (ledger)
|
||||
{
|
||||
subAccountHistoryStart(ledger, ahi);
|
||||
@@ -3964,7 +3970,7 @@ NetworkOPsImp::unsubAccountHistoryInternal(
|
||||
bool
|
||||
NetworkOPsImp::subBook(InfoSub::ref isrListener, Book const& book)
|
||||
{
|
||||
if (auto listeners = registry_.getOrderBookDB().makeBookListeners(book))
|
||||
if (auto listeners = registry_.get().getOrderBookDB().makeBookListeners(book))
|
||||
{
|
||||
listeners->addSubscriber(isrListener);
|
||||
}
|
||||
@@ -3980,7 +3986,7 @@ NetworkOPsImp::subBook(InfoSub::ref isrListener, Book const& book)
|
||||
bool
|
||||
NetworkOPsImp::unsubBook(std::uint64_t uSeq, Book const& book)
|
||||
{
|
||||
if (auto listeners = registry_.getOrderBookDB().getBookListeners(book))
|
||||
if (auto listeners = registry_.get().getOrderBookDB().getBookListeners(book))
|
||||
listeners->removeSubscriber(uSeq);
|
||||
|
||||
return true;
|
||||
@@ -3999,7 +4005,7 @@ NetworkOPsImp::acceptLedger(std::optional<std::chrono::milliseconds> consensusDe
|
||||
// FIXME Could we improve on this and remove the need for a specialized
|
||||
// API in Consensus?
|
||||
beginConsensus(m_ledgerMaster.getClosedLedger()->header().hash, {});
|
||||
mConsensus.simulate(registry_.getTimeKeeper().closeTime(), consensusDelay);
|
||||
mConsensus.simulate(registry_.get().getTimeKeeper().closeTime(), consensusDelay);
|
||||
return m_ledgerMaster.getCurrentLedger()->header().seq;
|
||||
}
|
||||
|
||||
@@ -4018,12 +4024,12 @@ 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_.getNetworkIDService().getNetworkID();
|
||||
jvResult[jss::network_id] = registry_.get().getNetworkIDService().getNetworkID();
|
||||
}
|
||||
|
||||
if ((mMode >= OperatingMode::SYNCING) && !isNeedNetworkLedger())
|
||||
{
|
||||
jvResult[jss::validated_ledgers] = registry_.getLedgerMaster().getCompleteLedgers();
|
||||
jvResult[jss::validated_ledgers] = registry_.get().getLedgerMaster().getCompleteLedgers();
|
||||
}
|
||||
|
||||
std::lock_guard sl(mSubLock);
|
||||
@@ -4082,14 +4088,14 @@ NetworkOPsImp::subServer(InfoSub::ref isrListener, Json::Value& jvResult, bool a
|
||||
// CHECKME: is it necessary to provide a random number here?
|
||||
beast::rngfill(uRandom.begin(), uRandom.size(), crypto_prng());
|
||||
|
||||
auto const& feeTrack = registry_.getFeeTrack();
|
||||
auto const& feeTrack = registry_.get().getFeeTrack();
|
||||
jvResult[jss::random] = to_string(uRandom);
|
||||
jvResult[jss::server_status] = strOperatingMode(admin);
|
||||
jvResult[jss::load_base] = feeTrack.getLoadBase();
|
||||
jvResult[jss::load_factor] = feeTrack.getLoadFactor();
|
||||
jvResult[jss::hostid] = getHostId(admin);
|
||||
jvResult[jss::pubkey_node] =
|
||||
toBase58(TokenType::NodePublic, registry_.getApp().nodeIdentity().first);
|
||||
toBase58(TokenType::NodePublic, registry_.get().getApp().nodeIdentity().first);
|
||||
|
||||
std::lock_guard sl(mSubLock);
|
||||
return mStreamMaps[sServer].emplace(isrListener->getSeq(), isrListener).second;
|
||||
@@ -4276,7 +4282,7 @@ NetworkOPsImp::getBookPage(
|
||||
STAmount saDirRate;
|
||||
|
||||
auto const rate = transferRate(view, book.out.account);
|
||||
auto viewJ = registry_.getJournal("View");
|
||||
auto viewJ = registry_.get().getJournal("View");
|
||||
|
||||
while (!bDone && iLimit-- > 0)
|
||||
{
|
||||
@@ -4649,11 +4655,11 @@ make_NetworkOPs(
|
||||
NetworkOPs::clock_type& clock,
|
||||
bool standalone,
|
||||
std::size_t minPeerCount,
|
||||
bool startvalid,
|
||||
JobQueue& job_queue,
|
||||
bool startValid,
|
||||
JobQueue& jobQueue,
|
||||
LedgerMaster& ledgerMaster,
|
||||
ValidatorKeys const& validatorKeys,
|
||||
boost::asio::io_context& io_svc,
|
||||
boost::asio::io_context& ioCtx,
|
||||
beast::Journal journal,
|
||||
beast::insight::Collector::ptr const& collector)
|
||||
{
|
||||
@@ -4662,11 +4668,11 @@ make_NetworkOPs(
|
||||
clock,
|
||||
standalone,
|
||||
minPeerCount,
|
||||
startvalid,
|
||||
job_queue,
|
||||
startValid,
|
||||
jobQueue,
|
||||
ledgerMaster,
|
||||
validatorKeys,
|
||||
io_svc,
|
||||
ioCtx,
|
||||
journal,
|
||||
collector);
|
||||
}
|
||||
|
||||
@@ -21,11 +21,11 @@ make_NetworkOPs(
|
||||
NetworkOPs::clock_type& clock,
|
||||
bool standalone,
|
||||
std::size_t minPeerCount,
|
||||
bool start_valid,
|
||||
JobQueue& job_queue,
|
||||
bool startValid,
|
||||
JobQueue& jobQueue,
|
||||
LedgerMaster& ledgerMaster,
|
||||
ValidatorKeys const& validatorKeys,
|
||||
boost::asio::io_context& io_svc,
|
||||
boost::asio::io_context& ioCtx,
|
||||
beast::Journal journal,
|
||||
beast::insight::Collector::ptr const& collector);
|
||||
|
||||
|
||||
@@ -327,10 +327,10 @@ public:
|
||||
* @param id Hash of the transaction.
|
||||
* @param range Range of ledgers to check, if present.
|
||||
* @param ec Default error code value.
|
||||
* @return Transaction and its metadata if found, otherwise TxSearched::all
|
||||
* @return Transaction and its metadata if found, otherwise TxSearched::All
|
||||
* if a range is provided and all ledgers from the range are present
|
||||
* in the database, TxSearched::some if a range is provided and not
|
||||
* all ledgers are present, TxSearched::unknown if the range is not
|
||||
* in the database, TxSearched::Some if a range is provided and not
|
||||
* all ledgers are present, TxSearched::Unknown if the range is not
|
||||
* provided or a deserializing error occurred. In the last case the
|
||||
* error code is returned via the ec parameter, in other cases the
|
||||
* default error code is not changed.
|
||||
@@ -405,7 +405,7 @@ public:
|
||||
transactionDbHasSpace(Config const& config);
|
||||
|
||||
private:
|
||||
ServiceRegistry& registry_;
|
||||
std::reference_wrapper<ServiceRegistry> registry_;
|
||||
bool useTxTables_;
|
||||
beast::Journal j_;
|
||||
std::unique_ptr<DatabaseCon> ledgerDb_, txdb_;
|
||||
|
||||
@@ -70,8 +70,8 @@ makeLedgerDBs(
|
||||
boost::format("PRAGMA cache_size=-%d;") %
|
||||
kilobytes(config.getValueFor(SizedItem::txnDBCache)));
|
||||
|
||||
if (!setup.standAlone || setup.startUp == StartUpType::LOAD ||
|
||||
setup.startUp == StartUpType::LOAD_FILE || setup.startUp == StartUpType::REPLAY)
|
||||
if (!setup.standAlone || setup.startUp == StartUpType::Load ||
|
||||
setup.startUp == StartUpType::LoadFile || setup.startUp == StartUpType::Replay)
|
||||
{
|
||||
// Check if AccountTransactions has primary key
|
||||
std::string cid, name, type;
|
||||
@@ -675,16 +675,16 @@ transactionsSQL(
|
||||
std::string maxClause;
|
||||
std::string minClause;
|
||||
|
||||
if (options.maxLedger != 0u)
|
||||
if (options.ledgerRange.max != 0u)
|
||||
{
|
||||
maxClause = boost::str(
|
||||
boost::format("AND AccountTransactions.LedgerSeq <= '%u'") % options.maxLedger);
|
||||
boost::format("AND AccountTransactions.LedgerSeq <= '%u'") % options.ledgerRange.max);
|
||||
}
|
||||
|
||||
if (options.minLedger != 0u)
|
||||
if (options.ledgerRange.min != 0u)
|
||||
{
|
||||
minClause = boost::str(
|
||||
boost::format("AND AccountTransactions.LedgerSeq >= '%u'") % options.minLedger);
|
||||
boost::format("AND AccountTransactions.LedgerSeq >= '%u'") % options.ledgerRange.min);
|
||||
}
|
||||
|
||||
std::string sql;
|
||||
@@ -1021,14 +1021,14 @@ accountTxPage(
|
||||
ORDER BY AccountTransactions.LedgerSeq %s,
|
||||
AccountTransactions.TxnSeq %s
|
||||
LIMIT %u;)")) %
|
||||
toBase58(options.account) % options.minLedger % options.maxLedger % order % order %
|
||||
queryLimit);
|
||||
toBase58(options.account) % options.ledgerRange.min % options.ledgerRange.max % order %
|
||||
order % queryLimit);
|
||||
}
|
||||
else
|
||||
{
|
||||
char const* const compare = forward ? ">=" : "<=";
|
||||
std::uint32_t const minLedger = forward ? findLedger + 1 : options.minLedger;
|
||||
std::uint32_t const maxLedger = forward ? options.maxLedger : findLedger - 1;
|
||||
std::uint32_t const minLedger = forward ? findLedger + 1 : options.ledgerRange.min;
|
||||
std::uint32_t const maxLedger = forward ? options.ledgerRange.max : findLedger - 1;
|
||||
|
||||
auto b58acct = toBase58(options.account);
|
||||
sql = boost::str(
|
||||
@@ -1192,7 +1192,7 @@ getTransaction(
|
||||
auto const got_data = session.got_data();
|
||||
|
||||
if ((!got_data || txn != soci::i_ok || meta != soci::i_ok) && !range)
|
||||
return TxSearched::unknown;
|
||||
return TxSearched::Unknown;
|
||||
|
||||
if (!got_data)
|
||||
{
|
||||
@@ -1205,10 +1205,10 @@ getTransaction(
|
||||
soci::into(count, rti);
|
||||
|
||||
if (!session.got_data() || rti != soci::i_ok)
|
||||
return TxSearched::some;
|
||||
return TxSearched::Some;
|
||||
|
||||
return count == (range->last() - range->first() + 1) ? TxSearched::all
|
||||
: TxSearched::some;
|
||||
return count == (range->last() - range->first() + 1) ? TxSearched::All
|
||||
: TxSearched::Some;
|
||||
}
|
||||
|
||||
convert(sociRawTxnBlob, rawTxn);
|
||||
@@ -1236,7 +1236,7 @@ getTransaction(
|
||||
ec = rpcDB_DESERIALIZATION;
|
||||
}
|
||||
|
||||
return TxSearched::unknown;
|
||||
return TxSearched::Unknown;
|
||||
}
|
||||
|
||||
bool
|
||||
|
||||
@@ -377,10 +377,10 @@ newestAccountTxPage(
|
||||
* @param id Hash of the transaction.
|
||||
* @param range Range of ledgers to check, if present.
|
||||
* @param ec Default value of error code.
|
||||
* @return Transaction and its metadata if found, TxSearched::all if range
|
||||
* @return Transaction and its metadata if found, TxSearched::All if range
|
||||
* given and all ledgers from range are present in the database,
|
||||
* TxSearched::some if range given and not all ledgers are present,
|
||||
* TxSearched::unknown if range not given or deserializing error
|
||||
* TxSearched::Some if range given and not all ledgers are present,
|
||||
* TxSearched::Unknown if range not given or deserializing error
|
||||
* occurred. In the last case error code modified in ec link
|
||||
* parameter, in other cases default error code remained.
|
||||
*/
|
||||
|
||||
@@ -178,7 +178,8 @@ SQLiteDatabase::saveValidatedLedger(std::shared_ptr<Ledger const> const& ledger,
|
||||
{
|
||||
if (existsLedger())
|
||||
{
|
||||
if (!detail::saveValidatedLedger(*ledgerDb_, txdb_, registry_.getApp(), ledger, current))
|
||||
if (!detail::saveValidatedLedger(
|
||||
*ledgerDb_, txdb_, registry_.get().getApp(), ledger, current))
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -314,7 +315,7 @@ SQLiteDatabase::getTxHistory(LedgerIndex startIndex)
|
||||
if (existsTransaction())
|
||||
{
|
||||
auto db = checkoutTransaction();
|
||||
auto const res = detail::getTxHistory(*db, registry_.getApp(), startIndex, 20).first;
|
||||
auto const res = detail::getTxHistory(*db, registry_.get().getApp(), startIndex, 20).first;
|
||||
|
||||
if (!res.empty())
|
||||
return res;
|
||||
@@ -329,12 +330,12 @@ SQLiteDatabase::getOldestAccountTxs(AccountTxOptions const& options)
|
||||
if (!useTxTables_)
|
||||
return {};
|
||||
|
||||
LedgerMaster& ledgerMaster = registry_.getLedgerMaster();
|
||||
LedgerMaster& ledgerMaster = registry_.get().getLedgerMaster();
|
||||
|
||||
if (existsTransaction())
|
||||
{
|
||||
auto db = checkoutTransaction();
|
||||
return detail::getOldestAccountTxs(*db, registry_.getApp(), ledgerMaster, options, j_)
|
||||
return detail::getOldestAccountTxs(*db, registry_.get().getApp(), ledgerMaster, options, j_)
|
||||
.first;
|
||||
}
|
||||
|
||||
@@ -347,12 +348,12 @@ SQLiteDatabase::getNewestAccountTxs(AccountTxOptions const& options)
|
||||
if (!useTxTables_)
|
||||
return {};
|
||||
|
||||
LedgerMaster& ledgerMaster = registry_.getLedgerMaster();
|
||||
LedgerMaster& ledgerMaster = registry_.get().getLedgerMaster();
|
||||
|
||||
if (existsTransaction())
|
||||
{
|
||||
auto db = checkoutTransaction();
|
||||
return detail::getNewestAccountTxs(*db, registry_.getApp(), ledgerMaster, options, j_)
|
||||
return detail::getNewestAccountTxs(*db, registry_.get().getApp(), ledgerMaster, options, j_)
|
||||
.first;
|
||||
}
|
||||
|
||||
@@ -368,7 +369,7 @@ SQLiteDatabase::getOldestAccountTxsB(AccountTxOptions const& options)
|
||||
if (existsTransaction())
|
||||
{
|
||||
auto db = checkoutTransaction();
|
||||
return detail::getOldestAccountTxsB(*db, registry_.getApp(), options, j_).first;
|
||||
return detail::getOldestAccountTxsB(*db, registry_.get().getApp(), options, j_).first;
|
||||
}
|
||||
|
||||
return {};
|
||||
@@ -383,7 +384,7 @@ SQLiteDatabase::getNewestAccountTxsB(AccountTxOptions const& options)
|
||||
if (existsTransaction())
|
||||
{
|
||||
auto db = checkoutTransaction();
|
||||
return detail::getNewestAccountTxsB(*db, registry_.getApp(), options, j_).first;
|
||||
return detail::getNewestAccountTxsB(*db, registry_.get().getApp(), options, j_).first;
|
||||
}
|
||||
|
||||
return {};
|
||||
@@ -397,10 +398,10 @@ SQLiteDatabase::oldestAccountTxPage(AccountTxPageOptions const& options)
|
||||
|
||||
static std::uint32_t const page_length(200);
|
||||
auto onUnsavedLedger =
|
||||
std::bind(saveLedgerAsync, std::ref(registry_.getApp()), std::placeholders::_1);
|
||||
std::bind(saveLedgerAsync, std::ref(registry_.get().getApp()), std::placeholders::_1);
|
||||
AccountTxs ret;
|
||||
auto onTransaction =
|
||||
[&ret, &app = registry_.getApp()](
|
||||
[&ret, &app = registry_.get().getApp()](
|
||||
std::uint32_t ledger_index, std::string const& status, Blob&& rawTxn, Blob&& rawMeta) {
|
||||
convertBlobsToTxResult(
|
||||
ret, ledger_index, status, std::move(rawTxn), std::move(rawMeta), app);
|
||||
@@ -426,10 +427,10 @@ SQLiteDatabase::newestAccountTxPage(AccountTxPageOptions const& options)
|
||||
|
||||
static std::uint32_t const page_length(200);
|
||||
auto onUnsavedLedger =
|
||||
std::bind(saveLedgerAsync, std::ref(registry_.getApp()), std::placeholders::_1);
|
||||
std::bind(saveLedgerAsync, std::ref(registry_.get().getApp()), std::placeholders::_1);
|
||||
AccountTxs ret;
|
||||
auto onTransaction =
|
||||
[&ret, &app = registry_.getApp()](
|
||||
[&ret, &app = registry_.get().getApp()](
|
||||
std::uint32_t ledger_index, std::string const& status, Blob&& rawTxn, Blob&& rawMeta) {
|
||||
convertBlobsToTxResult(
|
||||
ret, ledger_index, status, std::move(rawTxn), std::move(rawMeta), app);
|
||||
@@ -455,7 +456,7 @@ SQLiteDatabase::oldestAccountTxPageB(AccountTxPageOptions const& options)
|
||||
|
||||
static std::uint32_t const page_length(500);
|
||||
auto onUnsavedLedger =
|
||||
std::bind(saveLedgerAsync, std::ref(registry_.getApp()), std::placeholders::_1);
|
||||
std::bind(saveLedgerAsync, std::ref(registry_.get().getApp()), std::placeholders::_1);
|
||||
MetaTxsList ret;
|
||||
auto onTransaction =
|
||||
[&ret](
|
||||
@@ -483,7 +484,7 @@ SQLiteDatabase::newestAccountTxPageB(AccountTxPageOptions const& options)
|
||||
|
||||
static std::uint32_t const page_length(500);
|
||||
auto onUnsavedLedger =
|
||||
std::bind(saveLedgerAsync, std::ref(registry_.getApp()), std::placeholders::_1);
|
||||
std::bind(saveLedgerAsync, std::ref(registry_.get().getApp()), std::placeholders::_1);
|
||||
MetaTxsList ret;
|
||||
auto onTransaction =
|
||||
[&ret](
|
||||
@@ -510,15 +511,15 @@ SQLiteDatabase::getTransaction(
|
||||
error_code_i& ec)
|
||||
{
|
||||
if (!useTxTables_)
|
||||
return TxSearched::unknown;
|
||||
return TxSearched::Unknown;
|
||||
|
||||
if (existsTransaction())
|
||||
{
|
||||
auto db = checkoutTransaction();
|
||||
return detail::getTransaction(*db, registry_.getApp(), id, range, ec);
|
||||
return detail::getTransaction(*db, registry_.get().getApp(), id, range, ec);
|
||||
}
|
||||
|
||||
return TxSearched::unknown;
|
||||
return TxSearched::Unknown;
|
||||
}
|
||||
|
||||
SQLiteDatabase::SQLiteDatabase(SQLiteDatabase&& rhs) noexcept
|
||||
|
||||
@@ -134,7 +134,7 @@ public:
|
||||
// Entries from [ips_fixed] config stanza
|
||||
std::vector<std::string> IPS_FIXED;
|
||||
|
||||
StartUpType START_UP = StartUpType::NORMAL;
|
||||
StartUpType START_UP = StartUpType::Normal;
|
||||
|
||||
bool START_VALID = false;
|
||||
|
||||
|
||||
@@ -211,12 +211,7 @@ doAccountTxHelp(RPC::Context& context, AccountTxArgs const& args)
|
||||
result.marker = args.marker;
|
||||
|
||||
RelationalDatabase::AccountTxPageOptions options = {
|
||||
args.account,
|
||||
result.ledgerRange.min,
|
||||
result.ledgerRange.max,
|
||||
result.marker,
|
||||
args.limit,
|
||||
isUnlimited(context.role)};
|
||||
args.account, result.ledgerRange, result.marker, args.limit, isUnlimited(context.role)};
|
||||
|
||||
auto& db = context.app.getRelationalDatabase();
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ struct TxResult
|
||||
std::optional<std::string> ctid;
|
||||
std::optional<NetClock::time_point> closeTime;
|
||||
std::optional<uint256> ledgerHash;
|
||||
TxSearched searchedAll = TxSearched::unknown;
|
||||
TxSearched searchedAll = TxSearched::Unknown;
|
||||
};
|
||||
|
||||
struct TxArgs
|
||||
@@ -77,7 +77,7 @@ doTxHelp(RPC::Context& context, TxArgs args)
|
||||
|
||||
using TxPair = std::pair<std::shared_ptr<Transaction>, std::shared_ptr<TxMeta>>;
|
||||
|
||||
result.searchedAll = TxSearched::unknown;
|
||||
result.searchedAll = TxSearched::Unknown;
|
||||
std::variant<TxPair, TxSearched> v;
|
||||
|
||||
if (args.ctid)
|
||||
@@ -172,10 +172,10 @@ populateJsonResponse(
|
||||
// handle errors
|
||||
if (error.toErrorCode() != rpcSUCCESS)
|
||||
{
|
||||
if (error.toErrorCode() == rpcTXN_NOT_FOUND && result.searchedAll != TxSearched::unknown)
|
||||
if (error.toErrorCode() == rpcTXN_NOT_FOUND && result.searchedAll != TxSearched::Unknown)
|
||||
{
|
||||
response = Json::Value(Json::objectValue);
|
||||
response[jss::searched_all] = (result.searchedAll == TxSearched::all);
|
||||
response[jss::searched_all] = (result.searchedAll == TxSearched::All);
|
||||
error.inject(response);
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user