mirror of
https://github.com/Xahau/xahaud.git
synced 2026-06-05 01:36:38 +00:00
Add true partitioning support to TaggedCache:
The primary change introduced in this commit is partitioning of the `TaggedCache`, with each partition being indepedent of each other, making it possible to potentially perform multiple cache operations in parallel. In particular, the `sweep` operation is now parallelized by default on systems with at least four cores present. The `TaggedCache` could also be instantiated in 'key-only' mode which complicated the interface significantly but was only used by a single consumer (the `FullBelowCache`). This commit splits the 'key-only' functionality of `TaggedCache`, and incorporates directly into `FullBelowCache`, resulting in simple and cleaner interfaces for both `TaggedCache` and `FullBelowCache` but at a cost: some code duplication. Lastly, this commit includes a medley of changes, including the restructuring of `Transaction`, reducing its size by 48 bytes.
This commit is contained in:
@@ -35,38 +35,12 @@
|
||||
|
||||
namespace ripple {
|
||||
|
||||
Transaction::Transaction(
|
||||
std::shared_ptr<STTx const> const& stx,
|
||||
std::string& reason,
|
||||
Application& app) noexcept
|
||||
: mTransaction(stx), mApp(app), j_(app.journal("Ledger"))
|
||||
{
|
||||
try
|
||||
{
|
||||
mTransactionID = mTransaction->getTransactionID();
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
reason = e.what();
|
||||
return;
|
||||
}
|
||||
|
||||
mStatus = NEW;
|
||||
}
|
||||
|
||||
//
|
||||
// Misc.
|
||||
//
|
||||
|
||||
void
|
||||
Transaction::setStatus(TransStatus ts, std::uint32_t lseq)
|
||||
{
|
||||
mStatus = ts;
|
||||
mInLedger = lseq;
|
||||
}
|
||||
|
||||
TransStatus
|
||||
Transaction::sqlTransactionStatus(boost::optional<std::string> const& status)
|
||||
sqlTransactionStatus(boost::optional<std::string> const& status)
|
||||
{
|
||||
char const c = (status) ? (*status)[0] : safe_cast<char>(txnSqlUnknown);
|
||||
|
||||
@@ -88,26 +62,6 @@ Transaction::sqlTransactionStatus(boost::optional<std::string> const& status)
|
||||
return INVALID;
|
||||
}
|
||||
|
||||
Transaction::pointer
|
||||
Transaction::transactionFromSQL(
|
||||
boost::optional<std::uint64_t> const& ledgerSeq,
|
||||
boost::optional<std::string> const& status,
|
||||
Blob const& rawTxn,
|
||||
Application& app)
|
||||
{
|
||||
std::uint32_t const inLedger =
|
||||
rangeCheckedCast<std::uint32_t>(ledgerSeq.value_or(0));
|
||||
|
||||
SerialIter it(makeSlice(rawTxn));
|
||||
auto txn = std::make_shared<STTx const>(it);
|
||||
std::string reason;
|
||||
auto tr = std::make_shared<Transaction>(txn, reason, app);
|
||||
|
||||
tr->setStatus(sqlTransactionStatus(status));
|
||||
tr->setLedger(inLedger);
|
||||
return tr;
|
||||
}
|
||||
|
||||
std::variant<
|
||||
std::pair<std::shared_ptr<Transaction>, std::shared_ptr<TxMeta>>,
|
||||
TxSearched>
|
||||
@@ -165,7 +119,7 @@ Transaction::load(
|
||||
|
||||
// options 1 to include the date of the transaction
|
||||
Json::Value
|
||||
Transaction::getJson(JsonOptions options, bool binary) const
|
||||
Transaction::getJson(Application& app, JsonOptions options, bool binary) const
|
||||
{
|
||||
Json::Value ret(mTransaction->getJson(JsonOptions::none, binary));
|
||||
|
||||
@@ -176,7 +130,7 @@ Transaction::getJson(JsonOptions options, bool binary) const
|
||||
|
||||
if (options == JsonOptions::include_date)
|
||||
{
|
||||
auto ct = mApp.getLedgerMaster().getCloseTimeBySeq(mInLedger);
|
||||
auto ct = app.getLedgerMaster().getCloseTimeBySeq(mInLedger);
|
||||
if (ct)
|
||||
ret[jss::date] = ct->time_since_epoch().count();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user