@@ -102,10 +102,12 @@ using object_restriction_predicate = std::function<bool(const Field&)>;
102
102
// predicate which returns true if any branch of the OR passes
103
103
// - create_predicate_function<Field>() -- switches on restriction type to determine which predicate template to use
104
104
// going forward
105
- // - restriction_argument_visitor< Field> -- Determines what type the restriction argument is and creates a
106
- // predicate functor for that type
105
+ // - make_predicate<Predicate, Field, ArgVariant > -- Determines what type the restriction argument is and creates
106
+ // a predicate functor for that type
107
107
// - attribute_assertion<Field> -- If the restriction is an attribute assertion, instead of using the
108
108
// restriction_argument_visitor, we recurse into restrictions_to_predicate with the current Field as the Object
109
+ // - embed_argument<Field, Predicate, Argument>() -- Embeds the argument into the predicate if it is a valid type
110
+ // for the predicate, and throws otherwise.
109
111
// - predicate_xyz<Argument> -- These are functors implementing the various predicate function types
110
112
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
111
113
@@ -306,26 +308,6 @@ struct predicate_has_none<fc::optional<OptionalType>, Argument, void> : predicat
306
308
};
307
309
// //////////////////////////////////////////// END PREDICATE FUNCTORS //////////////////////////////////////////////
308
310
309
- // Template to visit the restriction argument, resolving its type, and create the appropriate predicate functor, or
310
- // throw if the types are not compatible for the predicate assertion
311
- template <template <typename > class Predicate , typename Field>
312
- struct restriction_argument_visitor {
313
- using result_type = object_restriction_predicate<Field>;
314
-
315
- template <typename Argument,
316
- typename = std::enable_if_t <Predicate<Argument>::template can_evaluate_helper<Field>::value>>
317
- result_type make_predicate (const Argument& a, short ) {
318
- return Predicate<Argument>(a);
319
- }
320
- template <typename Argument>
321
- result_type make_predicate (const Argument&, long ) {
322
- FC_THROW_EXCEPTION (fc::assert_exception, " Invalid argument types for predicate: ${Field}, ${Argument}" ,
323
- (" Field" , fc::get_typename<Field>::name ())(" Argument" , fc::get_typename<Argument>::name ()));
324
- }
325
- template <typename Argument>
326
- result_type operator ()(const Argument& a) { return make_predicate (a, short ()); }
327
- };
328
-
329
311
// Forward declaration of restrictions_to_predicate, because attribute assertions and logical ORs recurse into it
330
312
template <typename Field> object_restriction_predicate<Field> restrictions_to_predicate (vector<restriction>, bool );
331
313
@@ -353,21 +335,23 @@ struct attribute_assertion<extension<Extension>> {
353
335
}
354
336
};
355
337
338
+ // Embed the argument into the predicate functor
356
339
template <typename F, typename P, typename A, typename = std::enable_if_t <P::valid>>
357
- object_restriction_predicate<F> mkpred (P p, A a, short ) {
340
+ object_restriction_predicate<F> embed_argument (P p, A a, short ) {
358
341
return std::bind (p, std::placeholders::_1, std::move (a));
359
342
}
360
343
template <typename F, typename P, typename A>
361
- object_restriction_predicate<F> mkpred (P, A, long ) {
344
+ object_restriction_predicate<F> embed_argument (P, A, long ) {
362
345
FC_THROW_EXCEPTION (fc::assert_exception, " Invalid types for predicated" );
363
346
}
364
347
348
+ // Resolve the argument type and make a predicate for it
365
349
template <template <typename ...> class Predicate , typename Field, typename ArgVariant>
366
350
object_restriction_predicate<Field> make_predicate (ArgVariant arg) {
367
351
return typelist::runtime::dispatch (typename ArgVariant::list (), arg.which (),
368
352
[&arg](auto t) mutable -> object_restriction_predicate<Field> {
369
353
using Arg = typename decltype (t)::type;
370
- return mkpred <Field>(Predicate<Field, Arg>(), std::move (arg.template get <Arg>()), short ());
354
+ return embed_argument <Field>(Predicate<Field, Arg>(), std::move (arg.template get <Arg>()), short ());
371
355
});
372
356
}
373
357
@@ -477,6 +461,7 @@ object_restriction_predicate<Object> restrictions_to_predicate(vector<restrictio
477
461
}
478
462
479
463
// To make the build gentler on RAM, break the operation list into several pieces to build over several files
464
+ // Process account create, update, and global parameters update operations separately, as they are the largest
480
465
using operation_list_1 = static_variant<typelist::slice<operation::list, 0 , 5 >>;
481
466
using operation_list_2 = static_variant<typelist::slice<operation::list, 5 , 10 >>;
482
467
using operation_list_3 = static_variant<typelist::slice<operation::list, 10 , 20 >>;
0 commit comments