Skip to content

Commit

Permalink
Update operation list slicing, fix MinGW build
Browse files Browse the repository at this point in the history
  • Loading branch information
abitmore committed Jun 5, 2021
1 parent 7992291 commit f41db5c
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 2 deletions.
4 changes: 3 additions & 1 deletion libraries/protocol/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ list(APPEND CUSTOM_AUTHS_FILES
custom_authorities/list_9.cpp
custom_authorities/list_10.cpp
custom_authorities/list_11.cpp
custom_authorities/list_12.cpp)
custom_authorities/list_12.cpp
custom_authorities/list_13.cpp
custom_authorities/list_14.cpp)

file(GLOB CUSTOM_AUTHS_HEADERS "custom_authorities/*.hxx")

Expand Down
41 changes: 41 additions & 0 deletions libraries/protocol/custom_authorities/list_13.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright (c) 2019 Contributors.
*
* The MIT License
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

#include "restriction_predicate.hxx"
#include "sliced_lists.hxx"

namespace graphene { namespace protocol {
using result_type = object_restriction_predicate<operation>;

result_type get_restriction_predicate_list_13(size_t idx, vector<restriction> rs) {
return typelist::runtime::dispatch(operation_list_13::list(), idx, [&rs] (auto t) -> result_type {
using Op = typename decltype(t)::type;
return [p=restrictions_to_predicate<Op>(std::move(rs), true)] (const operation& op) {
FC_ASSERT(op.which() == operation::tag<Op>::value,
"Supplied operation is incorrect type for restriction predicate");
return p(op.get<Op>());
};
});
}
} }
41 changes: 41 additions & 0 deletions libraries/protocol/custom_authorities/list_14.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright (c) 2019 Contributors.
*
* The MIT License
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

#include "restriction_predicate.hxx"
#include "sliced_lists.hxx"

namespace graphene { namespace protocol {
using result_type = object_restriction_predicate<operation>;

result_type get_restriction_predicate_list_14(size_t idx, vector<restriction> rs) {
return typelist::runtime::dispatch(operation_list_14::list(), idx, [&rs] (auto t) -> result_type {
using Op = typename decltype(t)::type;
return [p=restrictions_to_predicate<Op>(std::move(rs), true)] (const operation& op) {
FC_ASSERT(op.which() == operation::tag<Op>::value,
"Supplied operation is incorrect type for restriction predicate");
return p(op.get<Op>());
};
});
}
} }
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ restriction_predicate_function get_restriction_predicate(vector<restriction> rs,
return get_restriction_predicate_list_11(typelist::index_of<operation_list_11::list, Op>(), std::move(rs));
if (typelist::contains<operation_list_12::list, Op>())
return get_restriction_predicate_list_12(typelist::index_of<operation_list_12::list, Op>(), std::move(rs));
if (typelist::contains<operation_list_13::list, Op>())
return get_restriction_predicate_list_13(typelist::index_of<operation_list_13::list, Op>(), std::move(rs));
if (typelist::contains<operation_list_14::list, Op>())
return get_restriction_predicate_list_14(typelist::index_of<operation_list_14::list, Op>(), std::move(rs));
if (typelist::contains<virtual_operations_list::list, Op>())
FC_THROW_EXCEPTION( fc::assert_exception, "Virtual operations not allowed!" );

Expand All @@ -66,6 +70,7 @@ restriction_predicate_function get_restriction_predicate(vector<restriction> rs,
operation_list_7::list, operation_list_8::list,
operation_list_9::list, operation_list_10::list,
operation_list_11::list, operation_list_12::list,
operation_list_13::list, operation_list_14::list,
virtual_operations_list::list>,
Op>(), "");
FC_THROW_EXCEPTION(fc::assert_exception,
Expand Down
6 changes: 5 additions & 1 deletion libraries/protocol/custom_authorities/sliced_lists.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ using operation_list_11 = static_variant<typelist::builder<>
::add_list<typelist::slice<operation::list, 47, 51>>
::add<htlc_extend_operation> // 52
::finalize>;
using operation_list_12 = static_variant<typelist::slice<operation::list, 54>>;
using operation_list_12 = static_variant<typelist::slice<operation::list, 54, 59>>;
using operation_list_13 = static_variant<typelist::slice<operation::list, 59, 64>>;
using operation_list_14 = static_variant<typelist::slice<operation::list, 64>>;
using virtual_operations_list = static_variant<fill_order_operation, // 4
asset_settle_cancel_operation, // 42
fba_distribute_operation, // 44
Expand All @@ -67,5 +69,7 @@ object_restriction_predicate<operation> get_restriction_predicate_list_9(size_t
object_restriction_predicate<operation> get_restriction_predicate_list_10(size_t idx, vector<restriction> rs);
object_restriction_predicate<operation> get_restriction_predicate_list_11(size_t idx, vector<restriction> rs);
object_restriction_predicate<operation> get_restriction_predicate_list_12(size_t idx, vector<restriction> rs);
object_restriction_predicate<operation> get_restriction_predicate_list_13(size_t idx, vector<restriction> rs);
object_restriction_predicate<operation> get_restriction_predicate_list_14(size_t idx, vector<restriction> rs);

} } // namespace graphene::protocol

0 comments on commit f41db5c

Please sign in to comment.