mirror of
https://github.com/XRPLF/rippled.git
synced 2026-03-03 03:02:45 +00:00
Compare commits
7 Commits
develop
...
a1q123456/
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
65e0bf2169 | ||
|
|
860bb28996 | ||
|
|
99bda74121 | ||
|
|
ce23f20ccd | ||
|
|
276fe7dc11 | ||
|
|
1f841749c3 | ||
|
|
376be0d7b3 |
@@ -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 };
|
||||
|
||||
}
|
||||
|
||||
@@ -69,7 +69,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`
|
||||
@@ -106,9 +106,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,7 @@ public:
|
||||
struct AccountTxOptions
|
||||
{
|
||||
AccountID const& account;
|
||||
std::uint32_t minLedger;
|
||||
std::uint32_t maxLedger;
|
||||
LedgerRange ledgerRange;
|
||||
std::uint32_t offset;
|
||||
std::uint32_t limit;
|
||||
bool bUnlimited;
|
||||
@@ -59,8 +58,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 +245,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 +403,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 +453,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::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
|
||||
|
||||
@@ -32,7 +32,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)
|
||||
@@ -207,7 +207,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;
|
||||
@@ -1104,7 +1104,8 @@ Transactor::operator()()
|
||||
}
|
||||
#endif
|
||||
|
||||
if (auto const& trap = ctx_.registry.trapTxID(); trap && *trap == ctx_.tx.getTransactionID())
|
||||
if (auto const& trap = ctx_.registry.get().trapTxID();
|
||||
trap && *trap == ctx_.tx.getTransactionID())
|
||||
{
|
||||
trapTransaction(*trap);
|
||||
}
|
||||
@@ -1206,16 +1207,18 @@ Transactor::operator()()
|
||||
|
||||
// If necessary, remove any offers found unfunded during processing
|
||||
if ((result == tecOVERSIZE) || (result == tecKILLED))
|
||||
removeUnfundedOffers(view(), removedOffers, ctx_.registry.journal("View"));
|
||||
removeUnfundedOffers(view(), removedOffers, ctx_.registry.get().journal("View"));
|
||||
|
||||
if (result == tecEXPIRED)
|
||||
removeExpiredNFTokenOffers(view(), expiredNFTokenOffers, ctx_.registry.journal("View"));
|
||||
removeExpiredNFTokenOffers(
|
||||
view(), expiredNFTokenOffers, ctx_.registry.get().journal("View"));
|
||||
|
||||
if (result == tecINCOMPLETE)
|
||||
removeDeletedTrustLines(view(), removedTrustLines, ctx_.registry.journal("View"));
|
||||
removeDeletedTrustLines(view(), removedTrustLines, ctx_.registry.get().journal("View"));
|
||||
|
||||
if (result == tecEXPIRED)
|
||||
removeExpiredCredentials(view(), expiredCredentials, ctx_.registry.journal("View"));
|
||||
removeExpiredCredentials(
|
||||
view(), expiredCredentials, ctx_.registry.get().journal("View"));
|
||||
|
||||
applied = isTecClaim(result);
|
||||
}
|
||||
|
||||
@@ -279,7 +279,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));
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ CancelCheck::doApply()
|
||||
|
||||
AccountID const srcId{sleCheck->getAccountID(sfAccount)};
|
||||
AccountID const dstId{sleCheck->getAccountID(sfDestination)};
|
||||
auto viewJ = ctx_.registry.journal("View");
|
||||
auto viewJ = ctx_.registry.get().journal("View");
|
||||
|
||||
// If the check is not written to self (and it shouldn't be), remove the
|
||||
// check from the destination account root.
|
||||
|
||||
@@ -230,7 +230,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_.registry.journal("View");
|
||||
auto viewJ = ctx_.registry.get().journal("View");
|
||||
auto const optDeliverMin = ctx_.tx[~sfDeliverMin];
|
||||
|
||||
if (srcId != account_)
|
||||
|
||||
@@ -166,7 +166,7 @@ CreateCheck::doApply()
|
||||
|
||||
view().insert(sleCheck);
|
||||
|
||||
auto viewJ = ctx_.registry.journal("View");
|
||||
auto viewJ = ctx_.registry.get().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_)
|
||||
|
||||
@@ -69,7 +69,7 @@ CreateTicket::doApply()
|
||||
return tecINSUFFICIENT_RESERVE;
|
||||
}
|
||||
|
||||
beast::Journal viewJ{ctx_.registry.journal("View")};
|
||||
beast::Journal viewJ{ctx_.registry.get().journal("View")};
|
||||
|
||||
// The starting ticket sequence is the same as the current account
|
||||
// root sequence. Before we got here to doApply(), the transaction
|
||||
|
||||
@@ -553,7 +553,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);
|
||||
@@ -929,7 +929,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];
|
||||
|
||||
@@ -949,7 +949,7 @@ EscrowFinish::doApply()
|
||||
else
|
||||
flags = SF_CF_INVALID;
|
||||
|
||||
ctx_.registry.getHashRouter().setFlags(id, flags);
|
||||
ctx_.registry.get().getHashRouter().setFlags(id, flags);
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,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_.registry.journal("View"));
|
||||
return offerDelete(view(), sleOffer, ctx_.registry.get().journal("View"));
|
||||
}
|
||||
|
||||
JLOG(j_.debug()) << "Offer #" << offerSequence << " can't be found.";
|
||||
|
||||
@@ -143,7 +143,7 @@ CreateOffer::preclaim(PreclaimContext const& ctx)
|
||||
|
||||
std::uint32_t const uAccountSequence = sleCreator->getFieldU32(sfSequence);
|
||||
|
||||
auto viewJ = ctx.registry.journal("View");
|
||||
auto viewJ = ctx.registry.get().journal("View");
|
||||
|
||||
if (isGlobalFrozen(ctx.view, uPaysIssuerID) || isGlobalFrozen(ctx.view, uGetsIssuerID))
|
||||
{
|
||||
@@ -498,7 +498,7 @@ CreateOffer::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;
|
||||
@@ -532,7 +532,7 @@ CreateOffer::applyGuts(Sandbox& sb, Sandbox& sbCancel)
|
||||
// end up on the books.
|
||||
auto uRate = getRate(saTakerGets, saTakerPays);
|
||||
|
||||
auto viewJ = ctx_.registry.journal("View");
|
||||
auto viewJ = ctx_.registry.get().journal("View");
|
||||
|
||||
TER result = tesSUCCESS;
|
||||
|
||||
@@ -840,7 +840,7 @@ CreateOffer::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";
|
||||
|
||||
|
||||
@@ -316,7 +316,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_.registry.journal("View"));
|
||||
return closeChannel(slep, ctx_.view(), k.key, ctx_.registry.get().journal("View"));
|
||||
}
|
||||
|
||||
if (src != txAccount)
|
||||
@@ -465,7 +465,7 @@ PayChanClaim::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.journal("View"));
|
||||
return closeChannel(slep, ctx_.view(), k.key, ctx_.registry.get().journal("View"));
|
||||
}
|
||||
|
||||
if (txAccount != src && txAccount != dst)
|
||||
@@ -523,7 +523,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_.registry.journal("View"));
|
||||
return closeChannel(slep, ctx_.view(), k.key, ctx_.registry.get().journal("View"));
|
||||
|
||||
auto const settleExpiration =
|
||||
ctx_.view().header().parentCloseTime.time_since_epoch().count() +
|
||||
|
||||
@@ -425,7 +425,7 @@ Payment::doApply()
|
||||
account_,
|
||||
ctx_.tx.getFieldPathSet(sfPaths),
|
||||
ctx_.tx[~sfDomainID],
|
||||
ctx_.registry.logs(),
|
||||
ctx_.registry.get().logs(),
|
||||
&rcInput);
|
||||
// VFALCO NOTE We might not need to apply, depending
|
||||
// on the TER. But always applying *should*
|
||||
|
||||
@@ -314,7 +314,7 @@ SetSignerList::replaceSignerList()
|
||||
view().insert(signerList);
|
||||
writeSignersToSLE(signerList, flags);
|
||||
|
||||
auto viewJ = ctx_.registry.journal("View");
|
||||
auto viewJ = ctx_.registry.get().journal("View");
|
||||
// Add the signer list to the account's directory.
|
||||
auto const page =
|
||||
ctx_.view().dirInsert(ownerDirKeylet, signerListKeylet, describeOwnerDir(account_));
|
||||
|
||||
@@ -355,7 +355,7 @@ SetTrust::doApply()
|
||||
bool const bSetDeepFreeze = (uTxFlags & tfSetDeepFreeze);
|
||||
bool const bClearDeepFreeze = (uTxFlags & tfClearDeepFreeze);
|
||||
|
||||
auto viewJ = ctx_.registry.journal("View");
|
||||
auto viewJ = ctx_.registry.get().journal("View");
|
||||
|
||||
SLE::pointer sleDst = view().peek(keylet::account(uDstAccountID));
|
||||
|
||||
|
||||
@@ -106,7 +106,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];
|
||||
@@ -126,7 +126,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);
|
||||
});
|
||||
@@ -136,7 +136,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);
|
||||
});
|
||||
@@ -161,7 +161,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);
|
||||
@@ -179,7 +179,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];
|
||||
@@ -200,7 +200,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];
|
||||
@@ -226,7 +226,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];
|
||||
@@ -256,7 +256,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);
|
||||
@@ -280,7 +280,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];
|
||||
@@ -298,7 +298,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];
|
||||
|
||||
@@ -2179,7 +2179,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;
|
||||
})};
|
||||
|
||||
@@ -2372,7 +2372,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;
|
||||
})};
|
||||
|
||||
|
||||
@@ -27,7 +27,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;
|
||||
@@ -54,7 +54,7 @@ OrderBookDBImpl::setup(std::shared_ptr<ReadView const> const& ledger)
|
||||
if (standalone_)
|
||||
update(ledger);
|
||||
else
|
||||
registry_.getJobQueue().addJob(
|
||||
registry_.get().getJobQueue().addJob(
|
||||
jtUPDATE_PF, "OrderBookUpd" + std::to_string(ledger->seq()), [this, ledger]() {
|
||||
update(ledger);
|
||||
});
|
||||
@@ -92,7 +92,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);
|
||||
@@ -156,7 +156,7 @@ OrderBookDBImpl::update(std::shared_ptr<ReadView const> const& ledger)
|
||||
xrpDomainBooks_.swap(xrpDomainBooks);
|
||||
}
|
||||
|
||||
registry_.getLedgerMaster().newOrderBookDB();
|
||||
registry_.get().getLedgerMaster().newOrderBookDB();
|
||||
}
|
||||
|
||||
void
|
||||
@@ -226,7 +226,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_;
|
||||
|
||||
|
||||
@@ -774,8 +774,7 @@ public:
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
relationalDatabase_,
|
||||
"xrpl::ApplicationImp::getRelationalDatabase : non-null "
|
||||
"relational database");
|
||||
"xrpl::ApplicationImp::getRelationalDatabase : non-null relational database");
|
||||
return *relationalDatabase_;
|
||||
}
|
||||
|
||||
@@ -1198,22 +1197,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.";
|
||||
@@ -1229,7 +1228,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.
|
||||
@@ -1617,7 +1616,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>{};
|
||||
|
||||
|
||||
@@ -614,7 +614,7 @@ run(int argc, char** argv)
|
||||
|
||||
if (vm.count("start"))
|
||||
{
|
||||
config->START_UP = StartUpType::FRESH;
|
||||
config->START_UP = StartUpType::Fresh;
|
||||
}
|
||||
|
||||
if (vm.count("import"))
|
||||
@@ -625,7 +625,7 @@ run(int argc, char** argv)
|
||||
config->START_LEDGER = vm["ledger"].as<std::string>();
|
||||
if (vm.count("replay"))
|
||||
{
|
||||
config->START_UP = StartUpType::REPLAY;
|
||||
config->START_UP = StartUpType::Replay;
|
||||
if (vm.count("trap_tx_hash"))
|
||||
{
|
||||
uint256 tmp = {};
|
||||
@@ -644,16 +644,16 @@ run(int argc, char** argv)
|
||||
}
|
||||
}
|
||||
else
|
||||
config->START_UP = StartUpType::LOAD;
|
||||
config->START_UP = StartUpType::Load;
|
||||
}
|
||||
else if (vm.count("ledgerfile"))
|
||||
{
|
||||
config->START_LEDGER = vm["ledgerfile"].as<std::string>();
|
||||
config->START_UP = StartUpType::LOAD_FILE;
|
||||
config->START_UP = StartUpType::LoadFile;
|
||||
}
|
||||
else if (vm.count("load") || config->FAST_LOAD)
|
||||
{
|
||||
config->START_UP = StartUpType::LOAD;
|
||||
config->START_UP = StartUpType::Load;
|
||||
}
|
||||
|
||||
if (vm.count("trap_tx_hash") && vm.count("replay") == 0)
|
||||
@@ -664,13 +664,13 @@ run(int argc, char** argv)
|
||||
|
||||
if (vm.count("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.count("valid"))
|
||||
|
||||
@@ -211,27 +211,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_.app(),
|
||||
registry_.get().app(),
|
||||
make_FeeVote(
|
||||
setup_FeeVote(registry_.app().config().section("voting")),
|
||||
registry_.logs().journal("FeeVote")),
|
||||
setup_FeeVote(registry_.get().app().config().section("voting")),
|
||||
registry_.get().logs().journal("FeeVote")),
|
||||
ledgerMaster,
|
||||
*m_localTX,
|
||||
registry.getInboundTransactions(),
|
||||
beast::get_abstract_clock<std::chrono::steady_clock>(),
|
||||
validatorKeys,
|
||||
registry_.logs().journal("LedgerConsensus"))
|
||||
registry_.get().logs().journal("LedgerConsensus"))
|
||||
, validatorPK_(
|
||||
validatorKeys.keys ? validatorKeys.keys->publicKey : decltype(validatorPK_){})
|
||||
, validatorMasterPK_(
|
||||
@@ -692,7 +692,7 @@ private:
|
||||
void
|
||||
setAccountHistoryJobTimer(SubAccountHistoryInfoWeak subInfo);
|
||||
|
||||
ServiceRegistry& registry_;
|
||||
std::reference_wrapper<ServiceRegistry> registry_;
|
||||
beast::Journal m_journal;
|
||||
|
||||
std::unique_ptr<LocalTxs> m_localTX;
|
||||
@@ -879,7 +879,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_.app().nodeIdentity();
|
||||
auto const& id = registry_.get().app().nodeIdentity();
|
||||
|
||||
return RFC1751::getWordFromBlob(id.first.data(), id.first.size());
|
||||
}();
|
||||
@@ -893,7 +893,7 @@ NetworkOPsImp::setStateTimer()
|
||||
setHeartbeatTimer();
|
||||
|
||||
// Only do this work if a cluster is configured
|
||||
if (registry_.cluster().size() != 0)
|
||||
if (registry_.get().cluster().size() != 0)
|
||||
setClusterTimer();
|
||||
}
|
||||
|
||||
@@ -971,13 +971,13 @@ NetworkOPsImp::processHeartbeatTimer()
|
||||
{
|
||||
RclConsensusLogger clog("Heartbeat Timer", mConsensus.validating(), m_journal);
|
||||
{
|
||||
std::unique_lock lock{registry_.app().getMasterMutex()};
|
||||
std::unique_lock lock{registry_.get().app().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_.overlay().size();
|
||||
std::size_t const numPeers = registry_.get().overlay().size();
|
||||
|
||||
// do we have sufficient peers? If not, we are disconnected.
|
||||
if (numPeers < minPeerCount_)
|
||||
@@ -1029,7 +1029,7 @@ NetworkOPsImp::processHeartbeatTimer()
|
||||
CLOG(clog.ss()) << ". ";
|
||||
}
|
||||
|
||||
mConsensus.timerEntry(registry_.timeKeeper().closeTime(), clog.ss());
|
||||
mConsensus.timerEntry(registry_.get().timeKeeper().closeTime(), clog.ss());
|
||||
|
||||
CLOG(clog.ss()) << "consensus phase " << to_string(mLastConsensusPhase);
|
||||
ConsensusPhase const currPhase = mConsensus.phase();
|
||||
@@ -1047,17 +1047,18 @@ NetworkOPsImp::processHeartbeatTimer()
|
||||
void
|
||||
NetworkOPsImp::processClusterTimer()
|
||||
{
|
||||
if (registry_.cluster().size() == 0)
|
||||
if (registry_.get().cluster().size() == 0)
|
||||
return;
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
bool const update = registry_.cluster().update(
|
||||
registry_.app().nodeIdentity().first,
|
||||
bool const update = registry_.get().cluster().update(
|
||||
registry_.get().app().nodeIdentity().first,
|
||||
"",
|
||||
(m_ledgerMaster.getValidatedLedgerAge() <= 4min) ? registry_.getFeeTrack().getLocalFee()
|
||||
: 0,
|
||||
registry_.timeKeeper().now());
|
||||
(m_ledgerMaster.getValidatedLedgerAge() <= 4min)
|
||||
? registry_.get().getFeeTrack().getLocalFee()
|
||||
: 0,
|
||||
registry_.get().timeKeeper().now());
|
||||
|
||||
if (!update)
|
||||
{
|
||||
@@ -1067,7 +1068,7 @@ NetworkOPsImp::processClusterTimer()
|
||||
}
|
||||
|
||||
protocol::TMCluster cluster;
|
||||
registry_.cluster().for_each([&cluster](ClusterNode const& node) {
|
||||
registry_.get().cluster().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());
|
||||
@@ -1076,14 +1077,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_.overlay().foreach(
|
||||
registry_.get().overlay().foreach(
|
||||
send_if(std::make_shared<Message>(cluster, protocol::mtCLUSTER), peer_in_cluster()));
|
||||
setClusterTimer();
|
||||
}
|
||||
@@ -1129,7 +1130,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)
|
||||
{
|
||||
@@ -1139,8 +1140,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)
|
||||
{
|
||||
@@ -1157,7 +1158,7 @@ NetworkOPsImp::submitTransaction(std::shared_ptr<STTx const> const& iTrans)
|
||||
|
||||
std::string reason;
|
||||
|
||||
auto tx = std::make_shared<Transaction>(trans, reason, registry_.app());
|
||||
auto tx = std::make_shared<Transaction>(trans, reason, registry_.get().app());
|
||||
|
||||
m_job_queue.addJob(jtTRANSACTION, "SubmitTxn", [this, tx]() {
|
||||
auto t = tx;
|
||||
@@ -1168,7 +1169,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)
|
||||
{
|
||||
@@ -1189,14 +1190,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");
|
||||
|
||||
@@ -1206,12 +1208,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;
|
||||
}
|
||||
@@ -1314,7 +1316,7 @@ NetworkOPsImp::processTransactionSet(CanonicalTXSet const& set)
|
||||
for (auto const& [_, tx] : set)
|
||||
{
|
||||
std::string reason;
|
||||
auto transaction = std::make_shared<Transaction>(tx, reason, registry_.app());
|
||||
auto transaction = std::make_shared<Transaction>(tx, reason, registry_.get().app());
|
||||
|
||||
if (transaction->getStatus() == INVALID)
|
||||
{
|
||||
@@ -1322,7 +1324,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;
|
||||
}
|
||||
|
||||
@@ -1398,13 +1400,13 @@ NetworkOPsImp::apply(std::unique_lock<std::mutex>& batchLock)
|
||||
batchLock.unlock();
|
||||
|
||||
{
|
||||
std::unique_lock masterLock{registry_.app().getMasterMutex(), std::defer_lock};
|
||||
std::unique_lock masterLock{registry_.get().app().getMasterMutex(), std::defer_lock};
|
||||
bool changed = false;
|
||||
{
|
||||
std::unique_lock ledgerLock{m_ledgerMaster.peekMutex(), std::defer_lock};
|
||||
std::lock(masterLock, ledgerLock);
|
||||
|
||||
registry_.openLedger().modify([&](OpenView& view, beast::Journal j) {
|
||||
registry_.get().openLedger().modify([&](OpenView& view, beast::Journal j) {
|
||||
for (TransactionStatus& e : transactions)
|
||||
{
|
||||
// we check before adding to the batch
|
||||
@@ -1415,8 +1417,8 @@ NetworkOPsImp::apply(std::unique_lock<std::mutex>& batchLock)
|
||||
if (e.failType == FailHard::yes)
|
||||
flags |= tapFAIL_HARD;
|
||||
|
||||
auto const result = registry_.getTxQ().apply(
|
||||
registry_.app(), view, e.transaction->getSTransaction(), flags, j);
|
||||
auto const result = registry_.get().getTxQ().apply(
|
||||
registry_.get().app(), view, e.transaction->getSTransaction(), flags, j);
|
||||
e.result = result.ter;
|
||||
e.applied = result.applied;
|
||||
changed = changed || result.applied;
|
||||
@@ -1431,7 +1433,7 @@ NetworkOPsImp::apply(std::unique_lock<std::mutex>& batchLock)
|
||||
if (auto const l = m_ledgerMaster.getValidatedLedger())
|
||||
validatedLedgerIndex = l->header().seq;
|
||||
|
||||
auto newOL = registry_.openLedger().current();
|
||||
auto newOL = registry_.get().openLedger().current();
|
||||
for (TransactionStatus& e : transactions)
|
||||
{
|
||||
e.transaction->clearSubmitResult();
|
||||
@@ -1445,7 +1447,8 @@ 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 (e.result != tesSUCCESS)
|
||||
@@ -1480,7 +1483,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_.app());
|
||||
auto t = std::make_shared<Transaction>(trans, reason, registry_.get().app());
|
||||
if (t->getApplying())
|
||||
break;
|
||||
submit_held.emplace_back(t, false, false, FailHard::no);
|
||||
@@ -1534,7 +1537,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
|
||||
@@ -1571,7 +1574,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
|
||||
@@ -1586,18 +1590,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_.timeKeeper().now().time_since_epoch().count());
|
||||
registry_.get().timeKeeper().now().time_since_epoch().count());
|
||||
tx.set_deferred(e.result == terQUEUED);
|
||||
// FIXME: This should be when we received it
|
||||
registry_.overlay().relay(e.transaction->getID(), tx, *toSkip);
|
||||
registry_.get().overlay().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);
|
||||
}
|
||||
@@ -1773,7 +1778,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
|
||||
@@ -1818,7 +1823,7 @@ NetworkOPsImp::checkLastClosedLedger(Overlay::PeerSequence const& peerList, uint
|
||||
auto consensus = m_ledgerMaster.getLedgerByHash(closedLedger);
|
||||
|
||||
if (!consensus)
|
||||
consensus = registry_.getInboundLedgers().acquire(
|
||||
consensus = registry_.get().getInboundLedgers().acquire(
|
||||
closedLedger, 0, InboundLedger::Reason::CONSENSUS);
|
||||
|
||||
if (consensus &&
|
||||
@@ -1860,7 +1865,7 @@ NetworkOPsImp::switchLastClosedLedger(std::shared_ptr<Ledger const> const& newLC
|
||||
clearNeedNetworkLedger();
|
||||
|
||||
// Update fee computations.
|
||||
registry_.getTxQ().processClosedLedger(registry_.app(), *newLCL, true);
|
||||
registry_.get().getTxQ().processClosedLedger(registry_.get().app(), *newLCL, true);
|
||||
|
||||
// Caller must own master lock
|
||||
{
|
||||
@@ -1868,14 +1873,14 @@ 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_.app().config().features);
|
||||
rules = makeRulesGivenLedger(*lastVal, registry_.get().app().config().features);
|
||||
else
|
||||
rules.emplace(registry_.app().config().features);
|
||||
registry_.openLedger().accept(
|
||||
registry_.app(),
|
||||
rules.emplace(registry_.get().app().config().features);
|
||||
registry_.get().openLedger().accept(
|
||||
registry_.get().app(),
|
||||
*rules,
|
||||
newLCL,
|
||||
OrderedTxs({}),
|
||||
@@ -1885,7 +1890,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_.app(), view);
|
||||
return registry_.get().getTxQ().accept(registry_.get().app(), view);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1894,12 +1899,12 @@ 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_.timeKeeper().now().time_since_epoch().count());
|
||||
s.set_networktime(registry_.get().timeKeeper().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_.overlay().foreach(
|
||||
registry_.get().overlay().foreach(
|
||||
send_always(std::make_shared<Message>(s, protocol::mtSTATUS_CHANGE)));
|
||||
}
|
||||
|
||||
@@ -1940,23 +1945,24 @@ NetworkOPsImp::beginConsensus(
|
||||
"xrpl::NetworkOPsImp::beginConsensus : closedLedger parent matches "
|
||||
"hash");
|
||||
|
||||
registry_.validators().setNegativeUNL(prevLedger->negativeUNL());
|
||||
TrustChanges const changes = registry_.validators().updateTrusted(
|
||||
registry_.getValidations().getCurrentNodeIDs(),
|
||||
registry_.get().validators().setNegativeUNL(prevLedger->negativeUNL());
|
||||
TrustChanges const changes = registry_.get().validators().updateTrusted(
|
||||
registry_.get().getValidations().getCurrentNodeIDs(),
|
||||
closingInfo.parentCloseTime,
|
||||
*this,
|
||||
registry_.overlay(),
|
||||
registry_.getHashRouter());
|
||||
registry_.get().overlay(),
|
||||
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_.validators().getQuorumKeys().second);
|
||||
registry_.get().getAmendmentTable().trustChanged(
|
||||
registry_.get().validators().getQuorumKeys().second);
|
||||
}
|
||||
|
||||
mConsensus.startRound(
|
||||
registry_.timeKeeper().closeTime(),
|
||||
registry_.get().timeKeeper().closeTime(),
|
||||
networkClosed,
|
||||
prevLedger,
|
||||
changes.removed,
|
||||
@@ -1996,7 +2002,7 @@ NetworkOPsImp::processTrustedProposal(RCLCxPeerPos peerPos)
|
||||
return false;
|
||||
}
|
||||
|
||||
return mConsensus.peerProposal(registry_.timeKeeper().closeTime(), peerPos);
|
||||
return mConsensus.peerProposal(registry_.get().timeKeeper().closeTime(), peerPos);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2010,11 +2016,12 @@ NetworkOPsImp::mapComplete(std::shared_ptr<SHAMap> const& map, bool fromAcquire)
|
||||
protocol::TMHaveTransactionSet msg;
|
||||
msg.set_hash(map->getHash().as_uint256().begin(), 256 / 8);
|
||||
msg.set_status(protocol::tsHAVE);
|
||||
registry_.overlay().foreach(send_always(std::make_shared<Message>(msg, protocol::mtHAVE_SET)));
|
||||
registry_.get().overlay().foreach(
|
||||
send_always(std::make_shared<Message>(msg, protocol::mtHAVE_SET)));
|
||||
|
||||
// We acquired it because consensus asked us to
|
||||
if (fromAcquire)
|
||||
mConsensus.gotTxSet(registry_.timeKeeper().closeTime(), RCLTxSet{map});
|
||||
mConsensus.gotTxSet(registry_.get().timeKeeper().closeTime(), RCLTxSet{map});
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2022,7 +2029,7 @@ NetworkOPsImp::endConsensus(std::unique_ptr<std::stringstream> const& clog)
|
||||
{
|
||||
uint256 deadLedger = m_ledgerMaster.getClosedLedger()->header().parentHash;
|
||||
|
||||
for (auto const& it : registry_.overlay().getActivePeers())
|
||||
for (auto const& it : registry_.get().overlay().getActivePeers())
|
||||
{
|
||||
if (it && (it->getClosedLedgerHash() == deadLedger))
|
||||
{
|
||||
@@ -2032,7 +2039,8 @@ NetworkOPsImp::endConsensus(std::unique_ptr<std::stringstream> const& clog)
|
||||
}
|
||||
|
||||
uint256 networkClosed;
|
||||
bool ledgerChange = checkLastClosedLedger(registry_.overlay().getActivePeers(), networkClosed);
|
||||
bool ledgerChange =
|
||||
checkLastClosedLedger(registry_.get().overlay().getActivePeers(), networkClosed);
|
||||
|
||||
if (networkClosed.isZero())
|
||||
{
|
||||
@@ -2062,7 +2070,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_.timeKeeper().now() <
|
||||
if (registry_.get().timeKeeper().now() <
|
||||
(current->header().parentCloseTime + 2 * current->header().closeTimeResolution))
|
||||
{
|
||||
setMode(OperatingMode::FULL);
|
||||
@@ -2170,9 +2178,9 @@ NetworkOPsImp::pubServer()
|
||||
Json::Value jvObj(Json::objectValue);
|
||||
|
||||
ServerFeeSummary f{
|
||||
registry_.openLedger().current()->fees().base,
|
||||
registry_.getTxQ().getMetrics(*registry_.openLedger().current()),
|
||||
registry_.getFeeTrack()};
|
||||
registry_.get().openLedger().current()->fees().base,
|
||||
registry_.get().getTxQ().getMetrics(*registry_.get().openLedger().current()),
|
||||
registry_.get().getFeeTrack()};
|
||||
|
||||
jvObj[jss::type] = "serverStatus";
|
||||
jvObj[jss::server_status] = strOperatingMode();
|
||||
@@ -2264,7 +2272,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);
|
||||
@@ -2275,7 +2283,7 @@ NetworkOPsImp::pubValidation(std::shared_ptr<STValidation> const& val)
|
||||
if (auto hash = (*val)[~sfValidatedHash])
|
||||
jvObj[jss::validated_hash] = strHex(*hash);
|
||||
|
||||
auto const masterKey = registry_.validatorManifests().getMasterKey(signerPublic);
|
||||
auto const masterKey = registry_.get().validatorManifests().getMasterKey(signerPublic);
|
||||
|
||||
if (masterKey != signerPublic)
|
||||
jvObj[jss::master_key] = toBase58(TokenType::NodePublic, masterKey);
|
||||
@@ -2384,12 +2392,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;
|
||||
}
|
||||
|
||||
@@ -2421,7 +2429,7 @@ NetworkOPsImp::recvValidation(std::shared_ptr<STValidation> const& val, std::str
|
||||
else
|
||||
pendingValidations_.insert(val->getLedgerHash());
|
||||
scope_unlock unlock(lock);
|
||||
handleNewValidation(registry_.app(), val, source, bypassAccept, m_journal);
|
||||
handleNewValidation(registry_.get().app(), val, source, bypassAccept, m_journal);
|
||||
}
|
||||
catch (std::exception const& e)
|
||||
{
|
||||
@@ -2444,7 +2452,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_.validators().getTrustedKey(val->getSignerPublic());
|
||||
auto master = registry_.get().validators().getTrustedKey(val->getSignerPublic());
|
||||
if (master)
|
||||
{
|
||||
ss << toBase58(TokenType::NodePublic, *master);
|
||||
@@ -2458,7 +2466,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_.app().config().RELAY_UNTRUSTED_VALIDATIONS == 1 || val->isTrusted();
|
||||
return registry_.get().app().config().RELAY_UNTRUSTED_VALIDATIONS == 1 || val->isTrusted();
|
||||
}
|
||||
|
||||
Json::Value
|
||||
@@ -2500,7 +2508,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();
|
||||
@@ -2517,8 +2526,8 @@ NetworkOPsImp::getServerInfo(bool human, bool admin, bool counters)
|
||||
info[jss::hostid] = getHostId(admin);
|
||||
|
||||
// domain: if configured with a domain, report it:
|
||||
if (!registry_.app().config().SERVER_DOMAIN.empty())
|
||||
info[jss::server_domain] = registry_.app().config().SERVER_DOMAIN;
|
||||
if (!registry_.get().app().config().SERVER_DOMAIN.empty())
|
||||
info[jss::server_domain] = registry_.get().app().config().SERVER_DOMAIN;
|
||||
|
||||
info[jss::build_version] = BuildInfo::getVersionString();
|
||||
|
||||
@@ -2530,11 +2539,11 @@ NetworkOPsImp::getServerInfo(bool human, bool admin, bool counters)
|
||||
if (needNetworkLedger_)
|
||||
info[jss::network_ledger] = "waiting";
|
||||
|
||||
info[jss::validation_quorum] = static_cast<Json::UInt>(registry_.validators().quorum());
|
||||
info[jss::validation_quorum] = static_cast<Json::UInt>(registry_.get().validators().quorum());
|
||||
|
||||
if (admin)
|
||||
{
|
||||
switch (registry_.app().config().NODE_SIZE)
|
||||
switch (registry_.get().app().config().NODE_SIZE)
|
||||
{
|
||||
case 0:
|
||||
info[jss::node_size] = "tiny";
|
||||
@@ -2553,7 +2562,7 @@ NetworkOPsImp::getServerInfo(bool human, bool admin, bool counters)
|
||||
break;
|
||||
}
|
||||
|
||||
auto when = registry_.validators().expires();
|
||||
auto when = registry_.get().validators().expires();
|
||||
|
||||
if (!human)
|
||||
{
|
||||
@@ -2567,7 +2576,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_.validators().count());
|
||||
x[jss::count] = static_cast<Json::UInt>(registry_.get().validators().count());
|
||||
|
||||
if (when)
|
||||
{
|
||||
@@ -2580,7 +2589,7 @@ NetworkOPsImp::getServerInfo(bool human, bool admin, bool counters)
|
||||
{
|
||||
x[jss::expiration] = to_string(*when);
|
||||
|
||||
if (*when > registry_.timeKeeper().now())
|
||||
if (*when > registry_.get().timeKeeper().now())
|
||||
x[jss::status] = "active";
|
||||
else
|
||||
x[jss::status] = "expired";
|
||||
@@ -2605,12 +2614,13 @@ NetworkOPsImp::getServerInfo(bool human, bool admin, bool counters)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
info[jss::io_latency_ms] = static_cast<Json::UInt>(registry_.app().getIOLatency().count());
|
||||
info[jss::io_latency_ms] =
|
||||
static_cast<Json::UInt>(registry_.get().app().getIOLatency().count());
|
||||
|
||||
if (admin)
|
||||
{
|
||||
if (auto const localPubKey = registry_.validators().localPublicKey();
|
||||
localPubKey && registry_.app().getValidationPublicKey())
|
||||
if (auto const localPubKey = registry_.get().validators().localPublicKey();
|
||||
localPubKey && registry_.get().app().getValidationPublicKey())
|
||||
{
|
||||
info[jss::pubkey_validator] = toBase58(TokenType::NodePublic, localPubKey.value());
|
||||
}
|
||||
@@ -2622,17 +2632,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_.app().nodeIdentity().first);
|
||||
info[jss::pubkey_node] =
|
||||
toBase58(TokenType::NodePublic, registry_.get().app().nodeIdentity().first);
|
||||
|
||||
info[jss::complete_ledgers] = registry_.getLedgerMaster().getCompleteLedgers();
|
||||
info[jss::complete_ledgers] = registry_.get().getLedgerMaster().getCompleteLedgers();
|
||||
|
||||
if (amendmentBlocked_)
|
||||
info[jss::amendment_blocked] = true;
|
||||
@@ -2642,7 +2653,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_.overlay().size());
|
||||
info[jss::peers] = Json::UInt(registry_.get().overlay().size());
|
||||
|
||||
Json::Value lastClose = Json::objectValue;
|
||||
lastClose[jss::proposers] = Json::UInt(mConsensus.prevProposers());
|
||||
@@ -2664,13 +2675,14 @@ NetworkOPsImp::getServerInfo(bool human, bool admin, bool counters)
|
||||
if (admin)
|
||||
info[jss::load] = m_job_queue.getJson();
|
||||
|
||||
if (auto const netid = registry_.overlay().networkID())
|
||||
if (auto const netid = registry_.get().overlay().networkID())
|
||||
info[jss::network_id] = static_cast<Json::UInt>(*netid);
|
||||
|
||||
auto const escalationMetrics = registry_.getTxQ().getMetrics(*registry_.openLedger().current());
|
||||
auto const escalationMetrics =
|
||||
registry_.get().getTxQ().getMetrics(*registry_.get().openLedger().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. */
|
||||
@@ -2707,13 +2719,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;
|
||||
}
|
||||
@@ -2757,7 +2769,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_.timeKeeper().closeOffset();
|
||||
if (auto const closeOffset = registry_.get().timeKeeper().closeOffset();
|
||||
std::abs(closeOffset.count()) >= 60)
|
||||
l[jss::close_time_offset] = static_cast<std::uint32_t>(closeOffset.count());
|
||||
|
||||
@@ -2770,7 +2782,7 @@ NetworkOPsImp::getServerInfo(bool human, bool admin, bool counters)
|
||||
else
|
||||
{
|
||||
auto lCloseTime = lpClosed->header().closeTime;
|
||||
auto closeTime = registry_.timeKeeper().closeTime();
|
||||
auto closeTime = registry_.get().timeKeeper().closeTime();
|
||||
if (lCloseTime <= closeTime)
|
||||
{
|
||||
using namespace std::chrono_literals;
|
||||
@@ -2794,10 +2806,10 @@ 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_.overlay().getJqTransOverflow());
|
||||
info[jss::peer_disconnects] = std::to_string(registry_.overlay().getPeerDisconnect());
|
||||
info[jss::jq_trans_overflow] = std::to_string(registry_.get().overlay().getJqTransOverflow());
|
||||
info[jss::peer_disconnects] = std::to_string(registry_.get().overlay().getPeerDisconnect());
|
||||
info[jss::peer_disconnects_resources] =
|
||||
std::to_string(registry_.overlay().getPeerDisconnectCharges());
|
||||
std::to_string(registry_.get().overlay().getPeerDisconnectCharges());
|
||||
|
||||
// This array must be sorted in increasing order.
|
||||
static constexpr std::array<std::string_view, 7> protocols{
|
||||
@@ -2805,7 +2817,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 &&
|
||||
@@ -2829,9 +2841,9 @@ NetworkOPsImp::getServerInfo(bool human, bool admin, bool counters)
|
||||
}
|
||||
}
|
||||
|
||||
if (registry_.app().config().exists(SECTION_PORT_GRPC))
|
||||
if (registry_.get().app().config().exists(SECTION_PORT_GRPC))
|
||||
{
|
||||
auto const& grpcSection = registry_.app().config().section(SECTION_PORT_GRPC);
|
||||
auto const& grpcSection = registry_.get().app().config().section(SECTION_PORT_GRPC);
|
||||
auto const optPort = grpcSection.get("port");
|
||||
if (optPort && grpcSection.get("ip"))
|
||||
{
|
||||
@@ -2850,13 +2862,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
|
||||
@@ -2906,11 +2918,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);
|
||||
}
|
||||
|
||||
@@ -2934,7 +2946,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] = Config::FEE_UNITS_DEPRECATED;
|
||||
@@ -2946,7 +2958,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();
|
||||
@@ -3014,9 +3027,9 @@ void
|
||||
NetworkOPsImp::reportFeeChange()
|
||||
{
|
||||
ServerFeeSummary f{
|
||||
registry_.openLedger().current()->fees().base,
|
||||
registry_.getTxQ().getMetrics(*registry_.openLedger().current()),
|
||||
registry_.getFeeTrack()};
|
||||
registry_.get().openLedger().current()->fees().base,
|
||||
registry_.get().getTxQ().getMetrics(*registry_.get().openLedger().current()),
|
||||
registry_.get().getFeeTrack()};
|
||||
|
||||
// only schedule the job if something has changed
|
||||
if (f != mLastFeeSummary)
|
||||
@@ -3077,7 +3090,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);
|
||||
|
||||
@@ -3116,8 +3129,8 @@ NetworkOPsImp::transJson(
|
||||
// If the offer create is not self funded then add the owner balance
|
||||
if (account != amount.issue().account)
|
||||
{
|
||||
auto const ownerFunds =
|
||||
accountFunds(*ledger, account, amount, fhIGNORE_FREEZE, registry_.journal("View"));
|
||||
auto const ownerFunds = accountFunds(
|
||||
*ledger, account, amount, fhIGNORE_FREEZE, registry_.get().journal("View"));
|
||||
jvObj[jss::transaction][jss::owner_funds] = ownerFunds.getText();
|
||||
}
|
||||
}
|
||||
@@ -3194,7 +3207,7 @@ NetworkOPsImp::pubValidatedTransaction(
|
||||
}
|
||||
|
||||
if (transaction.getResult() == tesSUCCESS)
|
||||
registry_.getOrderBookDB().processTxn(ledger, transaction, jvObj);
|
||||
registry_.get().getOrderBookDB().processTxn(ledger, transaction, jvObj);
|
||||
|
||||
pubAccountTransaction(ledger, transaction, last);
|
||||
}
|
||||
@@ -3493,7 +3506,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;
|
||||
}
|
||||
@@ -3515,7 +3528,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_;
|
||||
@@ -3596,9 +3609,10 @@ NetworkOPsImp::addAccountHistoryJob(SubAccountHistoryInfoWeak subInfo)
|
||||
switch (dbType)
|
||||
{
|
||||
case Sqlite: {
|
||||
auto db = static_cast<SQLiteDatabase*>(®istry_.getRelationalDatabase());
|
||||
auto db =
|
||||
static_cast<SQLiteDatabase*>(®istry_.get().getRelationalDatabase());
|
||||
RelationalDatabase::AccountTxPageOptions options{
|
||||
accountId, minLedger, maxLedger, marker, 0, true};
|
||||
accountId, {minLedger, maxLedger}, marker, 0, true};
|
||||
return db->newestAccountTxPage(options);
|
||||
}
|
||||
// LCOV_EXCL_START
|
||||
@@ -3641,7 +3655,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;
|
||||
@@ -3688,7 +3703,7 @@ NetworkOPsImp::addAccountHistoryJob(SubAccountHistoryInfoWeak subInfo)
|
||||
return;
|
||||
}
|
||||
auto curTxLedger =
|
||||
registry_.getLedgerMaster().getLedgerBySeq(tx->getLedger());
|
||||
registry_.get().getLedgerMaster().getLedgerBySeq(tx->getLedger());
|
||||
if (!curTxLedger)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
@@ -3836,7 +3851,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);
|
||||
@@ -3896,7 +3911,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);
|
||||
else
|
||||
{
|
||||
@@ -3910,7 +3925,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;
|
||||
@@ -3929,7 +3944,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_.timeKeeper().closeTime(), consensusDelay);
|
||||
mConsensus.simulate(registry_.get().timeKeeper().closeTime(), consensusDelay);
|
||||
return m_ledgerMaster.getCurrentLedger()->header().seq;
|
||||
}
|
||||
|
||||
@@ -3948,12 +3963,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);
|
||||
@@ -4012,14 +4027,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_.app().nodeIdentity().first);
|
||||
toBase58(TokenType::NodePublic, registry_.get().app().nodeIdentity().first);
|
||||
|
||||
std::lock_guard sl(mSubLock);
|
||||
return mStreamMaps[sServer].emplace(isrListener->getSeq(), isrListener).second;
|
||||
@@ -4206,7 +4221,7 @@ NetworkOPsImp::getBookPage(
|
||||
STAmount saDirRate;
|
||||
|
||||
auto const rate = transferRate(view, book.out.account);
|
||||
auto viewJ = registry_.journal("View");
|
||||
auto viewJ = registry_.get().journal("View");
|
||||
|
||||
while (!bDone && iLimit-- > 0)
|
||||
{
|
||||
@@ -4575,11 +4590,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)
|
||||
{
|
||||
@@ -4588,11 +4603,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_;
|
||||
|
||||
@@ -69,8 +69,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;
|
||||
@@ -668,16 +668,16 @@ transactionsSQL(
|
||||
std::string maxClause = "";
|
||||
std::string minClause = "";
|
||||
|
||||
if (options.maxLedger)
|
||||
if (options.ledgerRange.max)
|
||||
{
|
||||
maxClause = boost::str(
|
||||
boost::format("AND AccountTransactions.LedgerSeq <= '%u'") % options.maxLedger);
|
||||
boost::format("AND AccountTransactions.LedgerSeq <= '%u'") % options.ledgerRange.max);
|
||||
}
|
||||
|
||||
if (options.minLedger)
|
||||
if (options.ledgerRange.min)
|
||||
{
|
||||
minClause = boost::str(
|
||||
boost::format("AND AccountTransactions.LedgerSeq >= '%u'") % options.minLedger);
|
||||
boost::format("AND AccountTransactions.LedgerSeq >= '%u'") % options.ledgerRange.min);
|
||||
}
|
||||
|
||||
std::string sql;
|
||||
@@ -998,14 +998,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(
|
||||
@@ -1159,7 +1159,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)
|
||||
{
|
||||
@@ -1172,10 +1172,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);
|
||||
@@ -1203,7 +1203,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,7 @@ SQLiteDatabase::saveValidatedLedger(std::shared_ptr<Ledger const> const& ledger,
|
||||
{
|
||||
if (existsLedger())
|
||||
{
|
||||
if (!detail::saveValidatedLedger(*ledgerDb_, txdb_, registry_.app(), ledger, current))
|
||||
if (!detail::saveValidatedLedger(*ledgerDb_, txdb_, registry_.get().app(), ledger, current))
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -314,7 +314,7 @@ SQLiteDatabase::getTxHistory(LedgerIndex startIndex)
|
||||
if (existsTransaction())
|
||||
{
|
||||
auto db = checkoutTransaction();
|
||||
auto const res = detail::getTxHistory(*db, registry_.app(), startIndex, 20).first;
|
||||
auto const res = detail::getTxHistory(*db, registry_.get().app(), startIndex, 20).first;
|
||||
|
||||
if (!res.empty())
|
||||
return res;
|
||||
@@ -329,12 +329,13 @@ 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_.app(), ledgerMaster, options, j_).first;
|
||||
return detail::getOldestAccountTxs(*db, registry_.get().app(), ledgerMaster, options, j_)
|
||||
.first;
|
||||
}
|
||||
|
||||
return {};
|
||||
@@ -346,12 +347,13 @@ 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_.app(), ledgerMaster, options, j_).first;
|
||||
return detail::getNewestAccountTxs(*db, registry_.get().app(), ledgerMaster, options, j_)
|
||||
.first;
|
||||
}
|
||||
|
||||
return {};
|
||||
@@ -366,7 +368,7 @@ SQLiteDatabase::getOldestAccountTxsB(AccountTxOptions const& options)
|
||||
if (existsTransaction())
|
||||
{
|
||||
auto db = checkoutTransaction();
|
||||
return detail::getOldestAccountTxsB(*db, registry_.app(), options, j_).first;
|
||||
return detail::getOldestAccountTxsB(*db, registry_.get().app(), options, j_).first;
|
||||
}
|
||||
|
||||
return {};
|
||||
@@ -381,7 +383,7 @@ SQLiteDatabase::getNewestAccountTxsB(AccountTxOptions const& options)
|
||||
if (existsTransaction())
|
||||
{
|
||||
auto db = checkoutTransaction();
|
||||
return detail::getNewestAccountTxsB(*db, registry_.app(), options, j_).first;
|
||||
return detail::getNewestAccountTxsB(*db, registry_.get().app(), options, j_).first;
|
||||
}
|
||||
|
||||
return {};
|
||||
@@ -395,10 +397,10 @@ SQLiteDatabase::oldestAccountTxPage(AccountTxPageOptions const& options)
|
||||
|
||||
static std::uint32_t const page_length(200);
|
||||
auto onUnsavedLedger =
|
||||
std::bind(saveLedgerAsync, std::ref(registry_.app()), std::placeholders::_1);
|
||||
std::bind(saveLedgerAsync, std::ref(registry_.get().app()), std::placeholders::_1);
|
||||
AccountTxs ret;
|
||||
auto onTransaction =
|
||||
[&ret, &app = registry_.app()](
|
||||
[&ret, &app = registry_.get().app()](
|
||||
std::uint32_t ledger_index, std::string const& status, Blob&& rawTxn, Blob&& rawMeta) {
|
||||
convertBlobsToTxResult(ret, ledger_index, status, rawTxn, rawMeta, app);
|
||||
};
|
||||
@@ -423,10 +425,10 @@ SQLiteDatabase::newestAccountTxPage(AccountTxPageOptions const& options)
|
||||
|
||||
static std::uint32_t const page_length(200);
|
||||
auto onUnsavedLedger =
|
||||
std::bind(saveLedgerAsync, std::ref(registry_.app()), std::placeholders::_1);
|
||||
std::bind(saveLedgerAsync, std::ref(registry_.get().app()), std::placeholders::_1);
|
||||
AccountTxs ret;
|
||||
auto onTransaction =
|
||||
[&ret, &app = registry_.app()](
|
||||
[&ret, &app = registry_.get().app()](
|
||||
std::uint32_t ledger_index, std::string const& status, Blob&& rawTxn, Blob&& rawMeta) {
|
||||
convertBlobsToTxResult(ret, ledger_index, status, rawTxn, rawMeta, app);
|
||||
};
|
||||
@@ -451,7 +453,7 @@ SQLiteDatabase::oldestAccountTxPageB(AccountTxPageOptions const& options)
|
||||
|
||||
static std::uint32_t const page_length(500);
|
||||
auto onUnsavedLedger =
|
||||
std::bind(saveLedgerAsync, std::ref(registry_.app()), std::placeholders::_1);
|
||||
std::bind(saveLedgerAsync, std::ref(registry_.get().app()), std::placeholders::_1);
|
||||
MetaTxsList ret;
|
||||
auto onTransaction =
|
||||
[&ret](
|
||||
@@ -479,7 +481,7 @@ SQLiteDatabase::newestAccountTxPageB(AccountTxPageOptions const& options)
|
||||
|
||||
static std::uint32_t const page_length(500);
|
||||
auto onUnsavedLedger =
|
||||
std::bind(saveLedgerAsync, std::ref(registry_.app()), std::placeholders::_1);
|
||||
std::bind(saveLedgerAsync, std::ref(registry_.get().app()), std::placeholders::_1);
|
||||
MetaTxsList ret;
|
||||
auto onTransaction =
|
||||
[&ret](
|
||||
@@ -506,15 +508,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_.app(), id, range, ec);
|
||||
return detail::getTransaction(*db, registry_.get().app(), id, range, ec);
|
||||
}
|
||||
|
||||
return TxSearched::unknown;
|
||||
return TxSearched::Unknown;
|
||||
}
|
||||
|
||||
SQLiteDatabase::SQLiteDatabase(SQLiteDatabase&& rhs) noexcept
|
||||
@@ -605,7 +607,8 @@ SQLiteDatabase::SQLiteDatabase(ServiceRegistry& registry, Config const& config,
|
||||
, j_(registry.journal("SQLiteDatabase"))
|
||||
{
|
||||
DatabaseCon::Setup const setup = setup_DatabaseCon(config, j_);
|
||||
if (!makeLedgerDBs(config, setup, DatabaseCon::CheckpointerSetup{&jobQueue, ®istry_.logs()}))
|
||||
if (!makeLedgerDBs(
|
||||
config, setup, DatabaseCon::CheckpointerSetup{&jobQueue, ®istry_.get().logs()}))
|
||||
{
|
||||
std::string_view constexpr error = "Failed to create ledger databases";
|
||||
|
||||
|
||||
@@ -126,7 +126,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;
|
||||
|
||||
|
||||
@@ -203,12 +203,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();
|
||||
|
||||
|
||||
@@ -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