1#include <xrpl/basics/base_uint.h>
2#include <xrpl/basics/contract.h>
3#include <xrpl/beast/utility/Journal.h>
4#include <xrpl/beast/utility/instrumentation.h>
5#include <xrpl/config/BasicConfig.h>
6#include <xrpl/config/Constants.h>
7#include <xrpl/nodestore/Backend.h>
8#include <xrpl/nodestore/Factory.h>
9#include <xrpl/nodestore/Manager.h>
10#include <xrpl/nodestore/NodeObject.h>
11#include <xrpl/nodestore/Scheduler.h>
12#include <xrpl/nodestore/Types.h>
14#include <boost/beast/core/string.hpp>
15#include <boost/core/ignore_unused.hpp>
121 return static_cast<bool>(
db_);
135 XRPL_ASSERT(
db_,
"xrpl::node_store::MemoryBackend::fetch : non-null database");
139 auto const iter =
db_->table.find(hash);
140 if (iter ==
db_->table.end())
145 *pObject = iter->second;
152 XRPL_ASSERT(
db_,
"xrpl::node_store::MemoryBackend::store : non-null database");
154 db_->table.emplace(object->getHash(),
object);
160 for (
auto const& e : batch)
172 XRPL_ASSERT(
db_,
"xrpl::node_store::MemoryBackend::forEach : non-null database");
173 for (
auto const& e :
db_->table)
A generic endpoint for log messages.
Holds a collection of configuration values.
A backend used for the NodeStore.
Base class for backend factories.
Singleton for managing NodeStore factories and back ends.
void open(bool) override
Open the backend.
bool isOpen() override
Returns true is the database is open.
int fdRequired() const override
Returns the number of file descriptors the backend expects to need.
std::map< uint256 const, std::shared_ptr< NodeObject > > Map
void storeBatch(Batch const &batch) override
Store a group of objects.
void close() override
Close the backend.
int getWriteLoad() override
Estimate the number of write operations pending.
std::string getName() override
Get the human-readable name of this backend.
void store(std::shared_ptr< NodeObject > const &object) override
Store a single object.
void forEach(std::function< void(std::shared_ptr< NodeObject >)> f) override
Visit every object in the database This is usually called during import.
~MemoryBackend() override
Status fetch(uint256 const &hash, std::shared_ptr< NodeObject > *pObject) override
Fetch a single object.
beast::Journal const journal_
MemoryBackend(size_t keyBytes, Section const &keyValues, beast::Journal journal)
void setDeletePath() override
Remove contents on disk upon destruction.
MemoryDB & open(std::string const &path)
std::string getName() const override
Retrieve the name of this factory.
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.
MemoryFactory * gMemoryFactory
void registerMemoryFactory(Manager &manager)
std::vector< std::shared_ptr< NodeObject > > Batch
A batch of NodeObjects to write at once.
Status
Return codes from Backend operations.
T get(Section const §ion, std::string const &name, T const &defaultValue=T{})
Retrieve a key/value pair from a section.
XRPL_NO_SANITIZE_ADDRESS void Throw(Args &&... args)
std::map< uint256 const, std::shared_ptr< NodeObject > > table