xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
include
xrpl
nodestore
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
13
namespace
xrpl
{
14
18
enum class
NodeObjectType
:
std::uint32_t
{
19
Unknown
= 0,
20
Ledger
= 1,
21
AccountNode
= 3,
22
TransactionNode
= 4,
23
Dummy
= 512
// an invalid or missing object
24
};
25
36
class
NodeObject
:
public
CountedObject
<NodeObject>
37
{
38
public
:
39
static
constexpr
std::size_t
kKeyBytes
= 32;
40
41
private
:
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.
45
struct
PrivateAccess
46
{
47
explicit
PrivateAccess
() =
default
;
48
};
49
50
public
:
51
// This constructor is private, use createObject instead.
52
NodeObject
(
NodeObjectType
type,
Blob
&& data,
UInt256
const
& hash,
PrivateAccess
);
53
66
static
std::shared_ptr<NodeObject>
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
87
private
:
88
NodeObjectType
const
type_
;
89
UInt256
const
hash_
;
90
Blob
const
data_
;
91
};
92
93
}
// namespace xrpl
xrpl::CountedObject< NodeObject >::CountedObject
CountedObject() noexcept
Definition
CountedObject.h:119
xrpl::Ledger
Holds a ledger.
Definition
include/xrpl/ledger/Ledger.h:76
xrpl::NodeObject::data_
Blob const data_
Definition
NodeObject.h:90
xrpl::NodeObject::NodeObject
NodeObject(NodeObjectType type, Blob &&data, UInt256 const &hash, PrivateAccess)
Definition
NodeObject.cpp:13
xrpl::NodeObject::kKeyBytes
static constexpr std::size_t kKeyBytes
Definition
NodeObject.h:39
xrpl::NodeObject::getHash
UInt256 const & getHash() const
Returns the hash of the data.
Definition
NodeObject.cpp:31
xrpl::NodeObject::hash_
UInt256 const hash_
Definition
NodeObject.h:89
xrpl::NodeObject::getType
NodeObjectType getType() const
Returns the type of this object.
Definition
NodeObject.cpp:25
xrpl::NodeObject::createObject
static std::shared_ptr< NodeObject > createObject(NodeObjectType type, Blob &&data, UInt256 const &hash)
Create an object from fields.
Definition
NodeObject.cpp:19
xrpl::NodeObject::type_
NodeObjectType const type_
Definition
NodeObject.h:88
xrpl::NodeObject::getData
Blob const & getData() const
Returns the underlying data.
Definition
NodeObject.cpp:37
cstddef
cstdint
std::uint32_t
memory
xrpl
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition
algorithm.h:5
xrpl::NodeObjectType
NodeObjectType
The types of node objects.
Definition
NodeObject.h:18
xrpl::NodeObjectType::Unknown
@ Unknown
Definition
NodeObject.h:19
xrpl::NodeObjectType::AccountNode
@ AccountNode
Definition
NodeObject.h:21
xrpl::NodeObjectType::Dummy
@ Dummy
Definition
NodeObject.h:23
xrpl::NodeObjectType::TransactionNode
@ TransactionNode
Definition
NodeObject.h:22
xrpl::UInt256
BaseUInt< 256 > UInt256
Definition
base_uint.h:580
xrpl::Blob
std::vector< unsigned char > Blob
Storage for linear binary data.
Definition
Blob.h:11
std::shared_ptr
std::size_t
xrpl::NodeObject::PrivateAccess
Definition
NodeObject.h:46
xrpl::NodeObject::PrivateAccess::PrivateAccess
PrivateAccess()=default
Generated by
1.17.0