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::NodeStore::MemoryBackend::fetch : non-null database");
139 Map::iterator
const iter =
db_->table.find(hash);
140 if (iter ==
db_->table.end())
145 *pObject = iter->second;
152 XRPL_ASSERT(
db_,
"xrpl::NodeStore::MemoryBackend::store : non-null database");
154 db_->table.emplace(object->getHash(),
object);
160 for (
auto const& e : batch)
172 XRPL_ASSERT(
db_,
"xrpl::NodeStore::MemoryBackend::forEach : non-null database");
173 for (
auto const& e :
db_->table)
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.
void setDeletePath() override
Remove contents on disk upon destruction.
void store(std::shared_ptr< NodeObject > const &object) override
Store a single object.
std::map< uint256 const, std::shared_ptr< NodeObject > > Map
Status fetch(uint256 const &hash, std::shared_ptr< NodeObject > *pObject) override
Fetch a single object.
beast::Journal const journal_
void close() override
Close the backend.
~MemoryBackend() override
void open(bool) override
Open the backend.
int fdRequired() const override
Returns the number of file descriptors the backend expects to need.
void forEach(std::function< void(std::shared_ptr< NodeObject >)> f) override
Visit every object in the database This is usually called during import.
bool isOpen() override
Returns true is the database is open.
std::string getName() override
Get the human-readable name of this backend.
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.
MemoryFactory * gMemoryFactory
Status
Return codes from Backend operations.
void registerMemoryFactory(Manager &manager)
std::vector< std::shared_ptr< NodeObject > > Batch
A batch of NodeObjects to write at once.
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