20 #include <ripple/app/main/Application.h>
21 #include <ripple/beast/hash/hash_append.h>
22 #include <ripple/core/ConfigSections.h>
23 #include <ripple/nodestore/Manager.h>
24 #include <ripple/nodestore/impl/DeterministicShard.h>
25 #include <ripple/nodestore/impl/Shard.h>
26 #include <ripple/protocol/digest.h>
28 #include <nudb/detail/format.hpp>
29 #include <nudb/nudb.hpp>
30 #include <openssl/ripemd.h>
37 boost::filesystem::path
const& dir,
43 , ctx_(
std::make_unique<nudb::context>())
47 app_.
getShardStore()->ledgersPerShard() <= 256 ? maxMemObjsTest
64 <<
" not created: " << msg;
73 <<
". Exception caught in function " << __func__
74 <<
". Error: " << e.
what();
80 return fail(
"shard store not exists");
82 if (index_ < db->earliestShardIndex())
83 return fail(
"Invalid shard index");
87 auto const type{
get(section,
"type",
"nudb")};
90 return fail(
"failed to find factory for " + type);
92 section.set(
"path",
dir_.string());
97 return fail(
"failed to create database");
100 h(finalKey.
data(), finalKey.
size());
104 auto digest = [&](
int n) {
105 auto const data{hash.data()};
113 for (
int i = 0; i < 8; i++)
114 result = (result << 8) + data[n * 8 + i];
128 auto const uid{
digest(0)};
129 auto const salt{
digest(1)};
138 backend_->open(
true, appType, uid, salt);
143 std::string(
". Exception caught in function ") + __func__ +
144 ". Error: " + e.
what());
153 boost::filesystem::path
const& shardDir,
160 if (!dShard->
init(finalKey))
185 <<
". Exception caught in function " << __func__
186 <<
". Error: " << e.
what();
207 <<
". Exception caught in function " << __func__
208 <<
". Error: " << e.
what();
Holds a collection of configuration values.
DeterministicShard(DeterministicShard const &)=delete
constexpr static std::uint64_t deterministicType
bool init(Serializer const &finalKey)
Initializes the deterministic shard.
std::shared_ptr< Backend > backend_
static std::string shardDatabase()
bool store(std::shared_ptr< NodeObject > const &nodeObject)
Store a node object in memory.
std::shared_ptr< DeterministicShard > make_DeterministicShard(Application &app, boost::filesystem::path const &shardDir, std::uint32_t shardIndex, Serializer const &finalKey, beast::Journal j)
Creates shared pointer to deterministic shard and initializes it.
virtual NodeStore::DatabaseShard * getShardStore()=0
std::unique_ptr< nudb::context > ctx_
const std::uint32_t index_
void const * data() const noexcept
static Hasher::result_type digest(void const *data, std::size_t size) noexcept
DeterministicShard class.
DummyScheduler scheduler_
std::uint32_t curMemObjs_
virtual Config & config()=0
A generic endpoint for log messages.
virtual Factory * find(std::string const &name)=0
Return a pointer to the matching factory if it exists.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::size_t size() const noexcept
static constexpr std::size_t keyBytes
const boost::filesystem::path dir_
static base_uint fromVoid(void const *data)
void close()
Finalizes and closes the shard.
const std::uint32_t maxMemObjs_
Message digest functions used in the codebase.
static Manager & instance()
Returns the instance of the manager singleton.
static NodeStore::Database & getShardStore(Application &app)
T & get(EitherAmount &amt)