BitShares-Core  4.0.0
BitShares blockchain implementation and command-line interface software
hardfork_visitor.hpp
Go to the documentation of this file.
1 #pragma once
2 /*
3  * Copyright (c) 2019 Contributors
4  *
5  * The MIT License
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a copy
8  * of this software and associated documentation files (the "Software"), to deal
9  * in the Software without restriction, including without limitation the rights
10  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11  * copies of the Software, and to permit persons to whom the Software is
12  * furnished to do so, subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be included in
15  * all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23  * THE SOFTWARE.
24  */
25 
27 
28 #include <graphene/chain/hardfork.hpp>
29 
30 #include <fc/reflect/typelist.hpp>
31 
32 #include <type_traits>
33 #include <functional>
34 
35 namespace graphene { namespace chain {
36 using namespace protocol;
37 namespace TL { using namespace fc::typelist; }
38 
47  using result_type = bool;
53 
55 
58  template<typename Op>
59  std::enable_if_t<operation::tag<Op>::value < operation::tag<first_unforked_op>::value, bool>
60  visit() { return true; }
61  template<typename Op>
62  std::enable_if_t<TL::contains<BSIP_40_ops, Op>(), bool>
63  visit() { return HARDFORK_BSIP_40_PASSED(now); }
64  template<typename Op>
65  std::enable_if_t<TL::contains<hf2103_ops, Op>(), bool>
66  visit() { return HARDFORK_CORE_2103_PASSED(now); }
68 
70  template<class W, class Op=typename W::type>
71  std::enable_if_t<TL::contains<operation::list, Op>(), bool>
72  operator()(W) { return visit<Op>(); }
74  template<class Op>
75  std::enable_if_t<TL::contains<operation::list, Op>(), bool>
76  operator()(const Op&) { return visit<Op>(); }
78  bool visit(operation::tag_type tag) {
79  return TL::runtime::dispatch(operation::list(), (size_t)tag, *this);
80  }
82  bool visit(const operation& op) {
83  return visit(op.which());
84  }
85 };
86 
87 } } // namespace graphene::chain
hardfork_visitor(fc::time_point_sec now)
Defines a template for manipulating and storing compile-time lists of types.
Definition: api.cpp:56
fc::static_variant< transfer_operation, limit_order_create_operation, limit_order_cancel_operation, call_order_update_operation, fill_order_operation, account_create_operation, account_update_operation, account_whitelist_operation, account_upgrade_operation, account_transfer_operation, asset_create_operation, asset_update_operation, asset_update_bitasset_operation, asset_update_feed_producers_operation, asset_issue_operation, asset_reserve_operation, asset_fund_fee_pool_operation, asset_settle_operation, asset_global_settle_operation, asset_publish_feed_operation, witness_create_operation, witness_update_operation, proposal_create_operation, proposal_update_operation, proposal_delete_operation, withdraw_permission_create_operation, withdraw_permission_update_operation, withdraw_permission_claim_operation, withdraw_permission_delete_operation, committee_member_create_operation, committee_member_update_operation, committee_member_update_global_parameters_operation, vesting_balance_create_operation, vesting_balance_withdraw_operation, worker_create_operation, custom_operation, assert_operation, balance_claim_operation, override_transfer_operation, transfer_to_blind_operation, blind_transfer_operation, transfer_from_blind_operation, asset_settle_cancel_operation, asset_claim_fees_operation, fba_distribute_operation, bid_collateral_operation, execute_bid_operation, asset_claim_pool_operation, asset_update_issuer_operation, htlc_create_operation, htlc_redeem_operation, htlc_redeemed_operation, htlc_extend_operation, htlc_refund_operation, custom_authority_create_operation, custom_authority_update_operation, custom_authority_delete_operation, ticket_create_operation, ticket_update_operation >
tag_type which() const
fc::static_variant< transfer_operation, limit_order_create_operation, limit_order_cancel_operation, call_order_update_operation, fill_order_operation, account_create_operation, account_update_operation, account_whitelist_operation, account_upgrade_operation, account_transfer_operation, asset_create_operation, asset_update_operation, asset_update_bitasset_operation, asset_update_feed_producers_operation, asset_issue_operation, asset_reserve_operation, asset_fund_fee_pool_operation, asset_settle_operation, asset_global_settle_operation, asset_publish_feed_operation, witness_create_operation, witness_update_operation, proposal_create_operation, proposal_update_operation, proposal_delete_operation, withdraw_permission_create_operation, withdraw_permission_update_operation, withdraw_permission_claim_operation, withdraw_permission_delete_operation, committee_member_create_operation, committee_member_update_operation, committee_member_update_global_parameters_operation, vesting_balance_create_operation, vesting_balance_withdraw_operation, worker_create_operation, custom_operation, assert_operation, balance_claim_operation, override_transfer_operation, transfer_to_blind_operation, blind_transfer_operation, transfer_from_blind_operation, asset_settle_cancel_operation, asset_claim_fees_operation, fba_distribute_operation, bid_collateral_operation, execute_bid_operation, asset_claim_pool_operation, asset_update_issuer_operation, htlc_create_operation, htlc_redeem_operation, htlc_redeemed_operation, htlc_extend_operation, htlc_refund_operation, custom_authority_create_operation, custom_authority_update_operation, custom_authority_delete_operation, ticket_create_operation, ticket_update_operation >::tag_type
int64_t tag_type
This namespace contains the list type, and all of the operations and queries which can be performed u...
Definition: typelist.hpp:14
The actual list type.
Definition: typelist.hpp:17
The hardfork_visitor struct checks whether a given operation type has been hardforked in or not...
Return dispatch(list< Types... >, std::size_t index, Callable c)
Index into the typelist for a type T, and invoke the callable with an argument wrapper<T>() ...
Definition: typelist.hpp:243