Speed up access to ledger index value that can be deleted.

This commit is contained in:
Mark Travis
2015-01-21 19:07:50 -08:00
committed by Nik Bougalis
parent f3c1f63444
commit 9430f3665b
2 changed files with 9 additions and 7 deletions

View File

@@ -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())
{

View File

@@ -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;