20#ifndef RIPPLE_NODESTORE_BASE_H_INCLUDED
21#define RIPPLE_NODESTORE_BASE_H_INCLUDED
23#include <xrpld/nodestore/Backend.h>
24#include <xrpld/nodestore/Database.h>
25#include <xrpld/nodestore/Types.h>
27#include <xrpl/basics/StringUtilities.h>
28#include <xrpl/basics/random.h>
29#include <xrpl/beast/unit_test.h>
30#include <xrpl/beast/utility/rngfill.h>
31#include <xrpl/beast/xor_shift_engine.h>
33#include <boost/algorithm/string.hpp>
54 return lhs->getHash() < rhs->getHash();
64 return (lhs->getType() == rhs->getType()) &&
65 (lhs->getHash() == rhs->getHash()) &&
66 (lhs->getData() == rhs->getData());
90 for (
int i = 0; i < numObjects; ++i)
129 for (
int i = 0; i < lhs.
size(); ++i)
131 if (!
isSame(lhs[i], rhs[i]))
150 for (
int i = 0; i < batch.
size(); ++i)
152 backend.
store(batch[i]);
163 for (
int i = 0; i < batch.
size(); ++i)
168 backend.
fetch(batch[i]->getHash().cbegin(), &
object);
170 BEAST_EXPECT(status ==
ok);
174 BEAST_EXPECT(
object !=
nullptr);
184 for (
int i = 0; i < batch.
size(); ++i)
189 backend.
fetch(batch[i]->getHash().cbegin(), &
object);
199 for (
int i = 0; i < batch.
size(); ++i)
203 Blob data(object->getData());
220 for (
int i = 0; i < batch.
size(); ++i)
225 if (
object !=
nullptr)
static std::shared_ptr< NodeObject > createObject(NodeObjectType type, Blob &&data, uint256 const &hash)
Create an object from fields.
A backend used for the NodeStore.
virtual Status fetch(void const *key, std::shared_ptr< NodeObject > *pObject)=0
Fetch a single object.
virtual void store(std::shared_ptr< NodeObject > const &object)=0
Store a single object.
Persistency layer for NodeObject.
std::shared_ptr< NodeObject > fetchNodeObject(uint256 const &hash, std::uint32_t ledgerSeq=0, FetchType fetchType=FetchType::synchronous, bool duplicate=false)
Fetch a node object.
virtual void store(NodeObjectType type, Blob &&data, uint256 const &hash, std::uint32_t ledgerSeq)=0
Store the object.
std::uint32_t earliestLedgerSeq() const noexcept
static int const numObjectsToTest
static Batch createPredictableBatch(int numObjects, std::uint64_t seed)
static bool areBatchesEqual(Batch const &lhs, Batch const &rhs)
static void fetchCopyOfBatch(Database &db, Batch *pCopy, Batch const &batch)
static void storeBatch(Database &db, Batch const &batch)
void fetchCopyOfBatch(Backend &backend, Batch *pCopy, Batch const &batch)
static std::size_t const maxPayloadBytes
void storeBatch(Backend &backend, Batch const &batch)
static std::size_t const minPayloadBytes
void fetchMissing(Backend &backend, Batch const &batch)
static constexpr std::size_t size()
void rngfill(void *buffer, std::size_t bytes, Generator &g)
bool isSame(std::shared_ptr< NodeObject > const &lhs, std::shared_ptr< NodeObject > const &rhs)
Returns true if objects are identical.
Status
Return codes from Backend operations.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::enable_if_t< std::is_integral< Integral >::value, Integral > rand_int()
NodeObjectType
The types of node objects.
Binary function that satisfies the strict-weak-ordering requirement.
bool operator()(std::shared_ptr< NodeObject > const &lhs, std::shared_ptr< NodeObject > const &rhs) const noexcept