xrpld
Loading...
Searching...
No Matches
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
8
10{
11public:
19 static constexpr std::size_t kMaxSerializedFulfillment = 256;
20
33
34public:
35 virtual ~Fulfillment() = default;
36
44 [[nodiscard]] virtual Buffer
45 fingerprint() const = 0;
46
48 [[nodiscard]] virtual Type
49 type() const = 0;
50
52 [[nodiscard]] virtual bool
53 validate(Slice data) const = 0;
54
61 [[nodiscard]] virtual std::uint32_t
62 cost() const = 0;
63
70 [[nodiscard]] virtual Condition
71 condition() const = 0;
72};
73
74inline bool
75operator==(Fulfillment const& lhs, Fulfillment const& rhs)
76{
77 // FIXME: for compound conditions, need to also check subtypes
78 return lhs.type() == rhs.type() && lhs.cost() == rhs.cost() &&
79 lhs.fingerprint() == rhs.fingerprint();
80}
81
82inline bool
83operator!=(Fulfillment const& lhs, Fulfillment const& rhs)
84{
85 return !(lhs == rhs);
86}
87
89bool
90match(Fulfillment const& f, Condition const& c);
91
102bool
103validate(Fulfillment const& f, Condition const& c, Slice m);
104
118bool
119validate(Fulfillment const& f, Condition const& c);
120
121} // namespace xrpl::cryptoconditions
Like std::vector<char> but better.
Definition Buffer.h:16
An immutable linear range of bytes.
Definition Slice.h:26
bool match(Fulfillment const &f, Condition const &c)
Determine whether the given fulfillment and condition match.
bool operator!=(Condition const &lhs, Condition const &rhs)
Definition Condition.h:85
bool validate(Fulfillment const &f, Condition const &c, Slice m)
Verify if the given message satisfies the fulfillment.
bool operator==(Condition const &lhs, Condition const &rhs)
Definition Condition.h:78
static std::unique_ptr< Fulfillment > deserialize(Slice s, std::error_code &ec)
Load a fulfillment from its binary form.
virtual Condition condition() const =0
Returns the condition associated with the given fulfillment.
virtual Buffer fingerprint() const =0
Returns the fulfillment's fingerprint:
virtual Type type() const =0
Returns the type of this condition.
virtual bool validate(Slice data) const =0
Validates a fulfillment.
virtual std::uint32_t cost() const =0
Calculates the cost associated with this fulfillment.
static constexpr std::size_t kMaxSerializedFulfillment
The largest binary fulfillment we support.
Definition Fulfillment.h:19