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");
97 Throw<std::runtime_error>(
"Missing path in Memory backend");
112 open(
bool createIfMissing)
override
120 return static_cast<bool>(
db_);
139 Map::iterator iter =
db_->
table.find(hash);
145 *pObject = iter->second;
154 for (
auto const& h : hashes)
164 return {results,
ok};
172 db_->
table.emplace(object->getHash(),
object);
178 for (
auto const& e : batch)
239 return std::make_unique<MemoryBackend>(keyBytes, keyValues, 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.
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.
MemoryBackend(size_t keyBytes, Section const &keyValues, beast::Journal journal)
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.
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.
std::pair< std::vector< std::shared_ptr< NodeObject > >, Status > fetchBatch(std::vector< uint256 const * > const &hashes) override
Fetch a batch synchronously.
static Manager & instance()
Returns the instance of the manager singleton.
T & get(EitherAmount &amt)
A backend used for the NodeStore.