1#include <xrpl/basics/contract.h>
2#include <xrpl/nodestore/Factory.h>
3#include <xrpl/nodestore/Manager.h>
5#include <boost/beast/core/string.hpp>
6#include <boost/core/ignore_unused.hpp>
49 auto const result =
map_.emplace(
53 Throw<std::runtime_error>(
"already open");
87 Throw<std::runtime_error>(
"Missing path in Memory backend");
110 return static_cast<bool>(
db_);
125 db_,
"xrpl::NodeStore::MemoryBackend::fetch : non-null database");
130 Map::iterator iter =
db_->
table.find(hash);
136 *pObject = iter->second;
145 for (
auto const& h : hashes)
155 return {results,
ok};
162 db_,
"xrpl::NodeStore::MemoryBackend::store : non-null database");
164 db_->
table.emplace(object->getHash(),
object);
170 for (
auto const& e :
batch)
184 "xrpl::NodeStore::MemoryBackend::for_each : non-null database");
A generic endpoint for log messages.
A backend used for the NodeStore.
Base class for backend factories.
Singleton for managing NodeStore factories and back ends.
virtual void insert(Factory &factory)=0
Add a factory.
void setDeletePath() override
Remove contents on disk upon destruction.
void store(std::shared_ptr< NodeObject > const &object) override
Store a single object.
beast::Journal const journal_
void close() override
Close the backend.
Status fetch(void const *key, std::shared_ptr< NodeObject > *pObject) override
Fetch a single object.
~MemoryBackend() override
void open(bool) override
Open the backend.
std::pair< std::vector< std::shared_ptr< NodeObject > >, Status > fetchBatch(std::vector< uint256 const * > const &hashes) override
Fetch a batch synchronously.
int fdRequired() const override
Returns the number of file descriptors the backend expects to need.
bool isOpen() override
Returns true is the database is open.
std::string getName() override
Get the human-readable name of this backend.
void for_each(std::function< void(std::shared_ptr< NodeObject >)> f) override
Visit every object in the database This is usually called during import.
void storeBatch(Batch const &batch) override
Store a group of objects.
MemoryBackend(size_t keyBytes, Section const &keyValues, beast::Journal journal)
int getWriteLoad() override
Estimate the number of write operations pending.
std::string getName() const override
Retrieve the name of this factory.
MemoryDB & open(std::string const &path)
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.
std::map< std::string, MemoryDB, boost::beast::iless > map_
MemoryFactory(Manager &manager)
Scheduling for asynchronous backend activity.
Holds a collection of configuration values.
static base_uint fromVoid(void const *data)
Status
Return codes from Backend operations.
void registerMemoryFactory(Manager &manager)
MemoryFactory * memoryFactory
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