Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Merge pull request #9213 from EOSIO/EPE-17-develop-final
Browse files Browse the repository at this point in the history
Replace fc::optional with std::optional
  • Loading branch information
Timothy Banks authored Aug 25, 2020
2 parents f352f66 + f045444 commit 9a10d21
Show file tree
Hide file tree
Showing 99 changed files with 625 additions and 922 deletions.
10 changes: 5 additions & 5 deletions libraries/chain/abi_serializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace eosio { namespace chain {
if( is_array )
fc::raw::pack( ds, var.as<vector<T>>() );
else if ( is_optional )
fc::raw::pack( ds, var.as<optional<T>>() );
fc::raw::pack( ds, var.as<std::optional<T>>() );
else
fc::raw::pack( ds, var.as<T>());
};
Expand All @@ -51,7 +51,7 @@ namespace eosio { namespace chain {
if( is_array )
return variant_from_stream<vector<T>>(stream);
else if ( is_optional )
return variant_from_stream<optional<T>>(stream);
return variant_from_stream<std::optional<T>>(stream);
return variant_from_stream<T>(stream);
},
pack_function<T>()
Expand All @@ -65,7 +65,7 @@ namespace eosio { namespace chain {
if( is_array )
return variant_from_stream<vector<T>>(stream);
else if ( is_optional )
return variant_from_stream<optional<T>>(stream);
return variant_from_stream<std::optional<T>>(stream);
return variant_from_stream<T>(stream, yield);
},
pack_function<T>()
Expand Down Expand Up @@ -619,10 +619,10 @@ namespace eosio { namespace chain {
return type_name();
}

optional<string> abi_serializer::get_error_message( uint64_t error_code )const {
std::optional<string> abi_serializer::get_error_message( uint64_t error_code )const {
auto itr = error_messages.find( error_code );
if( itr == error_messages.end() )
return optional<string>();
return std::optional<string>();

return itr->second;
}
Expand Down
26 changes: 12 additions & 14 deletions libraries/chain/authorization_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,10 @@ namespace eosio { namespace chain {
return _db.get<permission_object, by_owner>( boost::make_tuple(level.actor,level.permission) );
} EOS_RETHROW_EXCEPTIONS( chain::permission_query_exception, "Failed to retrieve permission: ${level}", ("level", level) ) }

optional<permission_name> authorization_manager::lookup_linked_permission( account_name authorizer_account,
account_name scope,
action_name act_name
)const
std::optional<permission_name> 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
Expand All @@ -295,16 +295,14 @@ namespace eosio { namespace chain {
if (link != nullptr) {
return link->required_permission;
}
return optional<permission_name>();

// return optional<permission_name>();
return std::optional<permission_name>();
} FC_CAPTURE_AND_RETHROW((authorizer_account)(scope)(act_name))
}

optional<permission_name> authorization_manager::lookup_minimum_permission( account_name authorizer_account,
account_name scope,
action_name act_name
)const
std::optional<permission_name> 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 ) {
Expand All @@ -318,12 +316,12 @@ namespace eosio { namespace chain {
}

try {
optional<permission_name> linked_permission = lookup_linked_permission(authorizer_account, scope, act_name);
std::optional<permission_name> 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<permission_name>();
return std::optional<permission_name>();

return linked_permission;
} FC_CAPTURE_AND_RETHROW((authorizer_account)(scope)(act_name))
Expand Down Expand Up @@ -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) );

Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ namespace eosio { namespace chain {
return validate_and_extract_block_extensions( block_extensions );
}

fc::optional<signed_block_v0> signed_block::to_signed_block_v0() const {
std::optional<signed_block_v0> signed_block::to_signed_block_v0() const {
if (prune_state != prune_state_type::complete_legacy)
return {};

Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/block_header_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<producer_authority_schedule>& new_producers,
const std::optional<producer_authority_schedule>& new_producers,
vector<digest_type>&& new_protocol_feature_activations,
const protocol_feature_set& pfs
)const
Expand Down
8 changes: 4 additions & 4 deletions libraries/chain/block_log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<genesis_state> get_genesis_state() const {
return std::visit(overloaded{[](const chain_id_type&) { return fc::optional<genesis_state>{}; },
[](const genesis_state& state) { return fc::optional<genesis_state>{state}; }},
std::optional<genesis_state> get_genesis_state() const {
return std::visit(overloaded{[](const chain_id_type&) { return std::optional<genesis_state>{}; },
[](const genesis_state& state) { return std::optional<genesis_state>{state}; }},
preamble.chain_context);
}

Expand Down Expand Up @@ -952,7 +952,7 @@ namespace eosio { namespace chain {
return backup_dir;
}

fc::optional<genesis_state> block_log::extract_genesis_state( const fc::path& block_dir ) {
std::optional<genesis_state> 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();
Expand Down
Loading

0 comments on commit 9a10d21

Please sign in to comment.