20 #include <ripple/basics/contract.h>
21 #include <ripple/nodestore/Factory.h>
22 #include <ripple/nodestore/Manager.h>
23 #include <boost/beast/core/string.hpp>
24 #include <boost/core/ignore_unused.hpp>
66 auto const result =
map_.emplace(
70 Throw<std::runtime_error>(
"already open");
98 Throw<std::runtime_error>(
"Missing path in Memory backend");
113 open(
bool createIfMissing)
override
121 return static_cast<bool>(
db_);
140 Map::iterator iter =
db_->
table.find(hash);
146 *pObject = iter->second;
159 Throw<std::runtime_error>(
"pure virtual called");
168 db_->
table.emplace(object->getHash(),
object);
174 for (
auto const& e : batch)
235 return std::make_unique<MemoryBackend>(
236 keyBytes, keyValues, scheduler, journal);
Holds a collection of configuration values.
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.
Base class for backend factories.
bool isOpen() override
Returns true is the database is open.
std::vector< std::shared_ptr< NodeObject > > fetchBatch(std::size_t n, void const *const *keys) override
Fetch a batch synchronously.
int fdRequired() const override
Returns the number of file descriptors the backend expects to need.
virtual void erase(Factory &factory)=0
Remove a factory.
~MemoryBackend() override
std::string getName() const override
Retrieve the name of this factory.
void setDeletePath() override
Remove contents on disk upon destruction.
std::string getName() override
Get the human-readable name of this backend.
Status fetch(void const *key, std::shared_ptr< NodeObject > *pObject) override
Fetch a single object.
void store(std::shared_ptr< NodeObject > const &object) override
Store a single object.
~MemoryFactory() override
std::map< std::string, MemoryDB, boost::beast::iless > map_
void close() override
Close the backend.
virtual void insert(Factory &factory)=0
Add a factory.
MemoryBackend(size_t keyBytes, Section const &keyValues, Scheduler &scheduler, beast::Journal journal)
MemoryDB & open(std::string const &path)
std::map< uint256 const, std::shared_ptr< NodeObject > > table
int getWriteLoad() override
Estimate the number of write operations pending.
A generic endpoint for log messages.
Scheduling for asynchronous backend activity.
void storeBatch(Batch const &batch) override
Store a group of objects.
Status
Return codes from Backend operations.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
const 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.
static base_uint fromVoid(void const *data)
static MemoryFactory memoryFactory
void open(bool createIfMissing) override
Open the backend.
void verify() override
Perform consistency checks on database.
bool canFetchBatch() override
Return true if batch fetches are optimized.
static Manager & instance()
Returns the instance of the manager singleton.
T & get(EitherAmount &amt)
A backend used for the NodeStore.