mirror of
https://github.com/XRPLF/rippled.git
synced 2026-07-30 10:30:22 +00:00
Co-authored-by: Marek Foss <marek.foss@neti-soft.com> Co-authored-by: Alex Kremer <akremer@ripple.com>
53 lines
1.2 KiB
C++
53 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include <xrpl/nodestore/NodeObject.h>
|
|
|
|
#include <memory>
|
|
|
|
namespace xrpl::node_store {
|
|
|
|
/**
|
|
* Parsed key/value blob into NodeObject components.
|
|
*
|
|
* This will extract the information required to construct a NodeObject. It
|
|
* also does consistency checking and returns the result, so it is possible
|
|
* to determine if the data is corrupted without throwing an exception. Not
|
|
* all forms of corruption are detected so further analysis will be needed
|
|
* to eliminate false negatives.
|
|
*
|
|
* @note This defines the database format of a NodeObject!
|
|
*/
|
|
class DecodedBlob
|
|
{
|
|
public:
|
|
/**
|
|
* Construct the decoded blob from raw data.
|
|
*/
|
|
DecodedBlob(void const* key, void const* value, int valueBytes);
|
|
|
|
/**
|
|
* Determine if the decoding was successful.
|
|
*/
|
|
[[nodiscard]] bool
|
|
wasOk() const noexcept
|
|
{
|
|
return success_;
|
|
}
|
|
|
|
/**
|
|
* Create a NodeObject from this data.
|
|
*/
|
|
std::shared_ptr<NodeObject>
|
|
createObject();
|
|
|
|
private:
|
|
bool success_{false};
|
|
|
|
void const* key_;
|
|
NodeObjectType objectType_{NodeObjectType::Unknown};
|
|
unsigned char const* objectData_{nullptr};
|
|
int dataBytes_;
|
|
};
|
|
|
|
} // namespace xrpl::node_store
|