rippled
Loading...
Searching...
No Matches
SHAMapAccountStateLeafNode.h
1#pragma once
2
3#include <xrpl/basics/CountedObject.h>
4#include <xrpl/protocol/HashPrefix.h>
5#include <xrpl/protocol/digest.h>
6#include <xrpl/shamap/SHAMapItem.h>
7#include <xrpl/shamap/SHAMapLeafNode.h>
8
9namespace xrpl {
10
13 public CountedObject<SHAMapAccountStateLeafNode>
14{
15public:
16 SHAMapAccountStateLeafNode(boost::intrusive_ptr<SHAMapItem const> item, std::uint32_t cowid)
17 : SHAMapLeafNode(std::move(item), cowid)
18 {
19 updateHash();
20 }
21
23 boost::intrusive_ptr<SHAMapItem const> item,
25 SHAMapHash const& hash)
26 : SHAMapLeafNode(std::move(item), cowid, hash)
27 {
28 }
29
31 clone(std::uint32_t cowid) const final override
32 {
33 return intr_ptr::make_shared<SHAMapAccountStateLeafNode>(item_, cowid, hash_);
34 }
35
37 getType() const final override
38 {
40 }
41
42 void
43 updateHash() final override
44 {
46 }
47
48 void
49 serializeForWire(Serializer& s) const final override
50 {
51 s.addRaw(item_->slice());
52 s.addBitString(item_->key());
54 }
55
56 void
57 serializeWithPrefix(Serializer& s) const final override
58 {
59 s.add32(HashPrefix::leafNode);
60 s.addRaw(item_->slice());
61 s.addBitString(item_->key());
62 }
63};
64
65} // namespace xrpl
Tracks the number of instances of an object.
A leaf node for a state object.
intr_ptr::SharedPtr< SHAMapTreeNode > clone(std::uint32_t cowid) const final override
Make a copy of this node, setting the owner.
void updateHash() final override
Recalculate the hash of this node.
SHAMapAccountStateLeafNode(boost::intrusive_ptr< SHAMapItem const > item, std::uint32_t cowid, SHAMapHash const &hash)
SHAMapNodeType getType() const final override
Determines the type of node.
SHAMapAccountStateLeafNode(boost::intrusive_ptr< SHAMapItem const > item, std::uint32_t cowid)
void serializeForWire(Serializer &s) const final override
Serialize the node in a format appropriate for sending over the wire.
void serializeWithPrefix(Serializer &s) const final override
Serialize the node in a format appropriate for hashing.
boost::intrusive_ptr< SHAMapItem const > item_
A shared intrusive pointer class that supports weak pointers.
std::uint32_t cowid() const
Returns the SHAMap that owns this node.
STL namespace.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
sha512_half_hasher::result_type sha512Half(Args const &... args)
Returns the SHA512-Half of a series of objects.
Definition digest.h:204
static constexpr unsigned char const wireTypeAccountState
@ leafNode
account state