rippled
Loading...
Searching...
No Matches
NodeObject.h
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2012, 2013 Ripple Labs Inc.
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#ifndef RIPPLE_NODESTORE_NODEOBJECT_H_INCLUDED
21#define RIPPLE_NODESTORE_NODEOBJECT_H_INCLUDED
22
23#include <xrpl/basics/Blob.h>
24#include <xrpl/basics/CountedObject.h>
25#include <xrpl/basics/base_uint.h>
26
27// VFALCO NOTE Intentionally not in the NodeStore namespace
28
29namespace ripple {
30
37 hotDUMMY = 512 // an invalid or missing object
38};
39
49class NodeObject : public CountedObject<NodeObject>
50{
51public:
52 static constexpr std::size_t keyBytes = 32;
53
54private:
55 // This hack is used to make the constructor effectively private
56 // except for when we use it in the call to make_shared.
57 // There's no portable way to make make_shared<> a friend work.
59 {
60 explicit PrivateAccess() = default;
61 };
62
63public:
64 // This constructor is private, use createObject instead.
66 NodeObjectType type,
67 Blob&& data,
68 uint256 const& hash,
70
83 createObject(NodeObjectType type, Blob&& data, uint256 const& hash);
84
87 getType() const;
88
90 uint256 const&
91 getHash() const;
92
94 Blob const&
95 getData() const;
96
97private:
100 Blob const mData;
101};
102
103} // namespace ripple
104
105#endif
Tracks the number of instances of an object.
A simple object that the Ledger uses to store entries.
Definition NodeObject.h:50
static constexpr std::size_t keyBytes
Definition NodeObject.h:52
uint256 const & getHash() const
Returns the hash of the data.
NodeObjectType const mType
Definition NodeObject.h:98
uint256 const mHash
Definition NodeObject.h:99
static std::shared_ptr< NodeObject > createObject(NodeObjectType type, Blob &&data, uint256 const &hash)
Create an object from fields.
Blob const & getData() const
Returns the underlying data.
NodeObjectType getType() const
Returns the type of this object.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25
NodeObjectType
The types of node objects.
Definition NodeObject.h:32
@ hotACCOUNT_NODE
Definition NodeObject.h:35
@ hotTRANSACTION_NODE
Definition NodeObject.h:36
@ hotUNKNOWN
Definition NodeObject.h:33
@ hotLEDGER
Definition NodeObject.h:34
@ hotDUMMY
Definition NodeObject.h:37