20#include <xrpld/nodestore/Factory.h>
21#include <xrpld/nodestore/Manager.h>
23#include <xrpl/basics/contract.h>
25#include <boost/beast/core/string.hpp>
26#include <boost/core/ignore_unused.hpp>
69 auto const result =
map_.emplace(
73 Throw<std::runtime_error>(
"already open");
100 Throw<std::runtime_error>(
"Missing path in Memory backend");
115 open(
bool createIfMissing)
override
123 return static_cast<bool>(
db_);
138 db_,
"ripple::NodeStore::MemoryBackend::fetch : non-null database");
143 Map::iterator iter =
db_->
table.find(hash);
149 *pObject = iter->second;
158 for (
auto const& h : hashes)
168 return {results,
ok};
175 db_,
"ripple::NodeStore::MemoryBackend::store : non-null database");
177 db_->
table.emplace(object->getHash(),
object);
183 for (
auto const& e :
batch)
197 "ripple::NodeStore::MemoryBackend::for_each : non-null database");
A generic endpoint for log messages.
A backend used for the NodeStore.
Base class for backend factories.
static Manager & instance()
Returns the instance of the manager singleton.
virtual void erase(Factory &factory)=0
Remove a factory.
virtual void insert(Factory &factory)=0
Add a factory.
void close() override
Close the backend.
void store(std::shared_ptr< NodeObject > const &object) override
Store a single object.
void open(bool createIfMissing) override
Open the backend.
std::string getName() override
Get the human-readable name of this backend.
~MemoryBackend() override
std::pair< std::vector< std::shared_ptr< NodeObject > >, Status > fetchBatch(std::vector< uint256 const * > const &hashes) override
Fetch a batch synchronously.
MemoryBackend(size_t keyBytes, Section const &keyValues, beast::Journal journal)
void for_each(std::function< void(std::shared_ptr< NodeObject >)> f) override
Visit every object in the database This is usually called during import.
int getWriteLoad() override
Estimate the number of write operations pending.
void storeBatch(Batch const &batch) override
Store a group of objects.
void setDeletePath() override
Remove contents on disk upon destruction.
int fdRequired() const override
Returns the number of file descriptors the backend expects to need.
Status fetch(void const *key, std::shared_ptr< NodeObject > *pObject) override
Fetch a single object.
bool isOpen() override
Returns true is the database is open.
beast::Journal const journal_
std::string getName() const override
Retrieve the name of this factory.
std::map< std::string, MemoryDB, boost::beast::iless > map_
~MemoryFactory() override
std::unique_ptr< Backend > createInstance(size_t keyBytes, Section const &keyValues, std::size_t burstSize, Scheduler &scheduler, beast::Journal journal) override
Create an instance of this factory's backend.
MemoryDB & open(std::string const &path)
Scheduling for asynchronous backend activity.
Holds a collection of configuration values.
static base_uint fromVoid(void const *data)
static MemoryFactory memoryFactory
Status
Return codes from Backend operations.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
T get(Section const §ion, std::string const &name, T const &defaultValue=T{})
Retrieve a key/value pair from a section.
std::map< uint256 const, std::shared_ptr< NodeObject > > table