rippled
Loading...
Searching...
No Matches
Condition.h
1#pragma once
2
3#include <xrpl/basics/Buffer.h>
4#include <xrpl/basics/Slice.h>
5#include <xrpl/conditions/detail/utils.h>
6
7#include <cstdint>
8#include <set>
9
10namespace xrpl {
11namespace cryptoconditions {
12
13enum class Type : std::uint8_t {
15 prefixSha256 = 1,
17 rsaSha256 = 3,
19};
20
22{
23public:
31 static constexpr std::size_t maxSerializedCondition = 128;
32
45
46public:
48
55
58
61
63 {
64 }
65
66 Condition(Type t, std::uint32_t c, Buffer&& fp) : type(t), fingerprint(std::move(fp)), cost(c)
67 {
68 }
69
70 ~Condition() = default;
71
72 Condition(Condition const&) = default;
73 Condition(Condition&&) = default;
74
75 Condition() = delete;
76};
77
78inline bool
79operator==(Condition const& lhs, Condition const& rhs)
80{
81 return lhs.type == rhs.type && lhs.cost == rhs.cost && lhs.subtypes == rhs.subtypes &&
82 lhs.fingerprint == rhs.fingerprint;
83}
84
85inline bool
86operator!=(Condition const& lhs, Condition const& rhs)
87{
88 return !(lhs == rhs);
89}
90
91} // namespace cryptoconditions
92
93} // namespace xrpl
Like std::vector<char> but better.
Definition Buffer.h:16
An immutable linear range of bytes.
Definition Slice.h:26
Buffer fingerprint
An identifier for this condition.
Definition Condition.h:54
static constexpr std::size_t maxSerializedCondition
The largest binary condition we support.
Definition Condition.h:31
std::set< Type > subtypes
For compound conditions, set of conditions includes.
Definition Condition.h:60
Condition(Condition &&)=default
Condition(Type t, std::uint32_t c, Buffer &&fp)
Definition Condition.h:66
std::uint32_t cost
The cost associated with this condition.
Definition Condition.h:57
Condition(Type t, std::uint32_t c, Slice fp)
Definition Condition.h:62
static std::unique_ptr< Condition > deserialize(Slice s, std::error_code &ec)
Load a condition from its binary form.
Condition(Condition const &)=default
STL namespace.
bool operator!=(Condition const &lhs, Condition const &rhs)
Definition Condition.h:86
bool operator==(Condition const &lhs, Condition const &rhs)
Definition Condition.h:79
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5