diff --git a/libraries/chain/abi_serializer.cpp b/libraries/chain/abi_serializer.cpp index 127b4966a9f..2604c975daf 100644 --- a/libraries/chain/abi_serializer.cpp +++ b/libraries/chain/abi_serializer.cpp @@ -38,7 +38,7 @@ namespace eosio { namespace chain { if( is_array ) fc::raw::pack( ds, var.as>() ); else if ( is_optional ) - fc::raw::pack( ds, var.as>() ); + fc::raw::pack( ds, var.as>() ); else fc::raw::pack( ds, var.as()); }; @@ -51,7 +51,7 @@ namespace eosio { namespace chain { if( is_array ) return variant_from_stream>(stream); else if ( is_optional ) - return variant_from_stream>(stream); + return variant_from_stream>(stream); return variant_from_stream(stream); }, pack_function() @@ -65,7 +65,7 @@ namespace eosio { namespace chain { if( is_array ) return variant_from_stream>(stream); else if ( is_optional ) - return variant_from_stream>(stream); + return variant_from_stream>(stream); return variant_from_stream(stream, yield); }, pack_function() @@ -619,10 +619,10 @@ namespace eosio { namespace chain { return type_name(); } - optional abi_serializer::get_error_message( uint64_t error_code )const { + std::optional abi_serializer::get_error_message( uint64_t error_code )const { auto itr = error_messages.find( error_code ); if( itr == error_messages.end() ) - return optional(); + return std::optional(); return itr->second; } diff --git a/libraries/chain/authorization_manager.cpp b/libraries/chain/authorization_manager.cpp index c12a3c27cc0..6e6f10b9a84 100644 --- a/libraries/chain/authorization_manager.cpp +++ b/libraries/chain/authorization_manager.cpp @@ -276,10 +276,10 @@ namespace eosio { namespace chain { return _db.get( boost::make_tuple(level.actor,level.permission) ); } EOS_RETHROW_EXCEPTIONS( chain::permission_query_exception, "Failed to retrieve permission: ${level}", ("level", level) ) } - optional authorization_manager::lookup_linked_permission( account_name authorizer_account, - account_name scope, - action_name act_name - )const + std::optional authorization_manager::lookup_linked_permission( account_name authorizer_account, + account_name scope, + action_name act_name + )const { try { // First look up a specific link for this message act_name @@ -295,16 +295,14 @@ namespace eosio { namespace chain { if (link != nullptr) { return link->required_permission; } - return optional(); - - // return optional(); + return std::optional(); } FC_CAPTURE_AND_RETHROW((authorizer_account)(scope)(act_name)) } - optional authorization_manager::lookup_minimum_permission( account_name authorizer_account, - account_name scope, - action_name act_name - )const + std::optional authorization_manager::lookup_minimum_permission( account_name authorizer_account, + account_name scope, + action_name act_name + )const { // Special case native actions cannot be linked to a minimum permission, so there is no need to check. if( scope == config::system_account_name ) { @@ -318,12 +316,12 @@ namespace eosio { namespace chain { } try { - optional linked_permission = lookup_linked_permission(authorizer_account, scope, act_name); + std::optional linked_permission = lookup_linked_permission(authorizer_account, scope, act_name); if( !linked_permission ) return config::active_name; if( *linked_permission == config::eosio_any_name ) - return optional(); + return std::optional(); return linked_permission; } FC_CAPTURE_AND_RETHROW((authorizer_account)(scope)(act_name)) @@ -418,7 +416,7 @@ namespace eosio { namespace chain { "the owner of the linked permission needs to be the actor of the declared authorization" ); const auto unlinked_permission_name = lookup_linked_permission(unlink.account, unlink.code, unlink.type); - EOS_ASSERT( unlinked_permission_name.valid(), transaction_exception, + EOS_ASSERT( unlinked_permission_name, transaction_exception, "cannot unlink non-existent permission link of account '${account}' for actions matching '${code}::${action}'", ("account", unlink.account)("code", unlink.code)("action", unlink.type) ); diff --git a/libraries/chain/block.cpp b/libraries/chain/block.cpp index ddee4ff0911..39322d12d25 100644 --- a/libraries/chain/block.cpp +++ b/libraries/chain/block.cpp @@ -133,7 +133,7 @@ namespace eosio { namespace chain { return validate_and_extract_block_extensions( block_extensions ); } - fc::optional signed_block::to_signed_block_v0() const { + std::optional signed_block::to_signed_block_v0() const { if (prune_state != prune_state_type::complete_legacy) return {}; diff --git a/libraries/chain/block_header_state.cpp b/libraries/chain/block_header_state.cpp index c79d7c7f3f2..ffc1fcb23dd 100644 --- a/libraries/chain/block_header_state.cpp +++ b/libraries/chain/block_header_state.cpp @@ -173,7 +173,7 @@ namespace eosio { namespace chain { signed_block_header pending_block_header_state::make_block_header( const checksum256_type& transaction_mroot, const checksum256_type& action_mroot, - const optional& new_producers, + const std::optional& new_producers, vector&& new_protocol_feature_activations, const protocol_feature_set& pfs )const diff --git a/libraries/chain/block_log.cpp b/libraries/chain/block_log.cpp index da38b3f9a2d..6cef49b1683 100644 --- a/libraries/chain/block_log.cpp +++ b/libraries/chain/block_log.cpp @@ -296,9 +296,9 @@ namespace eosio { namespace chain { uint64_t first_block_position() const { return first_block_pos; } chain_id_type chain_id() const { return preamble.chain_id(); } - fc::optional get_genesis_state() const { - return std::visit(overloaded{[](const chain_id_type&) { return fc::optional{}; }, - [](const genesis_state& state) { return fc::optional{state}; }}, + std::optional get_genesis_state() const { + return std::visit(overloaded{[](const chain_id_type&) { return std::optional{}; }, + [](const genesis_state& state) { return std::optional{state}; }}, preamble.chain_context); } @@ -952,7 +952,7 @@ namespace eosio { namespace chain { return backup_dir; } - fc::optional block_log::extract_genesis_state( const fc::path& block_dir ) { + std::optional block_log::extract_genesis_state( const fc::path& block_dir ) { boost::filesystem::path p(block_dir / "blocks.log"); for_each_file_in_dir_matches(block_dir, R"(blocks-1-\d+\.log)", [&p](boost::filesystem::path log_path) { p = log_path; }); return block_log_data(p).get_genesis_state(); diff --git a/libraries/chain/controller.cpp b/libraries/chain/controller.cpp index cc624c20c32..7f4a8626deb 100644 --- a/libraries/chain/controller.cpp +++ b/libraries/chain/controller.cpp @@ -74,7 +74,7 @@ class maybe_session { } explicit maybe_session(database& db) { - _session = db.start_undo_session(true); + _session.emplace(db.start_undo_session(true)); } maybe_session(const maybe_session&) = delete; @@ -96,7 +96,7 @@ class maybe_session { maybe_session& operator = ( maybe_session&& mv ) { if (mv._session) { - _session = move(*mv._session); + _session.emplace(move(*mv._session)); mv._session.reset(); } else { _session.reset(); @@ -106,7 +106,7 @@ class maybe_session { }; private: - optional _session; + std::optional _session; }; struct building_block { @@ -119,14 +119,14 @@ struct building_block { ,_trx_mroot_or_receipt_digests( digests_t{} ) {} - pending_block_header_state _pending_block_header_state; - optional _new_pending_producer_schedule; - vector _new_protocol_feature_activations; - size_t _num_new_protocol_features_that_have_activated = 0; - deque _pending_trx_metas; - deque _pending_trx_receipts; // boost deque in 1.71 with 1024 elements performs better + pending_block_header_state _pending_block_header_state; + std::optional _new_pending_producer_schedule; + vector _new_protocol_feature_activations; + size_t _num_new_protocol_features_that_have_activated = 0; + deque _pending_trx_metas; + deque _pending_trx_receipts; // boost deque in 1.71 with 1024 elements performs better static_variant _trx_mroot_or_receipt_digests; - digests_t _action_receipt_digests; + digests_t _action_receipt_digests; }; struct assembled_block { @@ -136,7 +136,7 @@ struct assembled_block { signed_block_ptr _unsigned_block; // if the _unsigned_block pre-dates block-signing authorities this may be present. - optional _new_producer_authority_cache; + std::optional _new_producer_authority_cache; }; struct completed_block { @@ -157,7 +157,7 @@ struct pending_state { maybe_session _db_session; block_stage_type _block_stage; controller::block_status _block_status = controller::block_status::incomplete; - optional _producer_block_id; + std::optional _producer_block_id; /** @pre _block_stage cannot hold completed_block alternative */ const pending_block_header_state& get_pending_block_header_state()const { @@ -226,32 +226,32 @@ struct controller_impl { reset_new_handler() { std::set_new_handler([](){ throw std::bad_alloc(); }); } }; - reset_new_handler rnh; // placed here to allow for this to be set before constructing the other fields - controller& self; - std::function shutdown; - chainbase::database db; - chainbase::database reversible_blocks; ///< a special database to persist blocks that have successfully been applied but are still reversible - block_log blog; - optional pending; - block_state_ptr head; - fork_database fork_db; - wasm_interface wasmif; - resource_limits_manager resource_limits; - authorization_manager authorization; - protocol_feature_manager protocol_features; - controller::config conf; - const chain_id_type chain_id; // read by thread_pool threads, value will not be changed - optional replay_head_time; - db_read_mode read_mode = db_read_mode::SPECULATIVE; - bool in_trx_requiring_checks = false; ///< if true, checks that are normally skipped on replay (e.g. auth checks) cannot be skipped - optional subjective_cpu_leeway; - bool trusted_producer_light_validation = false; - uint32_t snapshot_head_block = 0; - named_thread_pool thread_pool; - platform_timer timer; - fc::logger* deep_mind_logger = nullptr; + reset_new_handler rnh; // placed here to allow for this to be set before constructing the other fields + controller& self; + std::function shutdown; + chainbase::database db; + chainbase::database reversible_blocks; ///< a special database to persist blocks that have successfully been applied but are still reversible + block_log blog; + std::optional pending; + block_state_ptr head; + fork_database fork_db; + wasm_interface wasmif; + resource_limits_manager resource_limits; + authorization_manager authorization; + protocol_feature_manager protocol_features; + controller::config conf; + const chain_id_type chain_id; // read by thread_pool threads, value will not be changed + std::optional replay_head_time; + db_read_mode read_mode = db_read_mode::SPECULATIVE; + bool in_trx_requiring_checks = false; ///< if true, checks that are normally skipped on replay (e.g. auth checks) cannot be skipped + std::optional subjective_cpu_leeway; + bool trusted_producer_light_validation = false; + uint32_t snapshot_head_block = 0; + named_thread_pool thread_pool; + platform_timer timer; + fc::logger* deep_mind_logger = nullptr; #if defined(EOSIO_EOS_VM_RUNTIME_ENABLED) || defined(EOSIO_EOS_VM_JIT_RUNTIME_ENABLED) - vm::wasm_allocator wasm_alloc; + vm::wasm_allocator wasm_alloc; #endif typedef pair handler_key; @@ -892,8 +892,8 @@ struct controller_impl { resource_limits.add_to_snapshot(snapshot); } - static fc::optional extract_legacy_genesis_state( snapshot_reader& snapshot, uint32_t version ) { - fc::optional genesis; + static std::optional extract_legacy_genesis_state( snapshot_reader& snapshot, uint32_t version ) { + std::optional genesis; using v2 = legacy::snapshot_global_property_object_v2; if (std::clamp(version, v2::minimum_version, v2::maximum_version) == version ) { @@ -962,7 +962,7 @@ struct controller_impl { using v3 = legacy::snapshot_global_property_object_v3; if (std::clamp(header.version, v2::minimum_version, v2::maximum_version) == header.version ) { - fc::optional genesis = extract_legacy_genesis_state(*snapshot, header.version); + std::optional genesis = extract_legacy_genesis_state(*snapshot, header.version); EOS_ASSERT( genesis, snapshot_exception, "Snapshot indicates chain_snapshot_header version 2, but does not contain a genesis_state. " "It must be corrupted."); @@ -1478,7 +1478,7 @@ struct controller_impl { fc::time_point deadline, uint32_t billed_cpu_time_us, bool explicit_billed_cpu_time, - fc::optional explicit_net_usage_words ) + std::optional explicit_net_usage_words ) { EOS_ASSERT(deadline != fc::time_point(), transaction_exception, "deadline cannot be uninitialized"); @@ -1510,7 +1510,7 @@ struct controller_impl { try { const transaction& trn = trx->packed_trx()->get_transaction(); if( trx->implicit ) { - EOS_ASSERT( !explicit_net_usage_words.valid(), transaction_exception, "NET usage cannot be explicitly set for implicit transactions" ); + EOS_ASSERT( !explicit_net_usage_words, transaction_exception, "NET usage cannot be explicitly set for implicit transactions" ); trx_context.init_for_implicit_trx(); trx_context.enforce_whiteblacklist = false; } else { @@ -1596,7 +1596,7 @@ struct controller_impl { uint16_t confirm_block_count, const vector& new_protocol_feature_activations, controller::block_status s, - const optional& producer_block_id ) + const std::optional& producer_block_id ) { EOS_ASSERT( !pending, block_validate_exception, "pending block already exists" ); @@ -1697,7 +1697,7 @@ struct controller_impl { const auto& gpo = self.get_global_properties(); - if( gpo.proposed_schedule_block_num.valid() && // if there is a proposed schedule that was proposed in a block ... + if( gpo.proposed_schedule_block_num && // if there is a proposed schedule that was proposed in a block ... ( *gpo.proposed_schedule_block_num <= pbhs.dpos_irreversible_blocknum ) && // ... that has now become irreversible ... pbhs.prev_pending_schedule.schedule.producers.size() == 0 // ... and there was room for a new pending schedule prior to any possible promotion ) @@ -1715,7 +1715,7 @@ struct controller_impl { pending->_block_stage.get()._new_pending_producer_schedule = producer_authority_schedule::from_shared(gpo.proposed_schedule); db.modify( gpo, [&]( auto& gp ) { - gp.proposed_schedule_block_num = optional(); + gp.proposed_schedule_block_num = std::optional(); gp.proposed_schedule.version=0; gp.proposed_schedule.producers.clear(); }); @@ -1973,7 +1973,7 @@ struct controller_impl { : ( !!std::get<0>( trx_metas.at( packed_idx ) ) ? std::get<0>( trx_metas.at( packed_idx ) ) : std::get<1>( trx_metas.at( packed_idx ) ).get() ) ); - fc::optional explicit_net_usage_words; + std::optional explicit_net_usage_words; if( explicit_net ) { explicit_net_usage_words = receipt.net_usage_words.value; } @@ -2198,7 +2198,7 @@ struct controller_impl { } for( auto ritr = branches.first.rbegin(); ritr != branches.first.rend(); ++ritr ) { - optional except; + std::optional except; try { apply_block( *ritr, (*ritr)->is_valid() ? controller::block_status::validated : controller::block_status::complete, trx_lookup ); @@ -2722,7 +2722,7 @@ void controller::start_block( block_timestamp_type when, uint16_t confirm_block_ } my->start_block( when, confirm_block_count, new_protocol_feature_activations, - block_status::incomplete, optional() ); + block_status::incomplete, std::optional() ); } void controller::start_block( block_timestamp_type when, @@ -2736,7 +2736,7 @@ void controller::start_block( block_timestamp_type when, } my->start_block( when, confirm_block_count, new_protocol_feature_activations, - block_status::incomplete, optional() ); + block_status::incomplete, std::optional() ); } block_state_ptr controller::finalize_block( const signer_callback_type& signer_callback ) { @@ -2925,7 +2925,7 @@ const block_signing_authority& controller::pending_block_signing_authority()cons return my->pending->get_pending_block_header_state().valid_block_signing_authority; } -optional controller::pending_producer_block_id()const { +std::optional controller::pending_producer_block_id()const { EOS_ASSERT( my->pending, block_validate_exception, "no pending block" ); return my->pending->_producer_block_id; } @@ -3043,7 +3043,7 @@ int64_t controller::set_proposed_producers( vector producers return -1; } - if( gpo.proposed_schedule_block_num.valid() ) { + if( gpo.proposed_schedule_block_num ) { if( *gpo.proposed_schedule_block_num != cur_block_num ) return -1; // there is already a proposed schedule set in a previous block, wait for it to become pending @@ -3118,10 +3118,10 @@ const producer_authority_schedule& controller::pending_producers()const { return bb._pending_block_header_state.prev_pending_schedule.schedule; } -optional controller::proposed_producers()const { +std::optional controller::proposed_producers()const { const auto& gpo = get_global_properties(); - if( !gpo.proposed_schedule_block_num.valid() ) - return optional(); + if( !gpo.proposed_schedule_block_num ) + return std::optional(); return producer_authority_schedule::from_shared(gpo.proposed_schedule); } @@ -3232,7 +3232,7 @@ void controller::check_key_list( const public_key_type& key )const { } bool controller::is_building_block()const { - return my->pending.valid(); + return my->pending.has_value(); } bool controller::is_producing_block()const { @@ -3312,7 +3312,7 @@ void controller::set_subjective_cpu_leeway(fc::microseconds leeway) { my->subjective_cpu_leeway = leeway; } -fc::optional controller::get_subjective_cpu_leeway() const { +std::optional controller::get_subjective_cpu_leeway() const { return my->subjective_cpu_leeway; } @@ -3397,7 +3397,7 @@ vm::wasm_allocator& controller::get_wasm_allocator() { } #endif -fc::optional controller::convert_exception_to_error_code( const fc::exception& e ) { +std::optional controller::convert_exception_to_error_code( const fc::exception& e ) { const chain_exception* e_ptr = dynamic_cast( &e ); if( e_ptr == nullptr ) return {}; @@ -3415,7 +3415,7 @@ chain_id_type controller::extract_chain_id(snapshot_reader& snapshot) { }); // check if this is a legacy version of the snapshot, which has a genesis state instead of chain id - fc::optional genesis = controller_impl::extract_legacy_genesis_state(snapshot, header.version); + std::optional genesis = controller_impl::extract_legacy_genesis_state(snapshot, header.version); if (genesis) { return genesis->compute_chain_id(); } @@ -3429,7 +3429,7 @@ chain_id_type controller::extract_chain_id(snapshot_reader& snapshot) { return chain_id; } -fc::optional controller::extract_chain_id_from_db( const path& state_dir ) { +std::optional controller::extract_chain_id_from_db( const path& state_dir ) { try { chainbase::database db( state_dir, chainbase::database::read_only ); diff --git a/libraries/chain/include/eosio/chain/abi_serializer.hpp b/libraries/chain/include/eosio/chain/abi_serializer.hpp index fff2dd94439..61edfaee191 100644 --- a/libraries/chain/include/eosio/chain/abi_serializer.hpp +++ b/libraries/chain/include/eosio/chain/abi_serializer.hpp @@ -58,7 +58,7 @@ struct abi_serializer { type_name get_kv_table_type(name action)const; type_name get_action_result_type(name action_result)const; - optional get_error_message( uint64_t error_code )const; + std::optional get_error_message( uint64_t error_code )const; fc::variant binary_to_variant( const std::string_view& type, const bytes& binary, const yield_function_t& yield, bool short_path = false )const; fc::variant binary_to_variant( const std::string_view& type, fc::datastream& binary, const yield_function_t& yield, bool short_path = false )const; @@ -425,7 +425,7 @@ namespace impl { try { auto abi = resolver(act.account); - if (abi.valid()) { + if (abi) { auto type = abi->get_action_type(act.name); if (!type.empty()) { try { @@ -487,7 +487,7 @@ namespace impl { auto act = act_trace.act; try { auto abi = resolver(act.account); - if (abi.valid()) { + if (abi) { auto type = abi->get_action_result_type(act.name); if (!type.empty()) { binary_to_variant_context _ctx(*abi, ctx, type); @@ -665,7 +665,7 @@ namespace impl { * this will degrade to the common fc::to_variant as soon as the type no longer contains * ABI related info * - * @tparam Reslover - callable with the signature (const name& code_account) -> optional + * @tparam Reslover - callable with the signature (const name& code_account) -> std::optional */ template class abi_to_variant_visitor @@ -793,7 +793,7 @@ namespace impl { valid_empty_data = act.data.empty(); } else if ( data.is_object() ) { auto abi = resolver(act.account); - if (abi.valid()) { + if (abi) { auto type = abi->get_action_type(act.name); if (!type.empty()) { variant_to_binary_context _ctx(*abi, ctx, type); @@ -871,7 +871,7 @@ namespace impl { * this will degrade to the common fc::from_variant as soon as the type no longer contains * ABI related info * - * @tparam Reslover - callable with the signature (const name& code_account) -> optional + * @tparam Reslover - callable with the signature (const name& code_account) -> std::optional */ template class abi_from_variant_visitor : public reflector_init_visitor diff --git a/libraries/chain/include/eosio/chain/authority_checker.hpp b/libraries/chain/include/eosio/chain/authority_checker.hpp index b79971295ae..16a3f954090 100644 --- a/libraries/chain/include/eosio/chain/authority_checker.hpp +++ b/libraries/chain/include/eosio/chain/authority_checker.hpp @@ -129,7 +129,7 @@ namespace detail { return {range.begin(), range.end()}; } - static optional + static std::optional permission_status_in_cache( const permission_cache_type& permissions, const permission_level& level ) { @@ -141,7 +141,7 @@ namespace detail { if( itr != permissions.end() ) return itr->second; - return optional(); + return std::optional(); } private: diff --git a/libraries/chain/include/eosio/chain/authorization_manager.hpp b/libraries/chain/include/eosio/chain/authorization_manager.hpp index df441c1eb2c..a61770c3fdb 100644 --- a/libraries/chain/include/eosio/chain/authorization_manager.hpp +++ b/libraries/chain/include/eosio/chain/authorization_manager.hpp @@ -61,10 +61,10 @@ namespace eosio { namespace chain { * @param code_account The account which publishes the contract that handles the message * @param type The type of message */ - optional lookup_minimum_permission( account_name authorizer_account, - scope_name code_account, - action_name type - )const; + std::optional lookup_minimum_permission( account_name authorizer_account, + scope_name code_account, + action_name type + )const; /** * @brief Check authorizations of a vector of actions with provided keys, permission levels, and delay @@ -126,10 +126,10 @@ namespace eosio { namespace chain { void check_unlinkauth_authorization( const unlinkauth& unlink, const vector& auths )const; fc::microseconds check_canceldelay_authorization( const canceldelay& cancel, const vector& auths )const; - optional lookup_linked_permission( account_name authorizer_account, - scope_name code_account, - action_name type - )const; + std::optional lookup_linked_permission( account_name authorizer_account, + scope_name code_account, + action_name type + )const; }; } } /// namespace eosio::chain diff --git a/libraries/chain/include/eosio/chain/block.hpp b/libraries/chain/include/eosio/chain/block.hpp index 7053993a99f..5850c6c2350 100644 --- a/libraries/chain/include/eosio/chain/block.hpp +++ b/libraries/chain/include/eosio/chain/block.hpp @@ -144,7 +144,7 @@ namespace eosio { namespace chain { signed_block& operator=(const signed_block&) = delete; signed_block& operator=(signed_block&&) = default; signed_block clone() const { return *this; } - fc::optional to_signed_block_v0() const; + std::optional to_signed_block_v0() const; fc::enum_type prune_state{prune_state_type::complete_legacy}; deque transactions; /// new or generated transactions diff --git a/libraries/chain/include/eosio/chain/block_header.hpp b/libraries/chain/include/eosio/chain/block_header.hpp index faf00797de7..9f1d5b130b7 100644 --- a/libraries/chain/include/eosio/chain/block_header.hpp +++ b/libraries/chain/include/eosio/chain/block_header.hpp @@ -53,7 +53,7 @@ namespace eosio { namespace chain { * irreversible and that it the new producer schedule takes effect this block. */ - using new_producers_type = optional; + using new_producers_type = std::optional; uint32_t schedule_version = 0; new_producers_type new_producers; diff --git a/libraries/chain/include/eosio/chain/block_header_state.hpp b/libraries/chain/include/eosio/chain/block_header_state.hpp index c3eef9a032d..259a593fa21 100644 --- a/libraries/chain/include/eosio/chain/block_header_state.hpp +++ b/libraries/chain/include/eosio/chain/block_header_state.hpp @@ -83,7 +83,7 @@ struct pending_block_header_state : public detail::block_header_state_common { signed_block_header make_block_header( const checksum256_type& transaction_mroot, const checksum256_type& action_mroot, - const optional& new_producers, + const std::optional& new_producers, vector&& new_protocol_feature_activations, const protocol_feature_set& pfs)const; diff --git a/libraries/chain/include/eosio/chain/block_log.hpp b/libraries/chain/include/eosio/chain/block_log.hpp index fe6e6e9b10f..d1aa26a1a5e 100644 --- a/libraries/chain/include/eosio/chain/block_log.hpp +++ b/libraries/chain/include/eosio/chain/block_log.hpp @@ -72,7 +72,7 @@ namespace eosio { namespace chain { static fc::path repair_log( const fc::path& data_dir, uint32_t truncate_at_block = UINT32_MAX, const char* reversible_block_dir_name="" ); - static fc::optional extract_genesis_state( const fc::path& data_dir ); + static std::optional extract_genesis_state( const fc::path& data_dir ); static chain_id_type extract_chain_id( const fc::path& data_dir ); diff --git a/libraries/chain/include/eosio/chain/block_timestamp.hpp b/libraries/chain/include/eosio/chain/block_timestamp.hpp index 821e44efbff..a20f609ddcc 100644 --- a/libraries/chain/include/eosio/chain/block_timestamp.hpp +++ b/libraries/chain/include/eosio/chain/block_timestamp.hpp @@ -5,7 +5,6 @@ #include #include #include -#include #include namespace eosio { namespace chain { diff --git a/libraries/chain/include/eosio/chain/controller.hpp b/libraries/chain/include/eosio/chain/controller.hpp index 44620f09a8c..41150618cfb 100644 --- a/libraries/chain/include/eosio/chain/controller.hpp +++ b/libraries/chain/include/eosio/chain/controller.hpp @@ -225,13 +225,13 @@ namespace eosio { namespace chain { time_point pending_block_time()const; account_name pending_block_producer()const; const block_signing_authority& pending_block_signing_authority()const; - optional pending_producer_block_id()const; + std::optional pending_producer_block_id()const; const deque& get_pending_trx_receipts()const; - const producer_authority_schedule& active_producers()const; - const producer_authority_schedule& pending_producers()const; - optional proposed_producers()const; + const producer_authority_schedule& active_producers()const; + const producer_authority_schedule& pending_producers()const; + std::optional proposed_producers()const; uint32_t last_irreversible_block_num() const; block_id_type last_irreversible_block_id() const; @@ -296,7 +296,7 @@ namespace eosio { namespace chain { uint32_t get_terminate_at_block()const; void set_subjective_cpu_leeway(fc::microseconds leeway); - fc::optional get_subjective_cpu_leeway() const; + std::optional get_subjective_cpu_leeway() const; void set_greylist_limit( uint32_t limit ); uint32_t get_greylist_limit()const; @@ -312,7 +312,7 @@ namespace eosio { namespace chain { vm::wasm_allocator& get_wasm_allocator(); #endif - static fc::optional convert_exception_to_error_code( const fc::exception& e ); + static std::optional convert_exception_to_error_code( const fc::exception& e ); signal block_start; // block_num signal pre_accepted_block; @@ -337,7 +337,7 @@ namespace eosio { namespace chain { wasm_interface& get_wasm_interface(); - optional get_abi_serializer( account_name n, const abi_serializer::yield_function_t& yield )const { + std::optional get_abi_serializer( account_name n, const abi_serializer::yield_function_t& yield )const { if( n.good() ) { try { const auto& a = get_account( n ); @@ -346,7 +346,7 @@ namespace eosio { namespace chain { return abi_serializer( abi, yield ); } FC_CAPTURE_AND_LOG((n)) } - return optional(); + return std::optional(); } template @@ -369,7 +369,7 @@ namespace eosio { namespace chain { static chain_id_type extract_chain_id(snapshot_reader& snapshot); - static fc::optional extract_chain_id_from_db( const path& state_dir ); + static std::optional extract_chain_id_from_db( const path& state_dir ); void replace_producer_keys( const public_key_type& key ); void replace_account_keys( name account, name permission, const public_key_type& key ); diff --git a/libraries/chain/include/eosio/chain/exceptions.hpp b/libraries/chain/include/eosio/chain/exceptions.hpp index ab4a0307b1d..26f133f99a5 100644 --- a/libraries/chain/include/eosio/chain/exceptions.hpp +++ b/libraries/chain/include/eosio/chain/exceptions.hpp @@ -125,7 +125,7 @@ { if( code() == CODE ) throw *this;\ else fc::exception::dynamic_rethrow_exception(); \ } \ - fc::optional error_code; \ + std::optional error_code; \ }; namespace eosio { namespace chain { diff --git a/libraries/chain/include/eosio/chain/global_property_object.hpp b/libraries/chain/include/eosio/chain/global_property_object.hpp index 8536f23860f..51c5eb10cf3 100644 --- a/libraries/chain/include/eosio/chain/global_property_object.hpp +++ b/libraries/chain/include/eosio/chain/global_property_object.hpp @@ -26,7 +26,7 @@ namespace eosio { namespace chain { static constexpr uint32_t maximum_version = 2; static_assert(chain_snapshot_header::minimum_compatible_version <= maximum_version, "snapshot_global_property_object_v2 is no longer needed"); - optional proposed_schedule_block_num; + std::optional proposed_schedule_block_num; producer_schedule_type proposed_schedule; chain_config_v0 configuration; }; @@ -35,7 +35,7 @@ namespace eosio { namespace chain { static constexpr uint32_t maximum_version = 3; static_assert(chain_snapshot_header::minimum_compatible_version <= maximum_version, "snapshot_global_property_object_v3 is no longer needed"); - optional proposed_schedule_block_num; + std::optional proposed_schedule_block_num; producer_authority_schedule proposed_schedule; chain_config_v0 configuration; chain_id_type chain_id; @@ -54,7 +54,7 @@ namespace eosio { namespace chain { public: id_type id; - optional proposed_schedule_block_num; + std::optional proposed_schedule_block_num; shared_producer_authority_schedule proposed_schedule; chain_config configuration; chain_id_type chain_id; @@ -91,7 +91,7 @@ namespace eosio { namespace chain { >; struct snapshot_global_property_object { - optional proposed_schedule_block_num; + std::optional proposed_schedule_block_num; producer_authority_schedule proposed_schedule; chain_config configuration; chain_id_type chain_id; diff --git a/libraries/chain/include/eosio/chain/protocol_feature_manager.hpp b/libraries/chain/include/eosio/chain/protocol_feature_manager.hpp index 1fd0ad9db84..22b0df48905 100644 --- a/libraries/chain/include/eosio/chain/protocol_feature_manager.hpp +++ b/libraries/chain/include/eosio/chain/protocol_feature_manager.hpp @@ -94,13 +94,13 @@ class builtin_protocol_feature : public protocol_feature_base { }; struct protocol_feature { - digest_type feature_digest; - digest_type description_digest; - flat_set dependencies; - time_point earliest_allowed_activation_time; - bool preactivation_required = false; - bool enabled = false; - optional builtin_feature; + digest_type feature_digest; + digest_type description_digest; + flat_set dependencies; + time_point earliest_allowed_activation_time; + bool preactivation_required = false; + bool enabled = false; + std::optional builtin_feature; fc::variant to_variant( bool include_subjective_restrictions = true, fc::mutable_variant_object* additional_fields = nullptr )const; @@ -134,7 +134,7 @@ class protocol_feature_set { recognized_t is_recognized( const digest_type& feature_digest, time_point now )const; - optional get_builtin_digest( builtin_protocol_feature_t feature_codename )const; + std::optional get_builtin_digest( builtin_protocol_feature_t feature_codename )const; const protocol_feature& get_protocol_feature( const digest_type& feature_digest )const; @@ -317,7 +317,7 @@ class protocol_feature_manager { const protocol_feature_set& get_protocol_feature_set()const { return _protocol_feature_set; } - optional get_builtin_digest( builtin_protocol_feature_t feature_codename )const { + std::optional get_builtin_digest( builtin_protocol_feature_t feature_codename )const { return _protocol_feature_set.get_builtin_digest( feature_codename ); } diff --git a/libraries/chain/include/eosio/chain/resource_limits.hpp b/libraries/chain/include/eosio/chain/resource_limits.hpp index a49fbf36276..5eeaa8d7514 100644 --- a/libraries/chain/include/eosio/chain/resource_limits.hpp +++ b/libraries/chain/include/eosio/chain/resource_limits.hpp @@ -98,9 +98,9 @@ namespace eosio { namespace chain { namespace resource_limits { std::pair get_account_net_limit( const account_name& name, uint32_t greylist_limit = config::maximum_elastic_resource_multiplier ) const; std::pair - get_account_cpu_limit_ex( const account_name& name, uint32_t greylist_limit = config::maximum_elastic_resource_multiplier, const fc::optional& current_time={} ) const; + get_account_cpu_limit_ex( const account_name& name, uint32_t greylist_limit = config::maximum_elastic_resource_multiplier, const std::optional& current_time={} ) const; std::pair - get_account_net_limit_ex( const account_name& name, uint32_t greylist_limit = config::maximum_elastic_resource_multiplier, const fc::optional& current_time={} ) const; + get_account_net_limit_ex( const account_name& name, uint32_t greylist_limit = config::maximum_elastic_resource_multiplier, const std::optional& current_time={} ) const; int64_t get_account_ram_usage( const account_name& name ) const; diff --git a/libraries/chain/include/eosio/chain/thread_utils.hpp b/libraries/chain/include/eosio/chain/thread_utils.hpp index 3ec462d5402..1645034a0eb 100644 --- a/libraries/chain/include/eosio/chain/thread_utils.hpp +++ b/libraries/chain/include/eosio/chain/thread_utils.hpp @@ -1,6 +1,5 @@ #pragma once -#include #include #include #include @@ -32,7 +31,7 @@ namespace eosio { namespace chain { boost::asio::thread_pool _thread_pool; boost::asio::io_context _ioc; - fc::optional _ioc_work; + std::optional _ioc_work; }; diff --git a/libraries/chain/include/eosio/chain/trace.hpp b/libraries/chain/include/eosio/chain/trace.hpp index ca2b2d937a1..a6ad3c7f45c 100644 --- a/libraries/chain/include/eosio/chain/trace.hpp +++ b/libraries/chain/include/eosio/chain/trace.hpp @@ -31,7 +31,7 @@ namespace eosio { namespace chain { fc::unsigned_int action_ordinal; fc::unsigned_int creator_action_ordinal; fc::unsigned_int closest_unnotified_ancestor_action_ordinal; - fc::optional receipt; + std::optional receipt; action_name receiver; action act; bool context_free = false; @@ -40,11 +40,11 @@ namespace eosio { namespace chain { transaction_id_type trx_id; ///< the transaction that generated this action uint32_t block_num = 0; block_timestamp_type block_time; - fc::optional producer_block_id; + std::optional producer_block_id; flat_set account_ram_deltas; flat_set account_disk_deltas; - fc::optional except; - fc::optional error_code; + std::optional except; + std::optional error_code; std::vector return_value; }; @@ -52,17 +52,17 @@ namespace eosio { namespace chain { transaction_id_type id; uint32_t block_num = 0; block_timestamp_type block_time; - fc::optional producer_block_id; - fc::optional receipt; + std::optional producer_block_id; + std::optional receipt; fc::microseconds elapsed; uint64_t net_usage = 0; bool scheduled = false; vector action_traces; - fc::optional account_ram_delta; + std::optional account_ram_delta; transaction_trace_ptr failed_dtrx_trace; - fc::optional except; - fc::optional error_code; + std::optional except; + std::optional error_code; std::exception_ptr except_ptr; }; diff --git a/libraries/chain/include/eosio/chain/transaction_context.hpp b/libraries/chain/include/eosio/chain/transaction_context.hpp index 0dbfcf6d912..f0771d12818 100644 --- a/libraries/chain/include/eosio/chain/transaction_context.hpp +++ b/libraries/chain/include/eosio/chain/transaction_context.hpp @@ -150,11 +150,11 @@ namespace eosio { namespace chain { /// Fields: public: - controller& control; - const packed_transaction& packed_trx; - optional undo_session; - transaction_trace_ptr trace; - fc::time_point start; + controller& control; + const packed_transaction& packed_trx; + std::optional undo_session; + transaction_trace_ptr trace; + fc::time_point start; fc::time_point published; diff --git a/libraries/chain/include/eosio/chain/types.hpp b/libraries/chain/include/eosio/chain/types.hpp index 9c7ef150369..780e74492eb 100644 --- a/libraries/chain/include/eosio/chain/types.hpp +++ b/libraries/chain/include/eosio/chain/types.hpp @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include @@ -66,7 +65,6 @@ namespace eosio { namespace chain { using fc::variant_object; using fc::variant; using fc::enum_type; - using fc::optional; using fc::unsigned_int; using fc::signed_int; using fc::time_point_sec; @@ -408,7 +406,7 @@ namespace eosio { namespace chain { struct decompose<> { template static auto extract( uint16_t id, const vector& data, ResultVariant& result ) - -> fc::optional + -> std::optional { return {}; } @@ -421,7 +419,7 @@ namespace eosio { namespace chain { template static auto extract( uint16_t id, const vector& data, ResultVariant& result ) - -> fc::optional + -> std::optional { if( id == head_t::extension_id() ) { result = fc::raw::unpack( data ); diff --git a/libraries/chain/include/eosio/chain/wasm_eosio_binary_ops.hpp b/libraries/chain/include/eosio/chain/wasm_eosio_binary_ops.hpp index cc6149f5ba9..36c6327981c 100644 --- a/libraries/chain/include/eosio/chain/wasm_eosio_binary_ops.hpp +++ b/libraries/chain/include/eosio/chain/wasm_eosio_binary_ops.hpp @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include diff --git a/libraries/chain/include/eosio/chain/wasm_interface_private.hpp b/libraries/chain/include/eosio/chain/wasm_interface_private.hpp index 68a002713ee..3e15ed824de 100644 --- a/libraries/chain/include/eosio/chain/wasm_interface_private.hpp +++ b/libraries/chain/include/eosio/chain/wasm_interface_private.hpp @@ -213,7 +213,7 @@ namespace eosio { namespace chain { const wasm_interface::vm_type wasm_runtime_time; #ifdef EOSIO_EOS_VM_OC_RUNTIME_ENABLED - fc::optional eosvmoc; + std::optional eosvmoc; #endif }; diff --git a/libraries/chain/include/eosio/chain/webassembly/eos-vm-oc/ipc_protocol.hpp b/libraries/chain/include/eosio/chain/webassembly/eos-vm-oc/ipc_protocol.hpp index 01d9cc91d06..98949c4f79c 100644 --- a/libraries/chain/include/eosio/chain/webassembly/eos-vm-oc/ipc_protocol.hpp +++ b/libraries/chain/include/eosio/chain/webassembly/eos-vm-oc/ipc_protocol.hpp @@ -11,7 +11,7 @@ struct initialize_message { }; struct initalize_response_message { - fc::optional error_message; //no error message? everything groovy + std::optional error_message; //no error message? everything groovy }; struct code_tuple { diff --git a/libraries/chain/protocol_feature_manager.cpp b/libraries/chain/protocol_feature_manager.cpp index e97e87f7bb4..82da9deb542 100644 --- a/libraries/chain/protocol_feature_manager.cpp +++ b/libraries/chain/protocol_feature_manager.cpp @@ -388,7 +388,7 @@ Allows privileged contracts to get and set subsets of blockchain parameters. return recognized_t::ready; } - optional protocol_feature_set::get_builtin_digest( builtin_protocol_feature_t feature_codename )const { + std::optional protocol_feature_set::get_builtin_digest( builtin_protocol_feature_t feature_codename )const { uint32_t indx = static_cast( feature_codename ); if( indx >= _recognized_builtin_protocol_features.size() ) diff --git a/libraries/chain/resource_limits.cpp b/libraries/chain/resource_limits.cpp index bef37ed2ae8..3c8bcc90fb9 100644 --- a/libraries/chain/resource_limits.cpp +++ b/libraries/chain/resource_limits.cpp @@ -446,7 +446,7 @@ std::pair resource_limits_manager::get_account_cpu_limit( const a } std::pair -resource_limits_manager::get_account_cpu_limit_ex( const account_name& name, uint32_t greylist_limit, const fc::optional& current_time) const { +resource_limits_manager::get_account_cpu_limit_ex( const account_name& name, uint32_t greylist_limit, const std::optional& current_time) const { const auto& state = _db.get(); const auto& usage = _db.get(name); @@ -492,7 +492,7 @@ resource_limits_manager::get_account_cpu_limit_ex( const account_name& name, uin arl.max = impl::downgrade_cast(max_user_use_in_window); arl.last_usage_update_time = block_timestamp_type(usage.cpu_usage.last_ordinal); arl.current_used = arl.used; - if ( current_time.valid() ) { + if ( current_time ) { if (current_time->slot > usage.cpu_usage.last_ordinal) { auto history_usage = usage.cpu_usage; history_usage.add(0, current_time->slot, window_size); @@ -508,7 +508,7 @@ std::pair resource_limits_manager::get_account_net_limit( const a } std::pair -resource_limits_manager::get_account_net_limit_ex( const account_name& name, uint32_t greylist_limit, const fc::optional& current_time) const { +resource_limits_manager::get_account_net_limit_ex( const account_name& name, uint32_t greylist_limit, const std::optional& current_time) const { const auto& config = _db.get(); const auto& state = _db.get(); const auto& usage = _db.get(name); @@ -553,7 +553,7 @@ resource_limits_manager::get_account_net_limit_ex( const account_name& name, uin arl.max = impl::downgrade_cast(max_user_use_in_window); arl.last_usage_update_time = block_timestamp_type(usage.net_usage.last_ordinal); arl.current_used = arl.used; - if ( current_time.valid() ) { + if ( current_time ) { if (current_time->slot > usage.net_usage.last_ordinal) { auto history_usage = usage.net_usage; history_usage.add(0, current_time->slot, window_size); diff --git a/libraries/chain/transaction_context.cpp b/libraries/chain/transaction_context.cpp index 9d191b5cad9..11981eb6097 100644 --- a/libraries/chain/transaction_context.cpp +++ b/libraries/chain/transaction_context.cpp @@ -57,7 +57,7 @@ namespace eosio { namespace chain { ,pseudo_start(s) { if (!c.skip_db_sessions()) { - undo_session = c.mutable_db().start_undo_session(true); + undo_session.emplace(c.mutable_db().start_undo_session(true)); } trace->id = packed_trx.id(); trace->block_num = c.head_block_num() + 1; diff --git a/libraries/fc/include/fc/exception/exception.hpp b/libraries/fc/include/fc/exception/exception.hpp index 83ebb338eb2..c8565ccdd75 100644 --- a/libraries/fc/include/fc/exception/exception.hpp +++ b/libraries/fc/include/fc/exception/exception.hpp @@ -4,7 +4,6 @@ * @brief Defines exception's used by fc */ #include -#include #include #include #include @@ -139,7 +138,7 @@ namespace fc void from_variant( const variant& e, exception& ll ); typedef std::shared_ptr exception_ptr; - typedef optional oexception; + typedef std::optional oexception; /** diff --git a/libraries/fc/include/fc/filesystem.hpp b/libraries/fc/include/fc/filesystem.hpp index e3bfc3fa158..389c6108251 100644 --- a/libraries/fc/include/fc/filesystem.hpp +++ b/libraries/fc/include/fc/filesystem.hpp @@ -4,7 +4,6 @@ #include #include -#include #include namespace boost { @@ -195,13 +194,13 @@ namespace fc { { public: inline ~temp_file_base() { remove(); } - inline operator bool() const { return _path.valid(); } - inline bool operator!() const { return !_path; } + inline operator bool() const { return _path.has_value(); } + inline bool operator!() const { return !_path.has_value(); } const fc::path& path() const; void remove(); void release(); protected: - typedef fc::optional path_t; + typedef std::optional path_t; inline temp_file_base(const path_t& path) : _path(path) {} inline temp_file_base(path_t&& path) : _path(std::move(path)) {} path_t _path; diff --git a/libraries/fc/include/fc/io/raw.hpp b/libraries/fc/include/fc/io/raw.hpp index b861bb4ced7..e206c4c6702 100644 --- a/libraries/fc/include/fc/io/raw.hpp +++ b/libraries/fc/include/fc/io/raw.hpp @@ -3,7 +3,6 @@ #include #include #include -#include #include #include #include @@ -268,13 +267,13 @@ namespace fc { // optional template - void pack( Stream& s, const fc::optional& v ) { - fc::raw::pack( s, bool(!!v) ); - if( !!v ) fc::raw::pack( s, *v ); + void pack( Stream& s, const std::optional& v ) { + fc::raw::pack( s, v.has_value() ); + if( v ) fc::raw::pack( s, *v ); } template - void unpack( Stream& s, fc::optional& v ) + void unpack( Stream& s, std::optional& v ) { try { bool b; fc::raw::unpack( s, b ); if( b ) { v = T(); fc::raw::unpack( s, *v ); } diff --git a/libraries/fc/include/fc/io/raw_fwd.hpp b/libraries/fc/include/fc/io/raw_fwd.hpp index cb334cc67a2..e71d26ec3e3 100644 --- a/libraries/fc/include/fc/io/raw_fwd.hpp +++ b/libraries/fc/include/fc/io/raw_fwd.hpp @@ -83,9 +83,9 @@ namespace fc { template inline void unpack( Stream& s, ip::endpoint& v ); - template void unpack( Stream& s, fc::optional& v ); + template void unpack( Stream& s, std::optional& v ); template void unpack( Stream& s, const T& v ); - template void pack( Stream& s, const fc::optional& v ); + template void pack( Stream& s, const std::optional& v ); template void pack( Stream& s, const safe& v ); template void unpack( Stream& s, fc::safe& v ); diff --git a/libraries/fc/include/fc/log/logger_config.hpp b/libraries/fc/include/fc/log/logger_config.hpp index ffcb2f978a4..04de647d503 100644 --- a/libraries/fc/include/fc/log/logger_config.hpp +++ b/libraries/fc/include/fc/log/logger_config.hpp @@ -28,11 +28,11 @@ namespace fc { string name; ostring parent; /// if not set, then parents level is used. - fc::optional level; + std::optional level; bool enabled; /// if any appenders are sepecified, then parent's appenders are not set. bool additivity; - std::vector appenders; + std::vector appenders; }; struct logging_config { diff --git a/libraries/fc/include/fc/network/url.hpp b/libraries/fc/include/fc/network/url.hpp index 09007073ef0..c9cd47ce8cb 100644 --- a/libraries/fc/include/fc/network/url.hpp +++ b/libraries/fc/include/fc/network/url.hpp @@ -1,6 +1,5 @@ #pragma once #include -#include #include #include #include @@ -8,9 +7,9 @@ namespace fc { - typedef fc::optional ostring; - typedef fc::optional opath; - typedef fc::optional ovariant_object; + typedef std::optional ostring; + typedef std::optional opath; + typedef std::optional ovariant_object; namespace detail { class url_impl; } @@ -28,7 +27,7 @@ namespace fc { url( const url& c ); url( url&& c ); url( const string& proto, const ostring& host, const ostring& user, const ostring& pass, - const opath& path, const ostring& query, const ovariant_object& args, const fc::optional& port); + const opath& path, const ostring& query, const ovariant_object& args, const std::optional& port); ~url(); url& operator=( const url& c ); @@ -49,7 +48,7 @@ namespace fc { opath path()const; ostring query()const; ovariant_object args()const; - fc::optional port()const; + std::optional port()const; private: friend class mutable_url; diff --git a/libraries/fc/include/fc/optional.hpp b/libraries/fc/include/fc/optional.hpp deleted file mode 100644 index 520bbde418d..00000000000 --- a/libraries/fc/include/fc/optional.hpp +++ /dev/null @@ -1,276 +0,0 @@ -#pragma once -#include -#include - - -namespace fc { -#ifdef _MSC_VER -# pragma warning(push) -# pragma warning(disable:4521) /* multiple copy ctors */ -# pragma warning(disable:4522) /* multiple assignment operators */ -#endif - bool assert_optional(bool is_valid ); // defined in exception.cpp - - /** - * @brief provides stack-based nullable value similar to boost::optional - * - * Simply including boost::optional adds 35,000 lines to each object file, using - * fc::optional adds less than 400. - */ - template - class optional - { - public: - typedef T value_type; - typedef typename std::aligned_storage::type storage_type; - - optional():_valid(false){} - ~optional(){ reset(); } - - optional( optional& o ) - :_valid(false) - { - if( o._valid ) new (ptr()) T( *o ); - _valid = o._valid; - } - - optional( const optional& o ) - :_valid(false) - { - if( o._valid ) new (ptr()) T( *o ); - _valid = o._valid; - } - - optional( optional&& o ) - :_valid(false) - { - if( o._valid ) new (ptr()) T( fc::move(*o) ); - _valid = o._valid; - o.reset(); - } - - template - optional( const optional& o ) - :_valid(false) - { - if( o._valid ) new (ptr()) T( *o ); - _valid = o._valid; - } - - template - optional( optional& o ) - :_valid(false) - { - if( o._valid ) - { - new (ptr()) T( *o ); - } - _valid = o._valid; - } - - template - optional( optional&& o ) - :_valid(false) - { - if( o._valid ) new (ptr()) T( fc::move(*o) ); - _valid = o._valid; - o.reset(); - } - - template - optional( U&& u ) - :_valid(true) - { - new ((char*)ptr()) T( fc::forward(u) ); - } - - template - optional& operator=( U&& u ) - { - reset(); - new (ptr()) T( fc::forward(u) ); - _valid = true; - return *this; - } - - template - void emplace(Args&& ... args) { - if (_valid) { - reset(); - } - - new ((char*)ptr()) T( fc::forward(args)... ); - _valid = true; - } - - template - optional& operator=( optional& o ) { - if (this != &o) { - if( _valid && o._valid ) { - ref() = *o; - } else if( !_valid && o._valid ) { - new (ptr()) T( *o ); - _valid = true; - } else if (_valid) { - reset(); - } - } - return *this; - } - template - optional& operator=( const optional& o ) { - if (this != &o) { - if( _valid && o._valid ) { - ref() = *o; - } else if( !_valid && o._valid ) { - new (ptr()) T( *o ); - _valid = true; - } else if (_valid) { - reset(); - } - } - return *this; - } - - optional& operator=( optional& o ) { - if (this != &o) { - if( _valid && o._valid ) { - ref() = *o; - } else if( !_valid && o._valid ) { - new (ptr()) T( *o ); - _valid = true; - } else if (_valid) { - reset(); - } - } - return *this; - } - - optional& operator=( const optional& o ) { - if (this != &o) { - if( _valid && o._valid ) { - ref() = *o; - } else if( !_valid && o._valid ) { - new (ptr()) T( *o ); - _valid = true; - } else if (_valid) { - reset(); - } - } - return *this; - } - - template - optional& operator=( optional&& o ) - { - if (this != &o) - { - if( _valid && o._valid ) - { - ref() = fc::move(*o); - o.reset(); - } else if ( !_valid && o._valid ) { - *this = fc::move(*o); - } else if (_valid) { - reset(); - } - } - return *this; - } - - optional& operator=( optional&& o ) - { - if (this != &o) - { - if( _valid && o._valid ) - { - ref() = fc::move(*o); - o.reset(); - } else if ( !_valid && o._valid ) { - *this = fc::move(*o); - } else if (_valid) { - reset(); - } - } - return *this; - } - - bool valid()const { return _valid; } - bool operator!()const { return !_valid; } - - // this operation is not safe and can result in unintential - // casts and comparisons, use valid() or !! - explicit operator bool()const { return _valid; } - - T& operator*() { assert(_valid); return ref(); } - const T& operator*()const { assert(_valid); return ref(); } - - T* operator->() - { - assert(_valid); - return ptr(); - } - const T* operator->()const - { - assert(_valid); - return ptr(); - } - - optional& operator=(std::nullptr_t) - { - reset(); - return *this; - } - - friend bool operator < ( const optional a, optional b ) - { - if( a.valid() && b.valid() ) return *a < *b; - return a.valid() < b.valid(); - } - friend bool operator == ( const optional a, optional b ) - { - if( a.valid() && b.valid() ) return *a == *b; - return a.valid() == b.valid(); - } - - void reset() - { - if( _valid ) - { - ref().~T(); // cal destructor - } - _valid = false; - } - private: - template friend class optional; - T& ref() { return *ptr(); } - const T& ref()const { return *ptr(); } - T* ptr() { return reinterpret_cast(&_value); } - const T* ptr()const { return reinterpret_cast(&_value); } - - bool _valid; - storage_type _value; - }; - - template - bool operator == ( const optional& left, const optional& right ) { - return (!left == !right) || (!!left && *left == *right); - } - template - bool operator == ( const optional& left, const U& u ) { - return !!left && *left == u; - } - template - bool operator != ( const optional& left, const optional& right ) { - return (!left != !right) || (!!left && *left != *right); - } - template - bool operator != ( const optional& left, const U& u ) { - return !left || *left != u; - } - -#ifdef _MSC_VER -# pragma warning(pop) -#endif - -} // namespace fc diff --git a/libraries/fc/include/fc/reflect/typename.hpp b/libraries/fc/include/fc/reflect/typename.hpp index d96cfd9b248..889c8fefa8d 100644 --- a/libraries/fc/include/fc/reflect/typename.hpp +++ b/libraries/fc/include/fc/reflect/typename.hpp @@ -5,7 +5,6 @@ #include #include -#include #include #include @@ -58,7 +57,7 @@ namespace fc { return n.c_str(); } }; - template struct get_typename> + template struct get_typename> { static const char* name() { static std::string n = std::string("optional<") + get_typename::name() + ">"; diff --git a/libraries/fc/include/fc/reflect/variant.hpp b/libraries/fc/include/fc/reflect/variant.hpp index f26f73cbe15..15b4e309b1f 100644 --- a/libraries/fc/include/fc/reflect/variant.hpp +++ b/libraries/fc/include/fc/reflect/variant.hpp @@ -25,9 +25,9 @@ namespace fc private: template - void add( mutable_variant_object& vo, const char* name, const optional& v )const + void add( mutable_variant_object& vo, const char* name, const std::optional& v )const { - if( v.valid() ) + if( v ) vo(name,*v); } template diff --git a/libraries/fc/include/fc/rpc/api_connection.hpp b/libraries/fc/include/fc/rpc/api_connection.hpp index c2268ea724a..8cd6c94fa14 100644 --- a/libraries/fc/include/fc/rpc/api_connection.hpp +++ b/libraries/fc/include/fc/rpc/api_connection.hpp @@ -1,6 +1,5 @@ #pragma once #include -#include #include #include #include @@ -174,7 +173,7 @@ namespace fc { std::function to_generic( const std::function(Args...)>& f )const; template - std::function to_generic( const std::function>(Args...)>& f )const; + std::function to_generic( const std::function>(Args...)>& f )const; template std::function to_generic( const std::function& f )const; @@ -393,7 +392,7 @@ namespace fc { } template std::function generic_api::api_visitor::to_generic( - const std::function>(Args...)>& f )const + const std::function>(Args...)>& f )const { auto api_con = _api_con; auto gapi = &_api; diff --git a/libraries/fc/include/fc/rpc/binary_api_connection.hpp b/libraries/fc/include/fc/rpc/binary_api_connection.hpp index 9c9ce2f7d11..81a81d33292 100644 --- a/libraries/fc/include/fc/rpc/binary_api_connection.hpp +++ b/libraries/fc/include/fc/rpc/binary_api_connection.hpp @@ -1,7 +1,6 @@ #pragma once #include #include -#include #include #include #include @@ -178,7 +177,7 @@ namespace fc { std::function to_generic( const std::function(Args...)>& f )const; template - std::function to_generic( const std::function>(Args...)>& f )const; + std::function to_generic( const std::function>(Args...)>& f )const; template std::function to_generic( const std::function& f )const; @@ -401,7 +400,7 @@ namespace fc { } template std::function generic_api::api_visitor::to_generic( - const std::function>(Args...)>& f )const + const std::function>(Args...)>& f )const { auto api_con = _api_con; auto gapi = &api; diff --git a/libraries/fc/include/fc/string.hpp b/libraries/fc/include/fc/string.hpp index 3a932351490..74dcf690b1d 100644 --- a/libraries/fc/include/fc/string.hpp +++ b/libraries/fc/include/fc/string.hpp @@ -1,9 +1,9 @@ #pragma once #include #include -#include #ifndef USE_FC_STRING +#include #include namespace fc { @@ -23,7 +23,7 @@ namespace fc inline fc::string to_string( size_t s) { return to_string(uint64_t(s)); } #endif - typedef fc::optional ostring; + typedef std::optional ostring; class variant_object; fc::string format_string( const fc::string&, const variant_object&, bool minimize = false ); fc::string trim( const fc::string& ); @@ -143,7 +143,7 @@ namespace fc { fc::string to_string( uint64_t ); fc::string to_string( int64_t ); - typedef fc::optional ostring; + typedef std::optional ostring; class variant_object; fc::string format_string( const fc::string&, const variant_object& ); diff --git a/libraries/fc/include/fc/time.hpp b/libraries/fc/include/fc/time.hpp index a401476e4ff..1c1b433bd53 100644 --- a/libraries/fc/include/fc/time.hpp +++ b/libraries/fc/include/fc/time.hpp @@ -1,7 +1,6 @@ #pragma once #include #include -#include #ifdef _MSC_VER #pragma warning (push) @@ -121,7 +120,7 @@ namespace fc { uint32_t utc_seconds; }; - typedef fc::optional otime_point; + typedef std::optional otime_point; /** return a human-readable approximate time, relative to now() * e.g., "4 hours ago", "2 months ago", etc. diff --git a/libraries/fc/include/fc/variant.hpp b/libraries/fc/include/fc/variant.hpp index a9f98a74982..f261076da90 100644 --- a/libraries/fc/include/fc/variant.hpp +++ b/libraries/fc/include/fc/variant.hpp @@ -10,7 +10,6 @@ #include // memset -#include #include #include #include @@ -349,10 +348,10 @@ namespace fc } template - variant( const optional& v ) + explicit variant( const std::optional& v ) { memset( this, 0, sizeof(*this) ); - if( v.valid() ) *this = variant(*v); + if( v.has_value() ) *this = variant(*v); } template @@ -367,7 +366,7 @@ namespace fc double _data; ///< Alligned according to double requirements char _type[sizeof(void*)]; ///< pad to void* size }; - typedef optional ovariant; + typedef std::optional ovariant; /** @ingroup Serializable */ void from_variant( const variant& var, string& vo ); @@ -390,9 +389,9 @@ namespace fc void from_variant( const variant& var, uint32_t& vo ); /** @ingroup Serializable */ template - void from_variant( const variant& var, optional& vo ) + void from_variant( const variant& var, std::optional& vo ) { - if( var.is_null() ) vo = optional(); + if( var.is_null() ) vo = std::optional(); else { vo = T(); diff --git a/libraries/fc/src/filesystem.cpp b/libraries/fc/src/filesystem.cpp index 24a96c99a17..1b8df2018cf 100644 --- a/libraries/fc/src/filesystem.cpp +++ b/libraries/fc/src/filesystem.cpp @@ -430,7 +430,7 @@ namespace fc { void temp_file_base::remove() { - if (_path.valid()) + if (_path) { try { @@ -446,7 +446,7 @@ namespace fc { void temp_file_base::release() { - _path = fc::optional(); + _path = std::optional(); } const fc::path& home_path() diff --git a/libraries/fc/src/log/gelf_appender.cpp b/libraries/fc/src/log/gelf_appender.cpp index b5b3fc643a6..8a7b810ce42 100644 --- a/libraries/fc/src/log/gelf_appender.cpp +++ b/libraries/fc/src/log/gelf_appender.cpp @@ -29,9 +29,9 @@ namespace fc class gelf_appender::impl { public: - config cfg; - optional gelf_endpoint; - udp_socket gelf_socket; + config cfg; + std::optional gelf_endpoint; + udp_socket gelf_socket; impl(const config& c) : cfg(c) diff --git a/libraries/fc/src/log/logger_config.cpp b/libraries/fc/src/log/logger_config.cpp index 032b29c26d4..58690967160 100644 --- a/libraries/fc/src/log/logger_config.cpp +++ b/libraries/fc/src/log/logger_config.cpp @@ -81,11 +81,11 @@ namespace fc { auto lgr = log_config::get().logger_map[cfg.loggers[i].name]; // TODO: finish configure logger here... - if( cfg.loggers[i].parent.valid() ) { + if( cfg.loggers[i].parent ) { lgr.set_parent( log_config::get().logger_map[*cfg.loggers[i].parent] ); } lgr.set_name(cfg.loggers[i].name); - if( cfg.loggers[i].level.valid() ) lgr.set_log_level( *cfg.loggers[i].level ); + if( cfg.loggers[i].level ) lgr.set_log_level( *cfg.loggers[i].level ); for( auto a = cfg.loggers[i].appenders.begin(); a != cfg.loggers[i].appenders.end(); ++a ){ diff --git a/libraries/fc/src/network/gntp.cpp b/libraries/fc/src/network/gntp.cpp index 89c17354f58..0c522d31378 100644 --- a/libraries/fc/src/network/gntp.cpp +++ b/libraries/fc/src/network/gntp.cpp @@ -45,19 +45,19 @@ namespace fc class gntp_notifier_impl { public: - gntp_notifier_impl(const std::string& host_to_notify = "127.0.0.1", uint16_t port = 23053, const optional& password = optional()); + gntp_notifier_impl(const std::string& host_to_notify = "127.0.0.1", uint16_t port = 23053, const std::optional& password = std::optional()); // there's no API to change these right now, it will always notify localhost at the default GNTP port std::string hostname; uint16_t port; - optional password; + std::optional password; std::string application_name; gntp_icon_ptr application_icon; gntp_notification_type_list notification_types; // list of all notification types we're registered to send - optional endpoint; // cache the last endpoint we've connected to + std::optional endpoint; // cache the last endpoint we've connected to bool connection_failed; // true after we've tried to connect and failed bool is_registered; // true after we've registered @@ -66,7 +66,7 @@ namespace fc }; gntp_notifier_impl::gntp_notifier_impl(const std::string& host_to_notify /* = "127.0.0.1" */, uint16_t port /* = 23053 */, - const optional& password /* = optional() */) : + const std::optional& password /* = std::optional() */) : hostname(host_to_notify), port(port), password(password), @@ -94,14 +94,14 @@ namespace fc ("error_report", er.to_detail_string())); sock->close(); // clear the cached endpoint and fall through to the full connection procedure - endpoint = optional(); + endpoint = std::optional(); } catch (...) { ilog("Failed to connect to GNTP service using an endpoint that previously worked"); sock->close(); // clear the cached endpoint and fall through to the full connection procedure - endpoint = optional(); + endpoint = std::optional(); } } if (!connected) @@ -165,7 +165,7 @@ namespace fc } gntp_notifier::gntp_notifier(const std::string& host_to_notify /* = "127.0.0.1" */, uint16_t port /* = 23053 */, - const optional& password /* = optional() */) : + const std::optional& password /* = std::optional() */) : my(new detail::gntp_notifier_impl(host_to_notify, port, password)) { } @@ -243,7 +243,7 @@ namespace fc } } gntp_guid gntp_notifier::send_notification(std::string name, std::string title, std::string text, - const gntp_icon_ptr& icon, optional coalescingId /* = optional() */) + const gntp_icon_ptr& icon, std::optional coalescingId /* = std::optional() */) { if (my->connection_failed) return gntp_guid(); diff --git a/libraries/fc/src/network/http/http_client.cpp b/libraries/fc/src/network/http/http_client.cpp index 98621a7e77e..6c0a82db98e 100644 --- a/libraries/fc/src/network/http/http_client.cpp +++ b/libraries/fc/src/network/http/http_client.cpp @@ -85,7 +85,7 @@ class http_client_impl { } }); - optional f_result; + std::optional f_result; f(f_result); _ioc.restart(); @@ -118,7 +118,7 @@ class http_client_impl { tcp::resolver local_resolver(_ioc); bool cancelled = false; - auto res = sync_do_with_deadline(s, deadline, [&local_resolver, &cancelled, &s, &host, &port](optional& final_ec){ + auto res = sync_do_with_deadline(s, deadline, [&local_resolver, &cancelled, &s, &host, &port](std::optional& final_ec){ local_resolver.async_resolve(host, port, [&cancelled, &s, &final_ec](const error_code& ec, tcp::resolver::results_type resolved ){ if (ec) { final_ec.emplace(ec); @@ -141,7 +141,7 @@ class http_client_impl { template error_code sync_write_with_timeout(SyncReadStream& s, http::request& req, const deadline_type& deadline ) { - return sync_do_with_deadline(s, deadline, [&s, &req](optional& final_ec){ + return sync_do_with_deadline(s, deadline, [&s, &req](std::optional& final_ec){ http::async_write(s, req, [&final_ec]( const error_code& ec, std::size_t ) { final_ec.emplace(ec); }); @@ -150,7 +150,7 @@ class http_client_impl { template error_code sync_read_with_timeout(SyncReadStream& s, boost::beast::flat_buffer& buffer, http::response& res, const deadline_type& deadline ) { - return sync_do_with_deadline(s, deadline, [&s, &buffer, &res](optional& final_ec){ + return sync_do_with_deadline(s, deadline, [&s, &buffer, &res](std::optional& final_ec){ http::async_read(s, buffer, res, [&final_ec]( const error_code& ec, std::size_t ) { final_ec.emplace(ec); }); @@ -213,7 +213,7 @@ class http_client_impl { error_code ec = sync_connect_with_timeout(ssl_socket->next_layer(), *dest.host(), dest.port() ? std::to_string(*dest.port()) : "443", deadline); if (!ec) { - ec = sync_do_with_deadline(ssl_socket->next_layer(), deadline, [&ssl_socket](optional& final_ec) { + ec = sync_do_with_deadline(ssl_socket->next_layer(), deadline, [&ssl_socket](std::optional& final_ec) { ssl_socket->async_handshake(ssl::stream_base::client, [&final_ec](const error_code& ec) { final_ec.emplace(ec); }); @@ -425,7 +425,7 @@ class http_client_impl { if(socket_file.empty()) FC_THROW_EXCEPTION( parse_error_exception, "couldn't discover socket path"); url_path = "/" / url_path; - return _unix_url_paths.emplace(full_url, fc::url("unix", socket_file.string(), ostring(), ostring(), url_path.string(), ostring(), ovariant_object(), fc::optional())).first->second; + return _unix_url_paths.emplace(full_url, fc::url("unix", socket_file.string(), ostring(), ostring(), url_path.string(), ostring(), ovariant_object(), std::optional())).first->second; } #endif diff --git a/libraries/fc/src/network/ntp.cpp b/libraries/fc/src/network/ntp.cpp index 539407195d9..00aeadf878f 100644 --- a/libraries/fc/src/network/ntp.cpp +++ b/libraries/fc/src/network/ntp.cpp @@ -243,11 +243,11 @@ namespace fc my->_ntp_thread.async( [=](){ my->request_now(); } ).get(); } - optional ntp::get_time()const + std::optional ntp::get_time()const { if( my->_last_ntp_delta_initialized ) return fc::time_point::now() + fc::microseconds(my->_last_ntp_delta_microseconds); - return optional(); + return std::optional(); } } //namespace fc diff --git a/libraries/fc/src/network/url.cpp b/libraries/fc/src/network/url.cpp index 069f94f7a34..defc2ab7c2a 100644 --- a/libraries/fc/src/network/url.cpp +++ b/libraries/fc/src/network/url.cpp @@ -60,7 +60,7 @@ namespace fc _path = fc::path( "/" ) / _lpath; #endif std::getline( ss, _largs ); - if( _args.valid() && _args->size() ) + if( _args && _args->size() ) { // TODO: args = fc::move(_args); _query = fc::move(_largs); @@ -74,7 +74,7 @@ namespace fc opath _path; ostring _query; ovariant_object _args; - fc::optional _port; + std::optional _port; }; } @@ -91,17 +91,17 @@ namespace fc { std::stringstream ss; ss<_proto<<"://"; - if( my->_user.valid() ) { + if( my->_user ) { ss << *my->_user; - if( my->_pass.valid() ) { + if( my->_pass ) { ss<<":"<<*my->_pass; } ss<<"@"; } - if( my->_host.valid() ) ss<<*my->_host; - if( my->_port.valid() ) ss<<":"<<*my->_port; - if( my->_path.valid() ) ss<_path->generic_string(); - if( my->_query.valid() ) ss<<"?"<<*my->_query; + if( my->_host ) ss<<*my->_host; + if( my->_port ) ss<<":"<<*my->_port; + if( my->_path ) ss<_path->generic_string(); + if( my->_query ) ss<<"?"<<*my->_query; // if( my->_args ) ss<<"?"<<*my->_args; return ss.str(); } @@ -132,7 +132,7 @@ namespace fc } url::url( const string& proto, const ostring& host, const ostring& user, const ostring& pass, - const opath& path, const ostring& query, const ovariant_object& args, const fc::optional& port) + const opath& path, const ostring& query, const ovariant_object& args, const std::optional& port) :my( std::make_shared() ) { my->_proto = proto; @@ -191,7 +191,7 @@ namespace fc { return my->_args; } - fc::optional url::port()const + std::optional url::port()const { return my->_port; } diff --git a/libraries/fc/src/rpc/websocket_api.cpp b/libraries/fc/src/rpc/websocket_api.cpp index 60ef7062b48..8539fc7cf87 100644 --- a/libraries/fc/src/rpc/websocket_api.cpp +++ b/libraries/fc/src/rpc/websocket_api.cpp @@ -77,7 +77,7 @@ void websocket_api_connection::send_notice( uint64_t callback_id, variants args /* = variants() */ ) { - fc::rpc::request req{ optional(), "notice", {callback_id, std::move(args)}}; + fc::rpc::request req{ std::optional(), "notice", {callback_id, std::move(args)}}; _connection.send_message( fc::json::to_string(req) ); } diff --git a/libraries/rodeos/embedded_rodeos.cpp b/libraries/rodeos/embedded_rodeos.cpp index 6864fd7ff70..f5f560624d1 100644 --- a/libraries/rodeos/embedded_rodeos.cpp +++ b/libraries/rodeos/embedded_rodeos.cpp @@ -253,7 +253,7 @@ rodeos_bool rodeos_query_transaction(rodeos_error* error, rodeos_query_handler* auto thread_state = handler->state_cache.get_state(); eosio::ship_protocol::transaction_trace tt; - if (snapshot->snap.has_value()) { + if (snapshot->snap) { tt = query_send_transaction(*thread_state, snapshot->partition->contract_kv_prefix, trx, snapshot->snap->snapshot(), memory, true); } else { diff --git a/libraries/rodeos/include/eosio/key_value.hpp b/libraries/rodeos/include/eosio/key_value.hpp index 6f845e4a432..985d3adfb8a 100644 --- a/libraries/rodeos/include/eosio/key_value.hpp +++ b/libraries/rodeos/include/eosio/key_value.hpp @@ -543,7 +543,7 @@ class kv_table { T operator[](const key_type& key) const { auto opt = get(key); - eosio::check(opt.has_value(), __FILE__ ":" + std::to_string(__LINE__) + " Key not found in `[]`"); + eosio::check(opt, __FILE__ ":" + std::to_string(__LINE__) + " Key not found in `[]`"); return *opt; } diff --git a/libraries/state_history/include/eosio/state_history/serialization.hpp b/libraries/state_history/include/eosio/state_history/serialization.hpp index 852554fa35b..dc4498a19bf 100644 --- a/libraries/state_history/include/eosio/state_history/serialization.hpp +++ b/libraries/state_history/include/eosio/state_history/serialization.hpp @@ -108,8 +108,8 @@ void history_pack_big_bytes(ST& ds, const eosio::chain::bytes& v) { } template -void history_pack_big_bytes(ST& ds, const fc::optional& v) { - fc::raw::pack(ds, v.valid()); +void history_pack_big_bytes(ST& ds, const std::optional& v) { + fc::raw::pack(ds, v.has_value()); if (v) history_pack_big_bytes(ds, *v); } @@ -319,7 +319,7 @@ ST& operator<<(ST& ds, const history_serial_wrapper& template ST& operator<<(ST& ds, const history_serial_wrapper& obj) { fc::raw::pack(ds, fc::unsigned_int(1)); - fc::raw::pack(ds, as_type>(obj.obj.proposed_schedule_block_num)); + fc::raw::pack(ds, as_type>(obj.obj.proposed_schedule_block_num)); fc::raw::pack(ds, make_history_serial_wrapper( obj.db, as_type(obj.obj.proposed_schedule))); fc::raw::pack(ds, make_history_serial_wrapper(obj.db, as_type(obj.obj.configuration))); @@ -541,8 +541,8 @@ ST& operator<<(ST& ds, const history_serial_wrapper return ds; } -inline fc::optional cap_error_code(const fc::optional& error_code) { - fc::optional result; +inline std::optional cap_error_code(const std::optional& error_code) { + std::optional result; if (!error_code) return result; @@ -579,16 +579,16 @@ ST& operator<<(ST& ds, const history_context_wrapper>(obj.obj.account_ram_deltas)); history_serialize_container(ds, obj.db, as_type>(obj.obj.account_disk_deltas)); - fc::optional e; + std::optional e; if (obj.obj.except) { if (debug_mode) e = obj.obj.except->to_string(); else e = "Y"; } - fc::raw::pack(ds, as_type>(e)); + fc::raw::pack(ds, as_type>(e)); fc::raw::pack(ds, - as_type>(debug_mode ? obj.obj.error_code : cap_error_code(obj.obj.error_code))); + as_type>(debug_mode ? obj.obj.error_code : cap_error_code(obj.obj.error_code))); fc::raw::pack(ds, as_type(obj.obj.return_value)); return ds; } @@ -626,15 +626,15 @@ ST& operator<<( ds, make_history_serial_wrapper(obj.db, as_type(*trace.account_ram_delta))); } - fc::optional e; + std::optional e; if (trace.except) { if (debug_mode) e = trace.except->to_string(); else e = "Y"; } - fc::raw::pack(ds, as_type>(e)); - fc::raw::pack(ds, as_type>(debug_mode ? trace.error_code : cap_error_code(trace.error_code))); + fc::raw::pack(ds, as_type>(e)); + fc::raw::pack(ds, as_type>(debug_mode ? trace.error_code : cap_error_code(trace.error_code))); fc::raw::pack(ds, bool(trace.failed_dtrx_trace)); if (trace.failed_dtrx_trace) { @@ -661,7 +661,7 @@ ST& operator<<( fc::raw::pack(ds, as_type(trx.max_cpu_usage_ms)); fc::raw::pack(ds, as_type(trx.delay_sec)); fc::raw::pack(ds, as_type(trx.transaction_extensions)); - fc::raw::pack(ds, as_type>({})); + fc::raw::pack(ds, as_type>({})); } return ds; diff --git a/libraries/state_history/include/eosio/state_history/transaction_trace_cache.hpp b/libraries/state_history/include/eosio/state_history/transaction_trace_cache.hpp index 54b0e0be988..cd47a15fe3c 100644 --- a/libraries/state_history/include/eosio/state_history/transaction_trace_cache.hpp +++ b/libraries/state_history/include/eosio/state_history/transaction_trace_cache.hpp @@ -12,7 +12,7 @@ using chain::transaction_id_type; struct transaction_trace_cache { std::map cached_traces; - fc::optional onblock_trace; + std::optional onblock_trace; void add_transaction(const transaction_trace_ptr& trace, const packed_transaction_ptr& transaction); diff --git a/libraries/state_history/include/eosio/state_history/types.hpp b/libraries/state_history/include/eosio/state_history/types.hpp index febf55260b5..43d0b509050 100644 --- a/libraries/state_history/include/eosio/state_history/types.hpp +++ b/libraries/state_history/include/eosio/state_history/types.hpp @@ -103,13 +103,13 @@ struct get_blocks_ack_request_v0 { }; struct get_blocks_result_v0 { - block_position head; - block_position last_irreversible; - fc::optional this_block; - fc::optional prev_block; - fc::optional block; - fc::optional traces; - fc::optional deltas; + block_position head; + block_position last_irreversible; + std::optional this_block; + std::optional prev_block; + std::optional block; + std::optional traces; + std::optional deltas; }; using state_request = fc::static_variant; @@ -149,33 +149,33 @@ struct action { }; struct action_trace_v0 { - fc::unsigned_int action_ordinal = {}; - fc::unsigned_int creator_action_ordinal = {}; - fc::optional receipt = {}; - uint64_t receiver = {}; - action act = {}; - bool context_free = {}; - int64_t elapsed = {}; - std::string console = {}; - std::vector account_ram_deltas = {}; - fc::optional except = {}; - fc::optional error_code = {}; + fc::unsigned_int action_ordinal = {}; + fc::unsigned_int creator_action_ordinal = {}; + std::optional receipt = {}; + uint64_t receiver = {}; + action act = {}; + bool context_free = {}; + int64_t elapsed = {}; + std::string console = {}; + std::vector account_ram_deltas = {}; + std::optional except = {}; + std::optional error_code = {}; }; struct action_trace_v1 { - fc::unsigned_int action_ordinal = {}; - fc::unsigned_int creator_action_ordinal = {}; - fc::optional receipt = {}; - uint64_t receiver = {}; - action act = {}; - bool context_free = {}; - int64_t elapsed = {}; - std::string console = {}; - std::vector account_ram_deltas = {}; - std::vector account_disk_deltas = {}; - fc::optional except = {}; - fc::optional error_code = {}; - bytes return_value = {}; + fc::unsigned_int action_ordinal = {}; + fc::unsigned_int creator_action_ordinal = {}; + std::optional receipt = {}; + uint64_t receiver = {}; + action act = {}; + bool context_free = {}; + int64_t elapsed = {}; + std::string console = {}; + std::vector account_ram_deltas = {}; + std::vector account_disk_deltas = {}; + std::optional except = {}; + std::optional error_code = {}; + bytes return_value = {}; }; using action_trace = fc::static_variant; @@ -201,7 +201,7 @@ struct partial_transaction_v1 { uint8_t max_cpu_usage_ms = {}; fc::unsigned_int delay_sec = {}; std::vector transaction_extensions = {}; - fc::optional prunable_data = {}; + std::optional prunable_data = {}; }; using partial_transaction = fc::static_variant; @@ -209,23 +209,23 @@ using partial_transaction = fc::static_variant; - eosio::chain::digest_type id = {}; - uint8_t status = {}; - uint32_t cpu_usage_us = {}; - fc::unsigned_int net_usage_words = {}; - int64_t elapsed = {}; - uint64_t net_usage = {}; - bool scheduled = {}; - std::vector action_traces = {}; - fc::optional account_ram_delta = {}; - fc::optional except = {}; - fc::optional error_code = {}; - - // semantically, this should be optional; + using transaction_trace = fc::static_variant; + eosio::chain::digest_type id = {}; + uint8_t status = {}; + uint32_t cpu_usage_us = {}; + fc::unsigned_int net_usage_words = {}; + int64_t elapsed = {}; + uint64_t net_usage = {}; + bool scheduled = {}; + std::vector action_traces = {}; + std::optional account_ram_delta = {}; + std::optional except = {}; + std::optional error_code = {}; + + // semantically, this should be std::optional; // it is represented as vector because optional cannot be used for incomplete type std::vector failed_dtrx_trace = {}; - fc::optional partial = {}; + std::optional partial = {}; }; using transaction_trace = fc::static_variant; @@ -236,11 +236,11 @@ struct transaction_trace_recurse { using optional_signed_block = std::variant; struct get_blocks_result_v1 { - block_position head; - block_position last_irreversible; - fc::optional this_block; - fc::optional prev_block; - optional_signed_block block; // packed as fc::optional> + block_position head; + block_position last_irreversible; + std::optional this_block; + std::optional prev_block; + optional_signed_block block; // packed as std::optional> opaque> traces; opaque> deltas; }; diff --git a/libraries/testing/include/eosio/testing/tester.hpp b/libraries/testing/include/eosio/testing/tester.hpp index e2e5ce1789d..5c1fb2b2828 100644 --- a/libraries/testing/include/eosio/testing/tester.hpp +++ b/libraries/testing/include/eosio/testing/tester.hpp @@ -10,6 +10,7 @@ #include #include +#include #define REQUIRE_EQUAL_OBJECTS(left, right) { auto a = fc::variant( left ); auto b = fc::variant( right ); BOOST_REQUIRE_EQUAL( true, a.is_object() ); \ BOOST_REQUIRE_EQUAL( true, b.is_object() ); \ @@ -153,7 +154,7 @@ namespace eosio { namespace testing { virtual ~base_tester() {}; - void init(const setup_policy policy = setup_policy::full, db_read_mode read_mode = db_read_mode::SPECULATIVE, optional genesis_max_inline_action_size = optional{}, optional config_max_nonprivileged_inline_action_size = optional{}); + void init(const setup_policy policy = setup_policy::full, db_read_mode read_mode = db_read_mode::SPECULATIVE, std::optional genesis_max_inline_action_size = std::optional{}, std::optional config_max_nonprivileged_inline_action_size = std::optional{}); void init(controller::config config, const snapshot_reader_ptr& snapshot); void init(controller::config config, const genesis_state& genesis); void init(controller::config config); @@ -163,13 +164,13 @@ namespace eosio { namespace testing { void execute_setup_policy(const setup_policy policy); void close(); - void open( protocol_feature_set&& pfs, fc::optional expected_chain_id, const std::function& lambda ); + void open( protocol_feature_set&& pfs, std::optional expected_chain_id, const std::function& lambda ); void open( protocol_feature_set&& pfs, const snapshot_reader_ptr& snapshot ); void open( protocol_feature_set&& pfs, const genesis_state& genesis ); - void open( protocol_feature_set&& pfs, fc::optional expected_chain_id = {} ); + void open( protocol_feature_set&& pfs, std::optional expected_chain_id = {} ); void open( const snapshot_reader_ptr& snapshot ); void open( const genesis_state& genesis ); - void open( fc::optional expected_chain_id = {} ); + void open( std::optional expected_chain_id = {} ); bool is_same_chain( base_tester& other ); virtual signed_block_ptr produce_block( fc::microseconds skip_time = fc::milliseconds(config::block_interval_ms) ) = 0; @@ -335,14 +336,14 @@ namespace eosio { namespace testing { static action_result wasm_assert_code( uint64_t error_code ) { return "assertion failure with error code: " + std::to_string(error_code); } auto get_resolver() { - return [this]( const account_name& name ) -> optional { + return [this]( const account_name& name ) -> std::optional { try { const auto& accnt = control->db().get( name ); abi_def abi; if( abi_serializer::to_abi( accnt.abi, abi )) { return abi_serializer( abi, abi_serializer::create_yield_function( abi_serializer_max_time ) ); } - return optional(); + return std::optional(); } FC_RETHROW_EXCEPTIONS( error, "Failed to find or parse ABI for ${name}", ("name", name)) }; } @@ -391,7 +392,7 @@ namespace eosio { namespace testing { return genesis; } - static std::pair default_config(const fc::temp_directory& tempdir, optional genesis_max_inline_action_size = optional{}, optional config_max_nonprivileged_inline_action_size = optional{}) { + static std::pair default_config(const fc::temp_directory& tempdir, std::optional genesis_max_inline_action_size = std::optional{}, std::optional config_max_nonprivileged_inline_action_size = std::optional{}) { controller::config cfg; cfg.blog.log_dir = tempdir.path() / config::default_blocks_dir_name; cfg.state_dir = tempdir.path() / config::default_state_dir_name; @@ -447,7 +448,7 @@ namespace eosio { namespace testing { class tester : public base_tester { public: - tester(setup_policy policy = setup_policy::full, db_read_mode read_mode = db_read_mode::SPECULATIVE, optional genesis_max_inline_action_size = optional{}, optional config_max_nonprivileged_inline_action_size = optional{}) { + tester(setup_policy policy = setup_policy::full, db_read_mode read_mode = db_read_mode::SPECULATIVE, std::optional genesis_max_inline_action_size = std::optional{}, std::optional config_max_nonprivileged_inline_action_size = std::optional{}) { init(policy, read_mode, genesis_max_inline_action_size, config_max_nonprivileged_inline_action_size); } diff --git a/libraries/testing/tester.cpp b/libraries/testing/tester.cpp index f26aa33d88e..9ec61d6ed1f 100644 --- a/libraries/testing/tester.cpp +++ b/libraries/testing/tester.cpp @@ -110,12 +110,12 @@ namespace eosio { namespace testing { protocol_feature_set make_protocol_feature_set(const subjective_restriction_map& custom_subjective_restrictions) { protocol_feature_set pfs; - map< builtin_protocol_feature_t, optional > visited_builtins; + map< builtin_protocol_feature_t, std::optional > visited_builtins; std::function add_builtins = [&pfs, &visited_builtins, &add_builtins, &custom_subjective_restrictions] ( builtin_protocol_feature_t codename ) -> digest_type { - auto res = visited_builtins.emplace( codename, optional() ); + auto res = visited_builtins.emplace( codename, std::optional() ); if( !res.second ) { EOS_ASSERT( res.first->second, protocol_feature_exception, "invariant failure: cycle found in builtin protocol feature dependencies" @@ -150,7 +150,7 @@ namespace eosio { namespace testing { return control->head_block_id() == other.control->head_block_id(); } - void base_tester::init(const setup_policy policy, db_read_mode read_mode, optional genesis_max_inline_action_size, optional config_max_nonprivileged_inline_action_size) { + void base_tester::init(const setup_policy policy, db_read_mode read_mode, std::optional genesis_max_inline_action_size, std::optional config_max_nonprivileged_inline_action_size) { auto def_conf = default_config(tempdir, genesis_max_inline_action_size, config_max_nonprivileged_inline_action_size); def_conf.first.read_mode = read_mode; cfg = def_conf.first; @@ -265,11 +265,11 @@ namespace eosio { namespace testing { open( make_protocol_feature_set(), genesis ); } - void base_tester::open( fc::optional expected_chain_id ) { + void base_tester::open( std::optional expected_chain_id ) { open( make_protocol_feature_set(), expected_chain_id ); } - void base_tester::open( protocol_feature_set&& pfs, fc::optional expected_chain_id, const std::function& lambda ) { + void base_tester::open( protocol_feature_set&& pfs, std::optional expected_chain_id, const std::function& lambda ) { if( !expected_chain_id ) { expected_chain_id = controller::extract_chain_id_from_db( cfg.state_dir ); if( !expected_chain_id ) { @@ -313,7 +313,7 @@ namespace eosio { namespace testing { }); } - void base_tester::open( protocol_feature_set&& pfs, fc::optional expected_chain_id ) { + void base_tester::open( protocol_feature_set&& pfs, std::optional expected_chain_id ) { open(std::move(pfs), expected_chain_id, [&control=this->control]() { control->startup( [](){}, []() { return false; } ); }); diff --git a/plugins/chain_plugin/chain_plugin.cpp b/plugins/chain_plugin/chain_plugin.cpp index 9f23453cca5..de070984417 100644 --- a/plugins/chain_plugin/chain_plugin.cpp +++ b/plugins/chain_plugin/chain_plugin.cpp @@ -148,15 +148,14 @@ class chain_plugin_impl { bool accept_transactions = false; bool api_accept_transactions = true; - - fc::optional fork_db; - fc::optional chain_config; - fc::optional chain; - fc::optional genesis; + std::optional fork_db; + std::optional chain_config; + std::optional chain; + std::optional genesis; //txn_msg_rate_limits rate_limits; - fc::optional wasm_runtime; - fc::microseconds abi_serializer_max_time_us; - fc::optional snapshot_path; + std::optional wasm_runtime; + fc::microseconds abi_serializer_max_time_us; + std::optional snapshot_path; // retained references to channels for easy publication @@ -166,7 +165,7 @@ class chain_plugin_impl { channels::irreversible_block::channel_type& irreversible_block_channel; channels::accepted_transaction::channel_type& accepted_transaction_channel; channels::applied_transaction::channel_type& applied_transaction_channel; - incoming::channels::block::channel_type& incoming_block_channel; + incoming::channels::block::channel_type& incoming_block_channel; // retained references to methods for easy calling incoming::methods::block_sync::method_type& incoming_block_sync_method; @@ -179,12 +178,12 @@ class chain_plugin_impl { methods::get_last_irreversible_block_number::method_type::handle get_last_irreversible_block_number_provider; // scoped connections for chain controller - fc::optional pre_accepted_block_connection; - fc::optional accepted_block_header_connection; - fc::optional accepted_block_connection; - fc::optional irreversible_block_connection; - fc::optional accepted_transaction_connection; - fc::optional applied_transaction_connection; + std::optional pre_accepted_block_connection; + std::optional accepted_block_header_connection; + std::optional accepted_block_connection; + std::optional irreversible_block_connection; + std::optional accepted_transaction_connection; + std::optional applied_transaction_connection; }; @@ -428,7 +427,7 @@ void clear_chainbase_files( const fc::path& p ) { fc::remove( p / "shared_memory.meta" ); } -optional read_builtin_protocol_feature( const fc::path& p ) { +std::optional read_builtin_protocol_feature( const fc::path& p ) { try { return fc::json::from_file( p ); } catch( const fc::exception& e ) { @@ -500,7 +499,7 @@ protocol_feature_set initialize_protocol_features( const fc::path& p, bool popul map found_builtin_protocol_features; map > builtin_protocol_features_to_add; // The bool in the pair is set to true if the builtin protocol feature has already been visited to add - map< builtin_protocol_feature_t, optional > visited_builtins; + map< builtin_protocol_feature_t, std::optional > visited_builtins; // Read all builtin protocol features if( directory_exists ) { @@ -590,7 +589,7 @@ protocol_feature_set initialize_protocol_features( const fc::path& p, bool popul std::function add_missing_builtins = [&pfs, &visited_builtins, &output_protocol_feature, &log_recognized_protocol_feature, &add_missing_builtins, populate_missing_builtins] ( builtin_protocol_feature_t codename ) -> digest_type { - auto res = visited_builtins.emplace( codename, optional() ); + auto res = visited_builtins.emplace( codename, std::optional() ); if( !res.second ) { EOS_ASSERT( res.first->second, protocol_feature_exception, "invariant failure: cycle found in builtin protocol feature dependencies" @@ -817,7 +816,7 @@ void chain_plugin::plugin_initialize(const variables_map& options) { my->chain_config->terminate_at_block = options.at( "terminate-at-block" ).as(); if( options.count( "extract-genesis-json" ) || options.at( "print-genesis-json" ).as()) { - fc::optional gs; + std::optional gs; if( fc::exists( my->blocks_dir / "blocks.log" )) { gs = block_log::extract_genesis_state( my->blocks_dir ); @@ -892,7 +891,7 @@ void chain_plugin::plugin_initialize(const variables_map& options) { } else if( options.at( "fix-reversible-blocks" ).as()) { if( !recover_reversible_blocks( my->chain_config->blog.log_dir / config::reversible_blocks_dir_name, my->chain_config->reversible_cache_size, - optional(), + std::optional(), options.at( "truncate-at-block" ).as())) { ilog( "Reversible blocks database verified to not be corrupted. Now exiting..." ); } else { @@ -916,7 +915,7 @@ void chain_plugin::plugin_initialize(const variables_map& options) { wlog("The --import-reversible-blocks option should be used by itself."); } - fc::optional chain_id; + std::optional chain_id; if (options.count( "snapshot" )) { my->snapshot_path = options.at( "snapshot" ).as(); EOS_ASSERT( fc::exists(*my->snapshot_path), plugin_config_exception, @@ -967,8 +966,8 @@ void chain_plugin::plugin_initialize(const variables_map& options) { chain_id = controller::extract_chain_id_from_db( my->chain_config->state_dir ); - fc::optional block_log_genesis; - fc::optional block_log_chain_id; + std::optional block_log_genesis; + std::optional block_log_chain_id; if( fc::is_regular_file( my->blocks_dir / "blocks.log" ) ) { block_log_genesis = block_log::extract_genesis_state( my->blocks_dir ); @@ -1296,7 +1295,7 @@ void chain_plugin::accept_transaction(const chain::packed_transaction_ptr& trx, } bool chain_plugin::recover_reversible_blocks( const fc::path& db_dir, uint32_t cache_size, - optional new_db_dir, uint32_t truncate_at_block ) { + std::optional new_db_dir, uint32_t truncate_at_block ) { try { chainbase::database reversible( db_dir, database::read_only); // Test if dirty // If it reaches here, then the reversible database is not dirty @@ -1345,7 +1344,7 @@ bool chain_plugin::recover_reversible_blocks( const fc::path& db_dir, uint32_t c ilog( "Reconstructing '${reversible_dir}' from backed up reversible directory", ("reversible_dir", reversible_dir) ); - optional old_reversible; + std::optional old_reversible; try { old_reversible = chainbase::database( backup_dir, database::read_only, 0, true ); @@ -2078,7 +2077,7 @@ read_only::get_producer_schedule_result read_only::get_producer_schedule( const template struct resolver_factory { static auto make(const Api* api, abi_serializer::yield_function_t yield) { - return [api, yield{std::move(yield)}](const account_name &name) -> optional { + return [api, yield{std::move(yield)}](const account_name &name) -> std::optional { const auto* accnt = api->db.db().template find(name); if (accnt != nullptr) { abi_def abi; @@ -2087,7 +2086,7 @@ struct resolver_factory { } } - return optional(); + return std::optional(); }; } }; @@ -2173,7 +2172,7 @@ read_only::get_scheduled_transactions( const read_only::get_scheduled_transactio fc::variant read_only::get_block(const read_only::get_block_params& params) const { signed_block_ptr block; - optional block_num; + std::optional block_num; EOS_ASSERT( !params.block_num_or_id.empty() && params.block_num_or_id.size() <= 64, chain::block_id_type_exception, @@ -2184,7 +2183,7 @@ fc::variant read_only::get_block(const read_only::get_block_params& params) cons block_num = fc::to_uint64(params.block_num_or_id); } catch( ... ) {} - if( block_num.valid() ) { + if( block_num ) { block = db.fetch_block_by_number( *block_num ); } else { try { @@ -2239,13 +2238,13 @@ fc::variant read_only::get_block_info(const read_only::get_block_info_params& pa fc::variant read_only::get_block_header_state(const get_block_header_state_params& params) const { block_state_ptr b; - optional block_num; + std::optional block_num; std::exception_ptr e; try { block_num = fc::to_uint64(params.block_num_or_id); } catch( ... ) {} - if( block_num.valid() ) { + if( block_num ) { b = db.fetch_block_state_by_number(*block_num); } else { try { @@ -2532,11 +2531,11 @@ read_only::get_account_results read_only::get_account( const get_account_params& uint32_t greylist_limit = db.is_resource_greylisted(result.account_name) ? 1 : config::maximum_elastic_resource_multiplier; const block_timestamp_type current_usage_time (db.head_block_time()); result.net_limit.set( rm.get_account_net_limit_ex( result.account_name, greylist_limit, current_usage_time).first ); - if ( result.net_limit.last_usage_update_time.valid() && (result.net_limit.last_usage_update_time->slot == 0) ) { // account has no action yet + if ( result.net_limit.last_usage_update_time && (result.net_limit.last_usage_update_time->slot == 0) ) { // account has no action yet result.net_limit.last_usage_update_time = accnt_obj.creation_date; } result.cpu_limit.set( rm.get_account_cpu_limit_ex( result.account_name, greylist_limit, current_usage_time).first ); - if ( result.cpu_limit.last_usage_update_time.valid() && (result.cpu_limit.last_usage_update_time->slot == 0) ) { // account has no action yet + if ( result.cpu_limit.last_usage_update_time && (result.cpu_limit.last_usage_update_time->slot == 0) ) { // account has no action yet result.cpu_limit.last_usage_update_time = accnt_obj.creation_date; } result.ram_usage = rm.get_account_ram_usage( result.account_name ); @@ -2570,7 +2569,7 @@ read_only::get_account_results read_only::get_account( const get_account_params& auto core_symbol = extract_core_symbol(); - if (params.expected_core_symbol.valid()) + if (params.expected_core_symbol) core_symbol = *(params.expected_core_symbol); const auto* t_id = d.find(boost::make_tuple( token_code, params.account_name, N(accounts) )); diff --git a/plugins/chain_plugin/include/eosio/chain_plugin/chain_plugin.hpp b/plugins/chain_plugin/include/eosio/chain_plugin/chain_plugin.hpp index 3cd158f5aa3..485d7c2cc4e 100644 --- a/plugins/chain_plugin/include/eosio/chain_plugin/chain_plugin.hpp +++ b/plugins/chain_plugin/include/eosio/chain_plugin/chain_plugin.hpp @@ -30,7 +30,6 @@ namespace eosio { using chain::public_key_type; using chain::transaction; using chain::transaction_id_type; - using fc::optional; using boost::container::flat_set; using chain::asset; using chain::symbol; @@ -94,40 +93,40 @@ class read_only { using get_info_params = empty; struct get_info_results { - string server_version; - chain::chain_id_type chain_id; - uint32_t head_block_num = 0; - uint32_t last_irreversible_block_num = 0; - chain::block_id_type last_irreversible_block_id; - chain::block_id_type head_block_id; - fc::time_point head_block_time; - account_name head_block_producer; - - uint64_t virtual_block_cpu_limit = 0; - uint64_t virtual_block_net_limit = 0; - - uint64_t block_cpu_limit = 0; - uint64_t block_net_limit = 0; - //string recent_slots; - //double participation_rate = 0; - optional server_version_string; - optional fork_db_head_block_num; - optional fork_db_head_block_id; - optional server_full_version_string; + string server_version; + chain::chain_id_type chain_id; + uint32_t head_block_num = 0; + uint32_t last_irreversible_block_num = 0; + chain::block_id_type last_irreversible_block_id; + chain::block_id_type head_block_id; + fc::time_point head_block_time; + account_name head_block_producer; + + uint64_t virtual_block_cpu_limit = 0; + uint64_t virtual_block_net_limit = 0; + + uint64_t block_cpu_limit = 0; + uint64_t block_net_limit = 0; + //string recent_slots; + //double participation_rate = 0; + std::optional server_version_string; + std::optional fork_db_head_block_num; + std::optional fork_db_head_block_id; + std::optional server_full_version_string; }; get_info_results get_info(const get_info_params&) const; struct get_activated_protocol_features_params { - optional lower_bound; - optional upper_bound; - uint32_t limit = 10; - bool search_by_block_num = false; - bool reverse = false; + std::optional lower_bound; + std::optional upper_bound; + uint32_t limit = 10; + bool search_by_block_num = false; + bool reverse = false; }; struct get_activated_protocol_features_results { - fc::variants activated_protocol_features; - optional more; + fc::variants activated_protocol_features; + std::optional more; }; get_activated_protocol_features_results get_activated_protocol_features( const get_activated_protocol_features_params& params )const; @@ -141,8 +140,8 @@ class read_only { int64_t used = 0; int64_t available = 0; int64_t max = 0; - optional last_usage_update_time; // optional for backward nodeos support - optional current_used; // optional for backward nodeos support + std::optional last_usage_update_time; // optional for backward nodeos support + std::optional current_used; // optional for backward nodeos support void set( const chain::resource_limits::account_resource_limit& arl) { used = arl.used; @@ -162,7 +161,7 @@ class read_only { fc::time_point last_code_update; fc::time_point created; - optional core_liquid_balance; + std::optional core_liquid_balance; int64_t ram_quota = 0; int64_t net_weight = 0; @@ -182,8 +181,8 @@ class read_only { }; struct get_account_params { - name account_name; - optional expected_core_symbol; + name account_name; + std::optional expected_core_symbol; }; get_account_results get_account( const get_account_params& params )const; @@ -193,7 +192,7 @@ class read_only { string wast; string wasm; fc::sha256 code_hash; - optional abi; + std::optional abi; }; struct get_code_params { @@ -212,7 +211,7 @@ class read_only { struct get_abi_results { name account_name; - optional abi; + std::optional abi; }; struct get_abi_params { @@ -230,15 +229,15 @@ class read_only { }; struct get_raw_abi_params { - name account_name; - optional abi_hash; + name account_name; + std::optional abi_hash; }; struct get_raw_abi_results { - name account_name; - fc::sha256 code_hash; - fc::sha256 abi_hash; - optional abi; + name account_name; + fc::sha256 code_hash; + fc::sha256 abi_hash; + std::optional abi; }; @@ -308,19 +307,19 @@ class read_only { fc::variant get_block_header_state(const get_block_header_state_params& params) const; struct get_table_rows_params { - bool json = false; - name code; - string scope; - name table; - string table_key; - string lower_bound; - string upper_bound; - uint32_t limit = 10; - string key_type; // type of key specified by index_position - string index_position; // 1 - primary (first), 2 - secondary index (in order defined by multi_index), 3 - third index, etc - string encode_type{"dec"}; //dec, hex , default=dec - optional reverse; - optional show_payer; // show RAM pyer + bool json = false; + name code; + string scope; + name table; + string table_key; + string lower_bound; + string upper_bound; + uint32_t limit = 10; + string key_type; // type of key specified by index_position + string index_position; // 1 - primary (first), 2 - secondary index (in order defined by multi_index), 3 - third index, etc + string encode_type{"dec"}; //dec, hex , default=dec + std::optional reverse; + std::optional show_payer; // show RAM pyer }; struct get_table_rows_result { @@ -332,12 +331,12 @@ class read_only { get_table_rows_result get_table_rows( const get_table_rows_params& params )const; struct get_table_by_scope_params { - name code; // mandatory - name table; // optional, act as filter - string lower_bound; // lower bound of scope, optional - string upper_bound; // upper bound of scope, optional - uint32_t limit = 10; - optional reverse; + name code; // mandatory + name table; // optional, act as filter + string lower_bound; // lower bound of scope, optional + string upper_bound; // upper bound of scope, optional + uint32_t limit = 10; + std::optional reverse; }; struct get_table_by_scope_result_row { name code; @@ -354,9 +353,9 @@ class read_only { get_table_by_scope_result get_table_by_scope( const get_table_by_scope_params& params )const; struct get_currency_balance_params { - name code; - name account; - optional symbol; + name code; + name account; + std::optional symbol; }; vector get_currency_balance( const get_currency_balance_params& params )const; @@ -734,7 +733,7 @@ class chain_plugin : public plugin { static bool recover_reversible_blocks( const fc::path& db_dir, uint32_t cache_size, - optional new_db_dir = optional(), + std::optional new_db_dir = std::optional(), uint32_t truncate_at_block = 0 ); diff --git a/plugins/history_plugin/history_plugin.cpp b/plugins/history_plugin/history_plugin.cpp index 540aba79917..d426ad04304 100644 --- a/plugins/history_plugin/history_plugin.cpp +++ b/plugins/history_plugin/history_plugin.cpp @@ -141,7 +141,7 @@ namespace eosio { std::set filter_on; std::set filter_out; chain_plugin* chain_plug = nullptr; - fc::optional applied_transaction_connection; + std::optional applied_transaction_connection; bool filter(const action_trace& act) { bool pass_on = false; diff --git a/plugins/history_plugin/include/eosio/history_plugin/history_plugin.hpp b/plugins/history_plugin/include/eosio/history_plugin/history_plugin.hpp index 0bbeda361be..365d902f428 100644 --- a/plugins/history_plugin/include/eosio/history_plugin/history_plugin.hpp +++ b/plugins/history_plugin/include/eosio/history_plugin/history_plugin.hpp @@ -10,7 +10,6 @@ namespace eosio { using std::shared_ptr; using namespace appbase; using chain::name; - using fc::optional; using chain::uint128_t; typedef shared_ptr history_ptr; @@ -27,9 +26,9 @@ class read_only { struct get_actions_params { - chain::account_name account_name; - optional pos; /// a absolute sequence positon -1 is the end/last action - optional offset; ///< the number of actions relative to pos, negative numbers return [pos-offset,pos), positive numbers return [pos,pos+offset) + chain::account_name account_name; + std::optional pos; /// a absolute sequence positon -1 is the end/last action + std::optional offset; ///< the number of actions relative to pos, negative numbers return [pos-offset,pos), positive numbers return [pos,pos+offset) }; struct ordered_action_result { @@ -43,7 +42,7 @@ class read_only { struct get_actions_result { vector actions; uint32_t last_irreversible_block; - optional time_limit_exceeded_error; + std::optional time_limit_exceeded_error; }; @@ -52,7 +51,7 @@ class read_only { struct get_transaction_params { string id; - optional block_num_hint; + std::optional block_num_hint; }; struct get_transaction_result { diff --git a/plugins/http_plugin/http_plugin.cpp b/plugins/http_plugin/http_plugin.cpp index 04c7f9b71c2..54179974221 100644 --- a/plugins/http_plugin/http_plugin.cpp +++ b/plugins/http_plugin/http_plugin.cpp @@ -186,32 +186,32 @@ namespace eosio { public: // key -> priority, url_handler map url_handlers; - optional listen_endpoint; - string access_control_allow_origin; - string access_control_allow_headers; - string access_control_max_age; - bool access_control_allow_credentials = false; - size_t max_body_size{1024*1024}; + std::optional listen_endpoint; + string access_control_allow_origin; + string access_control_allow_headers; + string access_control_max_age; + bool access_control_allow_credentials = false; + size_t max_body_size{1024*1024}; websocket_server_type server; uint16_t thread_pool_size = 2; - optional thread_pool; + std::optional thread_pool; std::atomic bytes_in_flight{0}; std::atomic requests_in_flight{0}; size_t max_bytes_in_flight = 0; int32_t max_requests_in_flight = -1; fc::microseconds max_response_time{30*1000}; - optional https_listen_endpoint; - string https_cert_chain; - string https_key; - https_ecdh_curve_t https_ecdh_curve = SECP384R1; + std::optional https_listen_endpoint; + string https_cert_chain; + string https_key; + https_ecdh_curve_t https_ecdh_curve = SECP384R1; websocket_server_tls_type https_server; #ifdef BOOST_ASIO_HAS_LOCAL_SOCKETS - optional unix_endpoint; + std::optional unix_endpoint; websocket_local_server_type unix_server; #endif diff --git a/plugins/net_plugin/include/eosio/net_plugin/net_plugin.hpp b/plugins/net_plugin/include/eosio/net_plugin/net_plugin.hpp index b7b3516e18f..750ac3a74a3 100644 --- a/plugins/net_plugin/include/eosio/net_plugin/net_plugin.hpp +++ b/plugins/net_plugin/include/eosio/net_plugin/net_plugin.hpp @@ -27,10 +27,10 @@ namespace eosio { void plugin_startup(); void plugin_shutdown(); - string connect( const string& endpoint ); - string disconnect( const string& endpoint ); - optional status( const string& endpoint )const; - vector connections()const; + string connect( const string& endpoint ); + string disconnect( const string& endpoint ); + std::optional status( const string& endpoint )const; + vector connections()const; private: std::shared_ptr my; diff --git a/plugins/net_plugin/include/eosio/net_plugin/protocol.hpp b/plugins/net_plugin/include/eosio/net_plugin/protocol.hpp index 85e1420aa50..f9202fa8301 100644 --- a/plugins/net_plugin/include/eosio/net_plugin/protocol.hpp +++ b/plugins/net_plugin/include/eosio/net_plugin/protocol.hpp @@ -136,7 +136,7 @@ namespace eosio { }; struct trx_message_v1 { - fc::optional trx_id; // only provided for large trx as trade-off for small trxs not worth it + std::optional trx_id; // only provided for large trx as trade-off for small trxs not worth it std::shared_ptr trx; }; diff --git a/plugins/net_plugin/net_plugin.cpp b/plugins/net_plugin/net_plugin.cpp index 303f3b4e6e4..80960056e88 100644 --- a/plugins/net_plugin/net_plugin.cpp +++ b/plugins/net_plugin/net_plugin.cpp @@ -269,8 +269,8 @@ namespace eosio { compat::channels::transaction_ack::channel_type::handle incoming_transaction_ack_subscription; - uint16_t thread_pool_size = 2; - optional thread_pool; + uint16_t thread_pool_size = 2; + std::optional thread_pool; private: mutable std::mutex chain_info_mtx; // protects chain_* @@ -551,7 +551,7 @@ namespace eosio { void update_endpoints(); - optional peer_requested; // this peer is requesting info from us + std::optional peer_requested; // this peer is requesting info from us std::atomic socket_open{false}; @@ -587,18 +587,18 @@ namespace eosio { std::atomic no_retry{no_reason}; - mutable std::mutex conn_mtx; //< mtx for last_req .. local_endpoint_port - optional last_req; - handshake_message last_handshake_recv; - handshake_message last_handshake_sent; - block_id_type fork_head; - uint32_t fork_head_num{0}; - fc::time_point last_close; - fc::sha256 conn_node_id; - string remote_endpoint_ip; - string remote_endpoint_port; - string local_endpoint_ip; - string local_endpoint_port; + mutable std::mutex conn_mtx; //< mtx for last_req .. local_endpoint_port + std::optional last_req; + handshake_message last_handshake_recv; + handshake_message last_handshake_sent; + block_id_type fork_head; + uint32_t fork_head_num{0}; + fc::time_point last_close; + fc::sha256 conn_node_id; + string remote_endpoint_ip; + string remote_endpoint_port; + string local_endpoint_ip; + string local_endpoint_port; connection_status get_status()const; @@ -935,7 +935,7 @@ namespace eosio { bool has_last_req = false; { std::lock_guard g_conn( self->conn_mtx ); - has_last_req = !!self->last_req; + has_last_req = self->last_req.has_value(); self->last_handshake_recv = handshake_message(); self->last_handshake_sent = handshake_message(); self->last_close = fc::time_point::now(); @@ -1333,7 +1333,7 @@ namespace eosio { static std::shared_ptr> create_send_buffer( const packed_transaction_ptr& trx ) { static_assert( trx_message_v1_which == net_message::position() ); - fc::optional trx_id; + std::optional trx_id; if( trx->get_estimated_size() > 1024 ) { // simple guess on threshold fc_dlog( logger, "including trx id, est size: ${es}", ("es", trx->get_estimated_size()) ); trx_id = trx->id(); @@ -2631,7 +2631,7 @@ namespace eosio { unsigned_int which{}; fc::raw::unpack( ds, which ); if( which == trx_message_v1_which ) { - fc::optional trx_id; + std::optional trx_id; fc::raw::unpack( ds, trx_id ); if( trx_id ) { if (trx_in_progress_sz > def_max_trx_in_progress_size) { @@ -2660,7 +2660,6 @@ namespace eosio { report_dropping_trx(ptr->id(), trx_in_progress_sz); return true; } - have_trx = my_impl->dispatcher->have_txn( ptr->id() ); } node_transaction_state nts = {ptr->id(), ptr->expiration(), 0, connection_id}; @@ -3784,12 +3783,12 @@ namespace eosio { return "no known connection for host"; } - optional net_plugin::status( const string& host )const { + std::optional net_plugin::status( const string& host )const { std::shared_lock g( my->connections_mtx ); auto con = my->find_connection( host ); if( con ) return con->get_status(); - return optional(); + return std::optional(); } vector net_plugin::connections()const { diff --git a/plugins/producer_plugin/include/eosio/producer_plugin/producer_plugin.hpp b/plugins/producer_plugin/include/eosio/producer_plugin/producer_plugin.hpp index 740eabae446..72860a8e1b3 100644 --- a/plugins/producer_plugin/include/eosio/producer_plugin/producer_plugin.hpp +++ b/plugins/producer_plugin/include/eosio/producer_plugin/producer_plugin.hpp @@ -14,23 +14,23 @@ class producer_plugin : public appbase::plugin { APPBASE_PLUGIN_REQUIRES((chain_plugin)(signature_provider_plugin)) struct runtime_options { - fc::optional max_transaction_time; - fc::optional max_irreversible_block_age; - fc::optional produce_time_offset_us; - fc::optional last_block_time_offset_us; - fc::optional max_scheduled_transaction_time_per_block_ms; - fc::optional subjective_cpu_leeway_us; - fc::optional incoming_defer_ratio; - fc::optional greylist_limit; + std::optional max_transaction_time; + std::optional max_irreversible_block_age; + std::optional produce_time_offset_us; + std::optional last_block_time_offset_us; + std::optional max_scheduled_transaction_time_per_block_ms; + std::optional subjective_cpu_leeway_us; + std::optional incoming_defer_ratio; + std::optional greylist_limit; }; struct whitelist_blacklist { - fc::optional< flat_set > actor_whitelist; - fc::optional< flat_set > actor_blacklist; - fc::optional< flat_set > contract_whitelist; - fc::optional< flat_set > contract_blacklist; - fc::optional< flat_set< std::pair > > action_blacklist; - fc::optional< flat_set > key_blacklist; + std::optional< flat_set > actor_whitelist; + std::optional< flat_set > actor_blacklist; + std::optional< flat_set > contract_whitelist; + std::optional< flat_set > contract_blacklist; + std::optional< flat_set< std::pair > > action_blacklist; + std::optional< flat_set > key_blacklist; }; struct greylist_params { @@ -57,15 +57,15 @@ class producer_plugin : public appbase::plugin { }; struct get_account_ram_corrections_params { - optional lower_bound; - optional upper_bound; - uint32_t limit = 10; - bool reverse = false; + std::optional lower_bound; + std::optional upper_bound; + uint32_t limit = 10; + bool reverse = false; }; struct get_account_ram_corrections_result { - std::vector rows; - optional more; + std::vector rows; + std::optional more; }; template diff --git a/plugins/producer_plugin/producer_plugin.cpp b/plugins/producer_plugin/producer_plugin.cpp index 52528e94437..efccd967982 100644 --- a/plugins/producer_plugin/producer_plugin.cpp +++ b/plugins/producer_plugin/producer_plugin.cpp @@ -180,7 +180,7 @@ class producer_plugin_impl : public std::enable_shared_from_this calculate_next_block_time(const account_name& producer_name, const block_timestamp_type& current_block_time) const; + std::optional calculate_next_block_time(const account_name& producer_name, const block_timestamp_type& current_block_time) const; void schedule_production_loop(); void schedule_maybe_produce_block( bool exhausted ); void produce_block(); @@ -204,7 +204,7 @@ class producer_plugin_impl : public std::enable_shared_from_this _producer_watermarks; pending_block_mode _pending_block_mode = pending_block_mode::speculating; unapplied_transaction_queue _unapplied_transactions; - fc::optional _thread_pool; + std::optional _thread_pool; std::atomic _max_transaction_time_ms; // modified by app thread, read by net_plugin thread pool fc::microseconds _max_irreversible_block_age_us; @@ -231,9 +231,9 @@ class producer_plugin_impl : public std::enable_shared_from_this _accepted_block_connection; - fc::optional _accepted_block_header_connection; - fc::optional _irreversible_block_connection; + std::optional _accepted_block_connection; + std::optional _accepted_block_header_connection; + std::optional _irreversible_block_connection; /* * HACK ALERT @@ -585,8 +585,8 @@ class producer_plugin_impl : public std::enable_shared_from_this& weak_this, optional wake_up_time); - optional calculate_producer_wake_up_time( const block_timestamp_type& ref_block_time ) const; + void schedule_delayed_production_loop(const std::weak_ptr& weak_this, std::optional wake_up_time); + std::optional calculate_producer_wake_up_time( const block_timestamp_type& ref_block_time ) const; }; @@ -1011,7 +1011,7 @@ producer_plugin::runtime_options producer_plugin::get_runtime_options() const { my->_max_scheduled_transaction_time_per_block_ms, my->chain_plug->chain().get_subjective_cpu_leeway() ? my->chain_plug->chain().get_subjective_cpu_leeway()->count() : - fc::optional(), + std::optional(), my->_incoming_defer_ratio, my->chain_plug->chain().get_greylist_limit() }; @@ -1056,12 +1056,12 @@ producer_plugin::whitelist_blacklist producer_plugin::get_whitelist_blacklist() void producer_plugin::set_whitelist_blacklist(const producer_plugin::whitelist_blacklist& params) { chain::controller& chain = my->chain_plug->chain(); - if(params.actor_whitelist.valid()) chain.set_actor_whitelist(*params.actor_whitelist); - if(params.actor_blacklist.valid()) chain.set_actor_blacklist(*params.actor_blacklist); - if(params.contract_whitelist.valid()) chain.set_contract_whitelist(*params.contract_whitelist); - if(params.contract_blacklist.valid()) chain.set_contract_blacklist(*params.contract_blacklist); - if(params.action_blacklist.valid()) chain.set_action_blacklist(*params.action_blacklist); - if(params.key_blacklist.valid()) chain.set_key_blacklist(*params.key_blacklist); + if(params.actor_whitelist) chain.set_actor_whitelist(*params.actor_whitelist); + if(params.actor_blacklist) chain.set_actor_blacklist(*params.actor_blacklist); + if(params.contract_whitelist) chain.set_contract_whitelist(*params.contract_whitelist); + if(params.contract_blacklist) chain.set_contract_blacklist(*params.contract_blacklist); + if(params.action_blacklist) chain.set_action_blacklist(*params.action_blacklist); + if(params.key_blacklist) chain.set_key_blacklist(*params.key_blacklist); } producer_plugin::integrity_hash_information producer_plugin::get_integrity_hash() const { @@ -1273,7 +1273,7 @@ producer_plugin::get_account_ram_corrections( const get_account_ram_corrections_ return result; } -optional producer_plugin_impl::calculate_next_block_time(const account_name& producer_name, const block_timestamp_type& current_block_time) const { +std::optional producer_plugin_impl::calculate_next_block_time(const account_name& producer_name, const block_timestamp_type& current_block_time) const { chain::controller& chain = chain_plug->chain(); const auto& hbs = chain.head_block_state(); const auto& active_schedule = hbs->active_schedule.producers; @@ -1282,7 +1282,7 @@ optional producer_plugin_impl::calculate_next_block_time(const a auto itr = std::find_if(active_schedule.begin(), active_schedule.end(), [&](const auto& asp){ return asp.producer_name == producer_name; }); if (itr == active_schedule.end()) { // this producer is not in the active producer set - return optional(); + return std::optional(); } size_t producer_index = itr - active_schedule.begin(); @@ -1925,9 +1925,9 @@ void producer_plugin_impl::schedule_maybe_produce_block( bool exhausted ) { } ) ); } -optional producer_plugin_impl::calculate_producer_wake_up_time( const block_timestamp_type& ref_block_time ) const { +std::optional producer_plugin_impl::calculate_producer_wake_up_time( const block_timestamp_type& ref_block_time ) const { // if we have any producers then we should at least set a timer for our next available slot - optional wake_up_time; + std::optional wake_up_time; for (const auto& p : _producers) { auto next_producer_block_time = calculate_next_block_time(p, ref_block_time); if (next_producer_block_time) { @@ -1949,7 +1949,7 @@ optional producer_plugin_impl::calculate_producer_wake_up_time( return wake_up_time; } -void producer_plugin_impl::schedule_delayed_production_loop(const std::weak_ptr& weak_this, optional wake_up_time) { +void producer_plugin_impl::schedule_delayed_production_loop(const std::weak_ptr& weak_this, std::optional wake_up_time) { if (wake_up_time) { fc_dlog(_log, "Scheduling Speculative/Production Change at ${time}", ("time", wake_up_time)); static const boost::posix_time::ptime epoch(boost::gregorian::date(1970, 1, 1)); @@ -1988,7 +1988,7 @@ static auto make_debug_time_logger() { }); } -static auto maybe_make_debug_time_logger() -> fc::optional { +static auto maybe_make_debug_time_logger() -> std::optional { if (_log.is_enabled( fc::log_level::debug ) ){ return make_debug_time_logger(); } else { diff --git a/plugins/signature_provider_plugin/signature_provider_plugin.cpp b/plugins/signature_provider_plugin/signature_provider_plugin.cpp index de39d4d5bb5..7dfa3dab647 100644 --- a/plugins/signature_provider_plugin/signature_provider_plugin.cpp +++ b/plugins/signature_provider_plugin/signature_provider_plugin.cpp @@ -47,7 +47,7 @@ class signature_provider_plugin_impl { if(boost::algorithm::starts_with(url_str, "unix://")) //send the entire string after unix:// to http_plugin. It'll auto-detect which part // is the unix socket path, and which part is the url to hit on the server - keosd_url = fc::url("unix", url_str.substr(7), fc::ostring(), fc::ostring(), fc::ostring(), fc::ostring(), fc::ovariant_object(), fc::optional()); + keosd_url = fc::url("unix", url_str.substr(7), fc::ostring(), fc::ostring(), fc::ostring(), fc::ostring(), fc::ovariant_object(), std::optional()); else keosd_url = fc::url(url_str); diff --git a/plugins/state_history_plugin/state_history_plugin.cpp b/plugins/state_history_plugin/state_history_plugin.cpp index 9253a19a920..eef63cb57f2 100644 --- a/plugins/state_history_plugin/state_history_plugin.cpp +++ b/plugins/state_history_plugin/state_history_plugin.cpp @@ -42,12 +42,12 @@ auto catch_and_log(F f) { struct state_history_plugin_impl : std::enable_shared_from_this { chain_plugin* chain_plug = nullptr; - fc::optional trace_log; - fc::optional chain_state_log; + std::optional trace_log; + std::optional chain_state_log; bool stopping = false; - fc::optional applied_transaction_connection; - fc::optional block_start_connection; - fc::optional accepted_block_connection; + std::optional applied_transaction_connection; + std::optional block_start_connection; + std::optional accepted_block_connection; string endpoint_address = "0.0.0.0"; uint16_t endpoint_port = 8080; std::unique_ptr acceptor; @@ -85,7 +85,7 @@ struct state_history_plugin_impl : std::enable_shared_from_this> send_queue; - fc::optional current_request; + std::optional current_request; bool need_to_send_update = false; session(std::shared_ptr plugin) @@ -195,7 +195,7 @@ struct state_history_plugin_impl : std::enable_shared_from_this -#include #include namespace fc { class variant; } @@ -21,8 +20,8 @@ class test_control_plugin_impl { void applied_irreversible_block(const chain::block_state_ptr& bsp); void process_next_block_state(const chain::block_state_ptr& bsp); - fc::optional _accepted_block_connection; - fc::optional _irreversible_block_connection; + std::optional _accepted_block_connection; + std::optional _irreversible_block_connection; chain::controller& _chain; account_name _producer; int32_t _where_in_sequence; diff --git a/plugins/trace_api_plugin/include/eosio/trace_api/chain_extraction.hpp b/plugins/trace_api_plugin/include/eosio/trace_api/chain_extraction.hpp index 02da39fccc6..f4a0f1ddaa3 100644 --- a/plugins/trace_api_plugin/include/eosio/trace_api/chain_extraction.hpp +++ b/plugins/trace_api_plugin/include/eosio/trace_api/chain_extraction.hpp @@ -120,7 +120,7 @@ class chain_extraction_impl_type { StoreProvider store; exception_handler except_handler; std::map cached_traces; - fc::optional onblock_trace; + std::optional onblock_trace; }; diff --git a/plugins/trace_api_plugin/trace_api_plugin.cpp b/plugins/trace_api_plugin/trace_api_plugin.cpp index 0fffa1d5eec..af284b5129e 100644 --- a/plugins/trace_api_plugin/trace_api_plugin.cpp +++ b/plugins/trace_api_plugin/trace_api_plugin.cpp @@ -356,10 +356,10 @@ struct trace_api_plugin_impl { using chain_extraction_t = chain_extraction_impl_type>; std::shared_ptr extraction; - fc::optional applied_transaction_connection; - fc::optional block_start_connection; - fc::optional accepted_block_connection; - fc::optional irreversible_block_connection; + std::optional applied_transaction_connection; + std::optional block_start_connection; + std::optional accepted_block_connection; + std::optional irreversible_block_connection; }; trace_api_plugin::trace_api_plugin() diff --git a/plugins/txn_test_gen_plugin/txn_test_gen_plugin.cpp b/plugins/txn_test_gen_plugin/txn_test_gen_plugin.cpp index d559d8b0184..89c33b0fa24 100644 --- a/plugins/txn_test_gen_plugin/txn_test_gen_plugin.cpp +++ b/plugins/txn_test_gen_plugin/txn_test_gen_plugin.cpp @@ -97,7 +97,7 @@ struct txn_test_gen_plugin_impl { uint64_t _txcount = 0; uint16_t thread_pool_size; - fc::optional thread_pool; + std::optional thread_pool; std::shared_ptr timer; name newaccountA; name newaccountB; diff --git a/plugins/wallet_plugin/include/eosio/wallet_plugin/se_wallet.hpp b/plugins/wallet_plugin/include/eosio/wallet_plugin/se_wallet.hpp index 9e33b194a37..62329d6af3d 100644 --- a/plugins/wallet_plugin/include/eosio/wallet_plugin/se_wallet.hpp +++ b/plugins/wallet_plugin/include/eosio/wallet_plugin/se_wallet.hpp @@ -32,7 +32,7 @@ class se_wallet final : public wallet_api { string create_key(string key_type) override; bool remove_key(string key) override; - fc::optional try_sign_digest(const digest_type digest, const public_key_type public_key) override; + std::optional try_sign_digest(const digest_type digest, const public_key_type public_key) override; private: std::unique_ptr my; diff --git a/plugins/wallet_plugin/include/eosio/wallet_plugin/wallet.hpp b/plugins/wallet_plugin/include/eosio/wallet_plugin/wallet.hpp index 92f2c0e2276..f1468cdb3ab 100644 --- a/plugins/wallet_plugin/include/eosio/wallet_plugin/wallet.hpp +++ b/plugins/wallet_plugin/include/eosio/wallet_plugin/wallet.hpp @@ -177,7 +177,7 @@ class soft_wallet final : public wallet_api /* Attempts to sign a digest via the given public_key */ - fc::optional try_sign_digest( const digest_type digest, const public_key_type public_key ) override; + std::optional try_sign_digest( const digest_type digest, const public_key_type public_key ) override; std::shared_ptr my; void encrypt_keys(); diff --git a/plugins/wallet_plugin/include/eosio/wallet_plugin/wallet_api.hpp b/plugins/wallet_plugin/include/eosio/wallet_plugin/wallet_api.hpp index bdca3ee93e1..4810898c9c1 100644 --- a/plugins/wallet_plugin/include/eosio/wallet_plugin/wallet_api.hpp +++ b/plugins/wallet_plugin/include/eosio/wallet_plugin/wallet_api.hpp @@ -97,7 +97,7 @@ class wallet_api /** Returns a signature given the digest and public_key, if this wallet can sign via that public key */ - virtual fc::optional try_sign_digest( const digest_type digest, const public_key_type public_key ) = 0; + virtual std::optional try_sign_digest( const digest_type digest, const public_key_type public_key ) = 0; }; }} diff --git a/plugins/wallet_plugin/include/eosio/wallet_plugin/yubihsm_wallet.hpp b/plugins/wallet_plugin/include/eosio/wallet_plugin/yubihsm_wallet.hpp index 49caa9c184b..abafbe8478c 100644 --- a/plugins/wallet_plugin/include/eosio/wallet_plugin/yubihsm_wallet.hpp +++ b/plugins/wallet_plugin/include/eosio/wallet_plugin/yubihsm_wallet.hpp @@ -32,7 +32,7 @@ class yubihsm_wallet final : public wallet_api { string create_key(string key_type) override; bool remove_key(string key) override; - fc::optional try_sign_digest(const digest_type digest, const public_key_type public_key) override; + std::optional try_sign_digest(const digest_type digest, const public_key_type public_key) override; private: std::unique_ptr my; diff --git a/plugins/wallet_plugin/se_wallet.cpp b/plugins/wallet_plugin/se_wallet.cpp index aa46fb2a4b1..5867a89180f 100644 --- a/plugins/wallet_plugin/se_wallet.cpp +++ b/plugins/wallet_plugin/se_wallet.cpp @@ -95,14 +95,14 @@ bool se_wallet::remove_key(string key) { FC_THROW_EXCEPTION(chain::wallet_exception, "Given key to delete not found in Secure Enclave wallet"); } -fc::optional se_wallet::try_sign_digest(const digest_type digest, const public_key_type public_key) { +std::optional se_wallet::try_sign_digest(const digest_type digest, const public_key_type public_key) { auto se_keys = secure_enclave::get_all_keys(); for(auto it = se_keys.begin(); it != se_keys.end(); ++it) if(it->public_key() == public_key) return it->sign(digest); - return fc::optional{}; + return std::optional(); } }} diff --git a/plugins/wallet_plugin/wallet.cpp b/plugins/wallet_plugin/wallet.cpp index 60cb494d3e2..a4859a584ec 100644 --- a/plugins/wallet_plugin/wallet.cpp +++ b/plugins/wallet_plugin/wallet.cpp @@ -115,18 +115,18 @@ class soft_wallet_impl string get_wallet_filename() const { return _wallet_filename; } - fc::optional try_get_private_key(const public_key_type& id)const + std::optional try_get_private_key(const public_key_type& id)const { auto it = _keys.find(id); if( it != _keys.end() ) return it->second; - return fc::optional(); + return std::optional(); } - fc::optional try_sign_digest( const digest_type digest, const public_key_type public_key ) { + std::optional try_sign_digest( const digest_type digest, const public_key_type public_key ) { auto it = _keys.find(public_key); if( it == _keys.end() ) - return fc::optional{}; + return std::optional(); return it->second.sign(digest); } @@ -396,7 +396,7 @@ private_key_type soft_wallet::get_private_key( public_key_type pubkey )const return my->get_private_key( pubkey ); } -fc::optional soft_wallet::try_sign_digest( const digest_type digest, const public_key_type public_key ) { +std::optional soft_wallet::try_sign_digest( const digest_type digest, const public_key_type public_key ) { return my->try_sign_digest(digest, public_key); } diff --git a/plugins/wallet_plugin/wallet_manager.cpp b/plugins/wallet_plugin/wallet_manager.cpp index 0b3bbc6c696..6eaa8a75025 100644 --- a/plugins/wallet_plugin/wallet_manager.cpp +++ b/plugins/wallet_plugin/wallet_manager.cpp @@ -233,7 +233,7 @@ wallet_manager::sign_transaction(const chain::signed_transaction& txn, const fla bool found = false; for (const auto& i : wallets) { if (!i.second->is_locked()) { - fc::optional sig = i.second->try_sign_digest(stxn.sig_digest(id, stxn.context_free_data), pk); + std::optional sig = i.second->try_sign_digest(stxn.sig_digest(id, stxn.context_free_data), pk); if (sig) { stxn.signatures.push_back(*sig); found = true; @@ -256,7 +256,7 @@ wallet_manager::sign_digest(const chain::digest_type& digest, const public_key_t try { for (const auto& i : wallets) { if (!i.second->is_locked()) { - fc::optional sig = i.second->try_sign_digest(digest, key); + std::optional sig = i.second->try_sign_digest(digest, key); if (sig) return *sig; } diff --git a/plugins/wallet_plugin/yubihsm_wallet.cpp b/plugins/wallet_plugin/yubihsm_wallet.cpp index 0ff2d83116f..d2de96ae6d1 100644 --- a/plugins/wallet_plugin/yubihsm_wallet.cpp +++ b/plugins/wallet_plugin/yubihsm_wallet.cpp @@ -133,10 +133,10 @@ struct yubihsm_wallet_impl { }); } - fc::optional try_sign_digest(const digest_type d, const public_key_type public_key) { + std::optional try_sign_digest(const digest_type d, const public_key_type public_key) { auto it = _keys.find(public_key); if(it == _keys.end()) - return fc::optional{}; + return std::optional(); size_t der_sig_sz = 128; uint8_t der_sig[der_sig_sz]; @@ -261,7 +261,7 @@ bool yubihsm_wallet::remove_key(string key) { return true; } -fc::optional yubihsm_wallet::try_sign_digest(const digest_type digest, const public_key_type public_key) { +std::optional yubihsm_wallet::try_sign_digest(const digest_type digest, const public_key_type public_key) { return my->try_sign_digest(digest, public_key); } diff --git a/programs/cleos/httpc.cpp b/programs/cleos/httpc.cpp index 607bbdeb17a..ecdb1541e15 100644 --- a/programs/cleos/httpc.cpp +++ b/programs/cleos/httpc.cpp @@ -149,7 +149,7 @@ namespace eosio { namespace client { namespace http { // non error results are guaranteed to return a non-empty range vector resolved_addresses; resolved_addresses.reserve(result.size()); - optional resolved_port; + std::optional resolved_port; bool is_loopback = true; for(const auto& r : result) { diff --git a/programs/cleos/main.cpp b/programs/cleos/main.cpp index 2142aea3dd1..4dbc2c9df32 100644 --- a/programs/cleos/main.cpp +++ b/programs/cleos/main.cpp @@ -347,14 +347,14 @@ chain::action generate_nonce_action() { } //resolver for ABI serializer to decode actions in proposed transaction in multisig contract -auto abi_serializer_resolver = [](const name& account) -> fc::optional { - static unordered_map > abi_cache; +auto abi_serializer_resolver = [](const name& account) -> std::optional { + static unordered_map > abi_cache; auto it = abi_cache.find( account ); if ( it == abi_cache.end() ) { const auto raw_abi_result = call(get_raw_abi_func, fc::mutable_variant_object("account_name", account)); const auto raw_abi_blob = raw_abi_result["abi"].as_blob().data; - fc::optional abis; + std::optional abis; if (raw_abi_blob.size() != 0) { abis.emplace(fc::raw::unpack(raw_abi_blob), abi_serializer::create_yield_function( abi_serializer_max_time )); } else { @@ -368,8 +368,8 @@ auto abi_serializer_resolver = [](const name& account) -> fc::optionalsecond; }; -auto abi_serializer_resolver_empty = [](const name& account) -> fc::optional { - return fc::optional(); +auto abi_serializer_resolver_empty = [](const name& account) -> std::optional { + return std::optional(); }; void prompt_for_wallet_password(string& pw, const string& name) { @@ -522,7 +522,7 @@ void print_action( const fc::variant& at ) { bytes variant_to_bin( const account_name& account, const action_name& action, const fc::variant& action_args_var ) { auto abis = abi_serializer_resolver( account ); - FC_ASSERT( abis.valid(), "No ABI found for ${contract}", ("contract", account)); + FC_ASSERT( abis, "No ABI found for ${contract}", ("contract", account)); auto action_type = abis->get_action_type( action ); FC_ASSERT( !action_type.empty(), "Unknown action ${action} in contract ${contract}", ("action", action)( "contract", account )); @@ -531,7 +531,7 @@ bytes variant_to_bin( const account_name& account, const action_name& action, co fc::variant bin_to_variant( const account_name& account, const action_name& action, const bytes& action_args) { auto abis = abi_serializer_resolver( account ); - FC_ASSERT( abis.valid(), "No ABI found for ${contract}", ("contract", account)); + FC_ASSERT( abis, "No ABI found for ${contract}", ("contract", account)); auto action_type = abis->get_action_type( action ); FC_ASSERT( !action_type.empty(), "Unknown action ${action} in contract ${contract}", ("action", action)( "contract", account )); @@ -603,7 +603,7 @@ void print_result( const fc::variant& result ) { try { cerr << " us\n"; if( status == "failed" ) { - auto soft_except = processed["except"].as>(); + auto soft_except = processed["except"].as>(); if( soft_except ) { edump((soft_except->to_detail_string())); } @@ -2213,7 +2213,7 @@ void get_account( const string& accountName, const string& coresym, bool json_fo asset staked; asset unstaking; - if( res.core_liquid_balance.valid() ) { + if( res.core_liquid_balance ) { unstaking = asset( 0, res.core_liquid_balance->get_symbol() ); // Correct core symbol for unstaking asset. staked = asset( 0, res.core_liquid_balance->get_symbol() ); // Correct core symbol for staked asset. } @@ -2433,7 +2433,7 @@ void get_account( const string& accountName, const string& coresym, bool json_fo } } - if( res.core_liquid_balance.valid() ) { + if( res.core_liquid_balance ) { std::cout << res.core_liquid_balance->get_symbol().name() << " balances: " << std::endl; std::cout << indent << std::left << std::setw(11) << "liquid:" << std::right << std::setw(18) << *res.core_liquid_balance << std::endl; @@ -2669,7 +2669,7 @@ int main( int argc, char** argv ) { } EOS_RETHROW_EXCEPTIONS(transaction_type_exception, "Invalid transaction format: '${data}'", ("data", fc::json::to_string(trx_var, fc::time_point::maximum()))) - fc::optional chain_id; + std::optional chain_id; if( str_chain_id.size() == 0 ) { ilog( "grabbing chain_id from ${n}", ("n", node_executable_name) ); @@ -2705,13 +2705,13 @@ int main( int argc, char** argv ) { getBlock->callback([&blockArg, &get_bhs, &get_binfo] { EOSC_ASSERT( !(get_bhs && get_binfo), "ERROR: Either --header-state or --info can be set" ); if (get_binfo) { - fc::optional block_num; + std::optional block_num; try { block_num = fc::to_int64(blockArg); } catch (...) { // error is handled in assertion below } - EOSC_ASSERT( block_num.valid() && (*block_num > 0), "Invalid block num: ${block_num}", ("block_num", blockArg) ); + EOSC_ASSERT( block_num && (*block_num > 0), "Invalid block num: ${block_num}", ("block_num", blockArg) ); const auto arg = fc::variant_object("block_num", static_cast(*block_num)); std::cout << fc::json::to_pretty_string(call(get_block_info_func, arg)) << std::endl; } else { @@ -3496,7 +3496,7 @@ int main( int argc, char** argv ) { } EOS_RETHROW_EXCEPTIONS(transaction_type_exception, "Invalid transaction format: '${data}'", ("data", fc::json::to_string(trx_var, fc::time_point::maximum()))) - fc::optional chain_id; + std::optional chain_id; if( str_chain_id.size() == 0 ) { ilog( "grabbing chain_id from ${n}", ("n", node_executable_name) ); diff --git a/programs/eosio-blocklog/main.cpp b/programs/eosio-blocklog/main.cpp index 49b41710261..c0dea933bd5 100644 --- a/programs/eosio-blocklog/main.cpp +++ b/programs/eosio-blocklog/main.cpp @@ -84,7 +84,7 @@ void blocklog::read_log() { first_block = block_logger.first_block_num(); } - optional reversible_blocks; + std::optional reversible_blocks; try { ilog("opening reversible db"); reversible_blocks.emplace(blocks_dir / config::reversible_blocks_dir_name, chainbase::database::read_only, config::default_reversible_cache_size); @@ -128,7 +128,7 @@ void blocklog::read_log() { auto print_block = [&](auto& next) { abi_serializer::to_variant(*next, pretty_output, - []( account_name n ) { return optional(); }, + []( account_name n ) { return std::optional(); }, abi_serializer::create_yield_function( deadline )); const auto block_id = next->calculate_id(); const uint32_t ref_block_prefix = block_id._hash[1]; diff --git a/programs/eosio-launcher/main.cpp b/programs/eosio-launcher/main.cpp index 819feaf0d0e..111cb246176 100644 --- a/programs/eosio-launcher/main.cpp +++ b/programs/eosio-launcher/main.cpp @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include @@ -423,8 +422,8 @@ struct launcher_def { producer_set_def producer_set; string start_temp; string start_script; - fc::optional max_block_cpu_usage; - fc::optional max_transaction_cpu_usage; + std::optional max_block_cpu_usage; + std::optional max_transaction_cpu_usage; eosio::chain::genesis_state genesis_from_file; void assign_name (eosd_def &node, bool is_bios); diff --git a/programs/eosio-tester/main.cpp b/programs/eosio-tester/main.cpp index f89352e7488..18baae26b86 100644 --- a/programs/eosio-tester/main.cpp +++ b/programs/eosio-tester/main.cpp @@ -135,11 +135,11 @@ struct intrinsic_context { protocol_feature_set make_protocol_feature_set() { protocol_feature_set pfs; - std::map> visited_builtins; + std::map> visited_builtins; std::function add_builtins = [&pfs, &visited_builtins, &add_builtins](builtin_protocol_feature_t codename) -> digest_type { - auto res = visited_builtins.emplace(codename, optional()); + auto res = visited_builtins.emplace(codename, std::optional()); if (!res.second) { EOS_ASSERT(res.first->second, protocol_feature_exception, "invariant failure: cycle found in builtin protocol feature dependencies"); @@ -182,10 +182,10 @@ struct test_chain { fc::temp_directory dir; std::unique_ptr cfg; std::unique_ptr control; - fc::optional applied_transaction_connection; - fc::optional accepted_block_connection; + std::optional applied_transaction_connection; + std::optional accepted_block_connection; eosio::state_history::transaction_trace_cache trace_cache; - fc::optional prev_block; + std::optional prev_block; std::map> history; std::unique_ptr intr_ctx; std::set refs; diff --git a/tests/chain_plugin_tests.cpp b/tests/chain_plugin_tests.cpp index 10e456cddc1..12797cb1111 100644 --- a/tests/chain_plugin_tests.cpp +++ b/tests/chain_plugin_tests.cpp @@ -45,19 +45,19 @@ BOOST_FIXTURE_TEST_CASE( get_block_with_invalid_abi, TESTER ) try { set_abi( N(asserter), contracts::asserter_abi().data() ); produce_blocks(1); - auto resolver = [&,this]( const account_name& name ) -> optional { + auto resolver = [&,this]( const account_name& name ) -> std::optional { try { const auto& accnt = this->control->db().get( name ); abi_def abi; if (abi_serializer::to_abi(accnt.abi, abi)) { return abi_serializer(abi, abi_serializer::create_yield_function( abi_serializer_max_time )); } - return optional(); + return std::optional(); } FC_RETHROW_EXCEPTIONS(error, "resolver failed at chain_plugin_tests::abi_invalid_type"); }; // abi should be resolved - BOOST_REQUIRE_EQUAL(true, resolver(N(asserter)).valid()); + BOOST_REQUIRE_EQUAL(true, resolver(N(asserter)).has_value()); // make an action using the valid contract & abi variant pretty_trx = mutable_variant_object() diff --git a/unittests/abi_tests.cpp b/unittests/abi_tests.cpp index fa4d8fc77ae..8ac12667931 100644 --- a/unittests/abi_tests.cpp +++ b/unittests/abi_tests.cpp @@ -62,7 +62,7 @@ void verify_round_trip_conversion( const abi_serializer& abis, const type_name& auto get_resolver(const abi_def& abi = abi_def()) { - return [&abi](const account_name &name) -> optional { + return [&abi](const account_name &name) -> std::optional { return abi_serializer(eosio_contract_abi(abi), abi_serializer::create_yield_function( max_serialization_time )); }; } @@ -3228,13 +3228,13 @@ BOOST_AUTO_TEST_CASE(serialize_optional_struct_type) } template -inline std::pair generate_action_trace(const fc::optional & return_value, const std::string & return_value_hex, bool parsable = true) +inline std::pair generate_action_trace(const std::optional & return_value, const std::string & return_value_hex, bool parsable = true) { action_trace at; at.action_ordinal = 0; at.creator_action_ordinal = 1; at.closest_unnotified_ancestor_action_ordinal = 2; - at.receipt = fc::optional{}; + at.receipt = std::optional{}; at.receiver = action_name{"test"}; at.act = eosio::chain::action( std::vector{ @@ -3249,8 +3249,8 @@ inline std::pair generate_action_trace(const fc::opti at.trx_id = transaction_id_type{"5d039021cf3262c5036a6ad40a809ae1440ae6c6792a48e6e95abf083b108d5f"}; at.block_num = 4; at.block_time = block_timestamp_type{5}; - at.producer_block_id = fc::optional{}; - if (return_value.valid()) { + at.producer_block_id = std::optional{}; + if (return_value.has_value()) { at.return_value = fc::raw::pack(*return_value); } std::stringstream expected_json; @@ -3283,7 +3283,7 @@ inline std::pair generate_action_trace(const fc::opti << "\"except\":null," << "\"error_code\":null," << "\"return_value_hex_data\":\"" << return_value_hex << "\""; - if (return_value.valid() && parsable) { + if (return_value.has_value() && parsable) { if (std::is_same::value) { expected_json << ",\"return_value_data\":\"" << *return_value << "\""; @@ -3301,14 +3301,14 @@ inline std::pair generate_action_trace(const fc::opti } inline std::pair generate_action_trace() { - return generate_action_trace(fc::optional(), ""); + return generate_action_trace(std::optional(), ""); } BOOST_AUTO_TEST_CASE(abi_to_variant__add_action__good_return_value) { action_trace at; std::string expected_json; - std::tie(at, expected_json) = generate_action_trace(fc::optional{6}, "0600"); + std::tie(at, expected_json) = generate_action_trace(std::optional{6}, "0600"); auto abi = R"({ "version": "eosio::abi/1.0", @@ -3339,7 +3339,7 @@ BOOST_AUTO_TEST_CASE(abi_to_variant__add_action__bad_return_value) { action_trace at; std::string expected_json; - std::tie(at, expected_json) = generate_action_trace(fc::optional{"no return"}, "096e6f2072657475726e", false); + std::tie(at, expected_json) = generate_action_trace(std::optional{"no return"}, "096e6f2072657475726e", false); auto abi = R"({ "version": "eosio::abi/1.0", diff --git a/unittests/api_tests.cpp b/unittests/api_tests.cpp index 6c2a5b36853..61a5e04b7c3 100644 --- a/unittests/api_tests.cpp +++ b/unittests/api_tests.cpp @@ -3091,14 +3091,14 @@ BOOST_FIXTURE_TEST_CASE(eosio_assert_code_tests, TESTER) { try { produce_block(); auto omsg1 = abis.get_error_message(1); - BOOST_REQUIRE_EQUAL( omsg1.valid(), true ); + BOOST_REQUIRE_EQUAL( omsg1.has_value(), true ); BOOST_CHECK_EQUAL( *omsg1, "standard error message" ); auto omsg2 = abis.get_error_message(2); - BOOST_CHECK_EQUAL( omsg2.valid(), false ); + BOOST_CHECK_EQUAL( omsg2.has_value(), false ); auto omsg3 = abis.get_error_message(42); - BOOST_REQUIRE_EQUAL( omsg3.valid(), true ); + BOOST_REQUIRE_EQUAL( omsg3.has_value(), true ); BOOST_CHECK_EQUAL( *omsg3, "The answer to life, the universe, and everything." ); produce_block(); @@ -3188,7 +3188,7 @@ BOOST_FIXTURE_TEST_CASE(action_ordinal_test, TESTER) { try { BOOST_REQUIRE_EQUAL(atrace[0].receiver, N(testapi)); BOOST_REQUIRE_EQUAL(atrace[0].act.account, N(testapi)); BOOST_REQUIRE_EQUAL(atrace[0].act.name, TEST_METHOD("test_action", "test_action_ordinal1")); - BOOST_REQUIRE_EQUAL(atrace[0].receipt.valid(), true); + BOOST_REQUIRE_EQUAL(atrace[0].receipt.has_value(), true); BOOST_REQUIRE_EQUAL(fc::raw::unpack(atrace[0].return_value), unsigned_int(1) ); BOOST_REQUIRE(pad(atrace[0].receipt->act_digest, atrace[0].act, atrace[0].return_value)); int start_gseq = atrace[0].receipt->global_sequence; @@ -3199,7 +3199,7 @@ BOOST_FIXTURE_TEST_CASE(action_ordinal_test, TESTER) { try { BOOST_REQUIRE_EQUAL(atrace[1].receiver, N(bob)); BOOST_REQUIRE_EQUAL(atrace[1].act.account, N(testapi)); BOOST_REQUIRE_EQUAL(atrace[1].act.name, TEST_METHOD("test_action", "test_action_ordinal1")); - BOOST_REQUIRE_EQUAL(atrace[1].receipt.valid(), true); + BOOST_REQUIRE_EQUAL(atrace[1].receipt.has_value(), true); BOOST_REQUIRE_EQUAL(fc::raw::unpack(atrace[1].return_value), "bob" ); BOOST_REQUIRE(pad(atrace[1].receipt->act_digest, atrace[1].act, atrace[1].return_value)); BOOST_REQUIRE_EQUAL(atrace[1].receipt->global_sequence, start_gseq + 1); @@ -3210,7 +3210,7 @@ BOOST_FIXTURE_TEST_CASE(action_ordinal_test, TESTER) { try { BOOST_REQUIRE_EQUAL(atrace[2].receiver, N(testapi)); BOOST_REQUIRE_EQUAL(atrace[2].act.account, N(testapi)); BOOST_REQUIRE_EQUAL(atrace[2].act.name, TEST_METHOD("test_action", "test_action_ordinal2")); - BOOST_REQUIRE_EQUAL(atrace[2].receipt.valid(), true); + BOOST_REQUIRE_EQUAL(atrace[2].receipt.has_value(), true); BOOST_REQUIRE_EQUAL(fc::raw::unpack(atrace[2].return_value), name("five") ); BOOST_REQUIRE(pad(atrace[2].receipt->act_digest, atrace[2].act, atrace[2].return_value)); BOOST_REQUIRE_EQUAL(atrace[2].receipt->global_sequence, start_gseq + 4); @@ -3221,7 +3221,7 @@ BOOST_FIXTURE_TEST_CASE(action_ordinal_test, TESTER) { try { BOOST_REQUIRE_EQUAL(atrace[3].receiver, N(testapi)); BOOST_REQUIRE_EQUAL(atrace[3].act.account, N(testapi)); BOOST_REQUIRE_EQUAL(atrace[3].act.name, TEST_METHOD("test_action", "test_action_ordinal3")); - BOOST_REQUIRE_EQUAL(atrace[3].receipt.valid(), true); + BOOST_REQUIRE_EQUAL(atrace[3].receipt.has_value(), true); BOOST_REQUIRE_EQUAL(fc::raw::unpack(atrace[3].return_value), unsigned_int(9) ); BOOST_REQUIRE(pad(atrace[3].receipt->act_digest, atrace[3].act, atrace[3].return_value)); BOOST_REQUIRE_EQUAL(atrace[3].receipt->global_sequence, start_gseq + 8); @@ -3232,7 +3232,7 @@ BOOST_FIXTURE_TEST_CASE(action_ordinal_test, TESTER) { try { BOOST_REQUIRE_EQUAL(atrace[4].receiver, N(charlie)); BOOST_REQUIRE_EQUAL(atrace[4].act.account, N(testapi)); BOOST_REQUIRE_EQUAL(atrace[4].act.name, TEST_METHOD("test_action", "test_action_ordinal1")); - BOOST_REQUIRE_EQUAL(atrace[4].receipt.valid(), true); + BOOST_REQUIRE_EQUAL(atrace[4].receipt.has_value(), true); BOOST_REQUIRE_EQUAL(fc::raw::unpack(atrace[4].return_value), "charlie" ); BOOST_REQUIRE(pad(atrace[4].receipt->act_digest, atrace[4].act, atrace[4].return_value)); BOOST_REQUIRE_EQUAL(atrace[4].receipt->global_sequence, start_gseq + 2); @@ -3243,7 +3243,7 @@ BOOST_FIXTURE_TEST_CASE(action_ordinal_test, TESTER) { try { BOOST_REQUIRE_EQUAL(atrace[5].receiver, N(bob)); BOOST_REQUIRE_EQUAL(atrace[5].act.account, N(bob)); BOOST_REQUIRE_EQUAL(atrace[5].act.name, TEST_METHOD("test_action", "test_action_ordinal_foo")); - BOOST_REQUIRE_EQUAL(atrace[5].receipt.valid(), true); + BOOST_REQUIRE_EQUAL(atrace[5].receipt.has_value(), true); BOOST_REQUIRE_EQUAL(fc::raw::unpack(atrace[5].return_value), 13.23 ); BOOST_REQUIRE(pad(atrace[5].receipt->act_digest, atrace[5].act, atrace[5].return_value)); BOOST_REQUIRE_EQUAL(atrace[5].receipt->global_sequence, start_gseq + 9); @@ -3254,7 +3254,7 @@ BOOST_FIXTURE_TEST_CASE(action_ordinal_test, TESTER) { try { BOOST_REQUIRE_EQUAL(atrace[6].receiver, N(david)); BOOST_REQUIRE_EQUAL(atrace[6].act.account, N(testapi)); BOOST_REQUIRE_EQUAL(atrace[6].act.name, TEST_METHOD("test_action", "test_action_ordinal1")); - BOOST_REQUIRE_EQUAL(atrace[6].receipt.valid(), true); + BOOST_REQUIRE_EQUAL(atrace[6].receipt.has_value(), true); BOOST_REQUIRE_EQUAL(fc::raw::unpack(atrace[6].return_value), "david" ); BOOST_REQUIRE(pad(atrace[6].receipt->act_digest, atrace[6].act, atrace[6].return_value)); BOOST_REQUIRE_EQUAL(atrace[6].receipt->global_sequence, start_gseq + 3); @@ -3265,7 +3265,7 @@ BOOST_FIXTURE_TEST_CASE(action_ordinal_test, TESTER) { try { BOOST_REQUIRE_EQUAL(atrace[7].receiver, N(charlie)); BOOST_REQUIRE_EQUAL(atrace[7].act.account, N(charlie)); BOOST_REQUIRE_EQUAL(atrace[7].act.name, TEST_METHOD("test_action", "test_action_ordinal_bar")); - BOOST_REQUIRE_EQUAL(atrace[7].receipt.valid(), true); + BOOST_REQUIRE_EQUAL(atrace[7].receipt.has_value(), true); BOOST_REQUIRE_EQUAL(fc::raw::unpack(atrace[7].return_value), 11.42f ); BOOST_REQUIRE(pad(atrace[7].receipt->act_digest, atrace[7].act, atrace[7].return_value)); BOOST_REQUIRE_EQUAL(atrace[7].receipt->global_sequence, start_gseq + 10); @@ -3276,7 +3276,7 @@ BOOST_FIXTURE_TEST_CASE(action_ordinal_test, TESTER) { try { BOOST_REQUIRE_EQUAL(atrace[8].receiver, N(david)); BOOST_REQUIRE_EQUAL(atrace[8].act.account, N(testapi)); BOOST_REQUIRE_EQUAL(atrace[8].act.name, TEST_METHOD("test_action", "test_action_ordinal2")); - BOOST_REQUIRE_EQUAL(atrace[8].receipt.valid(), true); + BOOST_REQUIRE_EQUAL(atrace[8].receipt.has_value(), true); BOOST_REQUIRE_EQUAL(fc::raw::unpack(atrace[8].return_value), true ); BOOST_REQUIRE(pad(atrace[8].receipt->act_digest, atrace[8].act, atrace[8].return_value)); BOOST_REQUIRE_EQUAL(atrace[8].receipt->global_sequence, start_gseq + 5); @@ -3287,7 +3287,7 @@ BOOST_FIXTURE_TEST_CASE(action_ordinal_test, TESTER) { try { BOOST_REQUIRE_EQUAL(atrace[9].receiver, N(erin)); BOOST_REQUIRE_EQUAL(atrace[9].act.account, N(testapi)); BOOST_REQUIRE_EQUAL(atrace[9].act.name, TEST_METHOD("test_action", "test_action_ordinal2")); - BOOST_REQUIRE_EQUAL(atrace[9].receipt.valid(), true); + BOOST_REQUIRE_EQUAL(atrace[9].receipt.has_value(), true); BOOST_REQUIRE_EQUAL(fc::raw::unpack(atrace[9].return_value), signed_int(7) ); BOOST_REQUIRE(pad(atrace[9].receipt->act_digest, atrace[9].act, atrace[9].return_value)); BOOST_REQUIRE_EQUAL(atrace[9].receipt->global_sequence, start_gseq + 6); @@ -3298,7 +3298,7 @@ BOOST_FIXTURE_TEST_CASE(action_ordinal_test, TESTER) { try { BOOST_REQUIRE_EQUAL(atrace[10].receiver, N(testapi)); BOOST_REQUIRE_EQUAL(atrace[10].act.account, N(testapi)); BOOST_REQUIRE_EQUAL(atrace[10].act.name, TEST_METHOD("test_action", "test_action_ordinal4")); - BOOST_REQUIRE_EQUAL(atrace[10].receipt.valid(), true); + BOOST_REQUIRE_EQUAL(atrace[10].receipt.has_value(), true); BOOST_REQUIRE_EQUAL(atrace[10].return_value.size(), 0 ); BOOST_REQUIRE_EQUAL(atrace[10].receipt->global_sequence, start_gseq + 7); } FC_LOG_AND_RETHROW() } @@ -3346,8 +3346,8 @@ BOOST_FIXTURE_TEST_CASE(action_ordinal_failtest1, TESTER) { try { BOOST_REQUIRE_EQUAL(atrace[0].receiver, N(testapi)); BOOST_REQUIRE_EQUAL(atrace[0].act.account, N(testapi)); BOOST_REQUIRE_EQUAL(atrace[0].act.name, TEST_METHOD("test_action", "test_action_ordinal1")); - BOOST_REQUIRE_EQUAL(atrace[0].receipt.valid(), false); - BOOST_REQUIRE_EQUAL(atrace[0].except.valid(), true); + BOOST_REQUIRE_EQUAL(atrace[0].receipt.has_value(), false); + BOOST_REQUIRE_EQUAL(atrace[0].except.has_value(), true); BOOST_REQUIRE_EQUAL(atrace[0].except->code(), 3050003); // not executed @@ -3357,8 +3357,8 @@ BOOST_FIXTURE_TEST_CASE(action_ordinal_failtest1, TESTER) { try { BOOST_REQUIRE_EQUAL(atrace[1].receiver, N(bob)); BOOST_REQUIRE_EQUAL(atrace[1].act.account, N(testapi)); BOOST_REQUIRE_EQUAL(atrace[1].act.name, TEST_METHOD("test_action", "test_action_ordinal1")); - BOOST_REQUIRE_EQUAL(atrace[1].receipt.valid(), false); - BOOST_REQUIRE_EQUAL(atrace[1].except.valid(), false); + BOOST_REQUIRE_EQUAL(atrace[1].receipt.has_value(), false); + BOOST_REQUIRE_EQUAL(atrace[1].except.has_value(), false); // not executed BOOST_REQUIRE_EQUAL((int)atrace[2].action_ordinal, 3); @@ -3367,8 +3367,8 @@ BOOST_FIXTURE_TEST_CASE(action_ordinal_failtest1, TESTER) { try { BOOST_REQUIRE_EQUAL(atrace[2].receiver, N(testapi)); BOOST_REQUIRE_EQUAL(atrace[2].act.account, N(testapi)); BOOST_REQUIRE_EQUAL(atrace[2].act.name, TEST_METHOD("test_action", "test_action_ordinal2")); - BOOST_REQUIRE_EQUAL(atrace[2].receipt.valid(), false); - BOOST_REQUIRE_EQUAL(atrace[2].except.valid(), false); + BOOST_REQUIRE_EQUAL(atrace[2].receipt.has_value(), false); + BOOST_REQUIRE_EQUAL(atrace[2].except.has_value(), false); } FC_LOG_AND_RETHROW() } @@ -3414,9 +3414,9 @@ BOOST_FIXTURE_TEST_CASE(action_ordinal_failtest2, TESTER) { try { BOOST_REQUIRE_EQUAL(atrace[0].receiver, N(testapi)); BOOST_REQUIRE_EQUAL(atrace[0].act.account, N(testapi)); BOOST_REQUIRE_EQUAL(atrace[0].act.name, TEST_METHOD("test_action", "test_action_ordinal1")); - BOOST_REQUIRE_EQUAL(atrace[0].receipt.valid(), true); + BOOST_REQUIRE_EQUAL(atrace[0].receipt.has_value(), true); BOOST_REQUIRE_EQUAL(fc::raw::unpack(atrace[0].return_value), unsigned_int(1) ); - BOOST_REQUIRE_EQUAL(atrace[0].except.valid(), false); + BOOST_REQUIRE_EQUAL(atrace[0].except.has_value(), false); int start_gseq = atrace[0].receipt->global_sequence; // executed @@ -3426,7 +3426,7 @@ BOOST_FIXTURE_TEST_CASE(action_ordinal_failtest2, TESTER) { try { BOOST_REQUIRE_EQUAL(atrace[1].receiver, N(bob)); BOOST_REQUIRE_EQUAL(atrace[1].act.account, N(testapi)); BOOST_REQUIRE_EQUAL(atrace[1].act.name, TEST_METHOD("test_action", "test_action_ordinal1")); - BOOST_REQUIRE_EQUAL(atrace[1].receipt.valid(), true); + BOOST_REQUIRE_EQUAL(atrace[1].receipt.has_value(), true); BOOST_REQUIRE_EQUAL(fc::raw::unpack(atrace[1].return_value), "bob" ); BOOST_REQUIRE_EQUAL(atrace[1].receipt->global_sequence, start_gseq + 1); @@ -3437,8 +3437,8 @@ BOOST_FIXTURE_TEST_CASE(action_ordinal_failtest2, TESTER) { try { BOOST_REQUIRE_EQUAL(atrace[2].receiver, N(testapi)); BOOST_REQUIRE_EQUAL(atrace[2].act.account, N(testapi)); BOOST_REQUIRE_EQUAL(atrace[2].act.name, TEST_METHOD("test_action", "test_action_ordinal2")); - BOOST_REQUIRE_EQUAL(atrace[2].receipt.valid(), false); - BOOST_REQUIRE_EQUAL(atrace[2].except.valid(), false); + BOOST_REQUIRE_EQUAL(atrace[2].receipt.has_value(), false); + BOOST_REQUIRE_EQUAL(atrace[2].except.has_value(), false); // not executed BOOST_REQUIRE_EQUAL((int)atrace[3].action_ordinal, 4); @@ -3447,8 +3447,8 @@ BOOST_FIXTURE_TEST_CASE(action_ordinal_failtest2, TESTER) { try { BOOST_REQUIRE_EQUAL(atrace[3].receiver, N(testapi)); BOOST_REQUIRE_EQUAL(atrace[3].act.account, N(testapi)); BOOST_REQUIRE_EQUAL(atrace[3].act.name, TEST_METHOD("test_action", "test_action_ordinal3")); - BOOST_REQUIRE_EQUAL(atrace[3].receipt.valid(), false); - BOOST_REQUIRE_EQUAL(atrace[3].except.valid(), false); + BOOST_REQUIRE_EQUAL(atrace[3].receipt.has_value(), false); + BOOST_REQUIRE_EQUAL(atrace[3].except.has_value(), false); // hey exception is here BOOST_REQUIRE_EQUAL((int)atrace[4].action_ordinal, 5); @@ -3457,8 +3457,8 @@ BOOST_FIXTURE_TEST_CASE(action_ordinal_failtest2, TESTER) { try { BOOST_REQUIRE_EQUAL(atrace[4].receiver, N(charlie)); BOOST_REQUIRE_EQUAL(atrace[4].act.account, N(testapi)); BOOST_REQUIRE_EQUAL(atrace[4].act.name, TEST_METHOD("test_action", "test_action_ordinal1")); - BOOST_REQUIRE_EQUAL(atrace[4].receipt.valid(), false); - BOOST_REQUIRE_EQUAL(atrace[4].except.valid(), true); + BOOST_REQUIRE_EQUAL(atrace[4].receipt.has_value(), false); + BOOST_REQUIRE_EQUAL(atrace[4].except.has_value(), true); BOOST_REQUIRE_EQUAL(atrace[4].except->code(), 3050003); // not executed @@ -3468,8 +3468,8 @@ BOOST_FIXTURE_TEST_CASE(action_ordinal_failtest2, TESTER) { try { BOOST_REQUIRE_EQUAL(atrace[5].receiver, N(bob)); BOOST_REQUIRE_EQUAL(atrace[5].act.account, N(bob)); BOOST_REQUIRE_EQUAL(atrace[5].act.name, TEST_METHOD("test_action", "test_action_ordinal_foo")); - BOOST_REQUIRE_EQUAL(atrace[5].receipt.valid(), false); - BOOST_REQUIRE_EQUAL(atrace[5].except.valid(), false); + BOOST_REQUIRE_EQUAL(atrace[5].receipt.has_value(), false); + BOOST_REQUIRE_EQUAL(atrace[5].except.has_value(), false); // not executed BOOST_REQUIRE_EQUAL((int)atrace[6].action_ordinal, 7); @@ -3478,8 +3478,8 @@ BOOST_FIXTURE_TEST_CASE(action_ordinal_failtest2, TESTER) { try { BOOST_REQUIRE_EQUAL(atrace[6].receiver, N(david)); BOOST_REQUIRE_EQUAL(atrace[6].act.account, N(testapi)); BOOST_REQUIRE_EQUAL(atrace[6].act.name, TEST_METHOD("test_action", "test_action_ordinal1")); - BOOST_REQUIRE_EQUAL(atrace[6].receipt.valid(), false); - BOOST_REQUIRE_EQUAL(atrace[6].except.valid(), false); + BOOST_REQUIRE_EQUAL(atrace[6].receipt.has_value(), false); + BOOST_REQUIRE_EQUAL(atrace[6].except.has_value(), false); // not executed BOOST_REQUIRE_EQUAL((int)atrace[7].action_ordinal, 8); @@ -3488,8 +3488,8 @@ BOOST_FIXTURE_TEST_CASE(action_ordinal_failtest2, TESTER) { try { BOOST_REQUIRE_EQUAL(atrace[7].receiver, N(charlie)); BOOST_REQUIRE_EQUAL(atrace[7].act.account, N(charlie)); BOOST_REQUIRE_EQUAL(atrace[7].act.name, TEST_METHOD("test_action", "test_action_ordinal_bar")); - BOOST_REQUIRE_EQUAL(atrace[7].receipt.valid(), false); - BOOST_REQUIRE_EQUAL(atrace[7].except.valid(), false); + BOOST_REQUIRE_EQUAL(atrace[7].receipt.has_value(), false); + BOOST_REQUIRE_EQUAL(atrace[7].except.has_value(), false); } FC_LOG_AND_RETHROW() } @@ -3535,9 +3535,9 @@ BOOST_FIXTURE_TEST_CASE(action_ordinal_failtest3, TESTER) { try { BOOST_REQUIRE_EQUAL(atrace[0].receiver, N(testapi)); BOOST_REQUIRE_EQUAL(atrace[0].act.account, N(testapi)); BOOST_REQUIRE_EQUAL(atrace[0].act.name, TEST_METHOD("test_action", "test_action_ordinal1")); - BOOST_REQUIRE_EQUAL(atrace[0].receipt.valid(), true); + BOOST_REQUIRE_EQUAL(atrace[0].receipt.has_value(), true); BOOST_REQUIRE_EQUAL(fc::raw::unpack(atrace[0].return_value), unsigned_int(1) ); - BOOST_REQUIRE_EQUAL(atrace[0].except.valid(), false); + BOOST_REQUIRE_EQUAL(atrace[0].except.has_value(), false); int start_gseq = atrace[0].receipt->global_sequence; // executed @@ -3547,7 +3547,7 @@ BOOST_FIXTURE_TEST_CASE(action_ordinal_failtest3, TESTER) { try { BOOST_REQUIRE_EQUAL(atrace[1].receiver, N(bob)); BOOST_REQUIRE_EQUAL(atrace[1].act.account, N(testapi)); BOOST_REQUIRE_EQUAL(atrace[1].act.name, TEST_METHOD("test_action", "test_action_ordinal1")); - BOOST_REQUIRE_EQUAL(atrace[1].receipt.valid(), true); + BOOST_REQUIRE_EQUAL(atrace[1].receipt.has_value(), true); BOOST_REQUIRE_EQUAL(fc::raw::unpack(atrace[1].return_value), "bob" ); BOOST_REQUIRE_EQUAL(atrace[1].receipt->global_sequence, start_gseq + 1); @@ -3558,7 +3558,7 @@ BOOST_FIXTURE_TEST_CASE(action_ordinal_failtest3, TESTER) { try { BOOST_REQUIRE_EQUAL(atrace[2].receiver, N(testapi)); BOOST_REQUIRE_EQUAL(atrace[2].act.account, N(testapi)); BOOST_REQUIRE_EQUAL(atrace[2].act.name, TEST_METHOD("test_action", "test_action_ordinal2")); - BOOST_REQUIRE_EQUAL(atrace[2].receipt.valid(), true); + BOOST_REQUIRE_EQUAL(atrace[2].receipt.has_value(), true); BOOST_REQUIRE_EQUAL(fc::raw::unpack(atrace[2].return_value), name("five") ); BOOST_REQUIRE_EQUAL(atrace[2].receipt->global_sequence, start_gseq + 4); @@ -3569,8 +3569,8 @@ BOOST_FIXTURE_TEST_CASE(action_ordinal_failtest3, TESTER) { try { BOOST_REQUIRE_EQUAL(atrace[3].receiver, N(testapi)); BOOST_REQUIRE_EQUAL(atrace[3].act.account, N(testapi)); BOOST_REQUIRE_EQUAL(atrace[3].act.name, TEST_METHOD("test_action", "test_action_ordinal3")); - BOOST_REQUIRE_EQUAL(atrace[3].receipt.valid(), false); - BOOST_REQUIRE_EQUAL(atrace[3].except.valid(), true); + BOOST_REQUIRE_EQUAL(atrace[3].receipt.has_value(), false); + BOOST_REQUIRE_EQUAL(atrace[3].except.has_value(), true); BOOST_REQUIRE_EQUAL(atrace[3].except->code(), 3050003); // executed @@ -3580,7 +3580,7 @@ BOOST_FIXTURE_TEST_CASE(action_ordinal_failtest3, TESTER) { try { BOOST_REQUIRE_EQUAL(atrace[4].receiver, N(charlie)); BOOST_REQUIRE_EQUAL(atrace[4].act.account, N(testapi)); BOOST_REQUIRE_EQUAL(atrace[4].act.name, TEST_METHOD("test_action", "test_action_ordinal1")); - BOOST_REQUIRE_EQUAL(atrace[4].receipt.valid(), true); + BOOST_REQUIRE_EQUAL(atrace[4].receipt.has_value(), true); BOOST_REQUIRE_EQUAL(fc::raw::unpack(atrace[4].return_value), "charlie" ); BOOST_REQUIRE_EQUAL(atrace[4].receipt->global_sequence, start_gseq + 2); @@ -3591,8 +3591,8 @@ BOOST_FIXTURE_TEST_CASE(action_ordinal_failtest3, TESTER) { try { BOOST_REQUIRE_EQUAL(atrace[5].receiver, N(bob)); BOOST_REQUIRE_EQUAL(atrace[5].act.account, N(bob)); BOOST_REQUIRE_EQUAL(atrace[5].act.name, TEST_METHOD("test_action", "test_action_ordinal_foo")); - BOOST_REQUIRE_EQUAL(atrace[5].receipt.valid(), false); - BOOST_REQUIRE_EQUAL(atrace[5].except.valid(), false); + BOOST_REQUIRE_EQUAL(atrace[5].receipt.has_value(), false); + BOOST_REQUIRE_EQUAL(atrace[5].except.has_value(), false); // executed BOOST_REQUIRE_EQUAL((int)atrace[6].action_ordinal, 7); @@ -3601,7 +3601,7 @@ BOOST_FIXTURE_TEST_CASE(action_ordinal_failtest3, TESTER) { try { BOOST_REQUIRE_EQUAL(atrace[6].receiver, N(david)); BOOST_REQUIRE_EQUAL(atrace[6].act.account, N(testapi)); BOOST_REQUIRE_EQUAL(atrace[6].act.name, TEST_METHOD("test_action", "test_action_ordinal1")); - BOOST_REQUIRE_EQUAL(atrace[6].receipt.valid(), true); + BOOST_REQUIRE_EQUAL(atrace[6].receipt.has_value(), true); BOOST_REQUIRE_EQUAL(fc::raw::unpack(atrace[6].return_value), "david" ); BOOST_REQUIRE_EQUAL(atrace[6].receipt->global_sequence, start_gseq + 3); @@ -3612,8 +3612,8 @@ BOOST_FIXTURE_TEST_CASE(action_ordinal_failtest3, TESTER) { try { BOOST_REQUIRE_EQUAL(atrace[7].receiver, N(charlie)); BOOST_REQUIRE_EQUAL(atrace[7].act.account, N(charlie)); BOOST_REQUIRE_EQUAL(atrace[7].act.name, TEST_METHOD("test_action", "test_action_ordinal_bar")); - BOOST_REQUIRE_EQUAL(atrace[7].receipt.valid(), false); - BOOST_REQUIRE_EQUAL(atrace[7].except.valid(), false); + BOOST_REQUIRE_EQUAL(atrace[7].receipt.has_value(), false); + BOOST_REQUIRE_EQUAL(atrace[7].except.has_value(), false); // executed BOOST_REQUIRE_EQUAL((int)atrace[8].action_ordinal, 9); @@ -3622,7 +3622,7 @@ BOOST_FIXTURE_TEST_CASE(action_ordinal_failtest3, TESTER) { try { BOOST_REQUIRE_EQUAL(atrace[8].receiver, N(david)); BOOST_REQUIRE_EQUAL(atrace[8].act.account, N(testapi)); BOOST_REQUIRE_EQUAL(atrace[8].act.name, TEST_METHOD("test_action", "test_action_ordinal2")); - BOOST_REQUIRE_EQUAL(atrace[8].receipt.valid(), true); + BOOST_REQUIRE_EQUAL(atrace[8].receipt.has_value(), true); BOOST_REQUIRE_EQUAL(fc::raw::unpack(atrace[8].return_value), true ); BOOST_REQUIRE_EQUAL(atrace[8].receipt->global_sequence, start_gseq + 5); @@ -3633,7 +3633,7 @@ BOOST_FIXTURE_TEST_CASE(action_ordinal_failtest3, TESTER) { try { BOOST_REQUIRE_EQUAL(atrace[9].receiver, N(erin)); BOOST_REQUIRE_EQUAL(atrace[9].act.account, N(testapi)); BOOST_REQUIRE_EQUAL(atrace[9].act.name, TEST_METHOD("test_action", "test_action_ordinal2")); - BOOST_REQUIRE_EQUAL(atrace[9].receipt.valid(), true); + BOOST_REQUIRE_EQUAL(atrace[9].receipt.has_value(), true); BOOST_REQUIRE_EQUAL(fc::raw::unpack(atrace[9].return_value), signed_int(7) ); BOOST_REQUIRE_EQUAL(atrace[9].receipt->global_sequence, start_gseq + 6); @@ -3644,7 +3644,7 @@ BOOST_FIXTURE_TEST_CASE(action_ordinal_failtest3, TESTER) { try { BOOST_REQUIRE_EQUAL(atrace[10].receiver, N(testapi)); BOOST_REQUIRE_EQUAL(atrace[10].act.account, N(testapi)); BOOST_REQUIRE_EQUAL(atrace[10].act.name, TEST_METHOD("test_action", "test_action_ordinal4")); - BOOST_REQUIRE_EQUAL(atrace[10].receipt.valid(), true); + BOOST_REQUIRE_EQUAL(atrace[10].receipt.has_value(), true); BOOST_REQUIRE_EQUAL(atrace[10].return_value.size(), 0 ); BOOST_REQUIRE_EQUAL(atrace[10].receipt->global_sequence, start_gseq + 7); @@ -3669,7 +3669,7 @@ BOOST_FIXTURE_TEST_CASE(action_results_tests, TESTER) { try { BOOST_CHECK_EQUAL( res->receipt->status, transaction_receipt::executed ); auto &atrace = res->action_traces; - BOOST_REQUIRE_EQUAL( atrace[0].receipt.valid(), true ); + BOOST_REQUIRE_EQUAL( atrace[0].receipt.has_value(), true ); BOOST_REQUIRE_EQUAL( atrace[0].return_value.size(), 4 ); BOOST_REQUIRE_EQUAL( fc::raw::unpack(atrace[0].return_value), 10 ); } ); diff --git a/unittests/delay_tests.cpp b/unittests/delay_tests.cpp index 198b1b0eb9c..b36f53c0e02 100644 --- a/unittests/delay_tests.cpp +++ b/unittests/delay_tests.cpp @@ -76,7 +76,7 @@ BOOST_FIXTURE_TEST_CASE( delay_error_create_account, validating_tester) { try { auto billed_cpu_time_us = control->get_global_properties().configuration.min_transaction_cpu_usage; auto dtrace = control->push_scheduled_transaction(scheduled_trxs.front(), fc::time_point::maximum(), billed_cpu_time_us, true); - BOOST_REQUIRE_EQUAL(dtrace->except.valid(), true); + BOOST_REQUIRE_EQUAL(dtrace->except.has_value(), true); BOOST_REQUIRE_EQUAL(dtrace->except->code(), missing_auth_exception::code_value); } FC_LOG_AND_RETHROW() } diff --git a/unittests/forked_tests.cpp b/unittests/forked_tests.cpp index 92215809216..dea998a5f90 100644 --- a/unittests/forked_tests.cpp +++ b/unittests/forked_tests.cpp @@ -763,7 +763,7 @@ BOOST_AUTO_TEST_CASE( push_block_returns_forked_transactions ) try { // test4 failed because it was tapos to a forked out block BOOST_CHECK_EQUAL( trace4->id, traces.at(3)->id ); BOOST_CHECK( !traces.at(3)->receipt ); - BOOST_CHECK( !!traces.at(3)->except ); + BOOST_CHECK( traces.at(3)->except ); // verify unapplied transactions ran BOOST_REQUIRE_EQUAL( c.control->get_account( N(test1) ).name, N(test1) ); diff --git a/unittests/producer_schedule_tests.cpp b/unittests/producer_schedule_tests.cpp index 32655b3fbc8..9e81b756668 100644 --- a/unittests/producer_schedule_tests.cpp +++ b/unittests/producer_schedule_tests.cpp @@ -216,7 +216,7 @@ BOOST_FIXTURE_TEST_CASE( producer_schedule_promotion_test, TESTER ) try { }; //wdump((fc::json::to_pretty_string(res))); wlog("set producer schedule to [alice,bob]"); - BOOST_REQUIRE_EQUAL( true, control->proposed_producers().valid() ); + BOOST_REQUIRE_EQUAL( true, control->proposed_producers().has_value() ); BOOST_CHECK_EQUAL( true, compare_schedules( sch1, *control->proposed_producers() ) ); BOOST_CHECK_EQUAL( control->pending_producers().version, 0u ); produce_block(); // Starts new block which promotes the proposed schedule to pending @@ -236,7 +236,7 @@ BOOST_FIXTURE_TEST_CASE( producer_schedule_promotion_test, TESTER ) try { producer_authority{N(carol), block_signing_authority_v0{1, {{get_public_key(N(carol), "active"),1}}}} }; wlog("set producer schedule to [alice,bob,carol]"); - BOOST_REQUIRE_EQUAL( true, control->proposed_producers().valid() ); + BOOST_REQUIRE_EQUAL( true, control->proposed_producers().has_value() ); BOOST_CHECK_EQUAL( true, compare_schedules( sch2, *control->proposed_producers() ) ); produce_block(); @@ -281,7 +281,7 @@ BOOST_FIXTURE_TEST_CASE( producer_schedule_reduction, tester ) try { producer_authority{N(carol), block_signing_authority_v0{ 1, {{get_public_key(N(carol), "active"),1}}}} }; wlog("set producer schedule to [alice,bob,carol]"); - BOOST_REQUIRE_EQUAL( true, control->proposed_producers().valid() ); + BOOST_REQUIRE_EQUAL( true, control->proposed_producers().has_value() ); BOOST_CHECK_EQUAL( true, compare_schedules( sch1, *control->proposed_producers() ) ); BOOST_CHECK_EQUAL( control->pending_producers().version, 0u ); produce_block(); // Starts new block which promotes the proposed schedule to pending @@ -300,7 +300,7 @@ BOOST_FIXTURE_TEST_CASE( producer_schedule_reduction, tester ) try { producer_authority{N(bob), block_signing_authority_v0{ 1, {{ get_public_key(N(bob), "active"),1}}}} }; wlog("set producer schedule to [alice,bob]"); - BOOST_REQUIRE_EQUAL( true, control->proposed_producers().valid() ); + BOOST_REQUIRE_EQUAL( true, control->proposed_producers().has_value() ); BOOST_CHECK_EQUAL( true, compare_schedules( sch2, *control->proposed_producers() ) ); produce_blocks(48); @@ -343,7 +343,7 @@ BOOST_AUTO_TEST_CASE( empty_producer_schedule_has_no_effect ) try { producer_authority{N(bob), block_signing_authority_v0{ 1, {{ get_public_key(N(bob), "active"),1}}}} }; wlog("set producer schedule to [alice,bob]"); - BOOST_REQUIRE_EQUAL( true, c.control->proposed_producers().valid() ); + BOOST_REQUIRE_EQUAL( true, c.control->proposed_producers().has_value() ); BOOST_CHECK_EQUAL( true, compare_schedules( sch1, *c.control->proposed_producers() ) ); BOOST_CHECK_EQUAL( c.control->pending_producers().producers.size(), 0u ); @@ -361,7 +361,7 @@ BOOST_AUTO_TEST_CASE( empty_producer_schedule_has_no_effect ) try { res = c.set_producers_legacy( {} ); wlog("set producer schedule to []"); - BOOST_REQUIRE_EQUAL( true, c.control->proposed_producers().valid() ); + BOOST_REQUIRE_EQUAL( true, c.control->proposed_producers().has_value() ); BOOST_CHECK_EQUAL( c.control->proposed_producers()->producers.size(), 0u ); BOOST_CHECK_EQUAL( c.control->proposed_producers()->version, 2u ); @@ -371,7 +371,7 @@ BOOST_AUTO_TEST_CASE( empty_producer_schedule_has_no_effect ) try { // Empty producer schedule does get promoted from proposed to pending c.produce_block(); BOOST_CHECK_EQUAL( c.control->pending_producers().version, 2u ); - BOOST_CHECK_EQUAL( false, c.control->proposed_producers().valid() ); + BOOST_CHECK_EQUAL( false, c.control->proposed_producers().has_value() ); // However it should not get promoted from pending to active c.produce_blocks(24); @@ -386,7 +386,7 @@ BOOST_AUTO_TEST_CASE( empty_producer_schedule_has_no_effect ) try { producer_authority{N(carol), block_signing_authority_v0{ 1, {{get_public_key(N(carol), "active"),1}}}} }; wlog("set producer schedule to [alice,bob,carol]"); - BOOST_REQUIRE_EQUAL( true, c.control->proposed_producers().valid() ); + BOOST_REQUIRE_EQUAL( true, c.control->proposed_producers().has_value() ); BOOST_CHECK_EQUAL( true, compare_schedules( sch2, *c.control->proposed_producers() ) ); BOOST_CHECK_EQUAL( c.control->proposed_producers()->version, 2u ); @@ -421,7 +421,7 @@ BOOST_AUTO_TEST_CASE( producer_watermark_test ) try { producer_authority{N(carol), block_signing_authority_v0{ 1, {{c.get_public_key(N(carol), "active"),1}}}} }; wlog("set producer schedule to [alice,bob,carol]"); - BOOST_REQUIRE_EQUAL( true, c.control->proposed_producers().valid() ); + BOOST_REQUIRE_EQUAL( true, c.control->proposed_producers().has_value() ); BOOST_CHECK_EQUAL( true, compare_schedules( sch1, *c.control->proposed_producers() ) ); BOOST_CHECK_EQUAL( c.control->pending_producers().version, 0u ); c.produce_block(); // Starts new block which promotes the proposed schedule to pending @@ -443,7 +443,7 @@ BOOST_AUTO_TEST_CASE( producer_watermark_test ) try { producer_authority{N(bob), block_signing_authority_v0{ 1, {{c.get_public_key(N(bob), "active"),1}}}} }; wlog("set producer schedule to [alice,bob]"); - BOOST_REQUIRE_EQUAL( true, c.control->proposed_producers().valid() ); + BOOST_REQUIRE_EQUAL( true, c.control->proposed_producers().has_value() ); BOOST_CHECK_EQUAL( true, compare_schedules( sch2, *c.control->proposed_producers() ) ); produce_until_transition( c, N(bob), N(carol) ); @@ -467,7 +467,7 @@ BOOST_AUTO_TEST_CASE( producer_watermark_test ) try { res = c.set_producers( {N(alice),N(bob),N(carol)} ); wlog("set producer schedule to [alice,bob,carol]"); - BOOST_REQUIRE_EQUAL( true, c.control->proposed_producers().valid() ); + BOOST_REQUIRE_EQUAL( true, c.control->proposed_producers().has_value() ); BOOST_CHECK_EQUAL( true, compare_schedules( sch1, *c.control->proposed_producers() ) ); produce_until_transition( c, N(bob), N(alice) ); @@ -574,7 +574,7 @@ BOOST_FIXTURE_TEST_CASE( satisfiable_msig_test, TESTER ) try { fc_exception_message_is( "producer schedule includes an unsatisfiable authority for alice" ) ); - BOOST_REQUIRE_EQUAL( false, control->proposed_producers().valid() ); + BOOST_REQUIRE_EQUAL( false, control->proposed_producers().has_value() ); } FC_LOG_AND_RETHROW() @@ -593,7 +593,7 @@ BOOST_FIXTURE_TEST_CASE( duplicate_producers_test, TESTER ) try { fc_exception_message_is( "duplicate producer name in producer schedule" ) ); - BOOST_REQUIRE_EQUAL( false, control->proposed_producers().valid() ); + BOOST_REQUIRE_EQUAL( false, control->proposed_producers().has_value() ); } FC_LOG_AND_RETHROW() @@ -611,7 +611,7 @@ BOOST_FIXTURE_TEST_CASE( duplicate_keys_test, TESTER ) try { fc_exception_message_is( "producer schedule includes a duplicated key for alice" ) ); - BOOST_REQUIRE_EQUAL( false, control->proposed_producers().valid() ); + BOOST_REQUIRE_EQUAL( false, control->proposed_producers().has_value() ); // ensure that multiple producers are allowed to share keys vector sch2 = { @@ -620,7 +620,7 @@ BOOST_FIXTURE_TEST_CASE( duplicate_keys_test, TESTER ) try { }; set_producer_schedule( sch2 ); - BOOST_REQUIRE_EQUAL( true, control->proposed_producers().valid() ); + BOOST_REQUIRE_EQUAL( true, control->proposed_producers().has_value() ); } FC_LOG_AND_RETHROW() BOOST_AUTO_TEST_CASE( large_authority_overflow_test ) try { diff --git a/unittests/protocol_feature_tests.cpp b/unittests/protocol_feature_tests.cpp index 2b314922f41..3176b27631b 100644 --- a/unittests/protocol_feature_tests.cpp +++ b/unittests/protocol_feature_tests.cpp @@ -1689,7 +1689,7 @@ BOOST_AUTO_TEST_CASE( wtmsig_block_signing_inflight_legacy_test ) { try { // ensure the last legacy block contains a new_producers auto last_legacy_block = c.produce_block(); - BOOST_REQUIRE_EQUAL(last_legacy_block->new_producers.valid(), true); + BOOST_REQUIRE_EQUAL(last_legacy_block->new_producers.has_value(), true); // promote to active schedule c.produce_block(); @@ -1723,7 +1723,7 @@ BOOST_AUTO_TEST_CASE( wtmsig_block_signing_inflight_extension_test ) { try { // ensure the first possible new block contains a producer_schedule_change_extension auto first_new_block = c.produce_block(); - BOOST_REQUIRE_EQUAL(first_new_block->new_producers.valid(), false); + BOOST_REQUIRE_EQUAL(first_new_block->new_producers.has_value(), false); BOOST_REQUIRE_EQUAL(first_new_block->header_extensions.size(), 1); BOOST_REQUIRE_EQUAL(first_new_block->header_extensions.at(0).first, producer_schedule_change_extension::extension_id()); diff --git a/unittests/resource_limits_test.cpp b/unittests/resource_limits_test.cpp index 6db20c2ab72..256b716fd17 100644 --- a/unittests/resource_limits_test.cpp +++ b/unittests/resource_limits_test.cpp @@ -353,7 +353,7 @@ BOOST_AUTO_TEST_SUITE(resource_limits_test) constexpr int64_t unlimited = -1; - using get_account_limit_ex_func = std::function(const resource_limits_manager*, const account_name&, uint32_t, const fc::optional&)>; + using get_account_limit_ex_func = std::function(const resource_limits_manager*, const account_name&, uint32_t, const std::optional&)>; auto test_get_account_limit_ex = [this](const account_name& test_account, const uint32_t window, get_account_limit_ex_func get_account_limit_ex) { constexpr uint32_t delta_slot = 100; diff --git a/unittests/restart_chain_tests.cpp b/unittests/restart_chain_tests.cpp index 6349efcb149..2f6f3abd69e 100644 --- a/unittests/restart_chain_tests.cpp +++ b/unittests/restart_chain_tests.cpp @@ -223,7 +223,7 @@ BOOST_AUTO_TEST_CASE(test_restart_with_different_chain_id) { genesis_state genesis; genesis.initial_timestamp = fc::time_point::from_iso_string("2020-01-01T00:00:01.000"); genesis.initial_key = eosio::testing::base_tester::get_public_key(config::system_account_name, "active"); - fc::optional chain_id = genesis.compute_chain_id(); + std::optional chain_id = genesis.compute_chain_id(); BOOST_REQUIRE_EXCEPTION(other.open(chain_id), chain_id_type_exception, fc_exception_message_starts_with("chain ID in state ")); } diff --git a/unittests/state_history_tests.cpp b/unittests/state_history_tests.cpp index dfca38ef86a..60bfecac3ec 100644 --- a/unittests/state_history_tests.cpp +++ b/unittests/state_history_tests.cpp @@ -330,7 +330,7 @@ BOOST_AUTO_TEST_CASE(test_state_result_abi) { transaction_trace_cache trace_cache; std::map history; - fc::optional prev_block; + std::optional prev_block; chain.control->applied_transaction.connect( [&](std::tuple t) { diff --git a/unittests/wasm_tests.cpp b/unittests/wasm_tests.cpp index dbc2abad57f..03fa1343293 100644 --- a/unittests/wasm_tests.cpp +++ b/unittests/wasm_tests.cpp @@ -178,14 +178,14 @@ BOOST_FIXTURE_TEST_CASE( abi_from_variant, TESTER ) try { set_abi(N(asserter), contracts::asserter_abi().data()); produce_blocks(1); - auto resolver = [&,this]( const account_name& name ) -> fc::optional { + auto resolver = [&,this]( const account_name& name ) -> std::optional { try { const auto& accnt = this->control->db().get( name ); abi_def abi; if (abi_serializer::to_abi(accnt.abi, abi)) { return abi_serializer(abi, abi_serializer::create_yield_function( abi_serializer_max_time )); } - return fc::optional(); + return std::optional(); } FC_RETHROW_EXCEPTIONS(error, "Failed to find or parse ABI for ${name}", ("name", name)) }; diff --git a/unittests/whitelist_blacklist_tests.cpp b/unittests/whitelist_blacklist_tests.cpp index 06cebb3dbfb..3392fd22dfc 100644 --- a/unittests/whitelist_blacklist_tests.cpp +++ b/unittests/whitelist_blacklist_tests.cpp @@ -57,7 +57,7 @@ class whitelist_blacklist_tester { } void shutdown() { - FC_ASSERT( chain.valid(), "chain is not up" ); + FC_ASSERT( chain, "chain is not up" ); last_produced_block = chain->get_last_produced_block_map(); wdump((last_produced_block)); chain.reset(); @@ -76,7 +76,7 @@ class whitelist_blacklist_tester { private: fc::temp_directory tempdir; // Must come before chain public: - fc::optional chain; + std::optional chain; flat_set sender_bypass_whiteblacklist; flat_set actor_whitelist; flat_set actor_blacklist;