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// VFALCO NOTE Intentionally not in the NodeStore namespace
8
9namespace xrpl {
10
14 Ledger = 1,
17 Dummy = 512 // an invalid or missing object
18};
19
29class NodeObject : public CountedObject<NodeObject>
30{
31public:
32 static constexpr std::size_t kKeyBytes = 32;
33
34private:
35 // This hack is used to make the constructor effectively private
36 // except for when we use it in the call to make_shared.
37 // There's no portable way to make make_shared<> a friend work.
39 {
40 explicit PrivateAccess() = default;
41 };
42
43public:
44 // This constructor is private, use createObject instead.
45 NodeObject(NodeObjectType type, Blob&& data, uint256 const& hash, PrivateAccess);
46
59 createObject(NodeObjectType type, Blob&& data, uint256 const& hash);
60
62 [[nodiscard]] NodeObjectType
63 getType() const;
64
66 [[nodiscard]] uint256 const&
67 getHash() const;
68
70 [[nodiscard]] Blob const&
71 getData() const;
72
73private:
76 Blob const data_;
77};
78
79} // namespace xrpl
uint256 const hash_
Definition NodeObject.h:75
Blob const data_
Definition NodeObject.h:76
static constexpr std::size_t kKeyBytes
Definition NodeObject.h:32
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:74
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:12
std::vector< unsigned char > Blob
Storage for linear binary data.
Definition Blob.h:10
BaseUInt< 256 > uint256
Definition base_uint.h:562