Skip to content

Commit

Permalink
Review fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
mtrippled committed Apr 28, 2020
1 parent 2fafd54 commit 93f6198
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 37 deletions.
4 changes: 2 additions & 2 deletions src/ripple/app/ledger/impl/LedgerMaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
#include <cassert>
#include <limits>
#include <memory>
#include <optional>
#include <vector>

namespace ripple {
Expand Down Expand Up @@ -153,7 +152,7 @@ shouldAcquire (
std::uint32_t const candidateLedger,
beast::Journal j)
{
bool ret = [&]()
bool const ret = [&]()
{
// Fetch ledger if it may be the current ledger
if (candidateLedger >= currentLedger)
Expand All @@ -164,6 +163,7 @@ shouldAcquire (
return true;

// Or if greater than or equal to a specific minimum ledger.
// Do nothing if the minimum ledger to keep online is unknown.
return minimumOnline.has_value() && candidateLedger >= *minimumOnline;
}();

Expand Down
64 changes: 30 additions & 34 deletions src/ripple/app/misc/SHAMapStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include <ripple/protocol/ErrorCodes.h>
#include <ripple/core/Stoppable.h>
#include <boost/optional.hpp>
#include <atomic>

namespace ripple {

Expand Down Expand Up @@ -69,39 +68,36 @@ class SHAMapStore
/** Returns the number of file descriptors that are needed. */
virtual int fdRequired() const = 0;

/** If online deletion is enabled, return the minimum ledger
* to keep online, which is the lower bound for attempting to acquire
* historical ledgers over the peer to peer network.
* If online_delete is not enabled, then the minimum value to
* keep online is the minimum ledger that has been persisted already.
*
* With online_delete,this value is governed by the
* following circumstances:
*
* Upon process startup:
*
* With advisory_delete enabled and online_delete having been executed
* previously:
* Upon process startup, this value is set to one past the value
* that is allowed to be deleted. In other words, anything greater
* than what can be deleted should be acquired from the network and
* then retained. If nothing has yet been deleted, then do not
* rely upon the value of what is allowed to be deleted because it
* could cause fetching of more history than configured by
* ledger_history.
*
* Without advisory_delete or if online_delete has never executed:
* Upon process startup, this value is set to the earliest ledger
* that has been persisted in SQLite.
*
* Each time online_delete executes:
*
* Just prior to clearing SQL databases of historical ledgers, move
* the value forward to one past the greatest ledger being deleted.
* This minimizes fetching of ledgers that are in the process of being
* deleted.
*/
virtual boost::optional<LedgerIndex> minimumOnline() const = 0;
/** The minimum ledger to try and maintain in our database.
This defines the lower bound for attempting to acquire historical
ledgers over the peer to peer network.
With online_delete,this value is governed by the following
circumstances:
- With advisory_delete enabled and online_delete having been executed
previously, this value is set to one past the value that is allowed to
be deleted. In other words, anything greater than what can be deleted
should be acquired from the network and then retained. If nothing has
yet been deleted, then do not rely upon the value of what is allowed
to be deleted because it could cause fetching of more history than
configured by ledger_history.
- Without advisory_delete or if online_delete has never executed, this
value is set to the earliest ledger that has been persisted in the
SQL database.
Each time online_delete executes, just prior to clearing SQL databases
of historical ledgers, move the value forward to one past the greatest
ledger being deleted. This minimizes fetching of ledgers that are in
the process of being deleted.
@return If online deletion is enabled and if it has been executed,
the minimum ledger to keep available; an unseated
optional otherwise.
*/
virtual boost::optional<LedgerIndex> minimumOnline() const = 0;
};

//------------------------------------------------------------------------------
Expand Down
4 changes: 3 additions & 1 deletion src/ripple/app/misc/SHAMapStoreImp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,9 @@ SHAMapStoreImp::onChildrenStopped()
boost::optional<LedgerIndex>
SHAMapStoreImp::minimumOnline() const
{
if (deleteInterval_)
// minimumOnline_ with 0 value is equivalent to unknown/not set.
// Don't attempt to acquire ledgers if that value is unknown.
if (deleteInterval_ && minimumOnline_)
return minimumOnline_.load();
return app_.getLedgerMaster().minSqlSeq();
}
Expand Down
1 change: 1 addition & 0 deletions src/ripple/app/misc/SHAMapStoreImp.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <ripple/app/ledger/LedgerMaster.h>
#include <ripple/core/DatabaseCon.h>
#include <ripple/nodestore/DatabaseRotating.h>
#include <atomic>
#include <condition_variable>
#include <thread>

Expand Down

0 comments on commit 93f6198

Please sign in to comment.