1#ifndef XRPL_NODESTORE_BASE_H_INCLUDED 
    2#define XRPL_NODESTORE_BASE_H_INCLUDED 
    4#include <xrpl/basics/StringUtilities.h> 
    5#include <xrpl/basics/random.h> 
    6#include <xrpl/beast/unit_test.h> 
    7#include <xrpl/beast/utility/rngfill.h> 
    8#include <xrpl/beast/xor_shift_engine.h> 
    9#include <xrpl/nodestore/Backend.h> 
   10#include <xrpl/nodestore/Database.h> 
   11#include <xrpl/nodestore/Types.h> 
   13#include <boost/algorithm/string.hpp> 
   34        return lhs->getHash() < rhs->getHash();
 
 
 
   44    return (lhs->getType() == rhs->getType()) &&
 
   45        (lhs->getHash() == rhs->getHash()) &&
 
   46        (lhs->getData() == rhs->getData());
 
 
   70        for (
int i = 0; i < numObjects; ++i)
 
 
  109            for (
int i = 0; i < lhs.
size(); ++i)
 
  111                if (!
isSame(lhs[i], rhs[i]))
 
 
  130        for (
int i = 0; i < 
batch.size(); ++i)
 
 
  143        for (
int i = 0; i < 
batch.size(); ++i)
 
  148                backend.
fetch(
batch[i]->getHash().cbegin(), &
object);
 
  150            BEAST_EXPECT(status == 
ok);
 
  154                BEAST_EXPECT(
object != 
nullptr);
 
 
  164        for (
int i = 0; i < 
batch.size(); ++i)
 
  169                backend.
fetch(
batch[i]->getHash().cbegin(), &
object);
 
 
  179        for (
int i = 0; i < 
batch.size(); ++i)
 
  183            Blob data(object->getData());
 
 
  200        for (
int i = 0; i < 
batch.size(); ++i)
 
  205            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 *const buffer, std::size_t const 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