20 #ifndef RIPPLE_NODESTORE_SHARD_H_INCLUDED
21 #define RIPPLE_NODESTORE_SHARD_H_INCLUDED
23 #include <ripple/app/ledger/Ledger.h>
24 #include <ripple/basics/BasicConfig.h>
25 #include <ripple/basics/RangeSet.h>
26 #include <ripple/core/DatabaseCon.h>
27 #include <ripple/nodestore/NodeObject.h>
28 #include <ripple/nodestore/Scheduler.h>
30 #include <boost/filesystem.hpp>
31 #include <nudb/nudb.hpp>
65 boost::optional<std::uint32_t>
83 boost::filesystem::path
const&
134 bool const writeSQLite,
135 boost::optional<uint256>
const& referenceHash);
193 boost::filesystem::path
const dir_;
std::shared_ptr< Backend > getBackend() const
const boost::filesystem::path dir_
std::unique_ptr< DatabaseCon > lgrSQLiteDB_
std::atomic< bool > removeOnDestroy_
void setBackendCache(std::lock_guard< std::recursive_mutex > const &lock)
bool valLedger(std::shared_ptr< Ledger const > const &ledger, std::shared_ptr< Ledger const > const &next) const
bool store(std::shared_ptr< Ledger const > const &ledger)
boost::filesystem::path const & getDir() const
bool initSQLite(std::lock_guard< std::recursive_mutex > const &lock)
static const uint256 finalKey
const std::uint32_t lastSeq_
RangeSet< std::uint32_t > storedSeqs
void removeOnDestroy()
If called, the shard directory will be removed when the shard is destroyed.
bool isLegacy() const
Returns true if the shard is older, without final key data.
static constexpr std::uint32_t version
std::shared_ptr< PCache > pCache() const
bool finalize(bool const writeSQLite, boost::optional< uint256 > const &referenceHash)
Finalize shard by walking its ledgers and verifying each Merkle tree.
std::shared_ptr< NodeObject > valFetch(uint256 const &hash) const
A collection of historical shards.
std::shared_ptr< NCache > nCache_
std::shared_ptr< Backend > backend_
const std::uint32_t firstSeq_
std::shared_ptr< PCache > pCache_
bool isFinal() const
Returns true if the shard is complete, validated, and immutable.
std::unique_ptr< DatabaseCon > SQLiteDB
const std::uint32_t maxLedgers_
A generic endpoint for log messages.
Scheduling for asynchronous backend activity.
std::unique_ptr< AcquireInfo > acquireInfo_
bool isBackendComplete() const
Returns true if all shard ledgers have been stored in the backend.
std::recursive_mutex mutex_
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
boost::optional< std::uint32_t > prepare()
Shard(Application &app, DatabaseShard const &db, std::uint32_t index, beast::Journal j)
void setFileStats(std::lock_guard< std::recursive_mutex > const &lock)
std::uint32_t fdRequired_
std::uint32_t index() const
std::pair< std::uint64_t, std::uint32_t > fileInfo() const
Returns a pair where the first item describes the storage space utilized and the second item is the n...
boost::icl::interval_set< T, std::less, ClosedInterval< T > > RangeSet
A set of closed intervals over the domain T.
bool open(Scheduler &scheduler, nudb::context &ctx)
Maintains a cache of keys with no associated data.
std::unique_ptr< DatabaseCon > txSQLiteDB_
bool containsLedger(std::uint32_t seq) const
const std::uint32_t index_
std::atomic< bool > stop_
std::shared_ptr< NCache > nCache() const
std::tuple< std::shared_ptr< Backend >, std::shared_ptr< PCache >, std::shared_ptr< NCache > > getBackendAll() const
bool storeSQLite(std::shared_ptr< Ledger const > const &ledger, std::lock_guard< std::recursive_mutex > const &lock)