BitShares-Core  7.0.2
BitShares blockchain node software and command-line wallet software
hardfork_visitor.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019 Contributors
3  *
4  * The MIT License
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  */
24 #pragma once
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 
45  using result_type = bool;
71 
73 
75  explicit hardfork_visitor(const fc::time_point_sec& head_block_time) : now(head_block_time) {}
76 
79  template<typename Op>
80  std::enable_if_t<operation::tag<Op>::value < protocol::operation::tag<first_unforked_op>::value, bool>
81  visit() { return true; }
82  template<typename Op>
83  std::enable_if_t<fc::typelist::contains<BSIP_40_ops, Op>(), bool>
84  visit() { return HARDFORK_BSIP_40_PASSED(now); }
85  template<typename Op>
86  std::enable_if_t<fc::typelist::contains<hf1604_ops, Op>(), bool>
87  visit() { return HARDFORK_CORE_1604_PASSED(now); }
88  template<typename Op>
89  std::enable_if_t<fc::typelist::contains<hf2103_ops, Op>(), bool>
90  visit() { return HARDFORK_CORE_2103_PASSED(now); }
91  template<typename Op>
92  std::enable_if_t<fc::typelist::contains<liquidity_pool_ops, Op>(), bool>
93  visit() { return HARDFORK_LIQUIDITY_POOL_PASSED(now); }
94  template<typename Op>
95  std::enable_if_t<fc::typelist::contains<samet_fund_ops, Op>(), bool>
96  visit() { return HARDFORK_CORE_2351_PASSED(now); }
97  template<typename Op>
98  std::enable_if_t<fc::typelist::contains<credit_offer_ops, Op>(), bool>
99  visit() { return HARDFORK_CORE_2362_PASSED(now); }
100  template<typename Op>
101  std::enable_if_t<fc::typelist::contains<credit_deal_update_op, Op>(), bool>
102  visit() { return HARDFORK_CORE_2595_PASSED(now); }
103  template<typename Op>
104  std::enable_if_t<fc::typelist::contains<liquidity_pool_update_op, Op>(), bool>
105  visit() { return HARDFORK_CORE_2604_PASSED(now); }
107 
109  template<class W, class Op=typename W::type>
110  std::enable_if_t<fc::typelist::contains<protocol::operation::list, Op>(), bool>
111  operator()(W) { return visit<Op>(); }
113  template<class Op>
114  std::enable_if_t<fc::typelist::contains<protocol::operation::list, Op>(), bool>
115  operator()(const Op&) { return visit<Op>(); }
117  bool visit(protocol::operation::tag_type tag) const {
118  return fc::typelist::runtime::dispatch(protocol::operation::list(), (size_t)tag, *this);
119  }
121  bool visit(const protocol::operation& op) const {
122  return visit(op.which());
123  }
124 };
125 
126 } } // namespace graphene::chain
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, liquidity_pool_create_operation, liquidity_pool_delete_operation, liquidity_pool_deposit_operation, liquidity_pool_withdraw_operation, liquidity_pool_exchange_operation, samet_fund_create_operation, samet_fund_delete_operation, samet_fund_update_operation, samet_fund_borrow_operation, samet_fund_repay_operation, credit_offer_create_operation, credit_offer_delete_operation, credit_offer_update_operation, credit_offer_accept_operation, credit_deal_repay_operation, credit_deal_expired_operation, liquidity_pool_update_operation, credit_deal_update_operation, limit_order_update_operation >::tag_type
int64_t tag_type
Definition: static_variant.hpp:46
fc::typelist::list
The actual list type.
Definition: typelist.hpp:17
graphene::protocol::samet_fund_delete_operation
Delete a SameT Fund object.
Definition: samet_fund.hpp:56
graphene::protocol::ticket_create_operation
Creates a new ticket.
Definition: ticket.hpp:47
graphene::protocol::credit_deal_repay_operation
Repay a credit deal.
Definition: credit_offer.hpp:163
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, liquidity_pool_create_operation, liquidity_pool_delete_operation, liquidity_pool_deposit_operation, liquidity_pool_withdraw_operation, liquidity_pool_exchange_operation, samet_fund_create_operation, samet_fund_delete_operation, samet_fund_update_operation, samet_fund_borrow_operation, samet_fund_repay_operation, credit_offer_create_operation, credit_offer_delete_operation, credit_offer_update_operation, credit_offer_accept_operation, credit_deal_repay_operation, credit_deal_expired_operation, liquidity_pool_update_operation, credit_deal_update_operation, limit_order_update_operation >::list
typelist::list< Types... > list
Definition: static_variant.hpp:47
graphene::protocol::credit_offer_create_operation
Create a new credit offer.
Definition: credit_offer.hpp:36
graphene::protocol::custom_authority_create_operation
Create a new custom authority.
Definition: custom_authority.hpp:36
graphene::protocol::liquidity_pool_exchange_operation
Exchange with a liquidity pool.
Definition: liquidity_pool.hpp:138
graphene::protocol::credit_offer_delete_operation
Delete a credit offer.
Definition: credit_offer.hpp:70
graphene::protocol::liquidity_pool_create_operation
Create a new liquidity pool.
Definition: liquidity_pool.hpp:34
typelist.hpp
Defines a template for manipulating and storing compile-time lists of types.
graphene::protocol::samet_fund_borrow_operation
Borrow from a SameT Fund.
Definition: samet_fund.hpp:94
graphene::protocol::samet_fund_create_operation
Create a new SameT Fund object.
Definition: samet_fund.hpp:36
graphene::protocol::samet_fund_update_operation
Update a SameT Fund object.
Definition: samet_fund.hpp:74
graphene::protocol::liquidity_pool_withdraw_operation
Withdraw from a liquidity pool.
Definition: liquidity_pool.hpp:114
graphene::protocol::custom_authority_delete_operation
Delete a custom authority.
Definition: custom_authority.hpp:107
operations.hpp
graphene::protocol::ticket_update_operation
Updates an existing ticket.
Definition: ticket.hpp:66
graphene::protocol::credit_offer_accept_operation
Accept a credit offer, thereby creating a credit deal.
Definition: credit_offer.hpp:135
fc::time_point_sec
Definition: time.hpp:74
graphene::protocol::liquidity_pool_deposit_operation
Deposit to a liquidity pool.
Definition: liquidity_pool.hpp:94
graphene::protocol::custom_authority_update_operation
Update a custom authority.
Definition: custom_authority.hpp:70
graphene::chain::hardfork_visitor::result_type
bool result_type
Definition: hardfork_visitor.hpp:45
graphene::chain::hardfork_visitor::now
fc::time_point_sec now
Definition: hardfork_visitor.hpp:72
graphene::protocol::liquidity_pool_delete_operation
Delete a liquidity pool.
Definition: liquidity_pool.hpp:56
graphene::protocol::credit_deal_expired_operation
A credit deal expired without being fully repaid.
Definition: credit_offer.hpp:184
graphene::chain::hardfork_visitor::hardfork_visitor
hardfork_visitor(const fc::time_point_sec &head_block_time)
Definition: hardfork_visitor.hpp:75
graphene::chain::hardfork_visitor
The hardfork_visitor struct checks whether a given operation type has been hardforked in or not.
Definition: hardfork_visitor.hpp:44
graphene::protocol::samet_fund_repay_operation
Repay to a SameT Fund.
Definition: samet_fund.hpp:113
fc::typelist::runtime::dispatch
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
graphene::protocol::credit_offer_update_operation
Update a credit offer.
Definition: credit_offer.hpp:88
graphene
Definition: api.cpp:48
graphene::protocol::operation
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, liquidity_pool_create_operation, liquidity_pool_delete_operation, liquidity_pool_deposit_operation, liquidity_pool_withdraw_operation, liquidity_pool_exchange_operation, samet_fund_create_operation, samet_fund_delete_operation, samet_fund_update_operation, samet_fund_borrow_operation, samet_fund_repay_operation, credit_offer_create_operation, credit_offer_delete_operation, credit_offer_update_operation, credit_offer_accept_operation, credit_deal_repay_operation, credit_deal_expired_operation, liquidity_pool_update_operation, credit_deal_update_operation, limit_order_update_operation > operation
Definition: operations.hpp:134