xrpld
Loading...
Searching...
No Matches
NodeObject.h
1#pragma once
2
3#include <xrpl/basics/Blob.h>
4#include <xrpl/basics/CountedObject.h>
5#include <xrpl/basics/base_uint.h>
6
7#include <cstddef>
8#include <cstdint>
9#include <memory>
10
11// VFALCO NOTE Intentionally not in the node_store namespace
12
13namespace xrpl {
14
20 Ledger = 1,
23 Dummy = 512 // an invalid or missing object
24};
25
36class NodeObject : public CountedObject<NodeObject>
37{
38public:
39 static constexpr std::size_t kKeyBytes = 32;
40
41private:
42 // This hack is used to make the constructor effectively private
43 // except for when we use it in the call to make_shared.
44 // There's no portable way to make make_shared<> a friend work.
46 {
47 explicit PrivateAccess() = default;
48 };
49
50public:
51 // This constructor is private, use createObject instead.
52 NodeObject(NodeObjectType type, Blob&& data, uint256 const& hash, PrivateAccess);
53
67 createObject(NodeObjectType type, Blob&& data, uint256 const& hash);
68
72 [[nodiscard]] NodeObjectType
73 getType() const;
74
78 [[nodiscard]] uint256 const&
79 getHash() const;
80
84 [[nodiscard]] Blob const&
85 getData() const;
86
87private:
90 Blob const data_;
91};
92
93} // namespace xrpl
uint256 const hash_
Definition NodeObject.h:89
Blob const data_
Definition NodeObject.h:90
static constexpr std::size_t kKeyBytes
Definition NodeObject.h:39
NodeObject(NodeObjectType type, Blob &&data, uint256 const &hash, PrivateAccess)
NodeObjectType getType() const
Returns the type of this object.
static std::shared_ptr< NodeObject > createObject(NodeObjectType type, Blob &&data, uint256 const &hash)
Create an object from fields.
NodeObjectType const type_
Definition NodeObject.h:88
uint256 const & getHash() const
Returns the hash of the data.
Blob const & getData() const
Returns the underlying data.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
NodeObjectType
The types of node objects.
Definition NodeObject.h:18
std::vector< unsigned char > Blob
Storage for linear binary data.
Definition Blob.h:11
BaseUInt< 256 > uint256
Definition base_uint.h:580