mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Speed up access to ledger index value that can be deleted.
This commit is contained in:
committed by
Nik Bougalis
parent
f3c1f63444
commit
9430f3665b
@@ -204,8 +204,8 @@ SHAMapStoreImp::SHAMapStoreImp (Setup const& setup,
|
||||
, scheduler_ (scheduler)
|
||||
, journal_ (journal)
|
||||
, nodeStoreJournal_ (nodeStoreJournal)
|
||||
, database_ (nullptr)
|
||||
, transactionMaster_ (transactionMaster)
|
||||
, canDelete_ (0)
|
||||
{
|
||||
if (setup_.deleteInterval)
|
||||
{
|
||||
@@ -326,17 +326,17 @@ SHAMapStoreImp::run()
|
||||
lastRotated = validatedSeq;
|
||||
state_db_.setLastRotated (lastRotated);
|
||||
}
|
||||
LedgerIndex canDelete = std::numeric_limits <LedgerIndex>::max();
|
||||
canDelete_ = std::numeric_limits <LedgerIndex>::max();
|
||||
if (setup_.advisoryDelete)
|
||||
canDelete = state_db_.getCanDelete();
|
||||
canDelete_ = state_db_.getCanDelete();
|
||||
|
||||
// will delete up to (not including) lastRotated)
|
||||
if (validatedSeq >= lastRotated + setup_.deleteInterval
|
||||
&& canDelete >= lastRotated - 1)
|
||||
&& canDelete_ >= lastRotated - 1)
|
||||
{
|
||||
journal_.debug << "rotating validatedSeq " << validatedSeq
|
||||
<< " lastRotated " << lastRotated << " deleteInterval "
|
||||
<< setup_.deleteInterval << " canDelete " << canDelete;
|
||||
<< setup_.deleteInterval << " canDelete_ " << canDelete_;
|
||||
|
||||
switch (health())
|
||||
{
|
||||
|
||||
@@ -85,7 +85,7 @@ private:
|
||||
NodeStore::Scheduler& scheduler_;
|
||||
beast::Journal journal_;
|
||||
beast::Journal nodeStoreJournal_;
|
||||
NodeStore::DatabaseRotating* database_;
|
||||
NodeStore::DatabaseRotating* database_ = nullptr;
|
||||
SavedStateDB state_db_;
|
||||
std::thread thread_;
|
||||
bool stop_ = false;
|
||||
@@ -95,6 +95,7 @@ private:
|
||||
Ledger::pointer newLedger_;
|
||||
Ledger::pointer validatedLedger_;
|
||||
TransactionMaster& transactionMaster_;
|
||||
std::atomic <LedgerIndex> canDelete_;
|
||||
// these do not exist upon SHAMapStore creation, but do exist
|
||||
// as of onPrepare() or before
|
||||
NetworkOPs* netOPs_ = nullptr;
|
||||
@@ -131,6 +132,7 @@ public:
|
||||
LedgerIndex
|
||||
setCanDelete (LedgerIndex seq) override
|
||||
{
|
||||
canDelete_ = seq;
|
||||
return state_db_.setCanDelete (seq);
|
||||
}
|
||||
|
||||
@@ -149,7 +151,7 @@ public:
|
||||
LedgerIndex
|
||||
getCanDelete() override
|
||||
{
|
||||
return state_db_.getCanDelete();
|
||||
return canDelete_;
|
||||
}
|
||||
|
||||
void onLedgerClosed (Ledger::pointer validatedLedger) override;
|
||||
|
||||
Reference in New Issue
Block a user