rippled
Loading...
Searching...
No Matches
SHAMapAccountStateLeafNode.h
1#ifndef XRPL_SHAMAP_SHAMAPACCOUNTSTATELEAFNODE_H_INCLUDED
2#define XRPL_SHAMAP_SHAMAPACCOUNTSTATELEAFNODE_H_INCLUDED
3
4#include <xrpl/basics/CountedObject.h>
5#include <xrpl/protocol/HashPrefix.h>
6#include <xrpl/protocol/digest.h>
7#include <xrpl/shamap/SHAMapItem.h>
8#include <xrpl/shamap/SHAMapLeafNode.h>
9
10namespace ripple {
11
14 : public SHAMapLeafNode,
15 public CountedObject<SHAMapAccountStateLeafNode>
16{
17public:
19 boost::intrusive_ptr<SHAMapItem const> item,
21 : SHAMapLeafNode(std::move(item), cowid)
22 {
23 updateHash();
24 }
25
27 boost::intrusive_ptr<SHAMapItem const> item,
29 SHAMapHash const& hash)
30 : SHAMapLeafNode(std::move(item), cowid, hash)
31 {
32 }
33
35 clone(std::uint32_t cowid) const final override
36 {
37 return intr_ptr::make_shared<SHAMapAccountStateLeafNode>(
38 item_, cowid, hash_);
39 }
40
42 getType() const final override
43 {
45 }
46
47 void
48 updateHash() final override
49 {
51 sha512Half(HashPrefix::leafNode, item_->slice(), item_->key())};
52 }
53
54 void
55 serializeForWire(Serializer& s) const final override
56 {
57 s.addRaw(item_->slice());
58 s.addBitString(item_->key());
60 }
61
62 void
63 serializeWithPrefix(Serializer& s) const final override
64 {
65 s.add32(HashPrefix::leafNode);
66 s.addRaw(item_->slice());
67 s.addBitString(item_->key());
68 }
69};
70
71} // namespace ripple
72
73#endif
Tracks the number of instances of an object.
SHAMapAccountStateLeafNode(boost::intrusive_ptr< SHAMapItem const > item, std::uint32_t cowid)
SHAMapAccountStateLeafNode(boost::intrusive_ptr< SHAMapItem const > item, std::uint32_t cowid, SHAMapHash const &hash)
void serializeForWire(Serializer &s) const final override
Serialize the node in a format appropriate for sending over the wire.
SHAMapNodeType getType() const final override
Determines the type of node.
void updateHash() final override
Recalculate the hash of this node.
void serializeWithPrefix(Serializer &s) const final override
Serialize the node in a format appropriate for hashing.
intr_ptr::SharedPtr< SHAMapTreeNode > clone(std::uint32_t cowid) const final override
Make a copy of this node, setting the owner.
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.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
static constexpr unsigned char const wireTypeAccountState
@ leafNode
account state
sha512_half_hasher::result_type sha512Half(Args const &... args)
Returns the SHA512-Half of a series of objects.
Definition digest.h:205
STL namespace.