rippled
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
7namespace xrpl {
8namespace cryptoconditions {
9
11{
12public:
20 static constexpr std::size_t maxSerializedFulfillment = 256;
21
34
35public:
36 virtual ~Fulfillment() = default;
37
45 virtual Buffer
46 fingerprint() const = 0;
47
49 virtual Type
50 type() const = 0;
51
53 virtual bool
54 validate(Slice data) const = 0;
55
62 virtual std::uint32_t
63 cost() const = 0;
64
71 virtual Condition
72 condition() const = 0;
73};
74
75inline bool
76operator==(Fulfillment const& lhs, Fulfillment const& rhs)
77{
78 // FIXME: for compound conditions, need to also check subtypes
79 return lhs.type() == rhs.type() && lhs.cost() == rhs.cost() && 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 cryptoconditions
122} // namespace xrpl
Like std::vector<char> but better.
Definition Buffer.h:16
An immutable linear range of bytes.
Definition Slice.h:26
bool operator!=(Condition const &lhs, Condition const &rhs)
Definition Condition.h:86
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:79
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
static constexpr std::size_t maxSerializedFulfillment
The largest binary fulfillment we support.
Definition Fulfillment.h:20
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.