rippled
Loading...
Searching...
No Matches
Fulfillment.h
1#ifndef XRPL_CONDITIONS_FULFILLMENT_H
2#define XRPL_CONDITIONS_FULFILLMENT_H
3
4#include <xrpld/conditions/Condition.h>
5
6#include <xrpl/basics/Buffer.h>
7#include <xrpl/basics/Slice.h>
8
9namespace ripple {
10namespace cryptoconditions {
11
13{
14public:
22 static constexpr std::size_t maxSerializedFulfillment = 256;
23
36
37public:
38 virtual ~Fulfillment() = default;
39
47 virtual Buffer
48 fingerprint() const = 0;
49
51 virtual Type
52 type() const = 0;
53
55 virtual bool
56 validate(Slice data) const = 0;
57
64 virtual std::uint32_t
65 cost() const = 0;
66
73 virtual Condition
74 condition() const = 0;
75};
76
77inline bool
78operator==(Fulfillment const& lhs, Fulfillment const& rhs)
79{
80 // FIXME: for compound conditions, need to also check subtypes
81 return lhs.type() == rhs.type() && lhs.cost() == rhs.cost() &&
82 lhs.fingerprint() == rhs.fingerprint();
83}
84
85inline bool
86operator!=(Fulfillment const& lhs, Fulfillment const& rhs)
87{
88 return !(lhs == rhs);
89}
90
92bool
93match(Fulfillment const& f, Condition const& c);
94
105bool
106validate(Fulfillment const& f, Condition const& c, Slice m);
107
121bool
122validate(Fulfillment const& f, Condition const& c);
123
124} // namespace cryptoconditions
125} // namespace ripple
126
127#endif
Like std::vector<char> but better.
Definition Buffer.h:17
An immutable linear range of bytes.
Definition Slice.h:27
bool operator==(Condition const &lhs, Condition const &rhs)
Definition Condition.h:83
bool operator!=(Condition const &lhs, Condition const &rhs)
Definition Condition.h:90
bool validate(Fulfillment const &f, Condition const &c, Slice m)
Verify if the given message satisfies the fulfillment.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
static std::unique_ptr< Fulfillment > deserialize(Slice s, std::error_code &ec)
Load a fulfillment from its binary form.
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 maxSerializedFulfillment
The largest binary fulfillment we support.
Definition Fulfillment.h:22
virtual Condition condition() const =0
Returns the condition associated with the given fulfillment.
virtual Buffer fingerprint() const =0
Returns the fulfillment's fingerprint: