Skip to content

Commit 1263cc5

Browse files
Compat with FC TNT Updates
This adds compatibility to bitshares/hardfork for bitshares/bitshares-fc#191
1 parent ca565a7 commit 1263cc5

File tree

4 files changed

+34
-30
lines changed

4 files changed

+34
-30
lines changed

libraries/fc

Submodule fc updated 50 files

libraries/protocol/custom_authorities/restriction_predicate.hxx

+30-27
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ template<typename I>
7575
const auto& to_num(const fc::safe<I>& i) { return i.value; }
7676
inline auto to_num(const fc::time_point_sec& t) { return t.sec_since_epoch(); }
7777

78+
// Shorthand to convert a typelist into a static_variant of that typelist
79+
template<typename List>
80+
using to_sv = typelist::apply<List, static_variant>;
81+
7882
namespace safenum = boost::safe_numerics::safe_compare;
7983

8084
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -127,7 +131,7 @@ using comparable_types_list = typelist::list<int64_t, string, time_point_sec, ac
127131
proposal_id_type, withdraw_permission_id_type,
128132
vesting_balance_id_type, worker_id_type, balance_id_type>;
129133
// Valid for list functions (in, not_in, has_all, has_none)
130-
struct make_flat_set { template<typename T> struct transform { using type = flat_set<T>; }; };
134+
template<typename T> struct make_flat_set { using type = flat_set<T>; };
131135
using list_types_list = typelist::transform<typelist::concat<typelist::list<bool, public_key_type, fc::sha256>,
132136
comparable_types_list>,
133137
make_flat_set>;
@@ -256,9 +260,15 @@ template<typename Field, typename Element>
256260
struct predicate_in<fc::optional<Field>, flat_set<Element>, std::enable_if_t<comparable_types<Field, Element>>> {
257261
// Check for optional value
258262
constexpr static bool valid = true;
263+
template<typename F = Field, std::enable_if_t<!std::is_same<F, share_type>::value, bool> = true>
259264
bool operator()(const fc::optional<Field>& f, const flat_set<Element>& c) const {
260265
if (!f.valid()) return predicate_result::Rejection(predicate_result::null_optional);
261-
return c.count(*f) != 0;
266+
return c.count(*f) != 0;
267+
}
268+
template<typename F = Field, std::enable_if_t<std::is_same<F, share_type>::value, bool> = true>
269+
bool operator()(const fc::optional<share_type>& f, const flat_set<Element>& c) const {
270+
if (!f.valid()) return predicate_result::Rejection(predicate_result::null_optional);
271+
return c.count(Element(f->value)) != 0;
262272
}
263273
};
264274
template<typename Container, typename Element>
@@ -470,32 +480,25 @@ object_restriction_predicate<Field> create_predicate_function(restriction_functi
470480
try {
471481
switch(func) {
472482
case restriction::func_eq:
473-
return make_predicate<predicate_eq, Field>(static_variant<equality_types_list>::import_from(std::move(arg)));
483+
return make_predicate<predicate_eq, Field>(to_sv<equality_types_list>::import_from(std::move(arg)));
474484
case restriction::func_ne:
475-
return make_predicate<predicate_ne, Field>(static_variant<equality_types_list>::import_from(std::move(arg)));
485+
return make_predicate<predicate_ne, Field>(to_sv<equality_types_list>::import_from(std::move(arg)));
476486
case restriction::func_lt:
477-
return make_predicate<predicate_lt, Field>(static_variant<comparable_types_list>
478-
::import_from(std::move(arg)));
487+
return make_predicate<predicate_lt, Field>(to_sv<comparable_types_list>::import_from(std::move(arg)));
479488
case restriction::func_le:
480-
return make_predicate<predicate_le, Field>(static_variant<comparable_types_list>
481-
::import_from(std::move(arg)));
489+
return make_predicate<predicate_le, Field>(to_sv<comparable_types_list>::import_from(std::move(arg)));
482490
case restriction::func_gt:
483-
return make_predicate<predicate_gt, Field>(static_variant<comparable_types_list>
484-
::import_from(std::move(arg)));
491+
return make_predicate<predicate_gt, Field>(to_sv<comparable_types_list>::import_from(std::move(arg)));
485492
case restriction::func_ge:
486-
return make_predicate<predicate_ge, Field>(static_variant<comparable_types_list>
487-
::import_from(std::move(arg)));
493+
return make_predicate<predicate_ge, Field>(to_sv<comparable_types_list>::import_from(std::move(arg)));
488494
case restriction::func_in:
489-
return make_predicate<predicate_in, Field>(static_variant<list_types_list>::import_from(std::move(arg)));
495+
return make_predicate<predicate_in, Field>(to_sv<list_types_list>::import_from(std::move(arg)));
490496
case restriction::func_not_in:
491-
return make_predicate<predicate_not_in, Field>(static_variant<list_types_list>
492-
::import_from(std::move(arg)));
497+
return make_predicate<predicate_not_in, Field>(to_sv<list_types_list>::import_from(std::move(arg)));
493498
case restriction::func_has_all:
494-
return make_predicate<predicate_has_all, Field>(static_variant<list_types_list>
495-
::import_from(std::move(arg)));
499+
return make_predicate<predicate_has_all, Field>(to_sv<list_types_list>::import_from(std::move(arg)));
496500
case restriction::func_has_none:
497-
return make_predicate<predicate_has_none, Field>(static_variant<list_types_list>
498-
::import_from(std::move(arg)));
501+
return make_predicate<predicate_has_none, Field>(to_sv<list_types_list>::import_from(std::move(arg)));
499502
case restriction::func_attr:
500503
FC_ASSERT(arg.which() == restriction_argument::tag<vector<restriction>>::value,
501504
"Argument type for attribute assertion must be restriction list");
@@ -590,14 +593,14 @@ object_restriction_predicate<Object> restrictions_to_predicate(vector<restrictio
590593
}
591594

592595
// To make the build gentler on RAM, break the operation list into several pieces to build over several files
593-
using operation_list_1 = static_variant<typelist::slice<operation::list, 0, 5>>;
594-
using operation_list_2 = static_variant<typelist::slice<operation::list, 5, 10>>;
595-
using operation_list_3 = static_variant<typelist::slice<operation::list, 10, 20>>;
596-
using operation_list_4 = static_variant<typelist::slice<operation::list, 20, 30>>;
597-
using operation_list_5 = static_variant<typelist::slice<operation::list, 30, 35>>;
598-
using operation_list_6 = static_variant<typelist::slice<operation::list, 35, 40>>;
599-
using operation_list_7 = static_variant<typelist::slice<operation::list, 40, 50>>;
600-
using operation_list_8 = static_variant<typelist::slice<operation::list, 50>>;
596+
using operation_list_1 = to_sv<typelist::slice<operation::list, 0, 5>>;
597+
using operation_list_2 = to_sv<typelist::slice<operation::list, 5, 10>>;
598+
using operation_list_3 = to_sv<typelist::slice<operation::list, 10, 20>>;
599+
using operation_list_4 = to_sv<typelist::slice<operation::list, 20, 30>>;
600+
using operation_list_5 = to_sv<typelist::slice<operation::list, 30, 35>>;
601+
using operation_list_6 = to_sv<typelist::slice<operation::list, 35, 40>>;
602+
using operation_list_7 = to_sv<typelist::slice<operation::list, 40, 50>>;
603+
using operation_list_8 = to_sv<typelist::slice<operation::list, 50>>;
601604

602605
object_restriction_predicate<operation> get_restriction_predicate_list_1(size_t idx, vector<restriction> rs);
603606
object_restriction_predicate<operation> get_restriction_predicate_list_2(size_t idx, vector<restriction> rs);

libraries/protocol/include/graphene/protocol/object_id.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ struct reflector<graphene::db::object_id<SpaceID,TypeID> >
169169
{
170170
typedef graphene::db::object_id<SpaceID,TypeID> type;
171171
typedef std::true_type is_defined;
172-
using native_members = typelist::list<fc::field_reflection<0, type, unsigned_int, &type::instance>>;
172+
using native_members = typelist::list<fc::field_reflector<0, type, unsigned_int, &type::instance>>;
173173
using inherited_members = typelist::list<>;
174174
using members = native_members;
175175
using base_classes = typelist::list<>;

tests/tests/custom_authority_tests.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,15 @@
3535

3636
using namespace graphene::chain;
3737
using namespace graphene::chain::test;
38+
namespace TL = fc::typelist;
3839

3940
namespace graphene { namespace protocol {
4041
bool operator==(const restriction& a, const restriction& b) {
4142
if (std::tie(a.member_index, a.restriction_type) != std::tie(b.member_index, b.restriction_type))
4243
return false;
4344
if (a.argument.is_type<void_t>())
4445
return b.argument.is_type<void_t>();
45-
using Value_Argument = static_variant<fc::typelist::slice<restriction::argument_type::list, 1>>;
46+
using Value_Argument = TL::apply<TL::slice<restriction::argument_type::list, 1>, static_variant>;
4647
return Value_Argument::import_from(a.argument) == Value_Argument::import_from(b.argument);
4748
}
4849
} }

0 commit comments

Comments
 (0)