xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
include
xrpl
conditions
Fulfillment.h
1
#pragma once
2
3
#include <xrpl/basics/Buffer.h>
4
#include <xrpl/basics/Slice.h>
5
#include <xrpl/conditions/Condition.h>
6
7
#include <
cstddef
>
8
#include <
cstdint
>
9
#include <
memory
>
10
#include <
system_error
>
11
12
namespace
xrpl::cryptoconditions
{
13
14
struct
Fulfillment
15
{
16
public
:
25
static
constexpr
std::size_t
kMaxSerializedFulfillment
= 256;
26
38
static
std::unique_ptr<Fulfillment>
39
deserialize
(
Slice
s,
std::error_code
& ec);
40
41
public
:
42
virtual
~Fulfillment
() =
default
;
43
52
[[nodiscard]]
virtual
Buffer
53
fingerprint
()
const
= 0;
54
58
[[nodiscard]]
virtual
Type
59
type
()
const
= 0;
60
64
[[nodiscard]]
virtual
bool
65
validate
(
Slice
data)
const
= 0;
66
74
[[nodiscard]]
virtual
std::uint32_t
75
cost
()
const
= 0;
76
84
[[nodiscard]]
virtual
Condition
85
condition
()
const
= 0;
86
};
87
88
inline
bool
89
operator==
(
Fulfillment
const
& lhs,
Fulfillment
const
& rhs)
90
{
91
// FIXME: for compound conditions, need to also check subtypes
92
return
lhs.
type
() == rhs.
type
() && lhs.
cost
() == rhs.
cost
() &&
93
lhs.
fingerprint
() == rhs.
fingerprint
();
94
}
95
99
bool
100
match
(Fulfillment
const
& f, Condition
const
& c);
101
113
bool
114
validate
(Fulfillment
const
& f, Condition
const
& c,
Slice
m);
115
130
bool
131
validate
(Fulfillment
const
& f, Condition
const
& c);
132
133
}
// namespace xrpl::cryptoconditions
xrpl::Buffer
Like std::vector<char> but better.
Definition
Buffer.h:19
xrpl::Slice
An immutable linear range of bytes.
Definition
Slice.h:28
xrpl::cryptoconditions::Condition
Definition
Condition.h:25
cstddef
cstdint
std::error_code
std::uint32_t
memory
xrpl::cryptoconditions
Definition
Condition.h:14
xrpl::cryptoconditions::match
bool match(Fulfillment const &f, Condition const &c)
Determine whether the given fulfillment and condition match.
Definition
Fulfillment.cpp:16
xrpl::cryptoconditions::validate
bool validate(Fulfillment const &f, Condition const &c, Slice m)
Verify if the given message satisfies the fulfillment.
Definition
Fulfillment.cpp:29
xrpl::cryptoconditions::Type
Type
Definition
Condition.h:16
xrpl::cryptoconditions::operator==
bool operator==(Condition const &lhs, Condition const &rhs)
Definition
Condition.h:89
std::size_t
xrpl::cryptoconditions::Fulfillment
Definition
Fulfillment.h:15
xrpl::cryptoconditions::Fulfillment::~Fulfillment
virtual ~Fulfillment()=default
xrpl::cryptoconditions::Fulfillment::deserialize
static std::unique_ptr< Fulfillment > deserialize(Slice s, std::error_code &ec)
Load a fulfillment from its binary form.
Definition
Fulfillment.cpp:41
xrpl::cryptoconditions::Fulfillment::condition
virtual Condition condition() const =0
Returns the condition associated with the given fulfillment.
xrpl::cryptoconditions::Fulfillment::fingerprint
virtual Buffer fingerprint() const =0
Returns the fulfillment's fingerprint:
xrpl::cryptoconditions::Fulfillment::type
virtual Type type() const =0
Returns the type of this condition.
xrpl::cryptoconditions::Fulfillment::validate
virtual bool validate(Slice data) const =0
Validates a fulfillment.
xrpl::cryptoconditions::Fulfillment::cost
virtual std::uint32_t cost() const =0
Calculates the cost associated with this fulfillment.
xrpl::cryptoconditions::Fulfillment::kMaxSerializedFulfillment
static constexpr std::size_t kMaxSerializedFulfillment
The largest binary fulfillment we support.
Definition
Fulfillment.h:25
system_error
std::unique_ptr
Generated by
1.17.0