diff --git a/.gitmodules b/.gitmodules index 4d3518d1b..495183b64 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,6 +4,6 @@ ignore = dirty [submodule "libraries/fc"] path = libraries/fc - url = https://github.com/peerplays-network/peerplays-fc.git + url = https://github.com/nathanhourt/peerplays-fc branch = latest-fc ignore = dirty diff --git a/CMakeLists.txt b/CMakeLists.txt index 4df202b35..175eac9b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,7 @@ set( CLI_CLIENT_EXECUTABLE_NAME graphene_client ) set( GUI_CLIENT_EXECUTABLE_NAME Peerplays ) set( CUSTOM_URL_SCHEME "gcs" ) set( INSTALLER_APP_ID "68ad7005-8eee-49c9-95ce-9eed97e5b347" ) +set( CMAKE_CXX_STANDARD 14 ) # http://stackoverflow.com/a/18369825 if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") @@ -46,7 +47,6 @@ LIST(APPEND BOOST_COMPONENTS thread system filesystem program_options - signals serialization chrono unit_test_framework diff --git a/libraries/CMakeLists.txt b/libraries/CMakeLists.txt index cf2355f13..a2d6305b6 100644 --- a/libraries/CMakeLists.txt +++ b/libraries/CMakeLists.txt @@ -5,6 +5,6 @@ add_subdirectory( egenesis ) add_subdirectory( fc ) add_subdirectory( net ) add_subdirectory( plugins ) -add_subdirectory( time ) add_subdirectory( utilities ) add_subdirectory( wallet ) +add_subdirectory( protocol ) diff --git a/libraries/app/CMakeLists.txt b/libraries/app/CMakeLists.txt index 52460c776..9290538a8 100644 --- a/libraries/app/CMakeLists.txt +++ b/libraries/app/CMakeLists.txt @@ -12,9 +12,8 @@ add_library( graphene_app ) # need to link graphene_debug_witness because plugins aren't sufficiently isolated #246 -#target_link_libraries( graphene_app graphene_market_history graphene_account_history graphene_chain fc graphene_db graphene_net graphene_utilities graphene_debug_witness ) target_link_libraries( graphene_app - PUBLIC graphene_net graphene_utilities + PUBLIC graphene_chain graphene_net graphene_utilities graphene_account_history graphene_accounts_list graphene_affiliate_stats graphene_bookie graphene_debug_witness graphene_elasticsearch graphene_es_objects graphene_generate_genesis graphene_market_history ) target_include_directories( graphene_app @@ -43,7 +42,7 @@ add_library( graphene_plugin ) target_link_libraries( graphene_plugin - PUBLIC graphene_net graphene_utilities ) + PUBLIC graphene_chain graphene_net graphene_utilities ) target_include_directories( graphene_plugin PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) diff --git a/libraries/app/api.cpp b/libraries/app/api.cpp index 1e8766345..b1be519b3 100644 --- a/libraries/app/api.cpp +++ b/libraries/app/api.cpp @@ -29,14 +29,15 @@ #include #include #include -#include +#include #include #include -#include +#include #include #include #include +#include #include #include #include @@ -169,7 +170,7 @@ namespace graphene { namespace app { { auto block_num = b.block_num(); auto& callback = _callbacks.find(id)->second; - fc::async( [capture_this,this,id,block_num,trx_num,trx,callback]() { + fc::async( [capture_this,id,block_num,trx_num,trx,callback]() { callback( fc::variant( transaction_confirmation{ id, block_num, trx_num, trx }, GRAPHENE_MAX_NESTED_OBJECTS ) ); } ); @@ -190,10 +191,10 @@ namespace graphene { namespace app { fc::variant network_broadcast_api::broadcast_transaction_synchronous(const signed_transaction& trx) { _app.chain_database()->check_tansaction_for_duplicated_operations(trx); - - fc::promise::ptr prom( new fc::promise() ); - broadcast_transaction_with_callback( [=]( const fc::variant& v ){ - prom->set_value(v); + + fc::promise::ptr prom = fc::promise::create(); + broadcast_transaction_with_callback( [prom]( const fc::variant& v ){ + prom->set_value(v); }, trx ); return fc::future(prom).wait(); diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index 17a254d4d..0ccb7ccb5 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -26,8 +26,10 @@ #include #include -#include -#include +#include +#include +#include +#include #include @@ -378,7 +380,6 @@ namespace detail { _chain_db->enable_standby_votes_tracking( _options->at("enable-standby-votes-tracking").as() ); } - bool replay = false; std::string replay_reason = "reason not provided"; if( _options->count("replay-blockchain") ) @@ -552,7 +553,7 @@ namespace detail { _chain_db->push_transaction( transaction_message.trx ); } FC_CAPTURE_AND_RETHROW( (transaction_message) ) } - virtual void handle_message(const message& message_to_process) override + virtual void handle_message(const message&) override { // not a transaction, not a block FC_THROW( "Invalid Message Type" ); diff --git a/libraries/app/config_util.cpp b/libraries/app/config_util.cpp index f06291b78..75b73a53f 100644 --- a/libraries/app/config_util.cpp +++ b/libraries/app/config_util.cpp @@ -210,7 +210,7 @@ static void load_config_file(const fc::path& config_ini_path, const bpo::options { deduplicator dedup; bpo::options_description unique_options("Graphene Witness Node"); - for( const boost::shared_ptr opt : cfg_options.options() ) + for( const boost::shared_ptr& opt : cfg_options.options() ) { const boost::shared_ptr od = dedup.next(opt); if( !od ) continue; @@ -259,7 +259,7 @@ static void create_new_config_file(const fc::path& config_ini_path, const fc::pa deduplicator dedup(modify_option_defaults); std::ofstream out_cfg(config_ini_path.preferred_string()); std::string plugin_header_surrounding( 78, '=' ); - for( const boost::shared_ptr opt : cfg_options.options() ) + for( const boost::shared_ptr& opt : cfg_options.options() ) { const boost::shared_ptr od = dedup.next(opt); if( !od ) continue; diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 95303223c..27958a986 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -26,8 +26,10 @@ #include #include #include -#include -#include +#include + +#include +#include #include @@ -37,7 +39,6 @@ #include #include -#include #include @@ -2594,10 +2595,9 @@ graphene::app::gpos_info database_api_impl::get_gpos_info(const account_id_type #endif vector account_vbos; - const time_point_sec now = _db.head_block_time(); auto vesting_range = _db.get_index_type().indices().get().equal_range(account); std::for_each(vesting_range.first, vesting_range.second, - [&account_vbos, now](const vesting_balance_object& balance) { + [&account_vbos](const vesting_balance_object& balance) { if(balance.balance.amount > 0 && balance.balance_type == vesting_balance_type::gpos && balance.balance.asset_id == asset_id_type()) account_vbos.emplace_back(balance); diff --git a/libraries/app/include/graphene/app/api.hpp b/libraries/app/include/graphene/app/api.hpp index e4329141f..36e2b8292 100644 --- a/libraries/app/include/graphene/app/api.hpp +++ b/libraries/app/include/graphene/app/api.hpp @@ -25,8 +25,8 @@ #include -#include -#include +#include +#include #include #include diff --git a/libraries/app/include/graphene/app/database_api.hpp b/libraries/app/include/graphene/app/database_api.hpp index ec5f8c1a4..eff67d01c 100644 --- a/libraries/app/include/graphene/app/database_api.hpp +++ b/libraries/app/include/graphene/app/database_api.hpp @@ -25,7 +25,7 @@ #include -#include +#include #include diff --git a/libraries/app/include/graphene/app/full_account.hpp b/libraries/app/include/graphene/app/full_account.hpp index 955857b7b..770dec94b 100644 --- a/libraries/app/include/graphene/app/full_account.hpp +++ b/libraries/app/include/graphene/app/full_account.hpp @@ -26,6 +26,8 @@ #include #include #include +#include +#include #include namespace graphene { namespace app { @@ -67,7 +69,6 @@ FC_REFLECT( graphene::app::full_account, (limit_orders) (call_orders) (settle_orders) - (proposals) (assets) (withdraws) (proposals) diff --git a/libraries/app/plugin.cpp b/libraries/app/plugin.cpp index cae488a66..02d1fdb82 100644 --- a/libraries/app/plugin.cpp +++ b/libraries/app/plugin.cpp @@ -23,7 +23,7 @@ */ #include -#include +#include namespace graphene { namespace app { diff --git a/libraries/chain/CMakeLists.txt b/libraries/chain/CMakeLists.txt index 4054878c6..8483ee1a0 100755 --- a/libraries/chain/CMakeLists.txt +++ b/libraries/chain/CMakeLists.txt @@ -5,11 +5,9 @@ set_source_files_properties( "${CMAKE_CURRENT_BINARY_DIR}/include/graphene/chain add_dependencies( build_hardfork_hpp cat-parts ) -file(GLOB HEADERS "include/graphene/chain/*.hpp") -file(GLOB PROTOCOL_HEADERS "include/graphene/chain/protocol/*.hpp") +file(GLOB HEADERS "include/graphene/chain/*.hpp" "${CMAKE_CURRENT_BINARY_DIR}/include/graphene/chain/hardfork.hpp") file(GLOB CPP_FILES "*.cpp") -file(GLOB PROTOCOL_CPP_FILES "protocol/*.cpp") #if( GRAPHENE_DISABLE_UNITY_BUILD ) list(FILTER CPP_FILES EXCLUDE REGEX "[/]database[.]cpp$") @@ -23,14 +21,12 @@ file(GLOB PROTOCOL_CPP_FILES "protocol/*.cpp") add_library( graphene_chain ${CPP_FILES} - ${PROTOCOL_CPP_FILES} ${HEADERS} - ${PROTOCOL_HEADERS} "${CMAKE_CURRENT_BINARY_DIR}/include/graphene/chain/hardfork.hpp" ) add_dependencies( graphene_chain build_hardfork_hpp ) -target_link_libraries( graphene_chain graphene_db ) +target_link_libraries( graphene_chain fc graphene_db graphene_protocol ) target_include_directories( graphene_chain PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" "${CMAKE_CURRENT_BINARY_DIR}/include" ) @@ -46,4 +42,3 @@ INSTALL( TARGETS ARCHIVE DESTINATION lib ) INSTALL( FILES ${HEADERS} DESTINATION "include/graphene/chain" ) -INSTALL( FILES ${PROTOCOL_HEADERS} DESTINATION "include/graphene/chain/protocol" ) diff --git a/libraries/chain/account_evaluator.cpp b/libraries/chain/account_evaluator.cpp index aa199c84f..8f73b0871 100644 --- a/libraries/chain/account_evaluator.cpp +++ b/libraries/chain/account_evaluator.cpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include @@ -214,7 +214,7 @@ object_id_type account_create_evaluator::do_apply( const account_create_operatio if( dynamic_properties.accounts_registered_this_interval % global_properties.parameters.accounts_per_fee_scale == 0 && global_properties.parameters.account_fee_scale_bitshifts != 0 ) { - d.modify(global_properties, [&dynamic_properties](global_property_object& p) { + d.modify(global_properties, [](global_property_object& p) { p.parameters.current_fees->get().basic_fee <<= p.parameters.account_fee_scale_bitshifts; }); } diff --git a/libraries/chain/account_object.cpp b/libraries/chain/account_object.cpp index 71ee28de8..15a41443e 100644 --- a/libraries/chain/account_object.cpp +++ b/libraries/chain/account_object.cpp @@ -36,10 +36,10 @@ share_type cut_fee(share_type a, uint16_t p) if( p == GRAPHENE_100_PERCENT ) return a; - fc::uint128 r(a.value); + fc::uint128_t r = a.value; r *= p; r /= GRAPHENE_100_PERCENT; - return r.to_uint64(); + return r; } void account_balance_object::adjust_balance(const asset& delta) diff --git a/libraries/chain/affiliate_payout.cpp b/libraries/chain/affiliate_payout.cpp index 3138117c7..9375f5b19 100644 --- a/libraries/chain/affiliate_payout.cpp +++ b/libraries/chain/affiliate_payout.cpp @@ -62,15 +62,15 @@ namespace graphene { namespace chain { //ilog("Paying ${p} of ${P} for ${s} of ${r}", ("p",payout.to_uint64())("P",to_pay.value)("s",share)("r",remaining) ); remaining -= share; } - FC_ASSERT( payout.to_uint64() <= to_pay ); + FC_ASSERT( payout <= to_pay ); if( payout > 0 ) { if ( accumulator.find(affiliate) == accumulator.end() ) - accumulator[affiliate] = payout.to_uint64(); + accumulator[affiliate] = payout; else - accumulator[affiliate] += payout.to_uint64(); - to_pay -= payout.to_uint64(); - paid += payout.to_uint64(); + accumulator[affiliate] += payout; + to_pay -= payout; + paid += payout; } } FC_ASSERT( to_pay == 0 ); diff --git a/libraries/chain/asset_evaluator.cpp b/libraries/chain/asset_evaluator.cpp index e61684389..08f7f087f 100644 --- a/libraries/chain/asset_evaluator.cpp +++ b/libraries/chain/asset_evaluator.cpp @@ -596,7 +596,6 @@ void_result asset_update_dividend_evaluator::do_apply( const asset_update_divide obj.referrer = op.issuer; obj.lifetime_referrer = op.issuer(db()).lifetime_referrer; - auto& params = db().get_global_properties().parameters; obj.network_fee_percentage = GRAPHENE_DEFAULT_NETWORK_PERCENT_OF_FEE; obj.lifetime_referrer_fee_percentage = GRAPHENE_DEFAULT_LIFETIME_REFERRER_PERCENT_OF_FEE; obj.referrer_rewards_percentage = GRAPHENE_DEFAULT_LIFETIME_REFERRER_PERCENT_OF_FEE; diff --git a/libraries/chain/asset_object.cpp b/libraries/chain/asset_object.cpp index 79ad88ada..56a1d947c 100644 --- a/libraries/chain/asset_object.cpp +++ b/libraries/chain/asset_object.cpp @@ -38,10 +38,11 @@ share_type asset_bitasset_data_object::max_force_settlement_volume(share_type cu if( options.maximum_force_settlement_volume == GRAPHENE_100_PERCENT ) return current_supply + force_settled_volume; - fc::uint128 volume = current_supply.value + force_settled_volume.value; + fc::uint128_t volume = current_supply.value; + volume += force_settled_volume.value; volume *= options.maximum_force_settlement_volume; volume /= GRAPHENE_100_PERCENT; - return volume.to_uint64(); + return volume; } void asset_bitasset_data_object::update_median_feeds(time_point_sec current_time) diff --git a/libraries/chain/balance_evaluator.cpp b/libraries/chain/balance_evaluator.cpp index 817d736f2..8cc11b851 100644 --- a/libraries/chain/balance_evaluator.cpp +++ b/libraries/chain/balance_evaluator.cpp @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #include -#include +#include namespace graphene { namespace chain { diff --git a/libraries/chain/betting_market_object.cpp b/libraries/chain/betting_market_object.cpp index d5efd56c6..756132332 100644 --- a/libraries/chain/betting_market_object.cpp +++ b/libraries/chain/betting_market_object.cpp @@ -75,7 +75,7 @@ namespace mpl = boost::mpl; amount_to_match_128 += backer_multiplier - GRAPHENE_BETTING_ODDS_PRECISION - 1; amount_to_match_128 /= backer_multiplier - GRAPHENE_BETTING_ODDS_PRECISION; } - return amount_to_match_128.to_uint64(); + return amount_to_match_128; } share_type bet_object::get_approximate_matching_amount(bool round_up /* = false */) const diff --git a/libraries/chain/block_database.cpp b/libraries/chain/block_database.cpp index 2dd9b7a2f..d86a5d250 100644 --- a/libraries/chain/block_database.cpp +++ b/libraries/chain/block_database.cpp @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #include -#include +#include #include namespace graphene { namespace chain { diff --git a/libraries/chain/buyback.cpp b/libraries/chain/buyback.cpp index 09341fe7c..152fc7bbd 100644 --- a/libraries/chain/buyback.cpp +++ b/libraries/chain/buyback.cpp @@ -22,7 +22,7 @@ * THE SOFTWARE. */ -#include +#include #include #include #include diff --git a/libraries/chain/committee_member_evaluator.cpp b/libraries/chain/committee_member_evaluator.cpp index 01614f994..439285b42 100644 --- a/libraries/chain/committee_member_evaluator.cpp +++ b/libraries/chain/committee_member_evaluator.cpp @@ -25,9 +25,8 @@ #include #include #include -#include -#include -#include +#include +#include #include namespace graphene { namespace chain { @@ -42,7 +41,7 @@ object_id_type committee_member_create_evaluator::do_apply( const committee_memb { try { vote_id_type vote_id; db().modify(db().get_global_properties(), [&vote_id](global_property_object& p) { - vote_id = get_next_vote_id(p, vote_id_type::committee); + vote_id = vote_id_type(vote_id_type::committee, p.next_available_vote_id++); }); const auto& new_del_object = db().create( [&]( committee_member_object& obj ){ diff --git a/libraries/chain/confidential_evaluator.cpp b/libraries/chain/confidential_evaluator.cpp index 9946b492d..4be4d0e14 100644 --- a/libraries/chain/confidential_evaluator.cpp +++ b/libraries/chain/confidential_evaluator.cpp @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #include -#include +#include #include #include #include diff --git a/libraries/chain/db_bet.cpp b/libraries/chain/db_bet.cpp index 8c3e13575..2df5238df 100644 --- a/libraries/chain/db_bet.cpp +++ b/libraries/chain/db_bet.cpp @@ -29,6 +29,8 @@ #include #include +#include + #include #include #include @@ -132,7 +134,7 @@ void database::resolve_betting_market_group(const betting_market_group_object& b bool group_was_canceled = resolutions.begin()->second == betting_market_resolution_type::cancel; if (group_was_canceled) - modify(betting_market_group, [group_was_canceled,this](betting_market_group_object& betting_market_group_obj) { + modify(betting_market_group, [this](betting_market_group_object& betting_market_group_obj) { betting_market_group_obj.on_canceled_event(*this, false); // this cancels the betting markets }); else { @@ -149,7 +151,7 @@ void database::resolve_betting_market_group(const betting_market_group_object& b }); } - modify(betting_market_group, [group_was_canceled,this](betting_market_group_object& betting_market_group_obj) { + modify(betting_market_group, [this](betting_market_group_object& betting_market_group_obj) { betting_market_group_obj.on_graded_event(*this); }); } @@ -263,7 +265,7 @@ void database::settle_betting_market_group(const betting_market_group_object& be share_type rake_amount; if (net_profits.value > 0 && rake_account_id) { - rake_amount = ((fc::uint128_t(net_profits.value) * rake_fee_percentage + GRAPHENE_100_PERCENT - 1) / GRAPHENE_100_PERCENT).to_uint64(); + rake_amount = ((fc::uint128_t(net_profits.value) * rake_fee_percentage + GRAPHENE_100_PERCENT - 1) / GRAPHENE_100_PERCENT); share_type affiliates_share; if (rake_amount.value) affiliates_share = payout_helper.payout( bettor_id, rake_amount ); @@ -303,7 +305,8 @@ void database::settle_betting_market_group(const betting_market_group_object& be remove(betting_market); } - const event_object& event = betting_market_group.event_id(*this); + // Fetch to check for existence + betting_market_group.event_id(*this); fc_dlog(fc::logger::get("betting"), "removing betting market group ${id}", ("id", betting_market_group.id)); remove(betting_market_group); @@ -492,7 +495,7 @@ int match_bet(database& db, const bet_object& taker_bet, const bet_object& maker payout_128 += taker_amount_to_match.value; payout_128 *= GRAPHENE_BETTING_ODDS_PRECISION; payout_128 /= maker_bet.back_or_lay == bet_type::back ? maker_amount_to_match.value : taker_amount_to_match.value; - assert(payout_128.to_uint64() == maker_bet.backer_multiplier); + assert(payout_128 == maker_bet.backer_multiplier); } #endif @@ -537,7 +540,6 @@ int match_bet(database& db, const bet_object& taker_bet, const bet_object& maker // because we matched at the maker's odds and not the taker's odds, the remaining amount to match // may not be an even multiple of the taker's odds; round it down. share_type taker_remaining_factor = unrounded_taker_remaining_amount_to_match / takers_odds_maker_odds_ratio; - share_type taker_remaining_maker_amount_to_match = taker_remaining_factor * takers_odds_maker_odds_ratio; share_type taker_remaining_bet_amount = taker_remaining_factor * takers_odds_taker_odds_ratio; taker_refund_amount = taker_bet.amount_to_bet.amount - taker_amount_to_match - taker_remaining_bet_amount; diff --git a/libraries/chain/db_block.cpp b/libraries/chain/db_block.cpp index c7881906e..670d47381 100644 --- a/libraries/chain/db_block.cpp +++ b/libraries/chain/db_block.cpp @@ -26,22 +26,18 @@ #include #include -#include -#include - #include #include #include #include -#include +#include #include -#include #include #include #include -#include +#include namespace { @@ -818,7 +814,7 @@ processed_transaction database::_apply_transaction(const signed_transaction& trx const auto& tapos_block_summary = block_summary_id_type( trx.ref_block_num )(*this); //Verify TaPoS block summary has correct ID prefix, and that this block's time is not past the expiration - FC_ASSERT( trx.ref_block_prefix == tapos_block_summary.block_id._hash[1] ); + FC_ASSERT( trx.ref_block_prefix == tapos_block_summary.block_id._hash[1].value() ); } fc::time_point_sec now = head_block_time(); @@ -831,8 +827,8 @@ processed_transaction database::_apply_transaction(const signed_transaction& trx //Insert transaction into unique transactions database. if( !(skip & skip_transaction_dupe_check) ) { - create([&trx_id,&trx](transaction_object& transaction) { - transaction.trx_id = trx_id; + create([&trx](transaction_history_object& transaction) { + transaction.trx_id = trx.id(); transaction.trx = trx; }); } diff --git a/libraries/chain/db_getter.cpp b/libraries/chain/db_getter.cpp index 7588c9fea..6bb9837ee 100644 --- a/libraries/chain/db_getter.cpp +++ b/libraries/chain/db_getter.cpp @@ -113,13 +113,15 @@ std::vector database::get_seeds(asset_id_type for_asset, uint8_t count { FC_ASSERT( count_winners <= 64 ); std::string salted_string = std::string(_random_number_generator._seed) + std::to_string(for_asset.instance.value); - uint32_t* seeds = (uint32_t*)(fc::sha256::hash(salted_string)._hash); + auto seeds_hash = fc::sha256::hash(salted_string); + uint32_t* seeds = (uint32_t*)(seeds_hash._hash); std::vector result; result.reserve(64); for( int s = 0; s < 8; ++s ) { - uint32_t* sub_seeds = ( uint32_t* ) fc::sha256::hash( std::to_string( seeds[s] ) + std::to_string( for_asset.instance.value ) )._hash; + auto sub_seeds_hash = fc::sha256::hash(std::to_string(seeds[s]) + std::to_string(for_asset.instance.value)); + uint32_t* sub_seeds = (uint32_t*) sub_seeds_hash._hash; for( int ss = 0; ss < 8; ++ss ) { result.push_back(sub_seeds[ss]); } diff --git a/libraries/chain/db_init.cpp b/libraries/chain/db_init.cpp index 43ba381d4..43fc906ad 100644 --- a/libraries/chain/db_init.cpp +++ b/libraries/chain/db_init.cpp @@ -40,7 +40,7 @@ #include #include #include -#include +#include #include #include #include @@ -101,8 +101,6 @@ #include #include -#include - #include #include @@ -149,8 +147,8 @@ const uint8_t operation_history_object::type_id; const uint8_t proposal_object::space_id; const uint8_t proposal_object::type_id; -const uint8_t transaction_object::space_id; -const uint8_t transaction_object::type_id; +const uint8_t transaction_history_object::space_id; +const uint8_t transaction_history_object::type_id; const uint8_t vesting_balance_object::space_id; const uint8_t vesting_balance_object::type_id; @@ -665,7 +663,7 @@ void database::init_genesis(const genesis_state_type& genesis_state) p.time = genesis_state.initial_timestamp; p.dynamic_flags = 0; p.witness_budget = 0; - p.recent_slots_filled = fc::uint128::max_value(); + p.recent_slots_filled = std::numeric_limits::max(); }); create([&](global_betting_statistics_object& betting_statistics) { betting_statistics.number_of_active_events = 0; @@ -888,7 +886,7 @@ void database::init_genesis(const genesis_state_type& genesis_state) for( const auto& handout : genesis_state.initial_balances ) { const auto asset_id = get_asset_id(handout.asset_symbol); - create([&handout,&get_asset_id,total_allocation,asset_id](balance_object& b) { + create([&handout,total_allocation,asset_id](balance_object& b) { b.balance = asset(handout.amount, asset_id); b.owner = handout.owner; }); @@ -1040,7 +1038,7 @@ void database::init_genesis(const genesis_state_type& genesis_state) _wso.last_scheduling_block = 0; - _wso.recent_slots_filled = fc::uint128::max_value(); + _wso.recent_slots_filled = std::numeric_limits::max(); // for shuffled for( const witness_id_type& wid : get_global_properties().active_witnesses ) @@ -1067,7 +1065,7 @@ void database::init_genesis(const genesis_state_type& genesis_state) _sso.last_scheduling_block = 0; - _sso.recent_slots_filled = fc::uint128::max_value(); + _sso.recent_slots_filled = std::numeric_limits::max(); }); assert( sso.id == son_schedule_id_type() ); diff --git a/libraries/chain/db_maint.cpp b/libraries/chain/db_maint.cpp index d7e7eb234..9ac8a50eb 100644 --- a/libraries/chain/db_maint.cpp +++ b/libraries/chain/db_maint.cpp @@ -22,10 +22,6 @@ * THE SOFTWARE. */ -#include - -#include - #include #include #include @@ -51,6 +47,14 @@ #include #include +#include + +#include + +#include + +#include + #define USE_VESTING_OBJECT_BY_ASSET_BALANCE_INDEX // vesting_balance_object by_asset_balance index needed namespace graphene { namespace chain { @@ -401,7 +405,7 @@ void database::pay_workers( share_type& budget ) // worker with more votes is preferred // if two workers exactly tie for votes, worker with lower ID is preferred - std::sort(active_workers.begin(), active_workers.end(), [this](const worker_object& wa, const worker_object& wb) { + std::sort(active_workers.begin(), active_workers.end(), [](const worker_object& wa, const worker_object& wb) { share_type wa_vote = wa.approving_stake(); share_type wb_vote = wb.approving_stake(); if( wa_vote != wb_vote ) @@ -421,10 +425,10 @@ void database::pay_workers( share_type& budget ) // Note: if there is a good chance that passed_time_count == day_count, // for better performance, can avoid the 128 bit calculation by adding a check. // Since it's not the case on BitShares mainnet, we're not using a check here. - fc::uint128 pay(requested_pay.value); + fc::uint128_t pay = requested_pay.value; pay *= passed_time_count; pay /= day_count; - requested_pay = pay.to_uint64(); + requested_pay = pay; share_type actual_pay = std::min(budget, requested_pay); //ilog(" ==> Paying ${a} to worker ${w}", ("w", active_worker.id)("a", actual_pay)); @@ -813,7 +817,7 @@ void database::initialize_budget_record( fc::time_point_sec now, budget_record& budget_u128 >>= GRAPHENE_CORE_ASSET_CYCLE_RATE_BITS; share_type budget; if( budget_u128 < reserve.value ) - rec.total_budget = share_type(budget_u128.to_uint64()); + rec.total_budget = share_type(budget_u128); else rec.total_budget = reserve; @@ -879,7 +883,7 @@ void database::process_budget() if( worker_budget_u128 >= available_funds.value ) worker_budget = available_funds; else - worker_budget = worker_budget_u128.to_uint64(); + worker_budget = worker_budget_u128; rec.worker_budget = worker_budget; available_funds -= worker_budget; @@ -1024,12 +1028,12 @@ void split_fba_balance( fc::uint128_t buyback_amount_128 = fba.accumulated_fba_fees.value; buyback_amount_128 *= designated_asset_buyback_pct; buyback_amount_128 /= GRAPHENE_100_PERCENT; - share_type buyback_amount = buyback_amount_128.to_uint64(); + share_type buyback_amount = buyback_amount_128; fc::uint128_t issuer_amount_128 = fba.accumulated_fba_fees.value; issuer_amount_128 *= designated_asset_issuer_pct; issuer_amount_128 /= GRAPHENE_100_PERCENT; - share_type issuer_amount = issuer_amount_128.to_uint64(); + share_type issuer_amount = issuer_amount_128; // this assert should never fail FC_ASSERT( buyback_amount + issuer_amount <= fba.accumulated_fba_fees ); @@ -1524,7 +1528,7 @@ void schedule_pending_dividend_balances(database& db, minimum_amount_to_distribute *= 100 * GRAPHENE_1_PERCENT; minimum_amount_to_distribute /= dividend_data.options.minimum_fee_percentage; wdump((total_fee_per_asset_in_payout_asset)(dividend_data.options)); - minimum_shares_to_distribute = minimum_amount_to_distribute.to_uint64(); + minimum_shares_to_distribute = minimum_amount_to_distribute; } dlog("Processing dividend payments of asset type ${payout_asset_type}, delta balance is ${delta_balance}", ("payout_asset_type", payout_asset_type(db).symbol)("delta_balance", delta_balance)); @@ -1586,7 +1590,7 @@ void schedule_pending_dividend_balances(database& db, fc::uint128_t amount_to_credit(delta_balance.value); amount_to_credit *= holder_balance.amount.value; amount_to_credit /= total_balance_of_dividend_asset.value; - share_type full_shares_to_credit((int64_t) amount_to_credit.to_uint64()); + share_type full_shares_to_credit((int64_t) amount_to_credit); share_type shares_to_credit = (uint64_t) floor(full_shares_to_credit.value * vesting_factor); if (shares_to_credit < full_shares_to_credit) { @@ -1623,7 +1627,7 @@ void schedule_pending_dividend_balances(database& db, fc::uint128_t amount_to_credit(delta_balance.value); amount_to_credit *= holder_balance.value; amount_to_credit /= total_balance_of_dividend_asset.value; - share_type shares_to_credit((int64_t) amount_to_credit.to_uint64()); + share_type shares_to_credit((int64_t) amount_to_credit); remaining_amount_to_distribute = credit_account(db, holder_balance_object.owner, @@ -1683,7 +1687,7 @@ void schedule_pending_dividend_balances(database& db, fc::uint128_t amount_to_debit(remaining_amount_to_recover.value); amount_to_debit *= pending_balance_object.pending_balance.value; amount_to_debit /= remaining_pending_balances.value; - share_type shares_to_debit((int64_t)amount_to_debit.to_uint64()); + share_type shares_to_debit((int64_t)amount_to_debit); remaining_amount_to_recover -= shares_to_debit; remaining_pending_balances -= pending_balance_object.pending_balance; @@ -1869,7 +1873,6 @@ void process_dividend_assets(database& db) { // if there was a previous payout, make our next payment one interval uint32_t current_time_sec = current_head_block_time.sec_since_epoch(); - fc::time_point_sec reference_time = *dividend_data_obj.last_scheduled_payout_time; uint32_t next_possible_time_sec = dividend_data_obj.last_scheduled_payout_time->sec_since_epoch(); do next_possible_time_sec += *dividend_data_obj.options.payout_interval; diff --git a/libraries/chain/db_management.cpp b/libraries/chain/db_management.cpp index c6380b8c4..30a383012 100644 --- a/libraries/chain/db_management.cpp +++ b/libraries/chain/db_management.cpp @@ -28,7 +28,8 @@ #include #include #include -#include + +#include #include diff --git a/libraries/chain/db_market.cpp b/libraries/chain/db_market.cpp index ad888532a..9f6148151 100644 --- a/libraries/chain/db_market.cpp +++ b/libraries/chain/db_market.cpp @@ -575,10 +575,10 @@ asset database::calculate_market_fee( const asset_object& trade_asset, const ass if( trade_asset.options.market_fee_percent == 0 ) return trade_asset.amount(0); - fc::uint128 a(trade_amount.amount.value); + fc::uint128_t a(trade_amount.amount.value); a *= trade_asset.options.market_fee_percent; a /= GRAPHENE_100_PERCENT; - asset percent_fee = trade_asset.amount(a.to_uint64()); + asset percent_fee = trade_asset.amount(a); if( percent_fee.amount > trade_asset.options.max_market_fee ) percent_fee.amount = trade_asset.options.max_market_fee; diff --git a/libraries/chain/db_notify.cpp b/libraries/chain/db_notify.cpp index 455b17a3b..2411a7de9 100644 --- a/libraries/chain/db_notify.cpp +++ b/libraries/chain/db_notify.cpp @@ -24,11 +24,11 @@ #include +#include +#include +#include + #include -#include -#include -#include -#include #include #include #include @@ -39,7 +39,7 @@ #include #include #include -#include +#include #include #include #include @@ -47,6 +47,13 @@ #include #include +#include +#include +#include +#include +#include +#include +#include using namespace fc; using namespace graphene::chain; @@ -440,7 +447,6 @@ void get_relevant_accounts( const object* obj, flat_set& accoun { case null_object_type: case base_object_type: - case OBJECT_TYPE_COUNT: return; case account_object_type:{ accounts.insert( obj->id ); @@ -508,7 +514,7 @@ void get_relevant_accounts( const object* obj, flat_set& accoun } case balance_object_type:{ /** these are free from any accounts */ break; - } case account_role_type:{ + } case account_role_object_type:{ const auto& aobj = dynamic_cast(obj); assert( aobj != nullptr ); accounts.insert( aobj->owner ); @@ -519,6 +525,8 @@ void get_relevant_accounts( const object* obj, flat_set& accoun assert( aobj != nullptr ); accounts.insert( aobj->son_account ); break; + } case son_proposal_object_type:{ + break; } case son_wallet_object_type:{ break; } case son_wallet_deposit_object_type:{ @@ -531,6 +539,83 @@ void get_relevant_accounts( const object* obj, flat_set& accoun accounts.insert( aobj->sidechain_address_account ); break; } case sidechain_transaction_object_type:{ + } case tournament_object_type:{ + auto aobj = dynamic_cast(obj); + assert(aobj != nullptr); + accounts.insert(aobj->creator); + accounts.insert(aobj->options.whitelist.begin(), aobj->options.whitelist.end()); + break; + } case tournament_details_object_type:{ + auto aobj = dynamic_cast(obj); + assert(aobj != nullptr); + accounts.insert(aobj->registered_players.begin(), aobj->registered_players.end()); + std::transform(aobj->payers.begin(), aobj->payers.end(), std::inserter(accounts, accounts.end()), + [](const auto& pair) { return pair.first; }); + std::for_each(aobj->players_payers.begin(), aobj->players_payers.end(), + [&accounts](const auto& pair) { + accounts.insert(pair.first); + accounts.insert(pair.second); + }); + break; + } case match_object_type:{ + auto aobj = dynamic_cast(obj); + assert(aobj != nullptr); + accounts.insert(aobj->players.begin(), aobj->players.end()); + std::for_each(aobj->game_winners.begin(), aobj->game_winners.end(), + [&accounts](const auto& set) { accounts.insert(set.begin(), set.end()); }); + accounts.insert(aobj->match_winners.begin(), aobj->match_winners.end()); + break; + } case game_object_type:{ + auto aobj = dynamic_cast(obj); + assert(aobj != nullptr); + accounts.insert(aobj->players.begin(), aobj->players.end()); + accounts.insert(aobj->winners.begin(), aobj->winners.end()); + break; + } case sport_object_type: + break; + case event_group_object_type: + break; + case event_object_type: + break; + case betting_market_rules_object_type: + break; + case betting_market_group_object_type: + break; + case betting_market_object_type: + break; + case bet_object_type:{ + auto aobj = dynamic_cast(obj); + assert(aobj != nullptr); + accounts.insert(aobj->bettor_id); + break; + } case custom_permission_object_type:{ + auto aobj = dynamic_cast(obj); + assert(aobj != nullptr); + accounts.insert(aobj->account); + add_authority_accounts(accounts, aobj->auth); + break; + } case custom_account_authority_object_type: + break; + case offer_object_type:{ + auto aobj = dynamic_cast(obj); + assert(aobj != nullptr); + accounts.insert(aobj->issuer); + if (aobj->bidder.valid()) + accounts.insert(*aobj->bidder); + break; + } case nft_metadata_object_type:{ + auto aobj = dynamic_cast(obj); + assert(aobj != nullptr); + accounts.insert(aobj->owner); + if (aobj->revenue_partner.valid()) + accounts.insert(*aobj->revenue_partner); + break; + } case nft_object_type:{ + auto aobj = dynamic_cast(obj); + assert(aobj != nullptr); + accounts.insert(aobj->owner); + accounts.insert(aobj->approved); + accounts.insert(aobj->approved_operators.begin(), aobj->approved_operators.end()); break; } } @@ -545,9 +630,9 @@ void get_relevant_accounts( const object* obj, flat_set& accoun break; case impl_reserved0_object_type: break; - case impl_asset_dynamic_data_type: + case impl_asset_dynamic_data_object_type: break; - case impl_asset_bitasset_data_type: + case impl_asset_bitasset_data_object_type: break; case impl_account_balance_object_type:{ const auto& aobj = dynamic_cast(obj); @@ -559,11 +644,11 @@ void get_relevant_accounts( const object* obj, flat_set& accoun assert( aobj != nullptr ); accounts.insert( aobj->owner ); break; - } case impl_transaction_object_type:{ - const auto& aobj = dynamic_cast(obj); - assert( aobj != nullptr ); + } case impl_transaction_history_object_type:{ + const auto& aobj = dynamic_cast(obj); + FC_ASSERT( aobj != nullptr ); transaction_get_impacted_accounts( aobj->trx, accounts, - ignore_custom_operation_required_auths); + ignore_custom_operation_required_auths ); break; } case impl_blinded_balance_object_type:{ const auto& aobj = dynamic_cast(obj); @@ -587,6 +672,44 @@ void get_relevant_accounts( const object* obj, flat_set& accoun break; case impl_fba_accumulator_object_type: break; + case impl_asset_dividend_data_object_type:{ + const auto& aobj = dynamic_cast(obj); + assert( aobj != nullptr ); + accounts.insert(aobj->dividend_distribution_account); + break; + } case impl_pending_dividend_payout_balance_for_holder_object_type:{ + const auto& aobj = dynamic_cast(obj); + assert( aobj != nullptr ); + accounts.insert(aobj->owner); + break; + } case impl_total_distributed_dividend_balance_object_type: + break; + case impl_betting_market_position_object_type:{ + const auto& aobj = dynamic_cast(obj); + assert( aobj != nullptr ); + accounts.insert(aobj->bettor_id); + break; + } case impl_global_betting_statistics_object_type: + break; + case impl_lottery_balance_object_type: + break; + case impl_sweeps_vesting_balance_object_type:{ + const auto& aobj = dynamic_cast(obj); + assert( aobj != nullptr ); + accounts.insert(aobj->owner); + break; + } case impl_offer_history_object_type:{ + const auto& aobj = dynamic_cast(obj); + assert( aobj != nullptr ); + accounts.insert(aobj->issuer); + if (aobj->bidder.valid()) + accounts.insert(*aobj->bidder); + break; + } case impl_son_statistics_object_type: { + break; + } case impl_son_schedule_object_type: { + break; + } } } } // end get_relevant_accounts( const object* obj, flat_set& accounts ) diff --git a/libraries/chain/db_update.cpp b/libraries/chain/db_update.cpp index a2989e2b7..f6b5c9506 100644 --- a/libraries/chain/db_update.cpp +++ b/libraries/chain/db_update.cpp @@ -35,20 +35,17 @@ #include #include #include -#include +#include #include #include -#include - -#include +#include namespace graphene { namespace chain { void database::update_global_dynamic_data( const signed_block& b, const uint32_t missed_blocks ) { const dynamic_global_property_object& _dgp = get_dynamic_global_properties(); - const global_property_object& gpo = get_global_properties(); // dynamic global properties updating modify( _dgp, [&b,this,missed_blocks]( dynamic_global_property_object& dgp ){ @@ -157,7 +154,8 @@ void database::clear_expired_transactions() { try { //Look for expired transactions in the deduplication list, and remove them. //Transactions must have expired by at least two forking windows in order to be removed. - auto& transaction_idx = static_cast(get_mutable_index(implementation_ids, impl_transaction_object_type)); + auto& transaction_idx = static_cast(get_mutable_index(implementation_ids, + impl_transaction_history_object_type)); const auto& dedupe_index = transaction_idx.indices().get(); while( (!dedupe_index.empty()) && (head_block_time() > dedupe_index.begin()->trx.expiration) ) transaction_idx.remove(*dedupe_index.begin()); @@ -428,7 +426,7 @@ void database::clear_expired_orders() auto& pays = order.balance; auto receives = (order.balance * mia.current_feed.settlement_price); receives.amount = (fc::uint128_t(receives.amount.value) * - (GRAPHENE_100_PERCENT - mia.options.force_settlement_offset_percent) / GRAPHENE_100_PERCENT).to_uint64(); + (GRAPHENE_100_PERCENT - mia.options.force_settlement_offset_percent) / GRAPHENE_100_PERCENT); assert(receives <= order.balance * mia.current_feed.settlement_price); price settlement_price = pays / receives; diff --git a/libraries/chain/db_witness_schedule.cpp b/libraries/chain/db_witness_schedule.cpp index 084c8e1d3..8e6116f61 100644 --- a/libraries/chain/db_witness_schedule.cpp +++ b/libraries/chain/db_witness_schedule.cpp @@ -27,7 +27,10 @@ #include #include #include -#include + +#include + +#include namespace graphene { namespace chain { @@ -267,7 +270,7 @@ void database::update_witness_schedule(const signed_block& next_block) modify(wso, [&](witness_schedule_object& _wso) { _wso.slots_since_genesis += schedule_slot; - witness_scheduler_rng rng(wso.rng_seed.data, _wso.slots_since_genesis); + witness_scheduler_rng rng(wso.rng_seed.data(), _wso.slots_since_genesis); _wso.scheduler._min_token_count = std::max(int(gpo.active_witnesses.size()) / 2, 1); @@ -332,7 +335,7 @@ void database::update_son_schedule(const signed_block& next_block) modify(sso, [&](son_schedule_object& _sso) { _sso.slots_since_genesis += schedule_slot; - witness_scheduler_rng rng(sso.rng_seed.data, _sso.slots_since_genesis); + witness_scheduler_rng rng(sso.rng_seed.data(), _sso.slots_since_genesis); _sso.scheduler._min_token_count = std::max(int(gpo.active_sons.size()) / 2, 1); @@ -391,12 +394,12 @@ uint32_t database::witness_participation_rate()const if (gpo.parameters.witness_schedule_algorithm == GRAPHENE_WITNESS_SHUFFLED_ALGORITHM) { const dynamic_global_property_object& dpo = get_dynamic_global_properties(); - return uint64_t(GRAPHENE_100_PERCENT) * dpo.recent_slots_filled.popcount() / 128; + return uint64_t(GRAPHENE_100_PERCENT) * fc::popcount(dpo.recent_slots_filled) / 128; } if (gpo.parameters.witness_schedule_algorithm == GRAPHENE_WITNESS_SCHEDULED_ALGORITHM) { const witness_schedule_object& wso = get_witness_schedule_object(); - return uint64_t(GRAPHENE_100_PERCENT) * wso.recent_slots_filled.popcount() / 128; + return uint64_t(GRAPHENE_100_PERCENT) * fc::popcount(wso.recent_slots_filled) / 128; } return 0; } diff --git a/libraries/chain/evaluator.cpp b/libraries/chain/evaluator.cpp index 2ae8f0e75..638df2bd8 100644 --- a/libraries/chain/evaluator.cpp +++ b/libraries/chain/evaluator.cpp @@ -33,9 +33,7 @@ #include #include #include -#include - -#include +#include namespace graphene { namespace chain { database& generic_evaluator::db()const { return trx_state->db(); } diff --git a/libraries/chain/event_evaluator.cpp b/libraries/chain/event_evaluator.cpp index 28e7476df..9c2ba9f19 100644 --- a/libraries/chain/event_evaluator.cpp +++ b/libraries/chain/event_evaluator.cpp @@ -29,6 +29,7 @@ #include #include #include +#include namespace graphene { namespace chain { diff --git a/libraries/chain/exceptions.cpp b/libraries/chain/exceptions.cpp new file mode 100644 index 000000000..9009a80c3 --- /dev/null +++ b/libraries/chain/exceptions.cpp @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2019 BitShares Blockchain Foundation, and contributors. + * + * The MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include + +namespace graphene { namespace chain { + + // Internal exceptions + + FC_IMPLEMENT_DERIVED_EXCEPTION( internal_exception, graphene::chain::chain_exception, 3990000, "internal exception" ) + + GRAPHENE_IMPLEMENT_INTERNAL_EXCEPTION( verify_auth_max_auth_exceeded, 1, "Exceeds max authority fan-out" ) + GRAPHENE_IMPLEMENT_INTERNAL_EXCEPTION( verify_auth_account_not_found, 2, "Auth account not found" ) + + + // Public exceptions + + FC_IMPLEMENT_EXCEPTION( chain_exception, 3000000, "blockchain exception" ) + + FC_IMPLEMENT_DERIVED_EXCEPTION( database_query_exception, chain_exception, 3010000, "database query exception" ) + FC_IMPLEMENT_DERIVED_EXCEPTION( block_validate_exception, chain_exception, 3020000, "block validation exception" ) + FC_IMPLEMENT_DERIVED_EXCEPTION( operation_validate_exception, chain_exception, 3040000, "operation validation exception" ) + FC_IMPLEMENT_DERIVED_EXCEPTION( operation_evaluate_exception, chain_exception, 3050000, "operation evaluation exception" ) + FC_IMPLEMENT_DERIVED_EXCEPTION( utility_exception, chain_exception, 3060000, "utility method exception" ) + FC_IMPLEMENT_DERIVED_EXCEPTION( undo_database_exception, chain_exception, 3070000, "undo database exception" ) + FC_IMPLEMENT_DERIVED_EXCEPTION( unlinkable_block_exception, chain_exception, 3080000, "unlinkable block" ) + FC_IMPLEMENT_DERIVED_EXCEPTION( black_swan_exception, chain_exception, 3090000, "black swan" ) + FC_IMPLEMENT_DERIVED_EXCEPTION( plugin_exception, chain_exception, 3100000, "plugin exception" ) + + FC_IMPLEMENT_DERIVED_EXCEPTION( insufficient_feeds, chain_exception, 37006, "insufficient feeds" ) + + FC_IMPLEMENT_DERIVED_EXCEPTION( pop_empty_chain, undo_database_exception, 3070001, "there are no blocks to pop" ) + + GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( transfer ); + GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( from_account_not_whitelisted, transfer, 1, "owner mismatch" ) + GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( to_account_not_whitelisted, transfer, 2, "owner mismatch" ) + GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( restricted_transfer_asset, transfer, 3, "restricted transfer asset" ) + + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( limit_order_create ); + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( limit_order_cancel ); + GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( call_order_update ); + GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( unfilled_margin_call, call_order_update, 1, "Updating call order would trigger a margin call that cannot be fully filled" ) + + GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( account_create ); + GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( max_auth_exceeded, account_create, 1, "Exceeds max authority fan-out" ) + GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( auth_account_not_found, account_create, 2, "Auth account not found" ) + GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( buyback_incorrect_issuer, account_create, 3, "Incorrect issuer specified for account" ) + GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( buyback_already_exists, account_create, 4, "Cannot create buyback for asset which already has buyback" ) + GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( buyback_too_many_markets, account_create, 5, "Too many buyback markets" ) + + GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( account_update ); + GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( max_auth_exceeded, account_update, 1, "Exceeds max authority fan-out" ) + GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( auth_account_not_found, account_update, 2, "Auth account not found" ) + + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( account_whitelist ); + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( account_upgrade ); + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( account_transfer ); + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_create ); + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_update ); + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_update_bitasset ); + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_update_feed_producers ); + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_issue ); + + GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_reserve ); + GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( invalid_on_mia, asset_reserve, 1, "invalid on mia" ) + + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_fund_fee_pool ); + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_settle ); + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_global_settle ); + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_publish_feed ); + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( committee_member_create ); + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( witness_create ); + + GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( proposal_create ); + GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( review_period_required, proposal_create, 1, "review_period required" ) + GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( review_period_insufficient, proposal_create, 2, "review_period insufficient" ) + + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( proposal_update ); + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( proposal_delete ); + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( withdraw_permission_create ); + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( withdraw_permission_update ); + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( withdraw_permission_claim ); + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( withdraw_permission_delete ); + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( fill_order ); + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( global_parameters_update ); + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( vesting_balance_create ); + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( vesting_balance_withdraw ); + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( worker_create ); + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( custom ); + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( assert ); + + GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( balance_claim ); + GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( claimed_too_often, balance_claim, 1, "balance claimed too often" ) + GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( invalid_claim_amount, balance_claim, 2, "invalid claim amount" ) + GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( owner_mismatch, balance_claim, 3, "owner mismatch" ) + + GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( override_transfer ); + GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( not_permitted, override_transfer, 1, "not permitted" ) + + GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( blind_transfer ); + GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( unknown_commitment, blind_transfer, 1, "Attempting to claim an unknown prior commitment" ); + + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( transfer_from_blind_operation ) + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_claim_fees_operation ) + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( bid_collateral_operation ) + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_claim_pool_operation ) + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_update_issuer_operation ) + + #define GRAPHENE_RECODE_EXC( cause_type, effect_type ) \ + catch( const cause_type& e ) \ + { throw( effect_type( e.what(), e.get_log() ) ); } + +} } // graphene::chain diff --git a/libraries/chain/fork_database.cpp b/libraries/chain/fork_database.cpp index 1cb4f77bc..b6c722214 100644 --- a/libraries/chain/fork_database.cpp +++ b/libraries/chain/fork_database.cpp @@ -23,7 +23,7 @@ */ #include #include -#include +#include namespace graphene { namespace chain { fork_database::fork_database() diff --git a/libraries/chain/genesis_state.cpp b/libraries/chain/genesis_state.cpp index 7907c79e8..a8ab549c2 100644 --- a/libraries/chain/genesis_state.cpp +++ b/libraries/chain/genesis_state.cpp @@ -24,8 +24,8 @@ #include -// these are required to serialize a genesis_state -#include +// this is required to serialize a genesis_state +#include namespace graphene { namespace chain { diff --git a/libraries/chain/get_config.cpp b/libraries/chain/get_config.cpp index 245d65984..2e1cb91e0 100644 --- a/libraries/chain/get_config.cpp +++ b/libraries/chain/get_config.cpp @@ -24,7 +24,7 @@ #include #include -#include +#include namespace graphene { namespace chain { @@ -74,7 +74,6 @@ fc::variant_object get_config() result[ "GRAPHENE_MAX_COLLATERAL_RATIO" ] = GRAPHENE_MAX_COLLATERAL_RATIO; result[ "GRAPHENE_DEFAULT_MAINTENANCE_COLLATERAL_RATIO" ] = GRAPHENE_DEFAULT_MAINTENANCE_COLLATERAL_RATIO; result[ "GRAPHENE_DEFAULT_MAX_SHORT_SQUEEZE_RATIO" ] = GRAPHENE_DEFAULT_MAX_SHORT_SQUEEZE_RATIO; - result[ "GRAPHENE_DEFAULT_MARGIN_PERIOD_SEC" ] = GRAPHENE_DEFAULT_MARGIN_PERIOD_SEC; result[ "GRAPHENE_DEFAULT_MAX_WITNESSES" ] = GRAPHENE_DEFAULT_MAX_WITNESSES; result[ "GRAPHENE_DEFAULT_MAX_COMMITTEE" ] = GRAPHENE_DEFAULT_MAX_COMMITTEE; result[ "GRAPHENE_DEFAULT_MAX_PROPOSAL_LIFETIME_SEC" ] = GRAPHENE_DEFAULT_MAX_PROPOSAL_LIFETIME_SEC; diff --git a/libraries/chain/include/graphene/chain/account_object.hpp b/libraries/chain/include/graphene/chain/account_object.hpp index 5f24adebf..c547af222 100644 --- a/libraries/chain/include/graphene/chain/account_object.hpp +++ b/libraries/chain/include/graphene/chain/account_object.hpp @@ -22,13 +22,15 @@ * THE SOFTWARE. */ #pragma once -#include +#include #include -#include +#include #include namespace graphene { namespace chain { class database; + class account_object; + class vesting_balance_object; /** * @class account_statistics_object @@ -541,6 +543,10 @@ namespace graphene { namespace chain { }} +MAP_OBJECT_ID_TO_TYPE(graphene::chain::account_object) +MAP_OBJECT_ID_TO_TYPE(graphene::chain::account_balance_object) +MAP_OBJECT_ID_TO_TYPE(graphene::chain::account_statistics_object) + FC_REFLECT_DERIVED( graphene::chain::account_object, (graphene::db::object), (membership_expiration_date)(registrar)(referrer)(lifetime_referrer) diff --git a/libraries/chain/include/graphene/chain/account_role_evaluator.hpp b/libraries/chain/include/graphene/chain/account_role_evaluator.hpp index 29c4ada60..ede10e01d 100644 --- a/libraries/chain/include/graphene/chain/account_role_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/account_role_evaluator.hpp @@ -2,8 +2,8 @@ #include #include -#include -#include +#include +#include namespace graphene { namespace chain { diff --git a/libraries/chain/include/graphene/chain/account_role_object.hpp b/libraries/chain/include/graphene/chain/account_role_object.hpp index 9455f4759..afaf8bf65 100644 --- a/libraries/chain/include/graphene/chain/account_role_object.hpp +++ b/libraries/chain/include/graphene/chain/account_role_object.hpp @@ -1,5 +1,5 @@ #pragma once -#include +#include #include #include @@ -13,7 +13,7 @@ namespace graphene { public: static const uint8_t space_id = protocol_ids; - static const uint8_t type_id = account_role_type; + static const uint8_t type_id = account_role_object_type; account_id_type owner; std::string name; @@ -45,5 +45,7 @@ namespace graphene } // namespace chain } // namespace graphene +MAP_OBJECT_ID_TO_TYPE(graphene::chain::account_role_object) + FC_REFLECT_DERIVED(graphene::chain::account_role_object, (graphene::db::object), - (owner)(name)(metadata)(allowed_operations)(whitelisted_accounts)(valid_to)) \ No newline at end of file + (owner)(name)(metadata)(allowed_operations)(whitelisted_accounts)(valid_to)) diff --git a/libraries/chain/include/graphene/chain/affiliate_payout.hpp b/libraries/chain/include/graphene/chain/affiliate_payout.hpp index 1c0ea703a..d69d398ba 100644 --- a/libraries/chain/include/graphene/chain/affiliate_payout.hpp +++ b/libraries/chain/include/graphene/chain/affiliate_payout.hpp @@ -23,8 +23,8 @@ */ #pragma once -#include -#include +#include +#include #include #include diff --git a/libraries/chain/include/graphene/chain/assert_evaluator.hpp b/libraries/chain/include/graphene/chain/assert_evaluator.hpp index b985a8498..e4bfdd00a 100644 --- a/libraries/chain/include/graphene/chain/assert_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/assert_evaluator.hpp @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #pragma once -#include +#include #include #include diff --git a/libraries/chain/include/graphene/chain/asset_evaluator.hpp b/libraries/chain/include/graphene/chain/asset_evaluator.hpp index d65d37fc2..360d1cd09 100644 --- a/libraries/chain/include/graphene/chain/asset_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/asset_evaluator.hpp @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #pragma once -#include +#include #include #include diff --git a/libraries/chain/include/graphene/chain/asset_object.hpp b/libraries/chain/include/graphene/chain/asset_object.hpp index d8c65e898..607414108 100644 --- a/libraries/chain/include/graphene/chain/asset_object.hpp +++ b/libraries/chain/include/graphene/chain/asset_object.hpp @@ -22,11 +22,10 @@ * THE SOFTWARE. */ #pragma once -#include -#include -#include -#include +#include #include +#include +#include /** * @defgroup prediction_market Prediction Market @@ -39,6 +38,9 @@ */ namespace graphene { namespace chain { + class account_object; + class asset_bitasset_data_object; + class asset_dividend_data_object; class database; class transaction_evaluation_state; using namespace graphene::db; @@ -59,7 +61,7 @@ namespace graphene { namespace chain { { public: static const uint8_t space_id = implementation_ids; - static const uint8_t type_id = impl_asset_dynamic_data_type; + static const uint8_t type_id = impl_asset_dynamic_data_object_type; /// The number of shares currently in existence share_type current_supply; @@ -111,13 +113,13 @@ namespace graphene { namespace chain { string amount_to_string(share_type amount)const; /// Convert an asset to a textual representation, i.e. "123.45" string amount_to_string(const asset& amount)const - { FC_ASSERT(amount.asset_id == id); return amount_to_string(amount.amount); } + { FC_ASSERT(amount.asset_id == get_id()); return amount_to_string(amount.amount); } /// Convert an asset to a textual representation with symbol, i.e. "123.45 USD" string amount_to_pretty_string(share_type amount)const { return amount_to_string(amount) + " " + symbol; } /// Convert an asset to a textual representation with symbol, i.e. "123.45 USD" string amount_to_pretty_string(const asset &amount)const - { FC_ASSERT(amount.asset_id == id); return amount_to_pretty_string(amount.amount); } + { FC_ASSERT(amount.asset_id == get_id()); return amount_to_pretty_string(amount.amount); } uint32_t get_issuer_num()const { return issuer.instance.value; } @@ -192,7 +194,7 @@ namespace graphene { namespace chain { { public: static const uint8_t space_id = implementation_ids; - static const uint8_t type_id = impl_asset_bitasset_data_type; + static const uint8_t type_id = impl_asset_bitasset_data_object_type; /// The asset this object belong to asset_id_type asset_id; @@ -370,7 +372,7 @@ namespace graphene { namespace chain { { public: static const uint8_t space_id = implementation_ids; - static const uint8_t type_id = impl_asset_dividend_data_type; + static const uint8_t type_id = impl_asset_dividend_data_object_type; /// The tunable options for Dividend-paying assets are stored in this field. dividend_asset_options options; @@ -414,7 +416,7 @@ namespace graphene { namespace chain { { public: static const uint8_t space_id = implementation_ids; - static const uint8_t type_id = impl_distributed_dividend_balance_data_type; + static const uint8_t type_id = impl_total_distributed_dividend_balance_object_type; asset_id_type dividend_holder_asset_type; asset_id_type dividend_payout_asset_type; @@ -513,6 +515,14 @@ namespace graphene { namespace chain { } } // graphene::chain +MAP_OBJECT_ID_TO_TYPE(graphene::chain::asset_object) +MAP_OBJECT_ID_TO_TYPE(graphene::chain::asset_dynamic_data_object) +MAP_OBJECT_ID_TO_TYPE(graphene::chain::asset_bitasset_data_object) +MAP_OBJECT_ID_TO_TYPE(graphene::chain::asset_dividend_data_object) +MAP_OBJECT_ID_TO_TYPE(graphene::chain::total_distributed_dividend_balance_object) +MAP_OBJECT_ID_TO_TYPE(graphene::chain::lottery_balance_object) +MAP_OBJECT_ID_TO_TYPE(graphene::chain::sweeps_vesting_balance_object) + FC_REFLECT_DERIVED( graphene::chain::asset_dynamic_data_object, (graphene::db::object), (current_supply)(sweeps_tickets_sold)(confidential_supply)(accumulated_fees)(fee_pool) ) diff --git a/libraries/chain/include/graphene/chain/balance_evaluator.hpp b/libraries/chain/include/graphene/chain/balance_evaluator.hpp index 9458b1734..ef1491b98 100644 --- a/libraries/chain/include/graphene/chain/balance_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/balance_evaluator.hpp @@ -23,7 +23,7 @@ */ #pragma once -#include +#include #include #include #include diff --git a/libraries/chain/include/graphene/chain/balance_object.hpp b/libraries/chain/include/graphene/chain/balance_object.hpp index 38a1a6494..a0f6ff232 100644 --- a/libraries/chain/include/graphene/chain/balance_object.hpp +++ b/libraries/chain/include/graphene/chain/balance_object.hpp @@ -71,6 +71,8 @@ namespace graphene { namespace chain { using balance_index = generic_index; } } +MAP_OBJECT_ID_TO_TYPE(graphene::chain::balance_object) + FC_REFLECT_DERIVED( graphene::chain::balance_object, (graphene::db::object), (owner)(balance)(vesting_policy)(last_claim_date) ) diff --git a/libraries/chain/include/graphene/chain/betting_market_evaluator.hpp b/libraries/chain/include/graphene/chain/betting_market_evaluator.hpp index eb245c4a0..36a516d72 100644 --- a/libraries/chain/include/graphene/chain/betting_market_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/betting_market_evaluator.hpp @@ -23,7 +23,7 @@ */ #pragma once -#include +#include #include #include diff --git a/libraries/chain/include/graphene/chain/betting_market_object.hpp b/libraries/chain/include/graphene/chain/betting_market_object.hpp index 36e8e6642..55271ddf2 100644 --- a/libraries/chain/include/graphene/chain/betting_market_object.hpp +++ b/libraries/chain/include/graphene/chain/betting_market_object.hpp @@ -23,14 +23,17 @@ */ #pragma once -#include +#include + +#include + #include #include -#include -#include #include +#include + namespace graphene { namespace chain { class betting_market_object; class betting_market_group_object; @@ -45,7 +48,7 @@ namespace fc { namespace graphene { namespace chain { -FC_DECLARE_EXCEPTION(no_transition, 100000, "Invalid state transition"); +FC_DECLARE_EXCEPTION(no_transition, 100000); class database; struct by_event_id; @@ -717,9 +720,16 @@ inline Stream& operator>>( Stream& s, betting_market_group_object& betting_marke } } // graphene::chain +MAP_OBJECT_ID_TO_TYPE(graphene::chain::betting_market_rules_object) +MAP_OBJECT_ID_TO_TYPE(graphene::chain::betting_market_group_object) +MAP_OBJECT_ID_TO_TYPE(graphene::chain::betting_market_object) +MAP_OBJECT_ID_TO_TYPE(graphene::chain::bet_object) +MAP_OBJECT_ID_TO_TYPE(graphene::chain::betting_market_position_object) + FC_REFLECT_DERIVED( graphene::chain::betting_market_rules_object, (graphene::db::object), (name)(description) ) -FC_REFLECT_DERIVED( graphene::chain::betting_market_group_object, (graphene::db::object), (description) ) -FC_REFLECT_DERIVED( graphene::chain::betting_market_object, (graphene::db::object), (group_id) ) +FC_REFLECT_DERIVED( graphene::chain::betting_market_group_object, (graphene::db::object), (description)(event_id)(rules_id)(asset_id)(total_matched_bets_amount)(never_in_play)(delay_before_settling)(settling_time) ) +FC_REFLECT_DERIVED( graphene::chain::betting_market_object, (graphene::db::object), (group_id)(description)(payout_condition)(resolution) ) FC_REFLECT_DERIVED( graphene::chain::bet_object, (graphene::db::object), (bettor_id)(betting_market_id)(amount_to_bet)(backer_multiplier)(back_or_lay)(end_of_delay) ) FC_REFLECT_DERIVED( graphene::chain::betting_market_position_object, (graphene::db::object), (bettor_id)(betting_market_id)(pay_if_payout_condition)(pay_if_not_payout_condition)(pay_if_canceled)(pay_if_not_canceled)(fees_collected) ) + diff --git a/libraries/chain/include/graphene/chain/block_database.hpp b/libraries/chain/include/graphene/chain/block_database.hpp index c5cf5df9e..2580e326c 100644 --- a/libraries/chain/include/graphene/chain/block_database.hpp +++ b/libraries/chain/include/graphene/chain/block_database.hpp @@ -23,12 +23,13 @@ */ #pragma once #include -#include +#include #include namespace graphene { namespace chain { - class index_entry; + struct index_entry; + using namespace graphene::protocol; class block_database { diff --git a/libraries/chain/include/graphene/chain/block_summary_object.hpp b/libraries/chain/include/graphene/chain/block_summary_object.hpp index 9f79d43e9..70fc52627 100644 --- a/libraries/chain/include/graphene/chain/block_summary_object.hpp +++ b/libraries/chain/include/graphene/chain/block_summary_object.hpp @@ -22,7 +22,8 @@ * THE SOFTWARE. */ #pragma once -#include +#include + #include namespace graphene { namespace chain { @@ -48,6 +49,7 @@ namespace graphene { namespace chain { } } +MAP_OBJECT_ID_TO_TYPE(graphene::chain::block_summary_object) FC_REFLECT_DERIVED( graphene::chain::block_summary_object, (graphene::db::object), (block_id) ) diff --git a/libraries/chain/include/graphene/chain/budget_record_object.hpp b/libraries/chain/include/graphene/chain/budget_record_object.hpp index 0da71ca5d..eed7ce0ed 100644 --- a/libraries/chain/include/graphene/chain/budget_record_object.hpp +++ b/libraries/chain/include/graphene/chain/budget_record_object.hpp @@ -22,7 +22,9 @@ * THE SOFTWARE. */ #pragma once -#include +#include + +#include #include namespace graphene { namespace chain { @@ -67,6 +69,8 @@ class budget_record_object : public graphene::db::abstract_object +#include namespace graphene { namespace chain { diff --git a/libraries/chain/include/graphene/chain/buyback_object.hpp b/libraries/chain/include/graphene/chain/buyback_object.hpp index 3d58429bc..fa673e3b0 100644 --- a/libraries/chain/include/graphene/chain/buyback_object.hpp +++ b/libraries/chain/include/graphene/chain/buyback_object.hpp @@ -23,7 +23,8 @@ */ #pragma once -#include +#include + #include #include @@ -64,6 +65,8 @@ typedef generic_index< buyback_object, buyback_multi_index_type > buyback_index; } } // graphene::chain +MAP_OBJECT_ID_TO_TYPE(graphene::chain::buyback_object) + FC_REFLECT_DERIVED( graphene::chain::buyback_object, (graphene::db::object), (asset_to_buy) ) GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::buyback_object ) diff --git a/libraries/chain/include/graphene/chain/chain_property_object.hpp b/libraries/chain/include/graphene/chain/chain_property_object.hpp index 3c7a77ff1..e9b7dc8f6 100644 --- a/libraries/chain/include/graphene/chain/chain_property_object.hpp +++ b/libraries/chain/include/graphene/chain/chain_property_object.hpp @@ -24,6 +24,7 @@ #pragma once #include +#include namespace graphene { namespace chain { @@ -42,6 +43,8 @@ class chain_property_object : public abstract_object } } +MAP_OBJECT_ID_TO_TYPE(graphene::chain::chain_property_object) + FC_REFLECT_DERIVED( graphene::chain::chain_property_object, (graphene::db::object), (chain_id) (immutable_parameters) diff --git a/libraries/chain/include/graphene/chain/committee_member_evaluator.hpp b/libraries/chain/include/graphene/chain/committee_member_evaluator.hpp index ec55b1d7a..388a43648 100644 --- a/libraries/chain/include/graphene/chain/committee_member_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/committee_member_evaluator.hpp @@ -24,6 +24,7 @@ #pragma once #include #include +#include namespace graphene { namespace chain { diff --git a/libraries/chain/include/graphene/chain/committee_member_object.hpp b/libraries/chain/include/graphene/chain/committee_member_object.hpp index fe7968d36..dfbbe9797 100644 --- a/libraries/chain/include/graphene/chain/committee_member_object.hpp +++ b/libraries/chain/include/graphene/chain/committee_member_object.hpp @@ -22,9 +22,10 @@ * THE SOFTWARE. */ #pragma once -#include #include #include +#include +#include namespace graphene { namespace chain { using namespace graphene::db; @@ -71,6 +72,7 @@ namespace graphene { namespace chain { using committee_member_index = generic_index; } } // graphene::chain +MAP_OBJECT_ID_TO_TYPE(graphene::chain::committee_member_object) FC_REFLECT_DERIVED( graphene::chain::committee_member_object, (graphene::db::object), (committee_member_account)(vote_id)(total_votes)(url) ) diff --git a/libraries/chain/include/graphene/chain/confidential_evaluator.hpp b/libraries/chain/include/graphene/chain/confidential_evaluator.hpp index bc877faf3..136519c73 100644 --- a/libraries/chain/include/graphene/chain/confidential_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/confidential_evaluator.hpp @@ -23,13 +23,10 @@ */ #pragma once #include +#include namespace graphene { namespace chain { -struct transfer_to_blind_operation; -struct transfer_from_blind_operation; -struct blind_transfer_operation; - class transfer_to_blind_evaluator : public evaluator { public: diff --git a/libraries/chain/include/graphene/chain/confidential_object.hpp b/libraries/chain/include/graphene/chain/confidential_object.hpp index acdb0ba5d..90df90def 100644 --- a/libraries/chain/include/graphene/chain/confidential_object.hpp +++ b/libraries/chain/include/graphene/chain/confidential_object.hpp @@ -23,8 +23,8 @@ */ #pragma once -#include -#include +#include +#include #include @@ -65,6 +65,7 @@ typedef generic_index #define GRAPHENE_MIN_UNDO_HISTORY 10 #define GRAPHENE_MAX_UNDO_HISTORY 10000 -#define GRAPHENE_MIN_BLOCK_SIZE_LIMIT (GRAPHENE_MIN_TRANSACTION_SIZE_LIMIT*5) // 5 transactions per block -#define GRAPHENE_MIN_TRANSACTION_EXPIRATION_LIMIT (GRAPHENE_MAX_BLOCK_INTERVAL * 5) // 5 transactions per block -#define GRAPHENE_BLOCKCHAIN_PRECISION uint64_t( 100000 ) - -#define GRAPHENE_BLOCKCHAIN_PRECISION_DIGITS 5 -#define GRAPHENE_DEFAULT_TRANSFER_FEE (1*GRAPHENE_BLOCKCHAIN_PRECISION) -#define GRAPHENE_MAX_INSTANCE_ID (uint64_t(-1)>>16) -/** percentage fields are fixed point with a denominator of 10,000 */ -#define GRAPHENE_100_PERCENT 10000 -#define GRAPHENE_1_PERCENT (GRAPHENE_100_PERCENT/100) -/** NOTE: making this a power of 2 (say 2^15) would greatly accelerate fee calcs */ -#define GRAPHENE_MAX_MARKET_FEE_PERCENT GRAPHENE_100_PERCENT -#define GRAPHENE_DEFAULT_FORCE_SETTLEMENT_DELAY (60*60*24) ///< 1 day -#define GRAPHENE_DEFAULT_FORCE_SETTLEMENT_OFFSET 0 ///< 1% -#define GRAPHENE_DEFAULT_FORCE_SETTLEMENT_MAX_VOLUME (20* GRAPHENE_1_PERCENT) ///< 20% -#define GRAPHENE_DEFAULT_PRICE_FEED_LIFETIME (60*60*24) ///< 1 day -#define GRAPHENE_MAX_FEED_PRODUCERS 200 -#define GRAPHENE_DEFAULT_MAX_AUTHORITY_MEMBERSHIP 10 -#define GRAPHENE_DEFAULT_MAX_ASSET_WHITELIST_AUTHORITIES 10 -#define GRAPHENE_DEFAULT_MAX_ASSET_FEED_PUBLISHERS 10 - -/** - * These ratios are fixed point numbers with a denominator of GRAPHENE_COLLATERAL_RATIO_DENOM, the - * minimum maitenance collateral is therefore 1.001x and the default - * maintenance ratio is 1.75x - */ -///@{ -#define GRAPHENE_COLLATERAL_RATIO_DENOM 1000 -#define GRAPHENE_MIN_COLLATERAL_RATIO 1001 ///< lower than this could result in divide by 0 -#define GRAPHENE_MAX_COLLATERAL_RATIO 32000 ///< higher than this is unnecessary and may exceed int16 storage -#define GRAPHENE_DEFAULT_MAINTENANCE_COLLATERAL_RATIO 1750 ///< Call when collateral only pays off 175% the debt -#define GRAPHENE_DEFAULT_MAX_SHORT_SQUEEZE_RATIO 1500 ///< Stop calling when collateral only pays off 150% of the debt -///@} -#define GRAPHENE_DEFAULT_MARGIN_PERIOD_SEC (30*60*60*24) - -#define GRAPHENE_DEFAULT_MIN_WITNESS_COUNT (11) -#define GRAPHENE_DEFAULT_MIN_COMMITTEE_MEMBER_COUNT (11) -#define GRAPHENE_DEFAULT_MIN_SON_COUNT (5) -#define GRAPHENE_DEFAULT_MAX_WITNESSES (1001) // SHOULD BE ODD -#define GRAPHENE_DEFAULT_MAX_COMMITTEE (1001) // SHOULD BE ODD -#define GRAPHENE_DEFAULT_MAX_SONS (15) -#define GRAPHENE_DEFAULT_MAX_PROPOSAL_LIFETIME_SEC (60*60*24*7*4) // Four weeks -#define GRAPHENE_DEFAULT_COMMITTEE_PROPOSAL_REVIEW_PERIOD_SEC (60*60*24*7*2) // Two weeks -#define GRAPHENE_DEFAULT_NETWORK_PERCENT_OF_FEE (20*GRAPHENE_1_PERCENT) -#define GRAPHENE_DEFAULT_LIFETIME_REFERRER_PERCENT_OF_FEE (30*GRAPHENE_1_PERCENT) -#define GRAPHENE_DEFAULT_MAX_BULK_DISCOUNT_PERCENT (50*GRAPHENE_1_PERCENT) -#define GRAPHENE_DEFAULT_BULK_DISCOUNT_THRESHOLD_MIN ( GRAPHENE_BLOCKCHAIN_PRECISION*int64_t(1000) ) -#define GRAPHENE_DEFAULT_BULK_DISCOUNT_THRESHOLD_MAX ( GRAPHENE_DEFAULT_BULK_DISCOUNT_THRESHOLD_MIN*int64_t(100) ) -#define GRAPHENE_DEFAULT_CASHBACK_VESTING_PERIOD_SEC (60*60*24*365) ///< 1 year -#define GRAPHENE_DEFAULT_CASHBACK_VESTING_THRESHOLD (GRAPHENE_BLOCKCHAIN_PRECISION*int64_t(100)) -#define GRAPHENE_DEFAULT_BURN_PERCENT_OF_FEE (20*GRAPHENE_1_PERCENT) -#define GRAPHENE_WITNESS_PAY_PERCENT_PRECISION (1000000000) -#define GRAPHENE_DEFAULT_MAX_ASSERT_OPCODE 1 -#define GRAPHENE_DEFAULT_FEE_LIQUIDATION_THRESHOLD GRAPHENE_BLOCKCHAIN_PRECISION * 100; -#define GRAPHENE_DEFAULT_ACCOUNTS_PER_FEE_SCALE 1000 -#define GRAPHENE_DEFAULT_ACCOUNT_FEE_SCALE_BITSHIFTS 4 -#define GRAPHENE_DEFAULT_MAX_BUYBACK_MARKETS 4 - -#define GRAPHENE_MAX_WORKER_NAME_LENGTH 63 - -#define GRAPHENE_MAX_URL_LENGTH 127 - -#define GRAPHENE_WITNESS_SHUFFLED_ALGORITHM 0 -#define GRAPHENE_WITNESS_SCHEDULED_ALGORITHM 1 - -// counter initialization values used to derive near and far future seeds for shuffling witnesses -// we use the fractional bits of sqrt(2) in hex -#define GRAPHENE_NEAR_SCHEDULE_CTR_IV ( (uint64_t( 0x6a09 ) << 0x30) \ - | (uint64_t( 0xe667 ) << 0x20) \ - | (uint64_t( 0xf3bc ) << 0x10) \ - | (uint64_t( 0xc908 ) ) ) - -// and the fractional bits of sqrt(3) in hex -#define GRAPHENE_FAR_SCHEDULE_CTR_IV ( (uint64_t( 0xbb67 ) << 0x30) \ - | (uint64_t( 0xae85 ) << 0x20) \ - | (uint64_t( 0x84ca ) << 0x10) \ - | (uint64_t( 0xa73b ) ) ) - -// counter used to determine bits of entropy -// must be less than or equal to secret_hash_type::data_length() -#define GRAPHENE_RNG_SEED_LENGTH (160 / 8) +#define GRAPHENE_MAX_NESTED_OBJECTS (200) -/** - * every second, the fraction of burned core asset which cycles is - * GRAPHENE_CORE_ASSET_CYCLE_RATE / (1 << GRAPHENE_CORE_ASSET_CYCLE_RATE_BITS) - */ -#define GRAPHENE_CORE_ASSET_CYCLE_RATE 17 -#define GRAPHENE_CORE_ASSET_CYCLE_RATE_BITS 32 - -#define GRAPHENE_DEFAULT_WITNESS_PAY_PER_BLOCK (GRAPHENE_BLOCKCHAIN_PRECISION * int64_t( 10) ) -#define GRAPHENE_DEFAULT_WITNESS_PAY_VESTING_SECONDS (60*60*24) -#define GRAPHENE_DEFAULT_WORKER_BUDGET_PER_DAY (GRAPHENE_BLOCKCHAIN_PRECISION * int64_t(500) * 1000 ) - -#define GRAPHENE_DEFAULT_MINIMUM_FEEDS 7 - -#define GRAPHENE_MAX_INTEREST_APR uint16_t( 10000 ) +#define GRAPHENE_CURRENT_DB_VERSION "PPY2.5" #define GRAPHENE_RECENTLY_MISSED_COUNT_INCREMENT 4 #define GRAPHENE_RECENTLY_MISSED_COUNT_DECREMENT 3 -#define GRAPHENE_CURRENT_DB_VERSION "PPY2.3" - -#define GRAPHENE_IRREVERSIBLE_THRESHOLD (70 * GRAPHENE_1_PERCENT) - -/** - * Reserved Account IDs with special meaning - */ -///@{ -/// Represents the current committee members, two-week review period -#define GRAPHENE_COMMITTEE_ACCOUNT (graphene::chain::account_id_type(0)) -/// Represents the current witnesses -#define GRAPHENE_WITNESS_ACCOUNT (graphene::chain::account_id_type(1)) -/// Represents the current committee members -#define GRAPHENE_RELAXED_COMMITTEE_ACCOUNT (graphene::chain::account_id_type(2)) -/// Represents the canonical account with NO authority (nobody can access funds in null account) -#define GRAPHENE_NULL_ACCOUNT (graphene::chain::account_id_type(3)) -/// Represents the canonical account with WILDCARD authority (anybody can access funds in temp account) -#define GRAPHENE_TEMP_ACCOUNT (graphene::chain::account_id_type(4)) -/// Represents the canonical account for specifying you will vote directly (as opposed to a proxy) -#define GRAPHENE_PROXY_TO_SELF_ACCOUNT (graphene::chain::account_id_type(5)) -/// -#define GRAPHENE_RAKE_FEE_ACCOUNT_ID (graphene::chain::account_id_type(6)) -/// Sentinel value used in the scheduler. -#define GRAPHENE_NULL_WITNESS (graphene::chain::witness_id_type(0)) -///@} - -#define GRAPHENE_FBA_STEALTH_DESIGNATED_ASSET (asset_id_type(743)) - -#define GRAPHENE_DEFAULT_RAKE_FEE_PERCENTAGE (3*GRAPHENE_1_PERCENT) - -/** - * Betting-related constants. - * - * We store bet multipliers as fixed-precision uint32_t. These values are - * the maximum power-of-ten bet we can have on a "symmetric" market: - * (decimal) 1.0001 - 10001 - * (fractional) 1:10000 - 10000:1 - */ -///@{ -/// betting odds (multipliers) are stored as fixed-precision, divide by this to get the actual multiplier -#define GRAPHENE_BETTING_ODDS_PRECISION 10000 -/// the smallest bet multiplier we will accept -#define GRAPHENE_BETTING_MIN_MULTIPLIER 10001 -/// the largest bet multiplier we will accept -#define GRAPHENE_BETTING_MAX_MULTIPLIER 100010000 -///@} -#define GRAPHENE_DEFAULT_MIN_BET_MULTIPLIER 10100 -#define GRAPHENE_DEFAULT_MAX_BET_MULTIPLIER 10000000 -#define GRAPHENE_DEFAULT_PERMITTED_BETTING_ODDS_INCREMENTS { { 20000, 100}, /* <= 2: 0.01 */ \ - { 30000, 200}, /* <= 3: 0.02 */ \ - { 40000, 500}, /* <= 4: 0.05 */ \ - { 60000, 1000}, /* <= 6: 0.10 */ \ - { 100000, 2000}, /* <= 10: 0.20 */ \ - { 200000, 5000}, /* <= 20: 0.50 */ \ - { 300000, 10000}, /* <= 30: 1.00 */ \ - { 500000, 20000}, /* <= 50: 2.00 */ \ - { 1000000, 50000}, /* <= 100: 5.00 */ \ - { 10000000, 100000} } /* <= 1000: 10.00 */ -#define GRAPHENE_DEFAULT_BETTING_PERCENT_FEE (2 * GRAPHENE_1_PERCENT) -#define GRAPHENE_DEFAULT_LIVE_BETTING_DELAY_TIME 5 // seconds -#define GRAPHENE_MAX_NESTED_OBJECTS (200) -#define TOURNAMENT_MIN_ROUND_DELAY 0 -#define TOURNAMENT_MAX_ROUND_DELAY 600 -#define TOURNAMENT_MIN_TIME_PER_COMMIT_MOVE 0 -#define TOURNAMENT_MAN_TIME_PER_COMMIT_MOVE 600 -#define TOURNAMENT_MIN_TIME_PER_REVEAL_MOVE 0 -#define TOURNAMENT_MAX_TIME_PER_REVEAL_MOVE 600 -#define TOURNAMENT_DEFAULT_RAKE_FEE_PERCENTAGE (3*GRAPHENE_1_PERCENT) -#define TOURNAMENT_MINIMAL_RAKE_FEE_PERCENTAGE (1*GRAPHENE_1_PERCENT) -#define TOURNAMENT_MAXIMAL_RAKE_FEE_PERCENTAGE (20*GRAPHENE_1_PERCENT) -#define TOURNAMENT_MAXIMAL_REGISTRATION_DEADLINE (60*60*24*30) // seconds, 30 days -#define TOURNAMENT_MAX_NUMBER_OF_WINS 100 -#define TOURNAMENT_MAX_PLAYERS_NUMBER 256 -#define TOURNAMENT_MAX_WHITELIST_LENGTH 1000 -#define TOURNAMENT_MAX_START_TIME_IN_FUTURE (60*60*24*7*4) // 1 month -#define TOURNAMENT_MAX_START_DELAY (60*60*24*7) // 1 week -#define SON_VESTING_AMOUNT (50*GRAPHENE_BLOCKCHAIN_PRECISION) // 50 PPY -#define SON_VESTING_PERIOD (60*60*24*2) // 2 days -#define SON_DEREGISTER_TIME (60*60*12) // 12 Hours in seconds -#define SON_HEARTBEAT_FREQUENCY (60*3) // 3 minutes in seconds -#define SON_DOWN_TIME (60*3*2) // 2 Heartbeats in seconds -#define SON_BITCOIN_MIN_TX_CONFIRMATIONS (1) -#define SON_PAY_TIME (60*60*24) // 1 day -#define SON_PAY_MAX (GRAPHENE_BLOCKCHAIN_PRECISION * int64_t(200)) -#define SWEEPS_DEFAULT_DISTRIBUTION_PERCENTAGE (2*GRAPHENE_1_PERCENT) -#define SWEEPS_DEFAULT_DISTRIBUTION_ASSET (graphene::chain::asset_id_type(0)) -#define SWEEPS_VESTING_BALANCE_MULTIPLIER 100000000 -#define SWEEPS_ACCUMULATOR_ACCOUNT (graphene::chain::account_id_type(0)) -#define GPOS_PERIOD (60*60*24*30*6) // 6 months -#define GPOS_SUBPERIOD (60*60*24*30) // 1 month -#define GPOS_VESTING_LOCKIN_PERIOD (60*60*24*30) // 1 month - -#define RBAC_MIN_PERMISSION_NAME_LENGTH 3 -#define RBAC_MAX_PERMISSION_NAME_LENGTH 10 -#define RBAC_MAX_PERMISSIONS_PER_ACCOUNT 5 // 5 per account -#define RBAC_MAX_ACCOUNT_AUTHORITY_LIFETIME 180*24*60*60 // 6 months -#define RBAC_MAX_AUTHS_PER_PERMISSION 15 // 15 ops linked per permission - -#define NFT_TOKEN_MIN_LENGTH 3 -#define NFT_TOKEN_MAX_LENGTH 15 -#define NFT_URI_MAX_LENGTH GRAPHENE_MAX_URL_LENGTH - -#define ACCOUNT_ROLES_MAX_PER_ACCOUNT 20 // Max 20 roles can be created by a resource owner -#define ACCOUNT_ROLES_MAX_LIFETIME 365*24*60*60 // 1 Year diff --git a/libraries/chain/include/graphene/chain/custom_account_authority_evaluator.hpp b/libraries/chain/include/graphene/chain/custom_account_authority_evaluator.hpp index 3fe1f6f99..1ca2f0bb8 100644 --- a/libraries/chain/include/graphene/chain/custom_account_authority_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/custom_account_authority_evaluator.hpp @@ -1,6 +1,7 @@ #pragma once #include -#include + +#include namespace graphene { @@ -35,4 +36,4 @@ class delete_custom_account_authority_evaluator : public evaluator +#include + #include #include @@ -23,7 +24,6 @@ namespace graphene { namespace chain { time_point_sec valid_to; }; - struct by_id; struct by_permission_and_op; struct by_expiration; using custom_account_authority_multi_index_type = multi_index_container< @@ -51,5 +51,7 @@ namespace graphene { namespace chain { } } // graphene::chain +MAP_OBJECT_ID_TO_TYPE(graphene::chain::custom_account_authority_object) + FC_REFLECT_DERIVED( graphene::chain::custom_account_authority_object, (graphene::db::object), - (permission_id)(operation_type)(valid_from)(valid_to) ) \ No newline at end of file + (permission_id)(operation_type)(valid_from)(valid_to) ) diff --git a/libraries/chain/include/graphene/chain/custom_evaluator.hpp b/libraries/chain/include/graphene/chain/custom_evaluator.hpp index 968f6e485..f9efe76ed 100644 --- a/libraries/chain/include/graphene/chain/custom_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/custom_evaluator.hpp @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #pragma once -#include +#include #include #include diff --git a/libraries/chain/include/graphene/chain/custom_permission_evaluator.hpp b/libraries/chain/include/graphene/chain/custom_permission_evaluator.hpp index c9bc2801a..9c1043ff9 100644 --- a/libraries/chain/include/graphene/chain/custom_permission_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/custom_permission_evaluator.hpp @@ -1,6 +1,8 @@ #pragma once + #include -#include + +#include namespace graphene { @@ -35,4 +37,4 @@ class delete_custom_permission_evaluator : public evaluator + +#include + +#include + #include #include @@ -25,7 +29,6 @@ namespace graphene { namespace chain { authority auth; }; - struct by_id; struct by_account_and_permission; using custom_permission_multi_index_type = multi_index_container< custom_permission_object, @@ -45,5 +48,7 @@ namespace graphene { namespace chain { } } // graphene::chain +MAP_OBJECT_ID_TO_TYPE(graphene::chain::custom_permission_object) + FC_REFLECT_DERIVED( graphene::chain::custom_permission_object, (graphene::db::object), - (account)(permission_name)(auth) ) \ No newline at end of file + (account)(permission_name)(auth) ) diff --git a/libraries/chain/include/graphene/chain/database.hpp b/libraries/chain/include/graphene/chain/database.hpp index 05927399b..d55175ec6 100644 --- a/libraries/chain/include/graphene/chain/database.hpp +++ b/libraries/chain/include/graphene/chain/database.hpp @@ -22,6 +22,7 @@ * THE SOFTWARE. */ #pragma once + #include #include #include @@ -30,17 +31,19 @@ #include #include #include +#include #include #include #include -#include -#include +#include +#include +#include -#include +#include -#include +#include #include @@ -51,6 +54,15 @@ namespace graphene { namespace chain { using graphene::db::object; class op_evaluator; class transaction_evaluation_state; + class proposal_object; + class operation_history_object; + class chain_property_object; + class witness_schedule_object; + class witness_object; + class force_settlement_object; + class limit_order_object; + class call_order_object; + class account_role_object; struct budget_record; diff --git a/libraries/chain/include/graphene/chain/evaluator.hpp b/libraries/chain/include/graphene/chain/evaluator.hpp index af90517ec..0a1cc9865 100644 --- a/libraries/chain/include/graphene/chain/evaluator.hpp +++ b/libraries/chain/include/graphene/chain/evaluator.hpp @@ -24,14 +24,17 @@ #pragma once #include #include -#include +#include namespace graphene { namespace chain { class database; - struct signed_transaction; class generic_evaluator; class transaction_evaluation_state; + class account_object; + class account_statistics_object; + class asset_object; + class asset_dynamic_data_object; class generic_evaluator { diff --git a/libraries/chain/include/graphene/chain/event_evaluator.hpp b/libraries/chain/include/graphene/chain/event_evaluator.hpp index 876ee94d2..4dfae857d 100644 --- a/libraries/chain/include/graphene/chain/event_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/event_evaluator.hpp @@ -23,9 +23,11 @@ */ #pragma once -#include #include #include +#include + +#include namespace graphene { namespace chain { diff --git a/libraries/chain/include/graphene/chain/event_group_evaluator.hpp b/libraries/chain/include/graphene/chain/event_group_evaluator.hpp index 65ff528e9..2e529f661 100644 --- a/libraries/chain/include/graphene/chain/event_group_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/event_group_evaluator.hpp @@ -23,7 +23,7 @@ */ #pragma once -#include +#include #include #include diff --git a/libraries/chain/include/graphene/chain/event_group_object.hpp b/libraries/chain/include/graphene/chain/event_group_object.hpp index 5f472e073..257cac216 100644 --- a/libraries/chain/include/graphene/chain/event_group_object.hpp +++ b/libraries/chain/include/graphene/chain/event_group_object.hpp @@ -23,9 +23,11 @@ */ #pragma once -#include +#include + #include #include + #include namespace graphene { namespace chain { @@ -58,4 +60,6 @@ typedef multi_index_container< typedef generic_index event_group_object_index; } } // graphene::chain +MAP_OBJECT_ID_TO_TYPE(graphene::chain::event_group_object) + FC_REFLECT_DERIVED( graphene::chain::event_group_object, (graphene::db::object), (name)(sport_id) ) diff --git a/libraries/chain/include/graphene/chain/event_object.hpp b/libraries/chain/include/graphene/chain/event_object.hpp index 4258cbb1e..6c92ddb60 100644 --- a/libraries/chain/include/graphene/chain/event_object.hpp +++ b/libraries/chain/include/graphene/chain/event_object.hpp @@ -23,14 +23,17 @@ */ #pragma once -#include +#include + +#include + #include #include -#include -#include #include +#include + namespace graphene { namespace chain { class event_object; } } @@ -158,5 +161,8 @@ typedef generic_index event_object_ return s; } } } // graphene::chain -FC_REFLECT(graphene::chain::event_object, (name)) +MAP_OBJECT_ID_TO_TYPE(graphene::chain::event_object) + +FC_REFLECT_DERIVED(graphene::chain::event_object, (graphene::db::object), + (name)(season)(start_time)(event_group_id)(at_least_one_betting_market_group_settled)(scores)) diff --git a/libraries/chain/include/graphene/chain/exceptions.hpp b/libraries/chain/include/graphene/chain/exceptions.hpp index ee2640291..56d964a36 100644 --- a/libraries/chain/include/graphene/chain/exceptions.hpp +++ b/libraries/chain/include/graphene/chain/exceptions.hpp @@ -24,7 +24,10 @@ #pragma once #include -#include +#include +#include +#include +#include #define GRAPHENE_ASSERT( expr, exc_type, FORMAT, ... ) \ FC_MULTILINE_MACRO_BEGIN \ @@ -32,15 +35,26 @@ FC_THROW_EXCEPTION( exc_type, FORMAT, __VA_ARGS__ ); \ FC_MULTILINE_MACRO_END - #define GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( op_name ) \ FC_DECLARE_DERIVED_EXCEPTION( \ + op_name ## _validate_exception, \ + graphene::chain::operation_validate_exception, \ + 3040000 + 100 * operation::tag< op_name ## _operation >::value \ + ) \ + FC_DECLARE_DERIVED_EXCEPTION( \ + op_name ## _evaluate_exception, \ + graphene::chain::operation_evaluate_exception, \ + 3050000 + 100 * operation::tag< op_name ## _operation >::value \ + ) + +#define GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( op_name ) \ + FC_IMPLEMENT_DERIVED_EXCEPTION( \ op_name ## _validate_exception, \ graphene::chain::operation_validate_exception, \ 3040000 + 100 * operation::tag< op_name ## _operation >::value, \ #op_name "_operation validation exception" \ ) \ - FC_DECLARE_DERIVED_EXCEPTION( \ + FC_IMPLEMENT_DERIVED_EXCEPTION( \ op_name ## _evaluate_exception, \ graphene::chain::operation_evaluate_exception, \ 3050000 + 100 * operation::tag< op_name ## _operation >::value, \ @@ -49,6 +63,14 @@ #define GRAPHENE_DECLARE_OP_VALIDATE_EXCEPTION( exc_name, op_name, seqnum, msg ) \ FC_DECLARE_DERIVED_EXCEPTION( \ + op_name ## _ ## exc_name, \ + graphene::chain::op_name ## _validate_exception, \ + 3040000 + 100 * operation::tag< op_name ## _operation >::value \ + + seqnum \ + ) + +#define GRAPHENE_IMPLEMENT_OP_VALIDATE_EXCEPTION( exc_name, op_name, seqnum, msg ) \ + FC_IMPLEMENT_DERIVED_EXCEPTION( \ op_name ## _ ## exc_name, \ graphene::chain::op_name ## _validate_exception, \ 3040000 + 100 * operation::tag< op_name ## _operation >::value \ @@ -58,6 +80,14 @@ #define GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( exc_name, op_name, seqnum, msg ) \ FC_DECLARE_DERIVED_EXCEPTION( \ + op_name ## _ ## exc_name, \ + graphene::chain::op_name ## _evaluate_exception, \ + 3050000 + 100 * operation::tag< op_name ## _operation >::value \ + + seqnum \ + ) + +#define GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( exc_name, op_name, seqnum, msg ) \ + FC_IMPLEMENT_DERIVED_EXCEPTION( \ op_name ## _ ## exc_name, \ graphene::chain::op_name ## _evaluate_exception, \ 3050000 + 100 * operation::tag< op_name ## _operation >::value \ @@ -82,30 +112,21 @@ namespace graphene { namespace chain { - FC_DECLARE_EXCEPTION( chain_exception, 3000000, "blockchain exception" ) - FC_DECLARE_DERIVED_EXCEPTION( database_query_exception, graphene::chain::chain_exception, 3010000, "database query exception" ) - FC_DECLARE_DERIVED_EXCEPTION( block_validate_exception, graphene::chain::chain_exception, 3020000, "block validation exception" ) - FC_DECLARE_DERIVED_EXCEPTION( transaction_exception, graphene::chain::chain_exception, 3030000, "transaction validation exception" ) - FC_DECLARE_DERIVED_EXCEPTION( operation_validate_exception, graphene::chain::chain_exception, 3040000, "operation validation exception" ) - FC_DECLARE_DERIVED_EXCEPTION( operation_evaluate_exception, graphene::chain::chain_exception, 3050000, "operation evaluation exception" ) - FC_DECLARE_DERIVED_EXCEPTION( utility_exception, graphene::chain::chain_exception, 3060000, "utility method exception" ) - FC_DECLARE_DERIVED_EXCEPTION( undo_database_exception, graphene::chain::chain_exception, 3070000, "undo database exception" ) - FC_DECLARE_DERIVED_EXCEPTION( unlinkable_block_exception, graphene::chain::chain_exception, 3080000, "unlinkable block" ) - FC_DECLARE_DERIVED_EXCEPTION( black_swan_exception, graphene::chain::chain_exception, 3090000, "black swan" ) - FC_DECLARE_DERIVED_EXCEPTION( plugin_exception, graphene::chain::chain_exception, 3100000, "plugin exception" ) + FC_DECLARE_EXCEPTION( chain_exception, 3000000 ) - FC_DECLARE_DERIVED_EXCEPTION( tx_missing_active_auth, graphene::chain::transaction_exception, 3030001, "missing required active authority" ) - FC_DECLARE_DERIVED_EXCEPTION( tx_missing_owner_auth, graphene::chain::transaction_exception, 3030002, "missing required owner authority" ) - FC_DECLARE_DERIVED_EXCEPTION( tx_missing_other_auth, graphene::chain::transaction_exception, 3030003, "missing required other authority" ) - FC_DECLARE_DERIVED_EXCEPTION( tx_irrelevant_sig, graphene::chain::transaction_exception, 3030004, "irrelevant signature included" ) - FC_DECLARE_DERIVED_EXCEPTION( tx_duplicate_sig, graphene::chain::transaction_exception, 3030005, "duplicate signature included" ) - FC_DECLARE_DERIVED_EXCEPTION( invalid_committee_approval, graphene::chain::transaction_exception, 3030006, "committee account cannot directly approve transaction" ) - FC_DECLARE_DERIVED_EXCEPTION( insufficient_fee, graphene::chain::transaction_exception, 3030007, "insufficient fee" ) + FC_DECLARE_DERIVED_EXCEPTION( database_query_exception, chain_exception, 3010000 ) + FC_DECLARE_DERIVED_EXCEPTION( block_validate_exception, chain_exception, 3020000 ) + FC_DECLARE_DERIVED_EXCEPTION( operation_validate_exception, chain_exception, 3040000 ) + FC_DECLARE_DERIVED_EXCEPTION( operation_evaluate_exception, chain_exception, 3050000 ) + FC_DECLARE_DERIVED_EXCEPTION( utility_exception, chain_exception, 3060000 ) + FC_DECLARE_DERIVED_EXCEPTION( undo_database_exception, chain_exception, 3070000 ) + FC_DECLARE_DERIVED_EXCEPTION( unlinkable_block_exception, chain_exception, 3080000 ) + FC_DECLARE_DERIVED_EXCEPTION( black_swan_exception, chain_exception, 3090000 ) + FC_DECLARE_DERIVED_EXCEPTION( plugin_exception, chain_exception, 3100000 ) - FC_DECLARE_DERIVED_EXCEPTION( invalid_pts_address, graphene::chain::utility_exception, 3060001, "invalid pts address" ) - FC_DECLARE_DERIVED_EXCEPTION( insufficient_feeds, graphene::chain::chain_exception, 37006, "insufficient feeds" ) + FC_DECLARE_DERIVED_EXCEPTION( insufficient_feeds, chain_exception, 37006 ) - FC_DECLARE_DERIVED_EXCEPTION( pop_empty_chain, graphene::chain::undo_database_exception, 3070001, "there are no blocks to pop" ) + FC_DECLARE_DERIVED_EXCEPTION( pop_empty_chain, undo_database_exception, 3070001 ) GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( transfer ); GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( from_account_not_whitelisted, transfer, 1, "owner mismatch" ) @@ -176,93 +197,11 @@ namespace graphene { namespace chain { GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( blind_transfer ); GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( unknown_commitment, blind_transfer, 1, "Attempting to claim an unknown prior commitment" ); - /* - FC_DECLARE_DERIVED_EXCEPTION( addition_overflow, graphene::chain::chain_exception, 30002, "addition overflow" ) - FC_DECLARE_DERIVED_EXCEPTION( subtraction_overflow, graphene::chain::chain_exception, 30003, "subtraction overflow" ) - FC_DECLARE_DERIVED_EXCEPTION( asset_type_mismatch, graphene::chain::chain_exception, 30004, "asset/price mismatch" ) - FC_DECLARE_DERIVED_EXCEPTION( unsupported_chain_operation, graphene::chain::chain_exception, 30005, "unsupported chain operation" ) - FC_DECLARE_DERIVED_EXCEPTION( unknown_transaction, graphene::chain::chain_exception, 30006, "unknown transaction" ) - FC_DECLARE_DERIVED_EXCEPTION( duplicate_transaction, graphene::chain::chain_exception, 30007, "duplicate transaction" ) - FC_DECLARE_DERIVED_EXCEPTION( zero_amount, graphene::chain::chain_exception, 30008, "zero amount" ) - FC_DECLARE_DERIVED_EXCEPTION( zero_price, graphene::chain::chain_exception, 30009, "zero price" ) - FC_DECLARE_DERIVED_EXCEPTION( asset_divide_by_self, graphene::chain::chain_exception, 30010, "asset divide by self" ) - FC_DECLARE_DERIVED_EXCEPTION( asset_divide_by_zero, graphene::chain::chain_exception, 30011, "asset divide by zero" ) - FC_DECLARE_DERIVED_EXCEPTION( new_database_version, graphene::chain::chain_exception, 30012, "new database version" ) - FC_DECLARE_DERIVED_EXCEPTION( unlinkable_block, graphene::chain::chain_exception, 30013, "unlinkable block" ) - FC_DECLARE_DERIVED_EXCEPTION( price_out_of_range, graphene::chain::chain_exception, 30014, "price out of range" ) - - FC_DECLARE_DERIVED_EXCEPTION( block_numbers_not_sequential, graphene::chain::chain_exception, 30015, "block numbers not sequential" ) - FC_DECLARE_DERIVED_EXCEPTION( invalid_previous_block_id, graphene::chain::chain_exception, 30016, "invalid previous block" ) - FC_DECLARE_DERIVED_EXCEPTION( invalid_block_time, graphene::chain::chain_exception, 30017, "invalid block time" ) - FC_DECLARE_DERIVED_EXCEPTION( time_in_past, graphene::chain::chain_exception, 30018, "time is in the past" ) - FC_DECLARE_DERIVED_EXCEPTION( time_in_future, graphene::chain::chain_exception, 30019, "time is in the future" ) - FC_DECLARE_DERIVED_EXCEPTION( invalid_block_digest, graphene::chain::chain_exception, 30020, "invalid block digest" ) - FC_DECLARE_DERIVED_EXCEPTION( invalid_committee_member_signee, graphene::chain::chain_exception, 30021, "invalid committee_member signee" ) - FC_DECLARE_DERIVED_EXCEPTION( failed_checkpoint_verification, graphene::chain::chain_exception, 30022, "failed checkpoint verification" ) - FC_DECLARE_DERIVED_EXCEPTION( wrong_chain_id, graphene::chain::chain_exception, 30023, "wrong chain id" ) - FC_DECLARE_DERIVED_EXCEPTION( unknown_block, graphene::chain::chain_exception, 30024, "unknown block" ) - FC_DECLARE_DERIVED_EXCEPTION( block_older_than_undo_history, graphene::chain::chain_exception, 30025, "block is older than our undo history allows us to process" ) - - FC_DECLARE_EXCEPTION( evaluation_error, 31000, "Evaluation Error" ) - FC_DECLARE_DERIVED_EXCEPTION( negative_deposit, graphene::chain::evaluation_error, 31001, "negative deposit" ) - FC_DECLARE_DERIVED_EXCEPTION( not_a_committee_member, graphene::chain::evaluation_error, 31002, "not a committee_member" ) - FC_DECLARE_DERIVED_EXCEPTION( unknown_balance_record, graphene::chain::evaluation_error, 31003, "unknown balance record" ) - FC_DECLARE_DERIVED_EXCEPTION( insufficient_funds, graphene::chain::evaluation_error, 31004, "insufficient funds" ) - FC_DECLARE_DERIVED_EXCEPTION( missing_signature, graphene::chain::evaluation_error, 31005, "missing signature" ) - FC_DECLARE_DERIVED_EXCEPTION( invalid_claim_password, graphene::chain::evaluation_error, 31006, "invalid claim password" ) - FC_DECLARE_DERIVED_EXCEPTION( invalid_withdraw_condition, graphene::chain::evaluation_error, 31007, "invalid withdraw condition" ) - FC_DECLARE_DERIVED_EXCEPTION( negative_withdraw, graphene::chain::evaluation_error, 31008, "negative withdraw" ) - FC_DECLARE_DERIVED_EXCEPTION( not_an_active_committee_member, graphene::chain::evaluation_error, 31009, "not an active committee_member" ) - FC_DECLARE_DERIVED_EXCEPTION( expired_transaction, graphene::chain::evaluation_error, 31010, "expired transaction" ) - FC_DECLARE_DERIVED_EXCEPTION( invalid_transaction_expiration, graphene::chain::evaluation_error, 31011, "invalid transaction expiration" ) - FC_DECLARE_DERIVED_EXCEPTION( oversized_transaction, graphene::chain::evaluation_error, 31012, "transaction exceeded the maximum transaction size" ) - - FC_DECLARE_DERIVED_EXCEPTION( invalid_account_name, graphene::chain::evaluation_error, 32001, "invalid account name" ) - FC_DECLARE_DERIVED_EXCEPTION( unknown_account_id, graphene::chain::evaluation_error, 32002, "unknown account id" ) - FC_DECLARE_DERIVED_EXCEPTION( unknown_account_name, graphene::chain::evaluation_error, 32003, "unknown account name" ) - FC_DECLARE_DERIVED_EXCEPTION( missing_parent_account_signature, graphene::chain::evaluation_error, 32004, "missing parent account signature" ) - FC_DECLARE_DERIVED_EXCEPTION( parent_account_retracted, graphene::chain::evaluation_error, 32005, "parent account retracted" ) - FC_DECLARE_DERIVED_EXCEPTION( account_expired, graphene::chain::evaluation_error, 32006, "account expired" ) - FC_DECLARE_DERIVED_EXCEPTION( account_already_registered, graphene::chain::evaluation_error, 32007, "account already registered" ) - FC_DECLARE_DERIVED_EXCEPTION( account_key_in_use, graphene::chain::evaluation_error, 32008, "account key already in use" ) - FC_DECLARE_DERIVED_EXCEPTION( account_retracted, graphene::chain::evaluation_error, 32009, "account retracted" ) - FC_DECLARE_DERIVED_EXCEPTION( unknown_parent_account_name, graphene::chain::evaluation_error, 32010, "unknown parent account name" ) - FC_DECLARE_DERIVED_EXCEPTION( unknown_committee_member_slate, graphene::chain::evaluation_error, 32011, "unknown committee_member slate" ) - FC_DECLARE_DERIVED_EXCEPTION( too_may_committee_members_in_slate, graphene::chain::evaluation_error, 32012, "too many committee_members in slate" ) - FC_DECLARE_DERIVED_EXCEPTION( pay_balance_remaining, graphene::chain::evaluation_error, 32013, "pay balance remaining" ) - - FC_DECLARE_DERIVED_EXCEPTION( not_a_committee_member_signature, graphene::chain::evaluation_error, 33002, "not committee_members signature" ) - - FC_DECLARE_DERIVED_EXCEPTION( invalid_precision, graphene::chain::evaluation_error, 35001, "invalid precision" ) - FC_DECLARE_DERIVED_EXCEPTION( invalid_asset_symbol, graphene::chain::evaluation_error, 35002, "invalid asset symbol" ) - FC_DECLARE_DERIVED_EXCEPTION( unknown_asset_id, graphene::chain::evaluation_error, 35003, "unknown asset id" ) - FC_DECLARE_DERIVED_EXCEPTION( asset_symbol_in_use, graphene::chain::evaluation_error, 35004, "asset symbol in use" ) - FC_DECLARE_DERIVED_EXCEPTION( invalid_asset_amount, graphene::chain::evaluation_error, 35005, "invalid asset amount" ) - FC_DECLARE_DERIVED_EXCEPTION( negative_issue, graphene::chain::evaluation_error, 35006, "negative issue" ) - FC_DECLARE_DERIVED_EXCEPTION( over_issue, graphene::chain::evaluation_error, 35007, "over issue" ) - FC_DECLARE_DERIVED_EXCEPTION( unknown_asset_symbol, graphene::chain::evaluation_error, 35008, "unknown asset symbol" ) - FC_DECLARE_DERIVED_EXCEPTION( asset_id_in_use, graphene::chain::evaluation_error, 35009, "asset id in use" ) - FC_DECLARE_DERIVED_EXCEPTION( not_user_issued, graphene::chain::evaluation_error, 35010, "not user issued" ) - FC_DECLARE_DERIVED_EXCEPTION( invalid_asset_name, graphene::chain::evaluation_error, 35011, "invalid asset name" ) - - FC_DECLARE_DERIVED_EXCEPTION( committee_member_vote_limit, graphene::chain::evaluation_error, 36001, "committee_member_vote_limit" ) - FC_DECLARE_DERIVED_EXCEPTION( insufficient_fee, graphene::chain::evaluation_error, 36002, "insufficient fee" ) - FC_DECLARE_DERIVED_EXCEPTION( negative_fee, graphene::chain::evaluation_error, 36003, "negative fee" ) - FC_DECLARE_DERIVED_EXCEPTION( missing_deposit, graphene::chain::evaluation_error, 36004, "missing deposit" ) - FC_DECLARE_DERIVED_EXCEPTION( insufficient_relay_fee, graphene::chain::evaluation_error, 36005, "insufficient relay fee" ) - - FC_DECLARE_DERIVED_EXCEPTION( invalid_market, graphene::chain::evaluation_error, 37001, "invalid market" ) - FC_DECLARE_DERIVED_EXCEPTION( unknown_market_order, graphene::chain::evaluation_error, 37002, "unknown market order" ) - FC_DECLARE_DERIVED_EXCEPTION( shorting_base_shares, graphene::chain::evaluation_error, 37003, "shorting base shares" ) - FC_DECLARE_DERIVED_EXCEPTION( insufficient_collateral, graphene::chain::evaluation_error, 37004, "insufficient collateral" ) - FC_DECLARE_DERIVED_EXCEPTION( insufficient_depth, graphene::chain::evaluation_error, 37005, "insufficient depth" ) - FC_DECLARE_DERIVED_EXCEPTION( insufficient_feeds, graphene::chain::evaluation_error, 37006, "insufficient feeds" ) - FC_DECLARE_DERIVED_EXCEPTION( invalid_feed_price, graphene::chain::evaluation_error, 37007, "invalid feed price" ) - - FC_DECLARE_DERIVED_EXCEPTION( price_multiplication_overflow, graphene::chain::evaluation_error, 38001, "price multiplication overflow" ) - FC_DECLARE_DERIVED_EXCEPTION( price_multiplication_underflow, graphene::chain::evaluation_error, 38002, "price multiplication underflow" ) - FC_DECLARE_DERIVED_EXCEPTION( price_multiplication_undefined, graphene::chain::evaluation_error, 38003, "price multiplication undefined product 0*inf" ) - */ + //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( transfer_from_blind_operation ) + //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( asset_claim_fees_operation ) + //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( bid_collateral_operation ) + //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( asset_claim_pool_operation ) + //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( asset_update_issuer_operation ) #define GRAPHENE_RECODE_EXC( cause_type, effect_type ) \ catch( const cause_type& e ) \ diff --git a/libraries/chain/include/graphene/chain/fba_accumulator_id.hpp b/libraries/chain/include/graphene/chain/fba_accumulator_id.hpp index 9bc0cf230..f0eefdbe6 100644 --- a/libraries/chain/include/graphene/chain/fba_accumulator_id.hpp +++ b/libraries/chain/include/graphene/chain/fba_accumulator_id.hpp @@ -23,7 +23,7 @@ */ #pragma once -#include +#include namespace graphene { namespace chain { diff --git a/libraries/chain/include/graphene/chain/fba_object.hpp b/libraries/chain/include/graphene/chain/fba_object.hpp index 3d1e1be0f..0927b2356 100644 --- a/libraries/chain/include/graphene/chain/fba_object.hpp +++ b/libraries/chain/include/graphene/chain/fba_object.hpp @@ -23,7 +23,7 @@ */ #pragma once -#include +#include #include #include @@ -49,6 +49,8 @@ class fba_accumulator_object : public graphene::db::abstract_object< fba_accumul } } // graphene::chain +MAP_OBJECT_ID_TO_TYPE(graphene::chain::fba_accumulator_object) + FC_REFLECT_DERIVED( graphene::chain::fba_accumulator_object, (graphene::db::object), (accumulated_fba_fees)(designated_asset) ) diff --git a/libraries/chain/include/graphene/chain/fork_database.hpp b/libraries/chain/include/graphene/chain/fork_database.hpp index 4007ca09f..5e811e3da 100644 --- a/libraries/chain/include/graphene/chain/fork_database.hpp +++ b/libraries/chain/include/graphene/chain/fork_database.hpp @@ -22,7 +22,9 @@ * THE SOFTWARE. */ #pragma once -#include +#include + +#include #include #include diff --git a/libraries/chain/include/graphene/chain/game_object.hpp b/libraries/chain/include/graphene/chain/game_object.hpp index abef14444..67a843bcb 100644 --- a/libraries/chain/include/graphene/chain/game_object.hpp +++ b/libraries/chain/include/graphene/chain/game_object.hpp @@ -23,12 +23,17 @@ */ #pragma once -#include #include -#include + +#include + #include #include + #include + +#include + #include namespace graphene { namespace chain { @@ -159,6 +164,8 @@ namespace graphene { namespace chain { } } +MAP_OBJECT_ID_TO_TYPE(graphene::chain::game_object) + FC_REFLECT_ENUM(graphene::chain::game_state, (game_in_progress) (expecting_commit_moves) @@ -166,6 +173,6 @@ FC_REFLECT_ENUM(graphene::chain::game_state, (game_complete)) //FC_REFLECT_TYPENAME(graphene::chain::game_object) // manually serialized -FC_REFLECT(graphene::chain::game_object, (players)) +FC_REFLECT_DERIVED(graphene::chain::game_object, (graphene::db::object), (players)) diff --git a/libraries/chain/include/graphene/chain/genesis_state.hpp b/libraries/chain/include/graphene/chain/genesis_state.hpp index b2f761183..046f5e061 100644 --- a/libraries/chain/include/graphene/chain/genesis_state.hpp +++ b/libraries/chain/include/graphene/chain/genesis_state.hpp @@ -23,9 +23,9 @@ */ #pragma once -#include -#include -#include +#include +#include +#include #include #include diff --git a/libraries/chain/include/graphene/chain/global_betting_statistics_object.hpp b/libraries/chain/include/graphene/chain/global_betting_statistics_object.hpp index 7c557be50..5bc957280 100644 --- a/libraries/chain/include/graphene/chain/global_betting_statistics_object.hpp +++ b/libraries/chain/include/graphene/chain/global_betting_statistics_object.hpp @@ -23,7 +23,8 @@ */ #pragma once -#include +#include + #include #include @@ -49,4 +50,6 @@ typedef generic_index -#include -#include -#include -#include +#include +#include + #include +#include +#include + namespace graphene { namespace chain { /** @@ -89,8 +91,6 @@ namespace graphene { namespace chain { * every time a block is found it decreases by * RECENTLY_MISSED_COUNT_DECREMENT. It is * never less than 0. - * - * If the recently_missed_count hits 2*UNDO_HISTORY then no new blocks may be pushed. */ uint32_t recently_missed_count = 0; @@ -130,6 +130,9 @@ namespace graphene { namespace chain { }; }} +MAP_OBJECT_ID_TO_TYPE(graphene::chain::dynamic_global_property_object) +MAP_OBJECT_ID_TO_TYPE(graphene::chain::global_property_object) + FC_REFLECT_DERIVED( graphene::chain::dynamic_global_property_object, (graphene::db::object), (head_block_number) (head_block_id) diff --git a/libraries/chain/include/graphene/chain/immutable_chain_parameters.hpp b/libraries/chain/include/graphene/chain/immutable_chain_parameters.hpp index f71288895..b0b62b481 100644 --- a/libraries/chain/include/graphene/chain/immutable_chain_parameters.hpp +++ b/libraries/chain/include/graphene/chain/immutable_chain_parameters.hpp @@ -24,7 +24,7 @@ #pragma once #include -#include +#include namespace graphene { namespace chain { diff --git a/libraries/chain/include/graphene/chain/impacted.hpp b/libraries/chain/include/graphene/chain/impacted.hpp index 3e070ce6c..6bb43048a 100644 --- a/libraries/chain/include/graphene/chain/impacted.hpp +++ b/libraries/chain/include/graphene/chain/impacted.hpp @@ -24,9 +24,9 @@ #pragma once #include -#include -#include -#include +#include +#include +#include namespace graphene { namespace chain { diff --git a/libraries/chain/include/graphene/chain/internal_exceptions.hpp b/libraries/chain/include/graphene/chain/internal_exceptions.hpp index 8a57ae23c..4381c6de6 100644 --- a/libraries/chain/include/graphene/chain/internal_exceptions.hpp +++ b/libraries/chain/include/graphene/chain/internal_exceptions.hpp @@ -23,11 +23,17 @@ */ #pragma once -#include #include #define GRAPHENE_DECLARE_INTERNAL_EXCEPTION( exc_name, seqnum, msg ) \ FC_DECLARE_DERIVED_EXCEPTION( \ + internal_ ## exc_name, \ + graphene::chain::internal_exception, \ + 3990000 + seqnum \ + ) + +#define GRAPHENE_IMPLEMENT_INTERNAL_EXCEPTION( exc_name, seqnum, msg ) \ + FC_IMPLEMENT_DERIVED_EXCEPTION( \ internal_ ## exc_name, \ graphene::chain::internal_exception, \ 3990000 + seqnum, \ @@ -36,7 +42,7 @@ namespace graphene { namespace chain { -FC_DECLARE_DERIVED_EXCEPTION( internal_exception, graphene::chain::chain_exception, 3990000, "internal exception" ) +FC_DECLARE_DERIVED_EXCEPTION( internal_exception, graphene::chain::chain_exception, 3990000 ) GRAPHENE_DECLARE_INTERNAL_EXCEPTION( verify_auth_max_auth_exceeded, 1, "Exceeds max authority fan-out" ) GRAPHENE_DECLARE_INTERNAL_EXCEPTION( verify_auth_account_not_found, 2, "Auth account not found" ) diff --git a/libraries/chain/include/graphene/chain/lottery_evaluator.hpp b/libraries/chain/include/graphene/chain/lottery_evaluator.hpp index 65c97d85b..663d13219 100644 --- a/libraries/chain/include/graphene/chain/lottery_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/lottery_evaluator.hpp @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #pragma once -#include +#include #include #include diff --git a/libraries/chain/include/graphene/chain/market_evaluator.hpp b/libraries/chain/include/graphene/chain/market_evaluator.hpp index 9d653c073..778f012c9 100644 --- a/libraries/chain/include/graphene/chain/market_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/market_evaluator.hpp @@ -23,7 +23,7 @@ */ #pragma once #include -#include +#include namespace graphene { namespace chain { @@ -31,9 +31,7 @@ namespace graphene { namespace chain { class asset_object; class asset_bitasset_data_object; class call_order_object; - struct call_order_update_operation; - struct limit_order_cancel_operation; - struct limit_order_create_operation; + class limit_order_object; class limit_order_create_evaluator : public evaluator { diff --git a/libraries/chain/include/graphene/chain/market_object.hpp b/libraries/chain/include/graphene/chain/market_object.hpp index 4bd3e0487..3da60243a 100644 --- a/libraries/chain/include/graphene/chain/market_object.hpp +++ b/libraries/chain/include/graphene/chain/market_object.hpp @@ -23,10 +23,10 @@ */ #pragma once -#include -#include #include #include +#include +#include #include @@ -65,7 +65,6 @@ class limit_order_object : public abstract_object asset amount_to_receive()const { return amount_for_sale() * sell_price; } }; -struct by_id; struct by_price; struct by_expiration; struct by_account; @@ -205,6 +204,10 @@ typedef generic_index + #include -#include +#include + +#include + #include #include + #include + +#include + #include namespace graphene { namespace chain { @@ -157,11 +164,13 @@ namespace graphene { namespace chain { } } +MAP_OBJECT_ID_TO_TYPE(graphene::chain::match_object) + FC_REFLECT_ENUM(graphene::chain::match_state, (waiting_on_previous_matches) (match_in_progress) (match_complete)) //FC_REFLECT_TYPENAME(graphene::chain::match_object) // manually serialized -FC_REFLECT(graphene::chain::match_object, (players)) +FC_REFLECT_DERIVED(graphene::chain::match_object, (graphene::db::object), (players)) diff --git a/libraries/chain/include/graphene/chain/nft_evaluator.hpp b/libraries/chain/include/graphene/chain/nft_evaluator.hpp index 0d0f5f51e..a75cc44be 100644 --- a/libraries/chain/include/graphene/chain/nft_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/nft_evaluator.hpp @@ -2,8 +2,9 @@ #include #include -#include -#include + +#include +#include namespace graphene { namespace chain { diff --git a/libraries/chain/include/graphene/chain/nft_object.hpp b/libraries/chain/include/graphene/chain/nft_object.hpp index 6a1508527..2f6be6175 100644 --- a/libraries/chain/include/graphene/chain/nft_object.hpp +++ b/libraries/chain/include/graphene/chain/nft_object.hpp @@ -1,5 +1,7 @@ #pragma once -#include + +#include + #include #include @@ -10,7 +12,7 @@ namespace graphene { namespace chain { { public: static const uint8_t space_id = protocol_ids; - static const uint8_t type_id = nft_metadata_type; + static const uint8_t type_id = nft_metadata_object_type; account_id_type owner; std::string name; @@ -88,6 +90,9 @@ namespace graphene { namespace chain { } } // graphene::chain +MAP_OBJECT_ID_TO_TYPE(graphene::chain::nft_metadata_object) +MAP_OBJECT_ID_TO_TYPE(graphene::chain::nft_object) + FC_REFLECT_DERIVED( graphene::chain::nft_metadata_object, (graphene::db::object), (owner) (name) diff --git a/libraries/chain/include/graphene/chain/offer_evaluator.hpp b/libraries/chain/include/graphene/chain/offer_evaluator.hpp index 46f7045b4..5d779cd6a 100644 --- a/libraries/chain/include/graphene/chain/offer_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/offer_evaluator.hpp @@ -1,7 +1,8 @@ -#include #include #include +#include + namespace graphene { namespace chain diff --git a/libraries/chain/include/graphene/chain/offer_object.hpp b/libraries/chain/include/graphene/chain/offer_object.hpp index fe176332f..cb6440c8d 100644 --- a/libraries/chain/include/graphene/chain/offer_object.hpp +++ b/libraries/chain/include/graphene/chain/offer_object.hpp @@ -1,5 +1,9 @@ #pragma once -#include + +#include + +#include + #include namespace graphene @@ -99,6 +103,9 @@ namespace graphene } // namespace chain } // namespace graphene +MAP_OBJECT_ID_TO_TYPE(graphene::chain::offer_object) +MAP_OBJECT_ID_TO_TYPE(graphene::chain::offer_history_object) + FC_REFLECT_DERIVED(graphene::chain::offer_object, (graphene::db::object), (issuer)(item_ids)(bidder)(bid_price)(minimum_price)( maximum_price)(buying_item)(offer_expiration_date)) diff --git a/libraries/chain/include/graphene/chain/operation_history_object.hpp b/libraries/chain/include/graphene/chain/operation_history_object.hpp index 891994727..b4538c601 100644 --- a/libraries/chain/include/graphene/chain/operation_history_object.hpp +++ b/libraries/chain/include/graphene/chain/operation_history_object.hpp @@ -23,82 +23,84 @@ */ #pragma once -#include +#include + +#include + #include #include namespace graphene { namespace chain { - /** - * @brief tracks the history of all logical operations on blockchain state - * @ingroup object - * @ingroup implementation - * - * All operations and virtual operations result in the creation of an - * operation_history_object that is maintained on disk as a stack. Each - * real or virtual operation is assigned a unique ID / sequence number that - * it can be referenced by. - * - * @note by default these objects are not tracked, the account_history_plugin must - * be loaded fore these objects to be maintained. - * - * @note this object is READ ONLY it can never be modified - */ - class operation_history_object : public abstract_object - { - public: - static const uint8_t space_id = protocol_ids; - static const uint8_t type_id = operation_history_object_type; - - operation_history_object( const operation& o ):op(o){} - operation_history_object(){} - - operation op; - operation_result result; - /** the block that caused this operation */ - uint32_t block_num = 0; - /** the transaction in the block */ - uint16_t trx_in_block = 0; - /** the operation within the transaction */ - uint16_t op_in_trx = 0; - /** any virtual operations implied by operation in block */ - uint32_t virtual_op = 0; - }; - - /** - * @brief a node in a linked list of operation_history_objects - * @ingroup implementation - * @ingroup object - * - * Account history is important for users and wallets even though it is - * not part of "core validation". Account history is maintained as - * a linked list stored on disk in a stack. Each account will point to the - * most recent account history object by ID. When a new operation relativent - * to that account is processed a new account history object is allcoated at - * the end of the stack and intialized to point to the prior object. - * - * This data is never accessed as part of chain validation and therefore - * can be kept on disk as a memory mapped file. Using a memory mapped file - * will help the operating system better manage / cache / page files and - * also accelerates load time. - * - * When the transaction history for a particular account is requested the - * linked list can be traversed with relatively effecient disk access because - * of the use of a memory mapped stack. - */ - class account_transaction_history_object : public abstract_object - { - public: - static const uint8_t space_id = implementation_ids; - static const uint8_t type_id = impl_account_transaction_history_object_type; - account_id_type account; /// the account this operation applies to - operation_history_id_type operation_id; - uint32_t sequence = 0; /// the operation position within the given account - account_transaction_history_id_type next; - }; - - struct by_id; +/** + * @brief tracks the history of all logical operations on blockchain state + * @ingroup object + * @ingroup implementation + * + * All operations and virtual operations result in the creation of an + * operation_history_object that is maintained on disk as a stack. Each + * real or virtual operation is assigned a unique ID / sequence number that + * it can be referenced by. + * + * @note by default these objects are not tracked, the account_history_plugin must + * be loaded fore these objects to be maintained. + * + * @note this object is READ ONLY it can never be modified + */ +class operation_history_object : public abstract_object +{ + public: + static const uint8_t space_id = protocol_ids; + static const uint8_t type_id = operation_history_object_type; + + operation_history_object( const operation& o ):op(o){} + operation_history_object(){} + + operation op; + operation_result result; + /** the block that caused this operation */ + uint32_t block_num = 0; + /** the transaction in the block */ + uint16_t trx_in_block = 0; + /** the operation within the transaction */ + uint16_t op_in_trx = 0; + /** any virtual operations implied by operation in block */ + uint32_t virtual_op = 0; +}; + +/** + * @brief a node in a linked list of operation_history_objects + * @ingroup implementation + * @ingroup object + * + * Account history is important for users and wallets even though it is + * not part of "core validation". Account history is maintained as + * a linked list stored on disk in a stack. Each account will point to the + * most recent account history object by ID. When a new operation relativent + * to that account is processed a new account history object is allcoated at + * the end of the stack and intialized to point to the prior object. + * + * This data is never accessed as part of chain validation and therefore + * can be kept on disk as a memory mapped file. Using a memory mapped file + * will help the operating system better manage / cache / page files and + * also accelerates load time. + * + * When the transaction history for a particular account is requested the + * linked list can be traversed with relatively effecient disk access because + * of the use of a memory mapped stack. + */ +class account_transaction_history_object : public abstract_object +{ + public: + static const uint8_t space_id = implementation_ids; + static const uint8_t type_id = impl_account_transaction_history_object_type; + account_id_type account; /// the account this operation applies to + operation_history_id_type operation_id; + uint32_t sequence = 0; /// the operation position within the given account + account_transaction_history_id_type next; +}; + struct by_seq; struct by_op; struct by_opid; @@ -136,9 +138,11 @@ typedef multi_index_container< typedef generic_index account_transaction_history_index; - } } // graphene::chain +MAP_OBJECT_ID_TO_TYPE(graphene::chain::operation_history_object) +MAP_OBJECT_ID_TO_TYPE(graphene::chain::account_transaction_history_object) + FC_REFLECT_DERIVED( graphene::chain::operation_history_object, (graphene::chain::object), (op)(result)(block_num)(trx_in_block)(op_in_trx)(virtual_op) ) FC_REFLECT_DERIVED( graphene::chain::account_transaction_history_object, (graphene::chain::object), diff --git a/libraries/chain/include/graphene/chain/proposal_evaluator.hpp b/libraries/chain/include/graphene/chain/proposal_evaluator.hpp index 3e8ee15e0..e4347df68 100644 --- a/libraries/chain/include/graphene/chain/proposal_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/proposal_evaluator.hpp @@ -23,7 +23,7 @@ */ #pragma once -#include +#include #include #include #include diff --git a/libraries/chain/include/graphene/chain/proposal_object.hpp b/libraries/chain/include/graphene/chain/proposal_object.hpp index d17d2c40f..b05e9e446 100644 --- a/libraries/chain/include/graphene/chain/proposal_object.hpp +++ b/libraries/chain/include/graphene/chain/proposal_object.hpp @@ -23,7 +23,7 @@ */ #pragma once -#include +#include #include #include @@ -94,6 +94,8 @@ typedef generic_index proposal_ } } // graphene::chain +MAP_OBJECT_ID_TO_TYPE(graphene::chain::proposal_object) + FC_REFLECT_DERIVED( graphene::chain::proposal_object, (graphene::chain::object), (expiration_time)(review_period_time)(proposed_transaction)(required_active_approvals) (available_active_approvals)(required_owner_approvals)(available_owner_approvals) diff --git a/libraries/chain/include/graphene/chain/protocol/types.hpp b/libraries/chain/include/graphene/chain/protocol/types.hpp deleted file mode 100644 index 56a4bb1cd..000000000 --- a/libraries/chain/include/graphene/chain/protocol/types.hpp +++ /dev/null @@ -1,599 +0,0 @@ -/* - * Copyright (c) 2015 Cryptonomex, Inc., and contributors. - * - * The MIT License - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#pragma once -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#define GRAPHENE_EXTERNAL_SERIALIZATION(ext, type) \ -namespace fc { \ - ext template void from_variant( const variant& v, type& vo, uint32_t max_depth ); \ - ext template void to_variant( const type& v, variant& vo, uint32_t max_depth ); \ -namespace raw { \ - ext template void pack< datastream, type >( datastream& s, const type& tx, uint32_t _max_depth=FC_PACK_MAX_DEPTH ); \ - ext template void pack< datastream, type >( datastream& s, const type& tx, uint32_t _max_depth=FC_PACK_MAX_DEPTH ); \ - ext template void unpack< datastream, type >( datastream& s, type& tx, uint32_t _max_depth=FC_PACK_MAX_DEPTH ); \ -} } // fc::raw - -#define FC_REFLECT_DERIVED_NO_TYPENAME( TYPE, INHERITS, MEMBERS ) \ -namespace fc { \ -template<> struct reflector {\ - typedef TYPE type; \ - typedef fc::true_type is_defined; \ - typedef fc::false_type is_enum; \ - enum member_count_enum { \ - local_member_count = 0 BOOST_PP_SEQ_FOR_EACH( FC_REFLECT_MEMBER_COUNT, +, MEMBERS ),\ - total_member_count = local_member_count BOOST_PP_SEQ_FOR_EACH( FC_REFLECT_BASE_MEMBER_COUNT, +, INHERITS )\ - }; \ - FC_REFLECT_DERIVED_IMPL_INLINE( TYPE, INHERITS, MEMBERS ) \ -}; \ -} // fc - - -namespace graphene { namespace chain { - using namespace graphene::db; - - using std::map; - using std::vector; - using std::unordered_map; - using std::string; - using std::deque; - using std::shared_ptr; - using std::weak_ptr; - using std::unique_ptr; - using std::set; - using std::pair; - using std::enable_shared_from_this; - using std::tie; - using std::make_pair; - - using fc::smart_ref; - 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; - using fc::time_point; - using fc::safe; - using fc::flat_map; - using fc::flat_set; - using fc::static_variant; - using fc::ecc::range_proof_type; - using fc::ecc::range_proof_info; - using fc::ecc::commitment_type; - struct void_t{}; - - typedef fc::ecc::private_key private_key_type; - typedef fc::sha256 chain_id_type; - - enum asset_issuer_permission_flags - { - charge_market_fee = 0x01, /**< an issuer-specified percentage of all market trades in this asset is paid to the issuer */ - white_list = 0x02, /**< accounts must be whitelisted in order to hold this asset */ - override_authority = 0x04, /**< issuer may transfer asset back to himself */ - transfer_restricted = 0x08, /**< require the issuer to be one party to every transfer */ - disable_force_settle = 0x10, /**< disable force settling */ - global_settle = 0x20, /**< allow the bitasset issuer to force a global settling -- this may be set in permissions, but not flags */ - disable_confidential = 0x40, /**< allow the asset to be used with confidential transactions */ - witness_fed_asset = 0x80, /**< allow the asset to be fed by witnesses */ - committee_fed_asset = 0x100 /**< allow the asset to be fed by the committee */ - }; - const static uint32_t ASSET_ISSUER_PERMISSION_MASK = charge_market_fee|white_list|override_authority|transfer_restricted|disable_force_settle|global_settle|disable_confidential - |witness_fed_asset|committee_fed_asset; - const static uint32_t UIA_ASSET_ISSUER_PERMISSION_MASK = charge_market_fee|white_list|override_authority|transfer_restricted|disable_confidential; - - enum reserved_spaces - { - relative_protocol_ids = 0, - protocol_ids = 1, - implementation_ids = 2 - }; - - inline bool is_relative( object_id_type o ){ return o.space() == 0; } - - /** - * List all object types from all namespaces here so they can - * be easily reflected and displayed in debug output. If a 3rd party - * wants to extend the core code then they will have to change the - * packed_object::type field from enum_type to uint16 to avoid - * warnings when converting packed_objects to/from json. - */ - enum object_type - { - null_object_type, - base_object_type, - account_object_type, - asset_object_type, - force_settlement_object_type, - committee_member_object_type, - witness_object_type, - limit_order_object_type, - call_order_object_type, - custom_object_type, - proposal_object_type, - operation_history_object_type, - withdraw_permission_object_type, - vesting_balance_object_type, - worker_object_type, - balance_object_type, - tournament_object_type, - tournament_details_object_type, - match_object_type, - game_object_type, - sport_object_type, - event_group_object_type, - event_object_type, - betting_market_rules_object_type, - betting_market_group_object_type, - betting_market_object_type, - bet_object_type, - custom_permission_object_type, - custom_account_authority_object_type, - offer_object_type, - nft_metadata_type, - nft_object_type, - account_role_type, - son_object_type, - son_proposal_object_type, - son_wallet_object_type, - son_wallet_deposit_object_type, - son_wallet_withdraw_object_type, - sidechain_address_object_type, - sidechain_transaction_object_type, - OBJECT_TYPE_COUNT ///< Sentry value which contains the number of different object types - }; - - enum impl_object_type - { - impl_global_property_object_type, - impl_dynamic_global_property_object_type, - impl_reserved0_object_type, // formerly index_meta_object_type, TODO: delete me - impl_asset_dynamic_data_type, - impl_asset_bitasset_data_type, - impl_account_balance_object_type, - impl_account_statistics_object_type, - impl_transaction_object_type, - impl_block_summary_object_type, - impl_account_transaction_history_object_type, - impl_blinded_balance_object_type, - impl_chain_property_object_type, - impl_witness_schedule_object_type, - impl_budget_record_object_type, - impl_special_authority_object_type, - impl_buyback_object_type, - impl_fba_accumulator_object_type, - impl_asset_dividend_data_type, - impl_pending_dividend_payout_balance_for_holder_object_type, - impl_distributed_dividend_balance_data_type, - impl_betting_market_position_object_type, - impl_global_betting_statistics_object_type, - impl_lottery_balance_object_type, - impl_sweeps_vesting_balance_object_type, - impl_offer_history_object_type, - impl_son_statistics_object_type, - impl_son_schedule_object_type - }; - - //typedef fc::unsigned_int object_id_type; - //typedef uint64_t object_id_type; - class account_object; - class committee_member_object; - class witness_object; - class asset_object; - class force_settlement_object; - class limit_order_object; - class call_order_object; - class custom_object; - class proposal_object; - class operation_history_object; - class withdraw_permission_object; - class vesting_balance_object; - class worker_object; - class balance_object; - class blinded_balance_object; - class tournament_object; - class tournament_details_object; - class match_object; - class game_object; - class sport_object; - class event_group_object; - class event_object; - class betting_market_rules_object; - class betting_market_group_object; - class betting_market_object; - class bet_object; - class custom_permission_object; - class custom_account_authority_object; - class offer_object; - class nft_metadata_object; - class nft_object; - class account_role_object; - class son_object; - class son_proposal_object; - class son_wallet_object; - class son_wallet_deposit_object; - class son_wallet_withdraw_object; - class sidechain_address_object; - class sidechain_transaction_object; - - typedef object_id< protocol_ids, account_object_type, account_object> account_id_type; - typedef object_id< protocol_ids, asset_object_type, asset_object> asset_id_type; - typedef object_id< protocol_ids, force_settlement_object_type, force_settlement_object> force_settlement_id_type; - typedef object_id< protocol_ids, committee_member_object_type, committee_member_object> committee_member_id_type; - typedef object_id< protocol_ids, witness_object_type, witness_object> witness_id_type; - typedef object_id< protocol_ids, limit_order_object_type, limit_order_object> limit_order_id_type; - typedef object_id< protocol_ids, call_order_object_type, call_order_object> call_order_id_type; - typedef object_id< protocol_ids, custom_object_type, custom_object> custom_id_type; - typedef object_id< protocol_ids, proposal_object_type, proposal_object> proposal_id_type; - typedef object_id< protocol_ids, operation_history_object_type, operation_history_object> operation_history_id_type; - typedef object_id< protocol_ids, withdraw_permission_object_type,withdraw_permission_object> withdraw_permission_id_type; - typedef object_id< protocol_ids, vesting_balance_object_type, vesting_balance_object> vesting_balance_id_type; - typedef object_id< protocol_ids, worker_object_type, worker_object> worker_id_type; - typedef object_id< protocol_ids, balance_object_type, balance_object> balance_id_type; - typedef object_id< protocol_ids, tournament_object_type, tournament_object> tournament_id_type; - typedef object_id< protocol_ids, tournament_details_object_type, tournament_details_object> tournament_details_id_type; - typedef object_id< protocol_ids, match_object_type, match_object> match_id_type; - typedef object_id< protocol_ids, game_object_type, game_object> game_id_type; - typedef object_id< protocol_ids, sport_object_type, sport_object> sport_id_type; - typedef object_id< protocol_ids, event_group_object_type, event_group_object> event_group_id_type; - typedef object_id< protocol_ids, event_object_type, event_object> event_id_type; - typedef object_id< protocol_ids, betting_market_rules_object_type, betting_market_rules_object> betting_market_rules_id_type; - typedef object_id< protocol_ids, betting_market_group_object_type, betting_market_group_object> betting_market_group_id_type; - typedef object_id< protocol_ids, betting_market_object_type, betting_market_object> betting_market_id_type; - typedef object_id< protocol_ids, bet_object_type, bet_object> bet_id_type; - typedef object_id< protocol_ids, custom_permission_object_type, custom_permission_object> custom_permission_id_type; - typedef object_id< protocol_ids, custom_account_authority_object_type, custom_account_authority_object> custom_account_authority_id_type; - typedef object_id< protocol_ids, offer_object_type, offer_object> offer_id_type; - typedef object_id< protocol_ids, nft_metadata_type, nft_metadata_object> nft_metadata_id_type; - typedef object_id< protocol_ids, nft_object_type, nft_object> nft_id_type; - typedef object_id< protocol_ids, account_role_type, account_role_object> account_role_id_type; - typedef object_id< protocol_ids, son_object_type, son_object> son_id_type; - typedef object_id< protocol_ids, son_proposal_object_type, son_proposal_object> son_proposal_id_type; - typedef object_id< protocol_ids, son_wallet_object_type, son_wallet_object> son_wallet_id_type; - typedef object_id< protocol_ids, son_wallet_deposit_object_type, son_wallet_deposit_object> son_wallet_deposit_id_type; - typedef object_id< protocol_ids, son_wallet_withdraw_object_type, son_wallet_withdraw_object> son_wallet_withdraw_id_type; - typedef object_id< protocol_ids, sidechain_address_object_type, sidechain_address_object> sidechain_address_id_type; - typedef object_id< protocol_ids, sidechain_transaction_object_type,sidechain_transaction_object> sidechain_transaction_id_type; - - // implementation types - class global_property_object; - class dynamic_global_property_object; - class asset_dynamic_data_object; - class asset_bitasset_data_object; - class account_balance_object; - class account_statistics_object; - class transaction_object; - class block_summary_object; - class account_transaction_history_object; - class chain_property_object; - class witness_schedule_object; - class budget_record_object; - class special_authority_object; - class buyback_object; - class fba_accumulator_object; - class asset_dividend_data_object; - class pending_dividend_payout_balance_for_holder_object; - class betting_market_position_object; - class global_betting_statistics_object; - class lottery_balance_object; - class sweeps_vesting_balance_object; - class offer_history_object; - class son_statistics_object; - class son_schedule_object; - - typedef object_id< implementation_ids, impl_global_property_object_type, global_property_object> global_property_id_type; - typedef object_id< implementation_ids, impl_dynamic_global_property_object_type, dynamic_global_property_object> dynamic_global_property_id_type; - typedef object_id< implementation_ids, impl_asset_dynamic_data_type, asset_dynamic_data_object> asset_dynamic_data_id_type; - typedef object_id< implementation_ids, impl_asset_bitasset_data_type, asset_bitasset_data_object> asset_bitasset_data_id_type; - typedef object_id< implementation_ids, impl_asset_dividend_data_type, asset_dividend_data_object> asset_dividend_data_id_type; - typedef object_id< implementation_ids, - impl_pending_dividend_payout_balance_for_holder_object_type, - pending_dividend_payout_balance_for_holder_object> pending_dividend_payout_balance_for_holder_object_type; - typedef object_id< implementation_ids, impl_account_balance_object_type, account_balance_object> account_balance_id_type; - typedef object_id< implementation_ids, impl_account_statistics_object_type, account_statistics_object> account_statistics_id_type; - typedef object_id< implementation_ids, impl_transaction_object_type, transaction_object> transaction_obj_id_type; - typedef object_id< implementation_ids, impl_block_summary_object_type, block_summary_object> block_summary_id_type; - - typedef object_id< implementation_ids, - impl_account_transaction_history_object_type, - account_transaction_history_object> account_transaction_history_id_type; - typedef object_id< implementation_ids, impl_chain_property_object_type, chain_property_object> chain_property_id_type; - typedef object_id< implementation_ids, impl_witness_schedule_object_type, witness_schedule_object> witness_schedule_id_type; - typedef object_id< implementation_ids, impl_budget_record_object_type, budget_record_object > budget_record_id_type; - typedef object_id< implementation_ids, impl_blinded_balance_object_type, blinded_balance_object > blinded_balance_id_type; - typedef object_id< implementation_ids, impl_special_authority_object_type, special_authority_object > special_authority_id_type; - typedef object_id< implementation_ids, impl_buyback_object_type, buyback_object > buyback_id_type; - typedef object_id< implementation_ids, impl_fba_accumulator_object_type, fba_accumulator_object > fba_accumulator_id_type; - typedef object_id< implementation_ids, impl_betting_market_position_object_type, betting_market_position_object > betting_market_position_id_type; - typedef object_id< implementation_ids, impl_global_betting_statistics_object_type, global_betting_statistics_object > global_betting_statistics_id_type; - typedef object_id< implementation_ids, impl_lottery_balance_object_type, lottery_balance_object > lottery_balance_id_type; - typedef object_id< implementation_ids, impl_sweeps_vesting_balance_object_type, sweeps_vesting_balance_object> sweeps_vesting_balance_id_type; - typedef object_id< implementation_ids, impl_offer_history_object_type, offer_history_object> offer_history_id_type; - typedef object_id< implementation_ids, impl_son_statistics_object_type, son_statistics_object > son_statistics_id_type; - typedef object_id< implementation_ids, impl_son_schedule_object_type, son_schedule_object> son_schedule_id_type; - - typedef fc::array symbol_type; - typedef fc::ripemd160 block_id_type; - typedef fc::ripemd160 checksum_type; - typedef fc::ripemd160 transaction_id_type; - typedef fc::sha256 digest_type; - typedef fc::ecc::compact_signature signature_type; - typedef safe share_type; - typedef fc::ripemd160 secret_hash_type; - typedef uint16_t weight_type; - - struct public_key_type - { - struct binary_key - { - binary_key() {} - uint32_t check = 0; - fc::ecc::public_key_data data; - }; - fc::ecc::public_key_data key_data; - public_key_type(); - public_key_type( const fc::ecc::public_key_data& data ); - public_key_type( const fc::ecc::public_key& pubkey ); - explicit public_key_type( const std::string& base58str ); - operator fc::ecc::public_key_data() const; - operator fc::ecc::public_key() const; - explicit operator std::string() const; - friend bool operator == ( const public_key_type& p1, const fc::ecc::public_key& p2); - friend bool operator == ( const public_key_type& p1, const public_key_type& p2); - friend bool operator != ( const public_key_type& p1, const public_key_type& p2); - // TODO: This is temporary for testing - bool is_valid_v1( const std::string& base58str ); - bool is_valid_muse( const std::string& base58str ); - }; - - struct extended_public_key_type - { - struct binary_key - { - binary_key() {} - uint32_t check = 0; - fc::ecc::extended_key_data data; - }; - - fc::ecc::extended_key_data key_data; - - extended_public_key_type(); - extended_public_key_type( const fc::ecc::extended_key_data& data ); - extended_public_key_type( const fc::ecc::extended_public_key& extpubkey ); - explicit extended_public_key_type( const std::string& base58str ); - operator fc::ecc::extended_public_key() const; - explicit operator std::string() const; - friend bool operator == ( const extended_public_key_type& p1, const fc::ecc::extended_public_key& p2); - friend bool operator == ( const extended_public_key_type& p1, const extended_public_key_type& p2); - friend bool operator != ( const extended_public_key_type& p1, const extended_public_key_type& p2); - }; - - struct extended_private_key_type - { - struct binary_key - { - binary_key() {} - uint32_t check = 0; - fc::ecc::extended_key_data data; - }; - - fc::ecc::extended_key_data key_data; - - extended_private_key_type(); - extended_private_key_type( const fc::ecc::extended_key_data& data ); - extended_private_key_type( const fc::ecc::extended_private_key& extprivkey ); - explicit extended_private_key_type( const std::string& base58str ); - operator fc::ecc::extended_private_key() const; - explicit operator std::string() const; - friend bool operator == ( const extended_private_key_type& p1, const fc::ecc::extended_private_key& p2); - friend bool operator == ( const extended_private_key_type& p1, const extended_private_key_type& p2); - friend bool operator != ( const extended_private_key_type& p1, const extended_private_key_type& p2); - }; - - typedef flat_map internationalized_string_type; - - typedef uint32_t bet_multiplier_type; -} } // graphene::chain - -namespace fc -{ - void to_variant( const graphene::chain::public_key_type& var, fc::variant& vo, uint32_t max_depth = 2 ); - void from_variant( const fc::variant& var, graphene::chain::public_key_type& vo, uint32_t max_depth = 2 ); - void to_variant( const graphene::chain::extended_public_key_type& var, fc::variant& vo, uint32_t max_depth = 2 ); - void from_variant( const fc::variant& var, graphene::chain::extended_public_key_type& vo, uint32_t max_depth = 2 ); - void to_variant( const graphene::chain::extended_private_key_type& var, fc::variant& vo, uint32_t max_depth = 2 ); - void from_variant( const fc::variant& var, graphene::chain::extended_private_key_type& vo, uint32_t max_depth = 2 ); -} - -FC_REFLECT( graphene::chain::public_key_type, (key_data) ) -FC_REFLECT( graphene::chain::public_key_type::binary_key, (data)(check) ) -FC_REFLECT( graphene::chain::extended_public_key_type, (key_data) ) -FC_REFLECT( graphene::chain::extended_public_key_type::binary_key, (check)(data) ) -FC_REFLECT( graphene::chain::extended_private_key_type, (key_data) ) -FC_REFLECT( graphene::chain::extended_private_key_type::binary_key, (check)(data) ) - -FC_REFLECT_ENUM( graphene::chain::object_type, - (null_object_type) - (base_object_type) - (account_object_type) - (force_settlement_object_type) - (asset_object_type) - (committee_member_object_type) - (witness_object_type) - (limit_order_object_type) - (call_order_object_type) - (custom_object_type) - (proposal_object_type) - (operation_history_object_type) - (withdraw_permission_object_type) - (vesting_balance_object_type) - (worker_object_type) - (balance_object_type) - (tournament_object_type) - (tournament_details_object_type) - (match_object_type) - (game_object_type) - (sport_object_type) - (event_group_object_type) - (event_object_type) - (betting_market_rules_object_type) - (betting_market_group_object_type) - (betting_market_object_type) - (bet_object_type) - (custom_permission_object_type) - (custom_account_authority_object_type) - (offer_object_type) - (nft_metadata_type) - (nft_object_type) - (account_role_type) - (son_object_type) - (son_proposal_object_type) - (son_wallet_object_type) - (son_wallet_deposit_object_type) - (son_wallet_withdraw_object_type) - (sidechain_address_object_type) - (sidechain_transaction_object_type) - (OBJECT_TYPE_COUNT) - ) -FC_REFLECT_ENUM( graphene::chain::impl_object_type, - (impl_global_property_object_type) - (impl_dynamic_global_property_object_type) - (impl_reserved0_object_type) - (impl_asset_dynamic_data_type) - (impl_asset_bitasset_data_type) - (impl_account_balance_object_type) - (impl_account_statistics_object_type) - (impl_transaction_object_type) - (impl_block_summary_object_type) - (impl_account_transaction_history_object_type) - (impl_blinded_balance_object_type) - (impl_chain_property_object_type) - (impl_witness_schedule_object_type) - (impl_budget_record_object_type) - (impl_special_authority_object_type) - (impl_buyback_object_type) - (impl_fba_accumulator_object_type) - (impl_asset_dividend_data_type) - (impl_pending_dividend_payout_balance_for_holder_object_type) - (impl_distributed_dividend_balance_data_type) - (impl_betting_market_position_object_type) - (impl_global_betting_statistics_object_type) - (impl_lottery_balance_object_type) - (impl_sweeps_vesting_balance_object_type) - (impl_offer_history_object_type) - (impl_son_statistics_object_type) - (impl_son_schedule_object_type) - ) - -FC_REFLECT_TYPENAME( graphene::chain::share_type ) - -FC_REFLECT_TYPENAME( graphene::chain::account_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::asset_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::force_settlement_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::committee_member_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::witness_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::limit_order_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::call_order_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::custom_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::proposal_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::operation_history_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::withdraw_permission_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::vesting_balance_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::worker_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::balance_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::sport_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::event_group_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::event_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::betting_market_rules_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::betting_market_group_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::betting_market_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::bet_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::tournament_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::offer_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::global_property_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::dynamic_global_property_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::asset_dynamic_data_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::asset_bitasset_data_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::account_balance_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::account_statistics_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::transaction_obj_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::block_summary_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::account_transaction_history_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::budget_record_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::special_authority_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::buyback_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::fba_accumulator_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::betting_market_position_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::global_betting_statistics_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::tournament_details_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::custom_permission_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::custom_account_authority_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::offer_history_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::nft_metadata_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::nft_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::account_role_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::son_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::son_proposal_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::son_wallet_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::son_wallet_deposit_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::son_wallet_withdraw_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::sidechain_address_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::sidechain_transaction_id_type ) - - -FC_REFLECT( graphene::chain::void_t, ) - -FC_REFLECT_ENUM( graphene::chain::asset_issuer_permission_flags, - (charge_market_fee) - (white_list) - (transfer_restricted) - (override_authority) - (disable_force_settle) - (global_settle) - (disable_confidential) - (witness_fed_asset) - (committee_fed_asset) - ) diff --git a/libraries/chain/include/graphene/chain/rbac_hardfork_visitor.hpp b/libraries/chain/include/graphene/chain/rbac_hardfork_visitor.hpp index 21cf492fe..2358dd0cd 100644 --- a/libraries/chain/include/graphene/chain/rbac_hardfork_visitor.hpp +++ b/libraries/chain/include/graphene/chain/rbac_hardfork_visitor.hpp @@ -1,5 +1,5 @@ #pragma once -#include +#include #include namespace graphene diff --git a/libraries/chain/include/graphene/chain/rock_paper_scissors.hpp b/libraries/chain/include/graphene/chain/rock_paper_scissors.hpp index 23015e3ec..f2b6c3825 100644 --- a/libraries/chain/include/graphene/chain/rock_paper_scissors.hpp +++ b/libraries/chain/include/graphene/chain/rock_paper_scissors.hpp @@ -26,11 +26,14 @@ #include +#include + +#include + #include #include #include #include -#include namespace graphene { namespace chain { struct rock_paper_scissors_game_details diff --git a/libraries/chain/include/graphene/chain/sidechain_address_evaluator.hpp b/libraries/chain/include/graphene/chain/sidechain_address_evaluator.hpp index 82bfcf1aa..1ff564b6b 100644 --- a/libraries/chain/include/graphene/chain/sidechain_address_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/sidechain_address_evaluator.hpp @@ -1,6 +1,7 @@ #pragma once #include -#include + +#include namespace graphene { namespace chain { diff --git a/libraries/chain/include/graphene/chain/sidechain_address_object.hpp b/libraries/chain/include/graphene/chain/sidechain_address_object.hpp index b8aa07c65..978b6166e 100644 --- a/libraries/chain/include/graphene/chain/sidechain_address_object.hpp +++ b/libraries/chain/include/graphene/chain/sidechain_address_object.hpp @@ -1,9 +1,10 @@ #pragma once -#include #include #include -#include +#include +#include + #include namespace graphene { namespace chain { @@ -86,6 +87,8 @@ namespace graphene { namespace chain { } } // graphene::chain +MAP_OBJECT_ID_TO_TYPE(graphene::chain::sidechain_address_object) + FC_REFLECT_DERIVED( graphene::chain::sidechain_address_object, (graphene::db::object), (sidechain_address_account) (sidechain) (deposit_public_key) (deposit_address) (deposit_address_data) diff --git a/libraries/chain/include/graphene/chain/sidechain_transaction_evaluator.hpp b/libraries/chain/include/graphene/chain/sidechain_transaction_evaluator.hpp index 702788ff4..66b817e91 100644 --- a/libraries/chain/include/graphene/chain/sidechain_transaction_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/sidechain_transaction_evaluator.hpp @@ -1,6 +1,7 @@ #pragma once #include -#include + +#include namespace graphene { namespace chain { diff --git a/libraries/chain/include/graphene/chain/sidechain_transaction_object.hpp b/libraries/chain/include/graphene/chain/sidechain_transaction_object.hpp index e9011ffb2..6f6846688 100644 --- a/libraries/chain/include/graphene/chain/sidechain_transaction_object.hpp +++ b/libraries/chain/include/graphene/chain/sidechain_transaction_object.hpp @@ -1,8 +1,9 @@ #pragma once +#include +#include +#include + #include -#include -#include -#include namespace graphene { namespace chain { using namespace graphene::db; @@ -69,6 +70,8 @@ FC_REFLECT_ENUM( graphene::chain::sidechain_transaction_status, (sent) (settled) ) +MAP_OBJECT_ID_TO_TYPE(graphene::chain::sidechain_transaction_object) + FC_REFLECT_DERIVED( graphene::chain::sidechain_transaction_object, (graphene::db::object ), (sidechain) (object_id) diff --git a/libraries/chain/include/graphene/chain/son_evaluator.hpp b/libraries/chain/include/graphene/chain/son_evaluator.hpp index c3f1ac495..9ac66e490 100644 --- a/libraries/chain/include/graphene/chain/son_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/son_evaluator.hpp @@ -1,6 +1,7 @@ #pragma once +#include + #include -#include namespace graphene { namespace chain { diff --git a/libraries/chain/include/graphene/chain/son_object.hpp b/libraries/chain/include/graphene/chain/son_object.hpp index 3335bd8a6..a3bd4e87d 100644 --- a/libraries/chain/include/graphene/chain/son_object.hpp +++ b/libraries/chain/include/graphene/chain/son_object.hpp @@ -1,8 +1,9 @@ #pragma once -#include #include #include -#include + +#include +#include namespace graphene { namespace chain { using namespace graphene::db; @@ -112,6 +113,9 @@ namespace graphene { namespace chain { } } // graphene::chain +MAP_OBJECT_ID_TO_TYPE(graphene::chain::son_object) +MAP_OBJECT_ID_TO_TYPE(graphene::chain::son_statistics_object) + FC_REFLECT_ENUM(graphene::chain::son_status, (inactive)(active)(request_maintenance)(in_maintenance)(deregistered) ) FC_REFLECT_DERIVED( graphene::chain::son_object, (graphene::db::object), diff --git a/libraries/chain/include/graphene/chain/son_proposal_object.hpp b/libraries/chain/include/graphene/chain/son_proposal_object.hpp index 7b1674b81..92ecf4a51 100644 --- a/libraries/chain/include/graphene/chain/son_proposal_object.hpp +++ b/libraries/chain/include/graphene/chain/son_proposal_object.hpp @@ -1,9 +1,10 @@ #pragma once -#include #include #include +#include + namespace graphene { namespace chain { enum class son_proposal_type @@ -37,6 +38,8 @@ using son_proposal_index = generic_index -#include -#include +#include +#include +#include namespace graphene { namespace chain { using namespace graphene::db; @@ -61,6 +61,8 @@ namespace graphene { namespace chain { using son_wallet_deposit_index = generic_index; } } // graphene::chain +MAP_OBJECT_ID_TO_TYPE(graphene::chain::son_wallet_deposit_object) + FC_REFLECT_DERIVED( graphene::chain::son_wallet_deposit_object, (graphene::db::object), (timestamp) (block_num) (sidechain) (sidechain_uid) (sidechain_transaction_id) (sidechain_from) (sidechain_to) (sidechain_currency) (sidechain_amount) diff --git a/libraries/chain/include/graphene/chain/son_wallet_evaluator.hpp b/libraries/chain/include/graphene/chain/son_wallet_evaluator.hpp index 78e8655f6..6856c2b83 100644 --- a/libraries/chain/include/graphene/chain/son_wallet_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/son_wallet_evaluator.hpp @@ -1,6 +1,6 @@ #pragma once #include -#include +#include namespace graphene { namespace chain { diff --git a/libraries/chain/include/graphene/chain/son_wallet_object.hpp b/libraries/chain/include/graphene/chain/son_wallet_object.hpp index 315def339..31765999b 100644 --- a/libraries/chain/include/graphene/chain/son_wallet_object.hpp +++ b/libraries/chain/include/graphene/chain/son_wallet_object.hpp @@ -1,7 +1,10 @@ #pragma once -#include -#include -#include +#include + +#include +#include + +#include namespace graphene { namespace chain { using namespace graphene::db; @@ -43,5 +46,7 @@ namespace graphene { namespace chain { using son_wallet_index = generic_index; } } // graphene::chain +MAP_OBJECT_ID_TO_TYPE(graphene::chain::son_wallet_object) + FC_REFLECT_DERIVED( graphene::chain::son_wallet_object, (graphene::db::object), (valid_from) (expires) (addresses) (sons) ) diff --git a/libraries/chain/include/graphene/chain/son_wallet_withdraw_object.hpp b/libraries/chain/include/graphene/chain/son_wallet_withdraw_object.hpp index d65f5cab7..9c9919730 100644 --- a/libraries/chain/include/graphene/chain/son_wallet_withdraw_object.hpp +++ b/libraries/chain/include/graphene/chain/son_wallet_withdraw_object.hpp @@ -1,7 +1,7 @@ #pragma once -#include -#include -#include +#include +#include +#include namespace graphene { namespace chain { using namespace graphene::db; @@ -60,6 +60,8 @@ namespace graphene { namespace chain { using son_wallet_withdraw_index = generic_index; } } // graphene::chain +MAP_OBJECT_ID_TO_TYPE(graphene::chain::son_wallet_withdraw_object) + FC_REFLECT_DERIVED( graphene::chain::son_wallet_withdraw_object, (graphene::db::object), (timestamp) (block_num) (sidechain) (peerplays_uid) (peerplays_transaction_id) (peerplays_from) (peerplays_asset) diff --git a/libraries/chain/include/graphene/chain/special_authority.hpp b/libraries/chain/include/graphene/chain/special_authority_evaluation.hpp similarity index 94% rename from libraries/chain/include/graphene/chain/special_authority.hpp rename to libraries/chain/include/graphene/chain/special_authority_evaluation.hpp index f091f7361..931b35a70 100644 --- a/libraries/chain/include/graphene/chain/special_authority.hpp +++ b/libraries/chain/include/graphene/chain/special_authority_evaluation.hpp @@ -23,11 +23,12 @@ */ #pragma once -#include +#include namespace graphene { namespace chain { class database; +using namespace protocol; void evaluate_special_authority( const database& db, const special_authority& auth ); diff --git a/libraries/chain/include/graphene/chain/special_authority_object.hpp b/libraries/chain/include/graphene/chain/special_authority_object.hpp index 75093f3a3..d1d999ee6 100644 --- a/libraries/chain/include/graphene/chain/special_authority_object.hpp +++ b/libraries/chain/include/graphene/chain/special_authority_object.hpp @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #pragma once -#include +#include #include #include @@ -63,6 +63,8 @@ typedef generic_index< special_authority_object, special_authority_multi_index_t } } // graphene::chain +MAP_OBJECT_ID_TO_TYPE(graphene::chain::special_authority_object) + FC_REFLECT_DERIVED( graphene::chain::special_authority_object, (graphene::db::object), diff --git a/libraries/chain/include/graphene/chain/sport_evaluator.hpp b/libraries/chain/include/graphene/chain/sport_evaluator.hpp index 4724e7951..0f91305d2 100644 --- a/libraries/chain/include/graphene/chain/sport_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/sport_evaluator.hpp @@ -23,7 +23,7 @@ */ #pragma once -#include +#include #include #include diff --git a/libraries/chain/include/graphene/chain/sport_object.hpp b/libraries/chain/include/graphene/chain/sport_object.hpp index 4f3139d8b..3da135b5f 100644 --- a/libraries/chain/include/graphene/chain/sport_object.hpp +++ b/libraries/chain/include/graphene/chain/sport_object.hpp @@ -23,7 +23,8 @@ */ #pragma once -#include +#include + #include #include @@ -48,4 +49,6 @@ typedef multi_index_container< typedef generic_index sport_object_index; } } // graphene::chain +MAP_OBJECT_ID_TO_TYPE(graphene::chain::sport_object) + FC_REFLECT_DERIVED( graphene::chain::sport_object, (graphene::db::object), (name) ) diff --git a/libraries/chain/include/graphene/chain/tournament_evaluator.hpp b/libraries/chain/include/graphene/chain/tournament_evaluator.hpp index 18a0140d2..9cce918dc 100644 --- a/libraries/chain/include/graphene/chain/tournament_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/tournament_evaluator.hpp @@ -1,5 +1,5 @@ #pragma once -#include +#include #include #include diff --git a/libraries/chain/include/graphene/chain/tournament_object.hpp b/libraries/chain/include/graphene/chain/tournament_object.hpp index 140770e2d..9f2e5860b 100644 --- a/libraries/chain/include/graphene/chain/tournament_object.hpp +++ b/libraries/chain/include/graphene/chain/tournament_object.hpp @@ -1,12 +1,19 @@ #pragma once -#include + +#include #include -#include +#include + +#include + #include #include + #include #include +#include + namespace graphene { namespace chain { class tournament_object; } } @@ -234,6 +241,9 @@ namespace graphene { namespace chain { } } +MAP_OBJECT_ID_TO_TYPE(graphene::chain::tournament_details_object) +MAP_OBJECT_ID_TO_TYPE(graphene::chain::tournament_object) + FC_REFLECT_DERIVED(graphene::chain::tournament_details_object, (graphene::db::object), (tournament_id) (registered_players) @@ -241,7 +251,7 @@ FC_REFLECT_DERIVED(graphene::chain::tournament_details_object, (graphene::db::ob (players_payers) (matches)) //FC_REFLECT_TYPENAME(graphene::chain::tournament_object) // manually serialized -FC_REFLECT(graphene::chain::tournament_object, (creator)) +FC_REFLECT_DERIVED(graphene::chain::tournament_object, (graphene::db::object), (creator)) FC_REFLECT_ENUM(graphene::chain::tournament_state, (accepting_registrations) (awaiting_start) diff --git a/libraries/chain/include/graphene/chain/transaction_evaluation_state.hpp b/libraries/chain/include/graphene/chain/transaction_evaluation_state.hpp index 5ffb4bb7d..c9da55c71 100644 --- a/libraries/chain/include/graphene/chain/transaction_evaluation_state.hpp +++ b/libraries/chain/include/graphene/chain/transaction_evaluation_state.hpp @@ -22,11 +22,15 @@ * THE SOFTWARE. */ #pragma once -#include +#include -namespace graphene { namespace chain { +#include + +namespace graphene { +namespace protocol { struct signed_transaction; } +namespace chain { class database; - struct signed_transaction; + using protocol::signed_transaction; /** * Place holder for state tracked while processing a transaction. This class provides helper methods that are diff --git a/libraries/chain/include/graphene/chain/transaction_object.hpp b/libraries/chain/include/graphene/chain/transaction_history_object.hpp similarity index 68% rename from libraries/chain/include/graphene/chain/transaction_object.hpp rename to libraries/chain/include/graphene/chain/transaction_history_object.hpp index aaaa31f16..e1f5f337d 100644 --- a/libraries/chain/include/graphene/chain/transaction_object.hpp +++ b/libraries/chain/include/graphene/chain/transaction_history_object.hpp @@ -23,7 +23,10 @@ */ #pragma once -#include +#include + +#include + #include #include @@ -39,14 +42,14 @@ namespace graphene { namespace chain { using namespace boost::multi_index; /** * The purpose of this object is to enable the detection of duplicate transactions. When a transaction is included - * in a block a transaction_object is added. At the end of block processing all transaction_objects that have - * expired can be removed from the index. + * in a block a transaction_history_object is added. At the end of block processing all transaction_history_objects that + * have expired can be removed from the index. */ - class transaction_object : public abstract_object + class transaction_history_object : public abstract_object { public: static const uint8_t space_id = implementation_ids; - static const uint8_t type_id = impl_transaction_object_type; + static const uint8_t type_id = impl_transaction_history_object_type; signed_transaction trx; transaction_id_type trx_id; @@ -55,20 +58,23 @@ namespace graphene { namespace chain { }; struct by_expiration; - struct by_id; struct by_trx_id; typedef multi_index_container< - transaction_object, + transaction_history_object, indexed_by< ordered_unique< tag, member< object, object_id_type, &object::id > >, - hashed_unique< tag, BOOST_MULTI_INDEX_MEMBER(transaction_object, transaction_id_type, trx_id), std::hash >, - ordered_non_unique< tag, const_mem_fun > + hashed_unique< tag, BOOST_MULTI_INDEX_MEMBER(transaction_history_object, transaction_id_type, trx_id), + std::hash >, + ordered_non_unique< tag, const_mem_fun< transaction_history_object, time_point_sec, + &transaction_history_object::get_expiration > > > > transaction_multi_index_type; - typedef generic_index transaction_index; + typedef generic_index transaction_index; } } -FC_REFLECT_DERIVED( graphene::chain::transaction_object, (graphene::db::object), (trx)(trx_id) ) +MAP_OBJECT_ID_TO_TYPE(graphene::chain::transaction_history_object) + +FC_REFLECT_DERIVED( graphene::chain::transaction_history_object, (graphene::db::object), (trx)(trx_id) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::transaction_object ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::transaction_history_object ) diff --git a/libraries/chain/include/graphene/chain/transfer_evaluator.hpp b/libraries/chain/include/graphene/chain/transfer_evaluator.hpp index 900ab0741..6c2bc7ee9 100644 --- a/libraries/chain/include/graphene/chain/transfer_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/transfer_evaluator.hpp @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #pragma once -#include +#include #include #include diff --git a/libraries/chain/include/graphene/chain/types.hpp b/libraries/chain/include/graphene/chain/types.hpp new file mode 100644 index 000000000..e5d8f2e45 --- /dev/null +++ b/libraries/chain/include/graphene/chain/types.hpp @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2015 Cryptonomex, Inc., and contributors. + * + * The MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#pragma once + +#include + +namespace graphene { namespace chain { using namespace protocol; } } + +GRAPHENE_DEFINE_IDS(chain, implementation_ids, impl_, + (global_property) + (dynamic_global_property) + (reserved0) + (asset_dynamic_data) + (asset_bitasset_data) + (account_balance) + (account_statistics) + (transaction_history) + (block_summary) + (account_transaction_history) + (blinded_balance) + (chain_property) + (witness_schedule) + (budget_record) + (special_authority) + (buyback) + (fba_accumulator) + (asset_dividend_data) + (pending_dividend_payout_balance_for_holder) + (total_distributed_dividend_balance) + (betting_market_position) + (global_betting_statistics) + (lottery_balance) + (sweeps_vesting_balance) + (offer_history) + (son_statistics) + (son_schedule)) diff --git a/libraries/chain/include/graphene/chain/vesting_balance_object.hpp b/libraries/chain/include/graphene/chain/vesting_balance_object.hpp index 1e87246ea..c60439b09 100644 --- a/libraries/chain/include/graphene/chain/vesting_balance_object.hpp +++ b/libraries/chain/include/graphene/chain/vesting_balance_object.hpp @@ -23,9 +23,9 @@ */ #pragma once -#include -#include +#include +#include #include #include @@ -37,6 +37,7 @@ namespace graphene { namespace chain { using namespace graphene::db; + using namespace graphene::protocol; struct vesting_policy_context { @@ -89,11 +90,11 @@ namespace graphene { namespace chain { */ struct cdd_vesting_policy { - uint32_t vesting_seconds = 0; - fc::uint128_t coin_seconds_earned; + uint32_t vesting_seconds = 0; + fc::uint128_t coin_seconds_earned; /** while coindays may accrue over time, none may be claimed before first_claim date */ - fc::time_point_sec start_claim; - fc::time_point_sec coin_seconds_earned_last_update; + fc::time_point_sec start_claim; + fc::time_point_sec coin_seconds_earned_last_update; /** * Compute coin_seconds_earned. Used to @@ -232,6 +233,8 @@ namespace graphene { namespace chain { } } // graphene::chain +MAP_OBJECT_ID_TO_TYPE(graphene::chain::vesting_balance_object) + FC_REFLECT(graphene::chain::linear_vesting_policy, (begin_timestamp) (vesting_cliff_seconds) diff --git a/libraries/chain/include/graphene/chain/vote_count.hpp b/libraries/chain/include/graphene/chain/vote_count.hpp index ab2f36129..17ea25084 100644 --- a/libraries/chain/include/graphene/chain/vote_count.hpp +++ b/libraries/chain/include/graphene/chain/vote_count.hpp @@ -24,7 +24,7 @@ #pragma once -#include +#include namespace graphene { namespace chain { diff --git a/libraries/chain/include/graphene/chain/withdraw_permission_object.hpp b/libraries/chain/include/graphene/chain/withdraw_permission_object.hpp index a6fee0c59..824d2f948 100644 --- a/libraries/chain/include/graphene/chain/withdraw_permission_object.hpp +++ b/libraries/chain/include/graphene/chain/withdraw_permission_object.hpp @@ -22,8 +22,9 @@ * THE SOFTWARE. */ #pragma once -#include +#include #include +#include #include namespace graphene { namespace chain { @@ -105,6 +106,8 @@ namespace graphene { namespace chain { } } // graphene::chain +MAP_OBJECT_ID_TO_TYPE(graphene::chain::withdraw_permission_object) + FC_REFLECT_DERIVED( graphene::chain::withdraw_permission_object, (graphene::db::object), (withdraw_from_account) (authorized_account) diff --git a/libraries/chain/include/graphene/chain/witness_object.hpp b/libraries/chain/include/graphene/chain/witness_object.hpp index 7928b46ef..2647dcd8d 100644 --- a/libraries/chain/include/graphene/chain/witness_object.hpp +++ b/libraries/chain/include/graphene/chain/witness_object.hpp @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #pragma once -#include +#include #include #include @@ -70,6 +70,8 @@ namespace graphene { namespace chain { using witness_index = generic_index; } } // graphene::chain +MAP_OBJECT_ID_TO_TYPE(graphene::chain::witness_object) + FC_REFLECT_DERIVED( graphene::chain::witness_object, (graphene::db::object), (witness_account) (last_aslot) diff --git a/libraries/chain/include/graphene/chain/witness_schedule_object.hpp b/libraries/chain/include/graphene/chain/witness_schedule_object.hpp index 2eff563f9..33a76de25 100644 --- a/libraries/chain/include/graphene/chain/witness_schedule_object.hpp +++ b/libraries/chain/include/graphene/chain/witness_schedule_object.hpp @@ -22,11 +22,16 @@ * THE SOFTWARE. */ #pragma once -#include -#include -#include #include #include +#include + +#include + +#include +#include + +#include namespace graphene { namespace chain { @@ -81,13 +86,13 @@ class witness_schedule_object : public graphene::db::abstract_object rng_seed; + std::array< char, sizeof(secret_hash_type) > rng_seed = {}; /** * Not necessary for consensus, but used for figuring out the participation rate. * The nth bit is 0 if the nth slot was unfilled, else it is 1. */ - fc::uint128 recent_slots_filled; + fc::uint128_t recent_slots_filled; }; class son_schedule_object : public graphene::db::abstract_object @@ -101,17 +106,19 @@ class son_schedule_object : public graphene::db::abstract_object rng_seed; + std::array< char, sizeof(secret_hash_type) > rng_seed = {}; /** * Not necessary for consensus, but used for figuring out the participation rate. * The nth bit is 0 if the nth slot was unfilled, else it is 1. */ - fc::uint128 recent_slots_filled; + fc::uint128_t recent_slots_filled; }; } } +MAP_OBJECT_ID_TO_TYPE(graphene::chain::witness_schedule_object) +MAP_OBJECT_ID_TO_TYPE(graphene::chain::son_schedule_object) FC_REFLECT( graphene::chain::witness_scheduler, (_turns) diff --git a/libraries/chain/include/graphene/chain/worker_object.hpp b/libraries/chain/include/graphene/chain/worker_object.hpp index 5e23f0b88..ec14631cf 100644 --- a/libraries/chain/include/graphene/chain/worker_object.hpp +++ b/libraries/chain/include/graphene/chain/worker_object.hpp @@ -22,11 +22,12 @@ * THE SOFTWARE. */ #pragma once -#include #include -#include +#include +#include namespace graphene { namespace chain { +class database; /** * @defgroup worker_types Implementations of the various worker types in the system @@ -159,6 +160,8 @@ using worker_index = generic_index #include -#include +#include #include diff --git a/libraries/chain/nft_evaluator.cpp b/libraries/chain/nft_evaluator.cpp index f7f007ff0..dc76590ad 100644 --- a/libraries/chain/nft_evaluator.cpp +++ b/libraries/chain/nft_evaluator.cpp @@ -1,9 +1,10 @@ #include #include -#include #include #include +#include + namespace graphene { namespace chain { void_result nft_metadata_create_evaluator::do_evaluate( const nft_metadata_create_operation& op ) diff --git a/libraries/chain/offer_evaluator.cpp b/libraries/chain/offer_evaluator.cpp index 1b8874662..e47206117 100644 --- a/libraries/chain/offer_evaluator.cpp +++ b/libraries/chain/offer_evaluator.cpp @@ -2,11 +2,13 @@ #include #include #include -#include #include #include #include #include + +#include + #include namespace graphene @@ -94,7 +96,6 @@ namespace graphene auto now = d.head_block_time(); FC_ASSERT(now >= HARDFORK_NFT_TIME, "Not allowed until NFT HF"); const auto &offer = op.offer_id(d); - op.bidder(d); for (const auto &item : offer.item_ids) { const auto &nft_obj = item(d); diff --git a/libraries/chain/proposal_evaluator.cpp b/libraries/chain/proposal_evaluator.cpp index 3ea4a836a..45ea211e4 100644 --- a/libraries/chain/proposal_evaluator.cpp +++ b/libraries/chain/proposal_evaluator.cpp @@ -26,9 +26,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include #include @@ -378,7 +378,7 @@ void_result proposal_update_evaluator::do_apply(const proposal_update_operation& // Potential optimization: if _executed_proposal is true, we can skip the modify step and make push_proposal skip // signature checks. This isn't done now because I just wrote all the proposals code, and I'm not yet 100% sure the // required approvals are sufficient to authorize the transaction. - d.modify(*_proposal, [&o, &d](proposal_object& p) { + d.modify(*_proposal, [&o](proposal_object& p) { p.available_active_approvals.insert(o.active_approvals_to_add.begin(), o.active_approvals_to_add.end()); p.available_owner_approvals.insert(o.owner_approvals_to_add.begin(), o.owner_approvals_to_add.end()); for( account_id_type id : o.active_approvals_to_remove ) diff --git a/libraries/chain/protocol/types.cpp b/libraries/chain/protocol/types.cpp deleted file mode 100644 index b7cac207a..000000000 --- a/libraries/chain/protocol/types.cpp +++ /dev/null @@ -1,280 +0,0 @@ -/* - * Copyright (c) 2015 Cryptonomex, Inc., and contributors. - * - * The MIT License - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#include -#include - -#include -#include -#include -#include - -namespace graphene { namespace chain { - - public_key_type::public_key_type():key_data(){}; - - public_key_type::public_key_type( const fc::ecc::public_key_data& data ) - :key_data( data ) {}; - - public_key_type::public_key_type( const fc::ecc::public_key& pubkey ) - :key_data( pubkey ) {}; - - public_key_type::public_key_type( const std::string& base58str ) - { - // TODO: Refactor syntactic checks into static is_valid() - // to make public_key_type API more similar to address API - std::string prefix( GRAPHENE_ADDRESS_PREFIX ); - - // TODO: This is temporary for testing - try - { - if( is_valid_v1( base58str ) ) - prefix = std::string( "BTS" ); - } - catch( ... ) - { - } - - try - { - if( is_valid_muse( base58str ) ) - prefix = std::string( "MUSE" ); - } - catch( ... ) - { - } - - const size_t prefix_len = prefix.size(); - FC_ASSERT( base58str.size() > prefix_len ); - FC_ASSERT( base58str.substr( 0, prefix_len ) == prefix , "", ("base58str", base58str) ); - auto bin = fc::from_base58( base58str.substr( prefix_len ) ); - auto bin_key = fc::raw::unpack(bin); - key_data = bin_key.data; - FC_ASSERT( fc::ripemd160::hash( key_data.data, key_data.size() )._hash[0] == bin_key.check ); - }; - - bool public_key_type::is_valid_muse( const std::string& base58str ) - { - std::string prefix( "MUSE" ); - - const size_t prefix_len = prefix.size(); - FC_ASSERT( base58str.size() > prefix_len ); - FC_ASSERT( base58str.substr( 0, prefix_len ) == prefix , "", ("base58str", base58str) ); - auto bin = fc::from_base58( base58str.substr( prefix_len ) ); - auto bin_key = fc::raw::unpack(bin); - key_data = bin_key.data; - FC_ASSERT( fc::ripemd160::hash( key_data.data, key_data.size() )._hash[0] == bin_key.check ); - return true; - } - - // TODO: This is temporary for testing - bool public_key_type::is_valid_v1( const std::string& base58str ) - { - std::string prefix( "BTS" ); - const size_t prefix_len = prefix.size(); - FC_ASSERT( base58str.size() > prefix_len ); - FC_ASSERT( base58str.substr( 0, prefix_len ) == prefix , "", ("base58str", base58str) ); - auto bin = fc::from_base58( base58str.substr( prefix_len ) ); - auto bin_key = fc::raw::unpack(bin); - fc::ecc::public_key_data key_data = bin_key.data; - FC_ASSERT( fc::ripemd160::hash( key_data.data, key_data.size() )._hash[0] == bin_key.check ); - return true; - } - - public_key_type::operator fc::ecc::public_key_data() const - { - return key_data; - }; - - public_key_type::operator fc::ecc::public_key() const - { - return fc::ecc::public_key( key_data ); - }; - - public_key_type::operator std::string() const - { - binary_key k; - k.data = key_data; - k.check = fc::ripemd160::hash( k.data.data, k.data.size() )._hash[0]; - auto data = fc::raw::pack( k ); - return GRAPHENE_ADDRESS_PREFIX + fc::to_base58( data.data(), data.size() ); - } - - bool operator == ( const public_key_type& p1, const fc::ecc::public_key& p2) - { - return p1.key_data == p2.serialize(); - } - - bool operator == ( const public_key_type& p1, const public_key_type& p2) - { - return p1.key_data == p2.key_data; - } - - bool operator != ( const public_key_type& p1, const public_key_type& p2) - { - return p1.key_data != p2.key_data; - } - - // extended_public_key_type - - extended_public_key_type::extended_public_key_type():key_data(){}; - - extended_public_key_type::extended_public_key_type( const fc::ecc::extended_key_data& data ) - :key_data( data ){}; - - extended_public_key_type::extended_public_key_type( const fc::ecc::extended_public_key& extpubkey ) - { - key_data = extpubkey.serialize_extended(); - }; - - extended_public_key_type::extended_public_key_type( const std::string& base58str ) - { - std::string prefix( GRAPHENE_ADDRESS_PREFIX ); - - const size_t prefix_len = prefix.size(); - FC_ASSERT( base58str.size() > prefix_len ); - FC_ASSERT( base58str.substr( 0, prefix_len ) == prefix , "", ("base58str", base58str) ); - auto bin = fc::from_base58( base58str.substr( prefix_len ) ); - auto bin_key = fc::raw::unpack(bin); - FC_ASSERT( fc::ripemd160::hash( bin_key.data.data, bin_key.data.size() )._hash[0] == bin_key.check ); - key_data = bin_key.data; - } - - extended_public_key_type::operator fc::ecc::extended_public_key() const - { - return fc::ecc::extended_public_key::deserialize( key_data ); - } - - extended_public_key_type::operator std::string() const - { - binary_key k; - k.data = key_data; - k.check = fc::ripemd160::hash( k.data.data, k.data.size() )._hash[0]; - auto data = fc::raw::pack( k ); - return GRAPHENE_ADDRESS_PREFIX + fc::to_base58( data.data(), data.size() ); - } - - bool operator == ( const extended_public_key_type& p1, const fc::ecc::extended_public_key& p2) - { - return p1.key_data == p2.serialize_extended(); - } - - bool operator == ( const extended_public_key_type& p1, const extended_public_key_type& p2) - { - return p1.key_data == p2.key_data; - } - - bool operator != ( const extended_public_key_type& p1, const extended_public_key_type& p2) - { - return p1.key_data != p2.key_data; - } - - // extended_private_key_type - - extended_private_key_type::extended_private_key_type():key_data(){}; - - extended_private_key_type::extended_private_key_type( const fc::ecc::extended_key_data& data ) - :key_data( data ){}; - - extended_private_key_type::extended_private_key_type( const fc::ecc::extended_private_key& extprivkey ) - { - key_data = extprivkey.serialize_extended(); - }; - - extended_private_key_type::extended_private_key_type( const std::string& base58str ) - { - std::string prefix( GRAPHENE_ADDRESS_PREFIX ); - - const size_t prefix_len = prefix.size(); - FC_ASSERT( base58str.size() > prefix_len ); - FC_ASSERT( base58str.substr( 0, prefix_len ) == prefix , "", ("base58str", base58str) ); - auto bin = fc::from_base58( base58str.substr( prefix_len ) ); - auto bin_key = fc::raw::unpack(bin); - FC_ASSERT( fc::ripemd160::hash( bin_key.data.data, bin_key.data.size() )._hash[0] == bin_key.check ); - key_data = bin_key.data; - } - - extended_private_key_type::operator fc::ecc::extended_private_key() const - { - return fc::ecc::extended_private_key::deserialize( key_data ); - } - - extended_private_key_type::operator std::string() const - { - binary_key k; - k.data = key_data; - k.check = fc::ripemd160::hash( k.data.data, k.data.size() )._hash[0]; - auto data = fc::raw::pack( k ); - return GRAPHENE_ADDRESS_PREFIX + fc::to_base58( data.data(), data.size() ); - } - - bool operator == ( const extended_private_key_type& p1, const fc::ecc::extended_public_key& p2) - { - return p1.key_data == p2.serialize_extended(); - } - - bool operator == ( const extended_private_key_type& p1, const extended_private_key_type& p2) - { - return p1.key_data == p2.key_data; - } - - bool operator != ( const extended_private_key_type& p1, const extended_private_key_type& p2) - { - return p1.key_data != p2.key_data; - } - -} } // graphene::chain - -namespace fc -{ - using namespace std; - void to_variant( const graphene::chain::public_key_type& var, fc::variant& vo, uint32_t max_depth ) - { - vo = std::string( var ); - } - - void from_variant( const fc::variant& var, graphene::chain::public_key_type& vo, uint32_t max_depth ) - { - vo = graphene::chain::public_key_type( var.as_string() ); - } - - void to_variant( const graphene::chain::extended_public_key_type& var, fc::variant& vo, uint32_t max_depth ) - { - vo = std::string( var ); - } - - void from_variant( const fc::variant& var, graphene::chain::extended_public_key_type& vo, uint32_t max_depth ) - { - vo = graphene::chain::extended_public_key_type( var.as_string() ); - } - - void to_variant( const graphene::chain::extended_private_key_type& var, fc::variant& vo, uint32_t max_depth ) - { - vo = std::string( var ); - } - - void from_variant( const fc::variant& var, graphene::chain::extended_private_key_type& vo, uint32_t max_depth ) - { - vo = graphene::chain::extended_private_key_type( var.as_string() ); - } -} // fc diff --git a/libraries/chain/small_objects.cpp b/libraries/chain/small_objects.cpp index 6b8af3d94..66812162f 100644 --- a/libraries/chain/small_objects.cpp +++ b/libraries/chain/small_objects.cpp @@ -22,7 +22,7 @@ * THE SOFTWARE. */ -#include +#include #include #include @@ -36,15 +36,20 @@ #include #include #include -#include +#include #include #include #include #include #include +#include #include +namespace graphene { namespace chain { +FC_IMPLEMENT_EXCEPTION(no_transition, 100000, "Invalid state transition"); +} } + GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::balance_object ) GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::block_summary_object ) GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::budget_record ) @@ -63,7 +68,7 @@ GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::global_propert GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::operation_history_object ) GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::account_transaction_history_object ) GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::special_authority_object ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::transaction_object ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::transaction_history_object ) GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::withdraw_permission_object ) GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::witness_object ) GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::witness_scheduler ) diff --git a/libraries/chain/son_evaluator.cpp b/libraries/chain/son_evaluator.cpp index 9c48c3e09..167ef9a90 100644 --- a/libraries/chain/son_evaluator.cpp +++ b/libraries/chain/son_evaluator.cpp @@ -21,7 +21,7 @@ object_id_type create_son_evaluator::do_apply(const son_create_operation& op) { try { vote_id_type vote_id; db().modify(db().get_global_properties(), [&vote_id](global_property_object& p) { - vote_id = get_next_vote_id(p, vote_id_type::son); + vote_id = vote_id_type(vote_id_type::son, p.next_available_vote_id++); }); const auto& new_son_object = db().create( [&]( son_object& obj ){ diff --git a/libraries/chain/special_authority.cpp b/libraries/chain/special_authority_evaluation.cpp similarity index 79% rename from libraries/chain/special_authority.cpp rename to libraries/chain/special_authority_evaluation.cpp index 74889f806..3c007f251 100644 --- a/libraries/chain/special_authority.cpp +++ b/libraries/chain/special_authority_evaluation.cpp @@ -22,31 +22,13 @@ * THE SOFTWARE. */ -#include +#include #include #include namespace graphene { namespace chain { -struct special_authority_validate_visitor -{ - typedef void result_type; - - void operator()( const no_special_authority& a ) {} - - void operator()( const top_holders_special_authority& a ) - { - FC_ASSERT( a.num_top_holders > 0 ); - } -}; - -void validate_special_authority( const special_authority& a ) -{ - special_authority_validate_visitor vtor; - a.visit( vtor ); -} - struct special_authority_evaluate_visitor { typedef void result_type; @@ -57,7 +39,7 @@ struct special_authority_evaluate_visitor void operator()( const top_holders_special_authority& a ) { - a.asset(db); // require asset to exist + db.get(a.asset); // require asset to exist } const database& db; diff --git a/libraries/chain/tournament_evaluator.cpp b/libraries/chain/tournament_evaluator.cpp index c90f5e102..d3c7acf71 100644 --- a/libraries/chain/tournament_evaluator.cpp +++ b/libraries/chain/tournament_evaluator.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -106,8 +106,7 @@ namespace graphene { namespace chain { object_id_type tournament_create_evaluator::do_apply( const tournament_create_operation& op ) { try { const tournament_details_object& tournament_details = - db().create( [&]( tournament_details_object& a ) { - }); + db().create( [&]( tournament_details_object& ) { }); const tournament_object& new_tournament = db().create( [&]( tournament_object& t ) { diff --git a/libraries/chain/tournament_object.cpp b/libraries/chain/tournament_object.cpp index ad64b34fb..715ef1d37 100644 --- a/libraries/chain/tournament_object.cpp +++ b/libraries/chain/tournament_object.cpp @@ -317,7 +317,7 @@ namespace graphene { namespace chain { share_type rake_amount = 0; if (dividend_id) - rake_amount = (fc::uint128_t(tournament_obj.prize_pool.value) * rake_fee_percentage / GRAPHENE_1_PERCENT / 100).to_uint64(); + rake_amount = (fc::uint128_t(tournament_obj.prize_pool.value) * rake_fee_percentage / GRAPHENE_1_PERCENT / 100); asset won_prize(tournament_obj.prize_pool - rake_amount, tournament_obj.options.buy_in.asset_id); tournament_payout_operation op; @@ -645,13 +645,6 @@ namespace graphene { namespace chain { } } - fc::sha256 rock_paper_scissors_throw::calculate_hash() const - { - std::vector full_throw_packed(fc::raw::pack(*this)); - return fc::sha256::hash(full_throw_packed.data(), full_throw_packed.size()); - } - - vector tournament_players_index::get_registered_tournaments_for_account( const account_id_type& a )const { auto iter = account_to_joined_tournaments.find(a); diff --git a/libraries/chain/vesting_balance_evaluator.cpp b/libraries/chain/vesting_balance_evaluator.cpp index 56eef1933..4b9c0e23f 100644 --- a/libraries/chain/vesting_balance_evaluator.cpp +++ b/libraries/chain/vesting_balance_evaluator.cpp @@ -26,6 +26,7 @@ #include #include #include +#include namespace graphene { namespace chain { diff --git a/libraries/chain/vesting_balance_object.cpp b/libraries/chain/vesting_balance_object.cpp index 3334d4f6a..4dea77897 100644 --- a/libraries/chain/vesting_balance_object.cpp +++ b/libraries/chain/vesting_balance_object.cpp @@ -59,7 +59,7 @@ asset linear_vesting_policy::get_allowed_withdraw( const vesting_policy_context& share_type total_vested = 0; if( elapsed_seconds < vesting_duration_seconds ) { - total_vested = (fc::uint128_t( begin_balance.value ) * elapsed_seconds / vesting_duration_seconds).to_uint64(); + total_vested = (fc::uint128_t( begin_balance.value ) * elapsed_seconds / vesting_duration_seconds); } else { @@ -127,7 +127,7 @@ asset cdd_vesting_policy::get_allowed_withdraw(const vesting_policy_context& ctx fc::uint128_t cs_earned = compute_coin_seconds_earned(ctx); fc::uint128_t withdraw_available = cs_earned / std::max(vesting_seconds, 1u); assert(withdraw_available <= ctx.balance.amount.value); - return asset(withdraw_available.to_uint64(), ctx.balance.asset_id); + return asset(static_cast(withdraw_available), ctx.balance.asset_id); } void cdd_vesting_policy::on_deposit(const vesting_policy_context& ctx) diff --git a/libraries/chain/witness_evaluator.cpp b/libraries/chain/witness_evaluator.cpp index 7bd261bbc..dd45e7434 100644 --- a/libraries/chain/witness_evaluator.cpp +++ b/libraries/chain/witness_evaluator.cpp @@ -26,7 +26,7 @@ #include #include #include -#include +#include namespace graphene { namespace chain { @@ -40,7 +40,7 @@ object_id_type witness_create_evaluator::do_apply( const witness_create_operatio { try { vote_id_type vote_id; db().modify(db().get_global_properties(), [&vote_id](global_property_object& p) { - vote_id = get_next_vote_id(p, vote_id_type::witness); + vote_id = vote_id_type(vote_id_type::witness, p.next_available_vote_id++); }); const auto& new_witness_object = db().create( [&]( witness_object& obj ) { diff --git a/libraries/chain/worker_evaluator.cpp b/libraries/chain/worker_evaluator.cpp index b5aea8f3b..b57396cf7 100644 --- a/libraries/chain/worker_evaluator.cpp +++ b/libraries/chain/worker_evaluator.cpp @@ -28,7 +28,7 @@ #include #include -#include +#include namespace graphene { namespace chain { @@ -84,8 +84,8 @@ object_id_type worker_create_evaluator::do_apply(const worker_create_evaluator:: database& d = db(); vote_id_type for_id, against_id; d.modify(d.get_global_properties(), [&for_id, &against_id](global_property_object& p) { - for_id = get_next_vote_id(p, vote_id_type::worker); - against_id = get_next_vote_id(p, vote_id_type::worker); + for_id = vote_id_type(vote_id_type::worker, p.next_available_vote_id++); + against_id = vote_id_type(vote_id_type::worker, p.next_available_vote_id++); }); return d.create([&](worker_object& w) { diff --git a/libraries/db/CMakeLists.txt b/libraries/db/CMakeLists.txt index 6feb985c6..b0899d868 100644 --- a/libraries/db/CMakeLists.txt +++ b/libraries/db/CMakeLists.txt @@ -1,6 +1,6 @@ file(GLOB HEADERS "include/graphene/db/*.hpp") add_library( graphene_db undo_database.cpp index.cpp object_database.cpp ${HEADERS} ) -target_link_libraries( graphene_db fc ) +target_link_libraries( graphene_db graphene_protocol fc ) target_include_directories( graphene_db PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) install( TARGETS diff --git a/libraries/db/include/graphene/db/flat_index.hpp b/libraries/db/include/graphene/db/flat_index.hpp index f1b7912ef..0d17cbfa5 100644 --- a/libraries/db/include/graphene/db/flat_index.hpp +++ b/libraries/db/include/graphene/db/flat_index.hpp @@ -93,14 +93,6 @@ namespace graphene { namespace db { } FC_CAPTURE_AND_RETHROW() } - virtual fc::uint128 hash()const override { - fc::uint128 result; - for( const auto& ptr : _objects ) - result += ptr.hash(); - - return result; - } - class const_iterator { public: diff --git a/libraries/db/include/graphene/db/fwd.hpp b/libraries/db/include/graphene/db/fwd.hpp index 36b4e7138..76c514dd9 100644 --- a/libraries/db/include/graphene/db/fwd.hpp +++ b/libraries/db/include/graphene/db/fwd.hpp @@ -33,3 +33,4 @@ namespace graphene { namespace db { typedef std::shared_ptr peer_ram_ptr; }} // namespace graphene::db + diff --git a/libraries/db/include/graphene/db/generic_index.hpp b/libraries/db/include/graphene/db/generic_index.hpp index fb11d44a3..812a6587d 100644 --- a/libraries/db/include/graphene/db/generic_index.hpp +++ b/libraries/db/include/graphene/db/generic_index.hpp @@ -28,12 +28,12 @@ #include #include -namespace graphene { namespace chain { +namespace graphene { namespace db { using boost::multi_index_container; using namespace boost::multi_index; - struct by_id{}; + struct by_id; /** * Almost all objects can be tracked and managed via a boost::multi_index container that uses * an unordered_unique key on the object ID. This template class adapts the generic index interface @@ -112,18 +112,7 @@ namespace graphene { namespace chain { const index_type& indices()const { return _indices; } - virtual fc::uint128 hash()const override { - fc::uint128 result; - for( const auto& ptr : _indices ) - { - result += ptr.hash(); - } - - return result; - } - private: - fc::uint128 _current_hash; index_type _indices; }; diff --git a/libraries/db/include/graphene/db/index.hpp b/libraries/db/include/graphene/db/index.hpp index 1bc593f42..6a6fb3f16 100644 --- a/libraries/db/include/graphene/db/index.hpp +++ b/libraries/db/include/graphene/db/index.hpp @@ -129,7 +129,6 @@ namespace graphene { namespace db { } virtual void inspect_all_objects(std::function inspector)const = 0; - virtual fc::uint128 hash()const = 0; virtual void add_observer( const shared_ptr& ) = 0; virtual void object_from_variant( const fc::variant& var, object& obj, uint32_t max_depth )const = 0; diff --git a/libraries/db/include/graphene/db/object.hpp b/libraries/db/include/graphene/db/object.hpp index c410e273e..2c0f2adc0 100644 --- a/libraries/db/include/graphene/db/object.hpp +++ b/libraries/db/include/graphene/db/object.hpp @@ -22,10 +22,10 @@ * THE SOFTWARE. */ #pragma once -#include +#include #include #include -#include +#include #define MAX_NESTING (200) @@ -77,7 +77,6 @@ namespace graphene { namespace db { virtual void move_from( object& obj ) = 0; virtual variant to_variant()const = 0; virtual vector pack()const = 0; - virtual fc::uint128 hash()const = 0; }; /** @@ -102,10 +101,6 @@ namespace graphene { namespace db { } virtual variant to_variant()const { return variant( static_cast(*this), MAX_NESTING ); } virtual vector pack()const { return fc::raw::pack( static_cast(*this) ); } - virtual fc::uint128 hash()const { - auto tmp = this->pack(); - return fc::city_hash_crc_128( tmp.data(), tmp.size() ); - } }; typedef flat_map annotation_map; @@ -139,6 +134,13 @@ namespace graphene { namespace db { } } // graphene::db +// Without this, pack(object_id) tries to match the template for +// pack(boost::multiprecision::uint128_t). No idea why. :-( +namespace boost { namespace multiprecision { namespace detail { +template +struct is_restricted_conversion : public mpl::true_ {}; +}}} + FC_REFLECT_TYPENAME( graphene::db::annotation_map ) FC_REFLECT( graphene::db::object, (id) ) FC_REFLECT_DERIVED_TEMPLATE( (typename Derived), graphene::db::annotated_object, (graphene::db::object), (annotations) ) diff --git a/libraries/db/include/graphene/db/object_database.hpp b/libraries/db/include/graphene/db/object_database.hpp index fa2109aab..d51249e11 100644 --- a/libraries/db/include/graphene/db/object_database.hpp +++ b/libraries/db/include/graphene/db/object_database.hpp @@ -121,11 +121,15 @@ namespace graphene { namespace db { return static_cast(obj); } - template - const T* find( object_id id )const { return find(id); } + template + auto find( object_id id )const -> const object_downcast_t* { + return find>(id); + } - template - const T& get( object_id id )const { return get(id); } + template + auto get( object_id id )const -> const object_downcast_t& { + return get>(id); + } template IndexType* add_index() @@ -139,6 +143,12 @@ namespace graphene { namespace db { return static_cast(_index[ObjectType::space_id][ObjectType::type_id].get()); } + template + SecondaryIndexType* add_secondary_index() + { + return get_mutable_index_type().template add_secondary_index(); + } + void pop_undo(); fc::path get_data_dir()const { return _data_dir; } diff --git a/libraries/db/include/graphene/db/simple_index.hpp b/libraries/db/include/graphene/db/simple_index.hpp index 0e807aef6..51679be2a 100644 --- a/libraries/db/include/graphene/db/simple_index.hpp +++ b/libraries/db/include/graphene/db/simple_index.hpp @@ -98,13 +98,6 @@ namespace graphene { namespace db { } } FC_CAPTURE_AND_RETHROW() } - virtual fc::uint128 hash()const override { - fc::uint128 result; - for( const auto& ptr : _objects ) - result += ptr->hash(); - - return result; - } class const_iterator { diff --git a/libraries/db/object_database.cpp b/libraries/db/object_database.cpp index fdde0fed6..7e67c9262 100644 --- a/libraries/db/object_database.cpp +++ b/libraries/db/object_database.cpp @@ -25,7 +25,6 @@ #include #include -#include namespace graphene { namespace db { diff --git a/libraries/egenesis/CMakeLists.txt b/libraries/egenesis/CMakeLists.txt index 755899999..ee6dc4a1c 100644 --- a/libraries/egenesis/CMakeLists.txt +++ b/libraries/egenesis/CMakeLists.txt @@ -57,3 +57,5 @@ INSTALL( TARGETS LIBRARY DESTINATION lib ARCHIVE DESTINATION lib ) +file(GLOB HEADERS "include/graphene/egenesis/*.hpp") +INSTALL( FILES ${HEADERS} DESTINATION "include/graphene/egenesis" ) diff --git a/libraries/egenesis/egenesis_brief.cpp.tmpl b/libraries/egenesis/egenesis_brief.cpp.tmpl index bd590eb30..bb4a7e586 100644 --- a/libraries/egenesis/egenesis_brief.cpp.tmpl +++ b/libraries/egenesis/egenesis_brief.cpp.tmpl @@ -17,7 +17,7 @@ ${generated_file_banner} * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #include namespace graphene { namespace egenesis { diff --git a/libraries/egenesis/egenesis_full.cpp.tmpl b/libraries/egenesis/egenesis_full.cpp.tmpl index 83285f11a..2b172fa04 100644 --- a/libraries/egenesis/egenesis_full.cpp.tmpl +++ b/libraries/egenesis/egenesis_full.cpp.tmpl @@ -17,7 +17,7 @@ ${generated_file_banner} * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #include namespace graphene { namespace egenesis { diff --git a/libraries/egenesis/embed_genesis.cpp b/libraries/egenesis/embed_genesis.cpp index c2ffd6864..b4c7d91c3 100644 --- a/libraries/egenesis/embed_genesis.cpp +++ b/libraries/egenesis/embed_genesis.cpp @@ -34,10 +34,10 @@ #include #include #include -#include +#include // we need to include the world in order to serialize fee_parameters -#include +#include using namespace graphene::chain; diff --git a/libraries/egenesis/include/graphene/egenesis/egenesis.hpp b/libraries/egenesis/include/graphene/egenesis/egenesis.hpp index 848a4d29c..8d5753017 100644 --- a/libraries/egenesis/include/graphene/egenesis/egenesis.hpp +++ b/libraries/egenesis/include/graphene/egenesis/egenesis.hpp @@ -27,7 +27,7 @@ #include #include -#include +#include #include namespace graphene { namespace egenesis { diff --git a/libraries/fc b/libraries/fc index 0e9259486..2f89e0812 160000 --- a/libraries/fc +++ b/libraries/fc @@ -1 +1 @@ -Subproject commit 0e9259486cb04a90ec709750143cc5be1da474ff +Subproject commit 2f89e0812a8262490a53efa599cb044ba08a12f8 diff --git a/libraries/net/CMakeLists.txt b/libraries/net/CMakeLists.txt index 1cc717284..af54791fd 100644 --- a/libraries/net/CMakeLists.txt +++ b/libraries/net/CMakeLists.txt @@ -3,6 +3,7 @@ file(GLOB HEADERS "include/graphene/net/*.hpp") set(SOURCES node.cpp stcp_socket.cpp core_messages.cpp + exceptions.cpp peer_database.cpp peer_connection.cpp message.cpp @@ -10,8 +11,8 @@ set(SOURCES node.cpp add_library( graphene_net ${SOURCES} ${HEADERS} ) -target_link_libraries( graphene_net graphene_chain ) -target_include_directories( graphene_net PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) +target_link_libraries( graphene_net PUBLIC fc graphene_db graphene_protocol ) +target_include_directories( graphene_net PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) if(MSVC) set_source_files_properties( node.cpp PROPERTIES COMPILE_FLAGS "/bigobj" ) diff --git a/libraries/chain/protocol/small_ops.cpp b/libraries/net/exceptions.cpp similarity index 51% rename from libraries/chain/protocol/small_ops.cpp rename to libraries/net/exceptions.cpp index cba4b1b73..4203c9f21 100644 --- a/libraries/chain/protocol/small_ops.cpp +++ b/libraries/net/exceptions.cpp @@ -21,23 +21,20 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +#include -#include -#include -#include -#include -#include -#include +namespace graphene { namespace net { + FC_IMPLEMENT_EXCEPTION( net_exception, 90000, "P2P Networking Exception" ) + FC_IMPLEMENT_DERIVED_EXCEPTION( send_queue_overflow, net_exception, 90001, + "send queue for this peer exceeded maximum size" ) + FC_IMPLEMENT_DERIVED_EXCEPTION( insufficient_relay_fee, net_exception, 90002, + "insufficient relay fee" ) + FC_IMPLEMENT_DERIVED_EXCEPTION( already_connected_to_requested_peer, net_exception, 90003, + "already connected to requested peer" ) + FC_IMPLEMENT_DERIVED_EXCEPTION( block_older_than_undo_history, net_exception, 90004, + "block is older than our undo history allows us to process" ) + FC_IMPLEMENT_DERIVED_EXCEPTION( peer_is_on_an_unreachable_fork, net_exception, 90005, + "peer is on another fork" ) + FC_IMPLEMENT_DERIVED_EXCEPTION( unlinkable_block_exception, net_exception, 90006, "unlinkable block" ) -#include - -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::balance_claim_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::buyback_account_options ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::fba_distribute_operation ) - -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::vesting_balance_create_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::vesting_balance_withdraw_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::vesting_balance_create_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::vesting_balance_withdraw_operation ) - -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::chain_parameters ) +} } diff --git a/libraries/net/include/graphene/net/core_messages.hpp b/libraries/net/include/graphene/net/core_messages.hpp index 8af0c3443..39d68fba7 100644 --- a/libraries/net/include/graphene/net/core_messages.hpp +++ b/libraries/net/include/graphene/net/core_messages.hpp @@ -24,7 +24,7 @@ #pragma once #include -#include +#include #include #include @@ -40,10 +40,10 @@ #include namespace graphene { namespace net { - using graphene::chain::signed_transaction; - using graphene::chain::block_id_type; - using graphene::chain::transaction_id_type; - using graphene::chain::signed_block; + using graphene::protocol::signed_transaction; + using graphene::protocol::block_id_type; + using graphene::protocol::transaction_id_type; + using graphene::protocol::signed_block; typedef fc::ecc::public_key_data node_id_t; typedef fc::ripemd160 item_hash_t; diff --git a/libraries/net/include/graphene/net/exceptions.hpp b/libraries/net/include/graphene/net/exceptions.hpp index 59da8ccb4..e95eea875 100644 --- a/libraries/net/include/graphene/net/exceptions.hpp +++ b/libraries/net/include/graphene/net/exceptions.hpp @@ -27,12 +27,12 @@ namespace graphene { namespace net { // registered in node.cpp - FC_DECLARE_EXCEPTION( net_exception, 90000, "P2P Networking Exception" ); - FC_DECLARE_DERIVED_EXCEPTION( send_queue_overflow, graphene::net::net_exception, 90001, "send queue for this peer exceeded maximum size" ); - FC_DECLARE_DERIVED_EXCEPTION( insufficient_relay_fee, graphene::net::net_exception, 90002, "insufficient relay fee" ); - FC_DECLARE_DERIVED_EXCEPTION( already_connected_to_requested_peer, graphene::net::net_exception, 90003, "already connected to requested peer" ); - FC_DECLARE_DERIVED_EXCEPTION( block_older_than_undo_history, graphene::net::net_exception, 90004, "block is older than our undo history allows us to process" ); - FC_DECLARE_DERIVED_EXCEPTION( peer_is_on_an_unreachable_fork, graphene::net::net_exception, 90005, "peer is on another fork" ); - FC_DECLARE_DERIVED_EXCEPTION( unlinkable_block_exception, graphene::net::net_exception, 90006, "unlinkable block" ) + FC_DECLARE_EXCEPTION( net_exception, 90000 ) + FC_DECLARE_DERIVED_EXCEPTION( send_queue_overflow, net_exception, 90001 ) + FC_DECLARE_DERIVED_EXCEPTION( insufficient_relay_fee, net_exception, 90002 ) + FC_DECLARE_DERIVED_EXCEPTION( already_connected_to_requested_peer, net_exception, 90003 ) + FC_DECLARE_DERIVED_EXCEPTION( block_older_than_undo_history, net_exception, 90004 ) + FC_DECLARE_DERIVED_EXCEPTION( peer_is_on_an_unreachable_fork, net_exception, 90005 ) + FC_DECLARE_DERIVED_EXCEPTION( unlinkable_block_exception, net_exception, 90006 ) } } diff --git a/libraries/net/include/graphene/net/message.hpp b/libraries/net/include/graphene/net/message.hpp index 686fea24a..1807eb169 100644 --- a/libraries/net/include/graphene/net/message.hpp +++ b/libraries/net/include/graphene/net/message.hpp @@ -24,9 +24,8 @@ #pragma once #include -#include +#include -#include #include #include #include diff --git a/libraries/net/include/graphene/net/node.hpp b/libraries/net/include/graphene/net/node.hpp index e17af148c..fe03ac0cb 100644 --- a/libraries/net/include/graphene/net/node.hpp +++ b/libraries/net/include/graphene/net/node.hpp @@ -27,14 +27,14 @@ #include #include -#include +#include #include namespace graphene { namespace net { using fc::variant_object; - using graphene::chain::chain_id_type; + using graphene::protocol::chain_id_type; namespace detail { @@ -193,7 +193,7 @@ namespace graphene { namespace net { { public: node(const std::string& user_agent); - ~node(); + virtual ~node(); void close(); @@ -272,8 +272,8 @@ namespace graphene { namespace net { void set_advanced_node_parameters(const fc::variant_object& params); fc::variant_object get_advanced_node_parameters(); - message_propagation_data get_transaction_propagation_data(const graphene::chain::transaction_id_type& transaction_id); - message_propagation_data get_block_propagation_data(const graphene::chain::block_id_type& block_id); + message_propagation_data get_transaction_propagation_data(const graphene::protocol::transaction_id_type& transaction_id); + message_propagation_data get_block_propagation_data(const graphene::protocol::block_id_type& block_id); node_id_t get_node_id() const; void set_allowed_peers(const std::vector& allowed_peers); diff --git a/libraries/net/include/graphene/net/peer_database.hpp b/libraries/net/include/graphene/net/peer_database.hpp index ff7f40368..931f6e33a 100644 --- a/libraries/net/include/graphene/net/peer_database.hpp +++ b/libraries/net/include/graphene/net/peer_database.hpp @@ -24,7 +24,7 @@ #pragma once #include -#include +#include #include #include diff --git a/libraries/net/include/graphene/net/stcp_socket.hpp b/libraries/net/include/graphene/net/stcp_socket.hpp index cca94d574..fb4bfbc72 100644 --- a/libraries/net/include/graphene/net/stcp_socket.hpp +++ b/libraries/net/include/graphene/net/stcp_socket.hpp @@ -26,6 +26,8 @@ #include #include +#include + namespace graphene { namespace net { /** @@ -61,8 +63,6 @@ class stcp_socket : public virtual fc::iostream fc::sha512 _shared_secret; fc::ecc::private_key _priv_key; - fc::array _buf; - //uint32_t _buf_len; fc::tcp_socket _sock; fc::aes_encoder _send_aes; fc::aes_decoder _recv_aes; diff --git a/libraries/net/node.cpp b/libraries/net/node.cpp index 14e32306d..442ae38bc 100644 --- a/libraries/net/node.cpp +++ b/libraries/net/node.cpp @@ -78,8 +78,8 @@ #include #include -#include -#include +#include +#include #include @@ -827,7 +827,7 @@ namespace graphene { namespace net { namespace detail { _maximum_blocks_per_peer_during_syncing(GRAPHENE_NET_MAX_BLOCKS_PER_PEER_DURING_SYNCING) { _rate_limiter.set_actual_rate_time_constant(fc::seconds(2)); - fc::rand_bytes(&_node_id.data[0], (int)_node_id.size()); + fc::rand_bytes((char*) _node_id.data(), (int)_node_id.size()); } node_impl::~node_impl() @@ -948,7 +948,7 @@ namespace graphene { namespace net { namespace detail { #if 0 try { - _retrigger_connect_loop_promise = fc::promise::ptr( new fc::promise("graphene::net::retrigger_connect_loop") ); + _retrigger_connect_loop_promise = fc::promise::create("graphene::net::retrigger_connect_loop"); if( is_wanting_new_connections() || !_add_once_node_list.empty() ) { if( is_wanting_new_connections() ) @@ -1078,7 +1078,7 @@ namespace graphene { namespace net { namespace detail { if( !_sync_items_to_fetch_updated ) { dlog( "no sync items to fetch right now, going to sleep" ); - _retrigger_fetch_sync_items_loop_promise = fc::promise::ptr( new fc::promise("graphene::net::retrigger_fetch_sync_items_loop") ); + _retrigger_fetch_sync_items_loop_promise = fc::promise::create("graphene::net::retrigger_fetch_sync_items_loop"); _retrigger_fetch_sync_items_loop_promise->wait(); _retrigger_fetch_sync_items_loop_promise.reset(); } @@ -1205,7 +1205,7 @@ namespace graphene { namespace net { namespace detail { if (!_items_to_fetch_updated) { - _retrigger_fetch_item_loop_promise = fc::promise::ptr(new fc::promise("graphene::net::retrigger_fetch_item_loop")); + _retrigger_fetch_item_loop_promise = fc::promise::create("graphene::net::retrigger_fetch_item_loop"); fc::microseconds time_until_retrigger = fc::microseconds::maximum(); if (next_peer_unblocked_time != fc::time_point::maximum()) time_until_retrigger = next_peer_unblocked_time - fc::time_point::now(); @@ -1297,7 +1297,7 @@ namespace graphene { namespace net { namespace detail { if (_new_inventory.empty()) { - _retrigger_advertise_inventory_loop_promise = fc::promise::ptr(new fc::promise("graphene::net::retrigger_advertise_inventory_loop")); + _retrigger_advertise_inventory_loop_promise = fc::promise::create("graphene::net::retrigger_advertise_inventory_loop"); _retrigger_advertise_inventory_loop_promise->wait(); _retrigger_advertise_inventory_loop_promise.reset(); } @@ -1337,7 +1337,7 @@ namespace graphene { namespace net { namespace detail { uint32_t handshaking_timeout = _peer_inactivity_timeout; fc::time_point handshaking_disconnect_threshold = fc::time_point::now() - fc::seconds(handshaking_timeout); - for( const peer_connection_ptr handshaking_peer : _handshaking_connections ) + for( const peer_connection_ptr& handshaking_peer : _handshaking_connections ) if( handshaking_peer->connection_initiation_time < handshaking_disconnect_threshold && handshaking_peer->get_last_message_received_time() < handshaking_disconnect_threshold && handshaking_peer->get_last_message_sent_time() < handshaking_disconnect_threshold ) @@ -1702,13 +1702,13 @@ namespace graphene { namespace net { namespace detail { dlog("is_already_connected_to_id returning true because the peer is us"); return true; } - for (const peer_connection_ptr active_peer : _active_connections) + for (const peer_connection_ptr& active_peer : _active_connections) if (node_id == active_peer->node_id) { dlog("is_already_connected_to_id returning true because the peer is already in our active list"); return true; } - for (const peer_connection_ptr handshaking_peer : _handshaking_connections) + for (const peer_connection_ptr& handshaking_peer : _handshaking_connections) if (node_id == handshaking_peer->node_id) { dlog("is_already_connected_to_id returning true because the peer is already in our handshaking list"); @@ -2875,7 +2875,7 @@ namespace graphene { namespace net { namespace detail { item_id advertised_item_id(item_ids_inventory_message_received.item_type, item_hash); bool we_advertised_this_item_to_a_peer = false; bool we_requested_this_item_from_a_peer = false; - for (const peer_connection_ptr peer : _active_connections) + for (const peer_connection_ptr& peer : _active_connections) { if (peer->inventory_advertised_to_peer.find(advertised_item_id) != peer->inventory_advertised_to_peer.end()) { diff --git a/libraries/net/peer_connection.cpp b/libraries/net/peer_connection.cpp index 9b753e6c3..44a803d1c 100644 --- a/libraries/net/peer_connection.cpp +++ b/libraries/net/peer_connection.cpp @@ -24,8 +24,8 @@ #include #include #include -#include -#include +#include +#include #include #include diff --git a/libraries/plugins/account_history/include/graphene/account_history/account_history_plugin.hpp b/libraries/plugins/account_history/include/graphene/account_history/account_history_plugin.hpp index 784c7e457..843150131 100644 --- a/libraries/plugins/account_history/include/graphene/account_history/account_history_plugin.hpp +++ b/libraries/plugins/account_history/include/graphene/account_history/account_history_plugin.hpp @@ -93,28 +93,3 @@ class affiliate_reward_index : public secondary_index }; } } //graphene::account_history - -/*struct by_id; -struct by_seq; -struct by_op; -typedef boost::multi_index_container< - graphene::chain::account_transaction_history_object, - boost::multi_index::indexed_by< - boost::multi_index::ordered_unique< tag, member< object, object_id_type, &object::id > >, - boost::multi_index::ordered_unique< tag, - composite_key< account_transaction_history_object, - member< account_transaction_history_object, account_id_type, &account_transaction_history_object::account>, - member< account_transaction_history_object, uint32_t, &account_transaction_history_object::sequence> - > - >, - boost::multi_index::ordered_unique< tag, - composite_key< account_transaction_history_object, - member< account_transaction_history_object, account_id_type, &account_transaction_history_object::account>, - member< account_transaction_history_object, operation_history_id_type, &account_transaction_history_object::operation_id> - > - > - > -> account_transaction_history_multi_index_type; - -typedef graphene::account_history::generic_index account_transaction_history_index; -*/ diff --git a/libraries/plugins/affiliate_stats/affiliate_stats_plugin.cpp b/libraries/plugins/affiliate_stats/affiliate_stats_plugin.cpp index 03b546593..7ec59e823 100644 --- a/libraries/plugins/affiliate_stats/affiliate_stats_plugin.cpp +++ b/libraries/plugins/affiliate_stats/affiliate_stats_plugin.cpp @@ -152,8 +152,8 @@ static optional> get_accou { FC_ASSERT( dynamic_cast(&obj) ); const account_transaction_history_object& ath = static_cast(obj); - const operation_history_object& oho = db.get( ath.operation_id ); - if( oho.op.which() == operation::tag::value ) + const operation_history_object* oho = db.find( ath.operation_id ); + if( oho != nullptr && oho->op.which() == operation::tag::value ) return std::make_pair( ath.account, ath.operation_id ); return optional>(); } diff --git a/libraries/plugins/affiliate_stats/include/graphene/affiliate_stats/affiliate_stats_api.hpp b/libraries/plugins/affiliate_stats/include/graphene/affiliate_stats/affiliate_stats_api.hpp index 29c45d9f0..b9f4ac648 100644 --- a/libraries/plugins/affiliate_stats/include/graphene/affiliate_stats/affiliate_stats_api.hpp +++ b/libraries/plugins/affiliate_stats/include/graphene/affiliate_stats/affiliate_stats_api.hpp @@ -27,8 +27,8 @@ #include #include -#include -#include +#include +#include #include #include diff --git a/libraries/plugins/affiliate_stats/include/graphene/affiliate_stats/affiliate_stats_objects.hpp b/libraries/plugins/affiliate_stats/include/graphene/affiliate_stats/affiliate_stats_objects.hpp index 1dc70276a..a6d3a63c6 100644 --- a/libraries/plugins/affiliate_stats/include/graphene/affiliate_stats/affiliate_stats_objects.hpp +++ b/libraries/plugins/affiliate_stats/include/graphene/affiliate_stats/affiliate_stats_objects.hpp @@ -48,7 +48,7 @@ class app_reward_object : public graphene::db::abstract_object app_reward_id_type; +typedef object_id app_reward_id_type; struct by_asset; struct by_app_asset; @@ -86,7 +86,7 @@ class referral_reward_object : public graphene::db::abstract_object referral_reward_id_type; +typedef object_id referral_reward_id_type; struct by_referral_asset; typedef multi_index_container< diff --git a/libraries/plugins/bookie/bookie_api.cpp b/libraries/plugins/bookie/bookie_api.cpp index 9caa9c625..4269364d7 100644 --- a/libraries/plugins/bookie/bookie_api.cpp +++ b/libraries/plugins/bookie/bookie_api.cpp @@ -152,7 +152,7 @@ fc::variants bookie_api_impl::get_objects(const vector& ids) con result.reserve(ids.size()); std::transform(ids.begin(), ids.end(), std::back_inserter(result), - [this, &db](object_id_type id) -> fc::variant { + [&db](object_id_type id) -> fc::variant { switch (id.type()) { case event_id_type::type_id: diff --git a/libraries/plugins/bookie/bookie_plugin.cpp b/libraries/plugins/bookie/bookie_plugin.cpp index 5bc31f14c..a8c06a0d9 100644 --- a/libraries/plugins/bookie/bookie_plugin.cpp +++ b/libraries/plugins/bookie/bookie_plugin.cpp @@ -64,6 +64,8 @@ class persistent_bet_object_helper : public secondary_index public: virtual ~persistent_bet_object_helper() {} + using watched_index = primary_index; + virtual void object_inserted(const object& obj) override; //virtual void object_removed( const object& obj ) override; //virtual void about_to_modify( const object& before ) override; @@ -99,6 +101,8 @@ class persistent_betting_market_object_helper : public secondary_index public: virtual ~persistent_betting_market_object_helper() {} + using watched_index = primary_index; + virtual void object_inserted(const object& obj) override; //virtual void object_removed( const object& obj ) override; //virtual void about_to_modify( const object& before ) override; @@ -134,6 +138,8 @@ class persistent_betting_market_group_object_helper : public secondary_index public: virtual ~persistent_betting_market_group_object_helper() {} + using watched_index = primary_index; + virtual void object_inserted(const object& obj) override; //virtual void object_removed( const object& obj ) override; //virtual void about_to_modify( const object& before ) override; @@ -169,6 +175,8 @@ class persistent_event_object_helper : public secondary_index public: virtual ~persistent_event_object_helper() {} + using watched_index = primary_index; + virtual void object_inserted(const object& obj) override; //virtual void object_removed( const object& obj ) override; //virtual void about_to_modify( const object& before ) override; @@ -465,45 +473,31 @@ void bookie_plugin::plugin_set_program_options(boost::program_options::options_d void bookie_plugin::plugin_initialize(const boost::program_options::variables_map& options) { - ilog("bookie plugin: plugin_startup() begin"); + ilog("bookie plugin: plugin_initialize() begin"); database().force_slow_replays(); database().applied_block.connect( [&]( const signed_block& b){ my->on_block_applied(b); } ); database().changed_objects.connect([&](const vector& changed_object_ids, const fc::flat_set& impacted_accounts){ my->on_objects_changed(changed_object_ids); }); database().new_objects.connect([this](const vector& ids, const flat_set& impacted_accounts) { my->on_objects_new(ids); }); database().removed_objects.connect([this](const vector& ids, const vector& objs, const flat_set& impacted_accounts) { my->on_objects_removed(ids); }); - //auto event_index = database().add_index >(); database().add_index >(); database().add_index >(); database().add_index >(); - const primary_index& bet_object_idx = database().get_index_type >(); - primary_index& nonconst_bet_object_idx = const_cast&>(bet_object_idx); - detail::persistent_bet_object_helper* persistent_bet_object_helper_index = nonconst_bet_object_idx.add_secondary_index(); - persistent_bet_object_helper_index->set_plugin_instance(this); - - const primary_index& betting_market_object_idx = database().get_index_type >(); - primary_index& nonconst_betting_market_object_idx = const_cast&>(betting_market_object_idx); - detail::persistent_betting_market_object_helper* persistent_betting_market_object_helper_index = nonconst_betting_market_object_idx.add_secondary_index(); - persistent_betting_market_object_helper_index->set_plugin_instance(this); - - const primary_index& betting_market_group_object_idx = database().get_index_type >(); - primary_index& nonconst_betting_market_group_object_idx = const_cast&>(betting_market_group_object_idx); - detail::persistent_betting_market_group_object_helper* persistent_betting_market_group_object_helper_index = nonconst_betting_market_group_object_idx.add_secondary_index(); - persistent_betting_market_group_object_helper_index->set_plugin_instance(this); - - const primary_index& event_object_idx = database().get_index_type >(); - primary_index& nonconst_event_object_idx = const_cast&>(event_object_idx); - detail::persistent_event_object_helper* persistent_event_object_helper_index = nonconst_event_object_idx.add_secondary_index(); - persistent_event_object_helper_index->set_plugin_instance(this); - - ilog("bookie plugin: plugin_startup() end"); + ilog("bookie plugin: plugin_initialize() end"); } void bookie_plugin::plugin_startup() { ilog("bookie plugin: plugin_startup()"); + + // Register secondary indexes + database().add_secondary_index()->set_plugin_instance(this); + database().add_secondary_index()->set_plugin_instance(this); + database().add_secondary_index()->set_plugin_instance(this); + database().add_secondary_index()->set_plugin_instance(this); + my->fill_localized_event_strings(); } @@ -519,7 +513,8 @@ asset bookie_plugin::get_total_matched_bet_amount_for_betting_market_group(betti } std::vector bookie_plugin::get_events_containing_sub_string(const std::string& sub_string, const std::string& language) { - ilog("bookie plugin: get_events_containing_sub_string(${sub_string}, ${language})", (sub_string)(language)); + ilog("bookie plugin: get_events_containing_sub_string(${sub_string}, ${language})", + ("sub_string", sub_string)("language", language)); return my->get_events_containing_sub_string(sub_string, language); } diff --git a/libraries/plugins/bookie/include/graphene/bookie/bookie_api.hpp b/libraries/plugins/bookie/include/graphene/bookie/bookie_api.hpp index 36c8a64bf..0919fc62f 100644 --- a/libraries/plugins/bookie/include/graphene/bookie/bookie_api.hpp +++ b/libraries/plugins/bookie/include/graphene/bookie/bookie_api.hpp @@ -29,8 +29,8 @@ #include #include -#include -#include +#include +#include #include using namespace graphene::chain; diff --git a/libraries/plugins/bookie/include/graphene/bookie/bookie_objects.hpp b/libraries/plugins/bookie/include/graphene/bookie/bookie_objects.hpp index 1166ced34..c9e20b8e8 100644 --- a/libraries/plugins/bookie/include/graphene/bookie/bookie_objects.hpp +++ b/libraries/plugins/bookie/include/graphene/bookie/bookie_objects.hpp @@ -52,7 +52,7 @@ class persistent_event_object : public graphene::db::abstract_object persistent_event_id_type; +typedef object_id persistent_event_id_type; struct by_event_id; typedef multi_index_container< diff --git a/libraries/plugins/bookie/include/graphene/bookie/bookie_plugin.hpp b/libraries/plugins/bookie/include/graphene/bookie/bookie_plugin.hpp index 333b8babe..93889cb80 100644 --- a/libraries/plugins/bookie/include/graphene/bookie/bookie_plugin.hpp +++ b/libraries/plugins/bookie/include/graphene/bookie/bookie_plugin.hpp @@ -23,8 +23,10 @@ */ #pragma once -#include #include +#include + +#include #include diff --git a/libraries/plugins/debug_witness/include/graphene/debug_witness/debug_witness.hpp b/libraries/plugins/debug_witness/include/graphene/debug_witness/debug_witness.hpp index 907d26ae9..0965345ee 100644 --- a/libraries/plugins/debug_witness/include/graphene/debug_witness/debug_witness.hpp +++ b/libraries/plugins/debug_witness/include/graphene/debug_witness/debug_witness.hpp @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include diff --git a/libraries/plugins/delayed_node/delayed_node_plugin.cpp b/libraries/plugins/delayed_node/delayed_node_plugin.cpp index 71de7db5a..8ad490bcb 100644 --- a/libraries/plugins/delayed_node/delayed_node_plugin.cpp +++ b/libraries/plugins/delayed_node/delayed_node_plugin.cpp @@ -23,7 +23,7 @@ */ #include -#include +#include #include #include diff --git a/libraries/plugins/generate_genesis/generate_genesis.cpp b/libraries/plugins/generate_genesis/generate_genesis.cpp index 88da427e1..c526611f7 100644 --- a/libraries/plugins/generate_genesis/generate_genesis.cpp +++ b/libraries/plugins/generate_genesis/generate_genesis.cpp @@ -296,12 +296,12 @@ void generate_genesis_plugin::generate_snapshot() auto balance_iter = by_effective_balance_index.begin(); for (; balance_iter != by_effective_balance_index.end(); ++balance_iter) { - fc::uint128 share_drop_amount = total_amount_to_distribute.value; + fc::uint128_t share_drop_amount = total_amount_to_distribute.value; share_drop_amount *= balance_iter->get_effective_balance().value; share_drop_amount /= total_bts_balance.value; - if (!share_drop_amount.to_uint64()) + if (!share_drop_amount) break; // balances are decreasing, so every balance after will also round to zero - total_shares_dropped += share_drop_amount.to_uint64(); + total_shares_dropped += share_drop_amount; effective_total_bts_balance += balance_iter->get_effective_balance(); } @@ -312,10 +312,10 @@ void generate_genesis_plugin::generate_snapshot() do { --balance_iter; - fc::uint128 share_drop_amount = remaining_amount_to_distribute.value; + fc::uint128_t share_drop_amount = remaining_amount_to_distribute.value; share_drop_amount *= balance_iter->get_effective_balance().value; share_drop_amount /= bts_balance_remaining.value; - graphene::chain::share_type amount_distributed = share_drop_amount.to_uint64(); + graphene::chain::share_type amount_distributed = share_drop_amount; by_effective_balance_index.modify(balance_iter, [&](my_account_balance_object& balance_object) { balance_object.sharedrop += amount_distributed; diff --git a/libraries/plugins/market_history/include/graphene/market_history/market_history_plugin.hpp b/libraries/plugins/market_history/include/graphene/market_history/market_history_plugin.hpp index b4d1254ca..ad56e557e 100644 --- a/libraries/plugins/market_history/include/graphene/market_history/market_history_plugin.hpp +++ b/libraries/plugins/market_history/include/graphene/market_history/market_history_plugin.hpp @@ -123,7 +123,6 @@ typedef multi_index_container< > > order_history_multi_index_type; - typedef generic_index bucket_index; typedef generic_index history_index; diff --git a/libraries/plugins/market_history/market_history_plugin.cpp b/libraries/plugins/market_history/market_history_plugin.cpp index 48c215f0c..baa6c3c23 100644 --- a/libraries/plugins/market_history/market_history_plugin.cpp +++ b/libraries/plugins/market_history/market_history_plugin.cpp @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include diff --git a/libraries/plugins/peerplays_sidechain/bitcoin/bitcoin_transaction.cpp b/libraries/plugins/peerplays_sidechain/bitcoin/bitcoin_transaction.cpp index b4fde6dc0..986897ab8 100644 --- a/libraries/plugins/peerplays_sidechain/bitcoin/bitcoin_transaction.cpp +++ b/libraries/plugins/peerplays_sidechain/bitcoin/bitcoin_transaction.cpp @@ -179,7 +179,7 @@ void bitcoin_transaction_builder::add_out(payment_type type, int64_t amount, con const auto pubkey_bytes = bytes(pubkey.begin(), pubkey.begin() + pubkey.size()); add_out(type, amount, pubkey_bytes, front); } else { - const auto hash256 = fc::sha256::hash(pubkey.begin(), pubkey.size()); + const auto hash256 = fc::sha256::hash((const char*)pubkey.begin(), pubkey.size()); const auto hash160 = fc::ripemd160::hash(hash256.data(), hash256.data_size()); add_out(type, amount, bytes(hash160.data(), hash160.data() + hash160.data_size()), front); } diff --git a/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/bitcoin_address.hpp b/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/bitcoin_address.hpp index b9467e2fb..15308d4af 100644 --- a/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/bitcoin_address.hpp +++ b/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/bitcoin_address.hpp @@ -3,7 +3,7 @@ #include #include -using namespace graphene::chain; +using namespace graphene::protocol; namespace graphene { namespace peerplays_sidechain { namespace bitcoin { @@ -217,6 +217,7 @@ class btc_timelocked_one_or_weighted_multisig_address : public btc_one_or_weight private: void create_redeem_script(const fc::ecc::public_key &user_key_data, const std::vector> &keys_data); +public: uint32_t latency_; }; diff --git a/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/serialize.hpp b/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/serialize.hpp index 2f1dfffe3..b234f8a4b 100644 --- a/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/serialize.hpp +++ b/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/serialize.hpp @@ -186,7 +186,7 @@ inline void pack(Stream &s, const bitcoin_transaction &tx, bool with_witness = t pack(s, out); if (flags & 1) { - for (const auto in : tx.vin) { + for (const auto& in : tx.vin) { pack_compact_size(s, in.scriptWitness.size()); for (const auto &sc : in.scriptWitness) pack(s, sc); @@ -294,13 +294,13 @@ inline void pack_tx_witness_signature(Stream &s, const std::vector &script { fc::datastream ps; - for (const auto in : tx.vin) + for (const auto& in : tx.vin) pack(ps, in.prevout); std::vector vec(ps.tellp()); if (vec.size()) { fc::datastream ds(vec.data(), size_t(vec.size())); - for (const auto in : tx.vin) + for (const auto& in : tx.vin) pack(ds, in.prevout); } @@ -309,13 +309,13 @@ inline void pack_tx_witness_signature(Stream &s, const std::vector &script { fc::datastream ps; - for (const auto in : tx.vin) + for (const auto& in : tx.vin) pack(ps, in.nSequence); std::vector vec(ps.tellp()); if (vec.size()) { fc::datastream ds(vec.data(), size_t(vec.size())); - for (const auto in : tx.vin) + for (const auto& in : tx.vin) pack(ds, in.nSequence); } @@ -324,13 +324,13 @@ inline void pack_tx_witness_signature(Stream &s, const std::vector &script { fc::datastream ps; - for (const auto out : tx.vout) + for (const auto& out : tx.vout) pack(ps, out); std::vector vec(ps.tellp()); if (vec.size()) { fc::datastream ds(vec.data(), size_t(vec.size())); - for (const auto out : tx.vout) + for (const auto& out : tx.vout) pack(ds, out); } diff --git a/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/sign_bitcoin_transaction.hpp b/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/sign_bitcoin_transaction.hpp index 418085624..365cbe4dc 100644 --- a/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/sign_bitcoin_transaction.hpp +++ b/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/sign_bitcoin_transaction.hpp @@ -6,7 +6,7 @@ namespace graphene { namespace peerplays_sidechain { namespace bitcoin { -class bitcoin_transaction; +struct bitcoin_transaction; const secp256k1_context_t *btc_context(); diff --git a/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/types.hpp b/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/types.hpp index 0997194b3..659a568f1 100644 --- a/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/types.hpp +++ b/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/types.hpp @@ -5,14 +5,14 @@ #include #include -#include +#include namespace graphene { namespace peerplays_sidechain { namespace bitcoin { -class bitcoin_transaction; +struct bitcoin_transaction; using bytes = std::vector; -using accounts_keys = std::map; +using accounts_keys = std::map; using full_btc_transaction = std::pair; enum class payment_type { diff --git a/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/defs.hpp b/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/defs.hpp index 706182368..0abf7fe21 100644 --- a/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/defs.hpp +++ b/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/defs.hpp @@ -8,9 +8,9 @@ #include #include -#include -#include -#include +#include +#include +#include namespace graphene { namespace peerplays_sidechain { diff --git a/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/sidechain_net_handler_bitcoin.hpp b/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/sidechain_net_handler_bitcoin.hpp index eb218a4c3..c641d49f4 100644 --- a/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/sidechain_net_handler_bitcoin.hpp +++ b/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/sidechain_net_handler_bitcoin.hpp @@ -1,5 +1,7 @@ #pragma once +#include + #include #include diff --git a/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/sidechain_net_manager.hpp b/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/sidechain_net_manager.hpp index c2d40e143..64518dd93 100644 --- a/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/sidechain_net_manager.hpp +++ b/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/sidechain_net_manager.hpp @@ -1,6 +1,7 @@ #pragma once -#include +#include + #include #include diff --git a/libraries/plugins/peerplays_sidechain/peerplays_sidechain_plugin.cpp b/libraries/plugins/peerplays_sidechain/peerplays_sidechain_plugin.cpp index dcd5e401f..9101c6149 100644 --- a/libraries/plugins/peerplays_sidechain/peerplays_sidechain_plugin.cpp +++ b/libraries/plugins/peerplays_sidechain/peerplays_sidechain_plugin.cpp @@ -5,11 +5,12 @@ #include #include + #include -#include #include #include #include +#include #include #include diff --git a/libraries/plugins/peerplays_sidechain/sidechain_net_handler_bitcoin.cpp b/libraries/plugins/peerplays_sidechain/sidechain_net_handler_bitcoin.cpp index dc5e88afb..680b188c9 100644 --- a/libraries/plugins/peerplays_sidechain/sidechain_net_handler_bitcoin.cpp +++ b/libraries/plugins/peerplays_sidechain/sidechain_net_handler_bitcoin.cpp @@ -12,10 +12,10 @@ #include #include -#include #include -#include #include +#include +#include #include #include #include diff --git a/libraries/plugins/peerplays_sidechain/sidechain_net_handler_peerplays.cpp b/libraries/plugins/peerplays_sidechain/sidechain_net_handler_peerplays.cpp index ecf3cc00c..7316b4fcf 100644 --- a/libraries/plugins/peerplays_sidechain/sidechain_net_handler_peerplays.cpp +++ b/libraries/plugins/peerplays_sidechain/sidechain_net_handler_peerplays.cpp @@ -11,13 +11,11 @@ #include #include #include -#include #include -#include -#include -#include #include +#include +#include #include namespace graphene { namespace peerplays_sidechain { diff --git a/libraries/plugins/witness/include/graphene/witness/witness.hpp b/libraries/plugins/witness/include/graphene/witness/witness.hpp index f0c3ece73..9ec5a02ca 100644 --- a/libraries/plugins/witness/include/graphene/witness/witness.hpp +++ b/libraries/plugins/witness/include/graphene/witness/witness.hpp @@ -79,7 +79,6 @@ class witness_plugin : public graphene::app::plugin { boost::program_options::variables_map _options; bool _production_enabled = false; - bool _consecutive_production_enabled = false; uint32_t _required_witness_participation = 33 * GRAPHENE_1_PERCENT; uint32_t _production_skip_flags = graphene::chain::database::skip_nothing; diff --git a/libraries/protocol/CMakeLists.txt b/libraries/protocol/CMakeLists.txt new file mode 100644 index 000000000..a96e3bfee --- /dev/null +++ b/libraries/protocol/CMakeLists.txt @@ -0,0 +1,56 @@ +file(GLOB HEADERS "include/graphene/protocol/*.hpp") + +list(APPEND SOURCES account.cpp + assert.cpp + asset_ops.cpp + block.cpp + confidential.cpp + chain_parameters.cpp + fee_schedule.cpp + memo.cpp + proposal.cpp + transfer.cpp + vote.cpp + witness.cpp + address.cpp + asset.cpp + authority.cpp + special_authority.cpp + committee_member.cpp + custom.cpp + market.cpp + operations.cpp + pts_address.cpp + small_ops.cpp + transaction.cpp + types.cpp + withdraw_permission.cpp + worker.cpp + betting_market.cpp + event.cpp + event_group.cpp + lottery_ops.cpp + small_ops.cpp + sport.cpp + tournament.cpp + small_ops.cpp + custom_permission.cpp + custom_account_authority.cpp + offer.cpp + nft.cpp + account_role.cpp + ) + + +add_library( graphene_protocol ${SOURCES} ${HEADERS} ) +target_link_libraries( graphene_protocol fc ) +target_include_directories( graphene_protocol PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) + +install( TARGETS + graphene_protocol + + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib +) +install( FILES ${HEADERS} DESTINATION "include/graphene/protocol" ) diff --git a/libraries/chain/protocol/account.cpp b/libraries/protocol/account.cpp similarity index 87% rename from libraries/chain/protocol/account.cpp rename to libraries/protocol/account.cpp index 2405369a8..ad77e00af 100644 --- a/libraries/chain/protocol/account.cpp +++ b/libraries/protocol/account.cpp @@ -21,13 +21,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include -#include -#include +#include -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * Names must comply with the following grammar (RFC 1035): @@ -63,13 +61,6 @@ bool is_valid_name( const string& name ) { try { const size_t len = name.size(); - /** this condition will prevent witnesses from including new names before this time, but - * allow them after this time. This check can be removed from the code after HARDFORK_385_TIME - * has passed. - */ - if( fc::time_point::now() < fc::time_point(HARDFORK_385_TIME) ) - FC_ASSERT( len >= 3 ); - if( len < GRAPHENE_MIN_ACCOUNT_NAME_LENGTH ) { ilog( "."); @@ -329,16 +320,16 @@ void account_transfer_operation::validate()const } -} } // graphene::chain +} } // graphene::protocol -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::account_options ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::account_create_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::account_whitelist_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::account_update_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::account_upgrade_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::account_transfer_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::account_create_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::account_whitelist_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::account_update_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::account_upgrade_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::account_transfer_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::account_options ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::account_create_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::account_whitelist_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::account_update_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::account_upgrade_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::account_transfer_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::account_create_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::account_whitelist_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::account_update_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::account_upgrade_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::account_transfer_operation ) diff --git a/libraries/chain/protocol/account_role.cpp b/libraries/protocol/account_role.cpp similarity index 94% rename from libraries/chain/protocol/account_role.cpp rename to libraries/protocol/account_role.cpp index 1d71d6cc5..1f52f7d2e 100644 --- a/libraries/chain/protocol/account_role.cpp +++ b/libraries/protocol/account_role.cpp @@ -1,9 +1,9 @@ -#include -#include +#include +#include namespace graphene { - namespace chain + namespace protocol { void account_role_create_operation::validate() const @@ -57,5 +57,5 @@ namespace graphene return k.fee + calculate_data_fee(fc::raw::pack_size(*this), k.price_per_kbyte); } - } // namespace chain + } // namespace protocol } // namespace graphene diff --git a/libraries/chain/protocol/address.cpp b/libraries/protocol/address.cpp similarity index 70% rename from libraries/chain/protocol/address.cpp rename to libraries/protocol/address.cpp index f0edbd490..4069f430b 100644 --- a/libraries/chain/protocol/address.cpp +++ b/libraries/protocol/address.cpp @@ -21,17 +21,14 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include -#include -#include +#include +#include #include #include #include -namespace graphene { - namespace chain { - +namespace graphene { namespace protocol { address::address( const std::string& base58str ) { std::string prefix( GRAPHENE_ADDRESS_PREFIX ); @@ -71,7 +68,7 @@ namespace graphene { address::address( const fc::ecc::public_key& pub ) { auto dat = pub.serialize(); - addr = fc::ripemd160::hash( fc::sha512::hash( dat.data, sizeof( dat ) ) ); + addr = fc::ripemd160::hash( fc::sha512::hash( (char*) dat.data(), dat.size() ) ); } address::address( const pts_address& ptsaddr ) @@ -81,35 +78,36 @@ namespace graphene { address::address( const fc::ecc::public_key_data& pub ) { - addr = fc::ripemd160::hash( fc::sha512::hash( pub.data, sizeof( pub ) ) ); + addr = fc::ripemd160::hash( fc::sha512::hash( (char*) pub.data(), pub.size() ) ); } - address::address( const graphene::chain::public_key_type& pub ) + address::address( const graphene::protocol::public_key_type& pub ) { - addr = fc::ripemd160::hash( fc::sha512::hash( pub.key_data.data, sizeof( pub.key_data ) ) ); + addr = fc::ripemd160::hash( fc::sha512::hash( (char*) pub.key_data.data(), pub.key_data.size() ) ); } address::operator std::string()const { - fc::array bin_addr; - memcpy( (char*)&bin_addr, (char*)&addr, sizeof( addr ) ); - auto checksum = fc::ripemd160::hash( (char*)&addr, sizeof( addr ) ); - memcpy( ((char*)&bin_addr)+20, (char*)&checksum._hash[0], 4 ); - return GRAPHENE_ADDRESS_PREFIX + fc::to_base58( bin_addr.data, sizeof( bin_addr ) ); + std::array bin_addr; + static_assert( bin_addr.size() >= sizeof(addr) + 4, "" ); + memcpy( bin_addr.data(), addr.data(), sizeof(addr) ); + auto checksum = fc::ripemd160::hash( addr.data(), sizeof(addr) ); + memcpy( bin_addr.data() + 20, (char*)&checksum._hash[0], 4 ); + return GRAPHENE_ADDRESS_PREFIX + fc::to_base58( bin_addr.data(), bin_addr.size() ); } -} } // namespace graphene::chain +} } // namespace graphene::protocol namespace fc { - void to_variant( const graphene::chain::address& var, variant& vo, uint32_t max_depth ) + void to_variant( const graphene::protocol::address& var, variant& vo, uint32_t max_depth ) { vo = std::string(var); } - void from_variant( const variant& var, graphene::chain::address& vo, uint32_t max_depth ) + void from_variant( const variant& var, graphene::protocol::address& vo, uint32_t max_depth ) { - vo = graphene::chain::address( var.as_string() ); + vo = graphene::protocol::address( var.as_string() ); } } -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::address ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::address ) diff --git a/libraries/chain/protocol/assert.cpp b/libraries/protocol/assert.cpp similarity index 82% rename from libraries/chain/protocol/assert.cpp rename to libraries/protocol/assert.cpp index 5ce61e45d..2d5454e0b 100644 --- a/libraries/chain/protocol/assert.cpp +++ b/libraries/protocol/assert.cpp @@ -21,13 +21,13 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include -#include -#include +#include +#include +#include #include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { bool account_name_eq_lit_predicate::validate()const { @@ -66,7 +66,7 @@ share_type assert_operation::calculate_fee(const fee_parameters_type& k)const return k.fee * predicates.size(); } -} } // namespace graphene::chain +} } // namespace graphene::protocol -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::assert_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::assert_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::assert_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::assert_operation ) diff --git a/libraries/chain/protocol/asset.cpp b/libraries/protocol/asset.cpp similarity index 95% rename from libraries/chain/protocol/asset.cpp rename to libraries/protocol/asset.cpp index 525e193b2..b3998f7b5 100644 --- a/libraries/chain/protocol/asset.cpp +++ b/libraries/protocol/asset.cpp @@ -21,12 +21,15 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include +#include #include #include #include +#include -namespace graphene { namespace chain { +#include + +namespace graphene { namespace protocol { typedef boost::multiprecision::uint128_t uint128_t; typedef boost::multiprecision::int128_t int128_t; @@ -206,8 +209,8 @@ const int64_t scaled_precision_lut[19] = p10< 16 >::v, p10< 17 >::v, p10< 18 >::v }; -} } // graphene::chain +} } // graphene::protocol -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::price ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::price_feed ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::price ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::price_feed ) diff --git a/libraries/chain/protocol/asset_ops.cpp b/libraries/protocol/asset_ops.cpp similarity index 75% rename from libraries/chain/protocol/asset_ops.cpp rename to libraries/protocol/asset_ops.cpp index 5dfd09ee8..614d54b2c 100644 --- a/libraries/chain/protocol/asset_ops.cpp +++ b/libraries/protocol/asset_ops.cpp @@ -21,12 +21,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include -#include +#include #include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * Valid symbols can contain [A-Z0-9], and '.' @@ -289,31 +288,31 @@ void lottery_asset_options::validate() const FC_ASSERT( total == GRAPHENE_100_PERCENT, "distribution amount not equals GRAPHENE_100_PERCENT" ); } -} } // namespace graphene::chain - -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_options ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::bitasset_options ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_create_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_global_settle_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_settle_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_fund_fee_pool_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_claim_fees_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_update_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_update_bitasset_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_update_feed_producers_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_publish_feed_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_issue_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_reserve_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_create_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_global_settle_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_settle_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_settle_cancel_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_fund_fee_pool_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_claim_fees_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_dividend_distribution_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_update_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_update_bitasset_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_update_feed_producers_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_publish_feed_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_issue_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_reserve_operation ) +} } // namespace graphene::protocol + +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_options ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::bitasset_options ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_create_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_global_settle_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_settle_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_fund_fee_pool_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_claim_fees_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_update_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_update_bitasset_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_update_feed_producers_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_publish_feed_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_issue_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_reserve_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_create_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_global_settle_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_settle_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_settle_cancel_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_fund_fee_pool_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_claim_fees_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_dividend_distribution_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_update_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_update_bitasset_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_update_feed_producers_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_publish_feed_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_issue_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_reserve_operation ) diff --git a/libraries/chain/protocol/authority.cpp b/libraries/protocol/authority.cpp similarity index 87% rename from libraries/chain/protocol/authority.cpp rename to libraries/protocol/authority.cpp index 6cfed2ecb..c3fd44dd3 100644 --- a/libraries/chain/protocol/authority.cpp +++ b/libraries/protocol/authority.cpp @@ -22,10 +22,11 @@ * THE SOFTWARE. */ -#include +#include + #include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { void add_authority_accounts( flat_set& result, @@ -36,6 +37,6 @@ void add_authority_accounts( result.insert( item.first ); } -} } // graphene::chain +} } // graphene::protocol -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::authority ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::authority ) diff --git a/libraries/chain/protocol/betting_market.cpp b/libraries/protocol/betting_market.cpp similarity index 94% rename from libraries/chain/protocol/betting_market.cpp rename to libraries/protocol/betting_market.cpp index 99712f9cb..a27b3dc71 100644 --- a/libraries/chain/protocol/betting_market.cpp +++ b/libraries/protocol/betting_market.cpp @@ -21,9 +21,9 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { void betting_market_rules_create_operation::validate() const { @@ -77,5 +77,5 @@ void bet_cancel_operation::validate() const -} } // graphene::chain +} } // graphene::protocol diff --git a/libraries/chain/protocol/block.cpp b/libraries/protocol/block.cpp similarity index 83% rename from libraries/chain/protocol/block.cpp rename to libraries/protocol/block.cpp index 725ea3a78..3b96579cc 100644 --- a/libraries/chain/protocol/block.cpp +++ b/libraries/protocol/block.cpp @@ -21,13 +21,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include -#include +#include #include -#include #include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { digest_type block_header::digest()const { return digest_type::hash(*this); @@ -35,13 +33,13 @@ namespace graphene { namespace chain { uint32_t block_header::num_from_id(const block_id_type& id) { - return fc::endian_reverse_u32(id._hash[0]); + return boost::endian::endian_reverse(id._hash[0].value()); } block_id_type signed_block_header::id()const { auto tmp = fc::sha224::hash( *this ); - tmp._hash[0] = fc::endian_reverse_u32(block_num()); // store the block num in the ID, 160 bits is plenty for the hash + tmp._hash[0] = boost::endian::endian_reverse(block_num()); // store the block num in the ID, 160 bits is plenty for the hash static_assert( sizeof(tmp._hash[0]) == 4, "should be 4 bytes" ); block_id_type result; memcpy(result._hash, tmp._hash, std::min(sizeof(result), sizeof(tmp))); @@ -92,6 +90,6 @@ namespace graphene { namespace chain { } } -GRAPHENE_EXTERNAL_SERIALIZATION(/*not extern*/, graphene::chain::block_header) -GRAPHENE_EXTERNAL_SERIALIZATION(/*not extern*/, graphene::chain::signed_block_header) -GRAPHENE_EXTERNAL_SERIALIZATION(/*not extern*/, graphene::chain::signed_block) +GRAPHENE_EXTERNAL_SERIALIZATION(/*not extern*/, graphene::protocol::block_header) +GRAPHENE_EXTERNAL_SERIALIZATION(/*not extern*/, graphene::protocol::signed_block_header) +GRAPHENE_EXTERNAL_SERIALIZATION(/*not extern*/, graphene::protocol::signed_block) diff --git a/libraries/chain/protocol/chain_parameters.cpp b/libraries/protocol/chain_parameters.cpp similarity index 96% rename from libraries/chain/protocol/chain_parameters.cpp rename to libraries/protocol/chain_parameters.cpp index a904b0e31..9e4fd440a 100644 --- a/libraries/chain/protocol/chain_parameters.cpp +++ b/libraries/protocol/chain_parameters.cpp @@ -1,7 +1,7 @@ -#include -#include +#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { chain_parameters::chain_parameters() { current_fees = std::make_shared(); } diff --git a/libraries/chain/protocol/committee_member.cpp b/libraries/protocol/committee_member.cpp similarity index 65% rename from libraries/chain/protocol/committee_member.cpp rename to libraries/protocol/committee_member.cpp index 3ce62783a..3972a44a1 100644 --- a/libraries/chain/protocol/committee_member.cpp +++ b/libraries/protocol/committee_member.cpp @@ -21,12 +21,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include -#include +#include +#include #include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { void committee_member_create_operation::validate()const { @@ -47,11 +47,11 @@ void committee_member_update_global_parameters_operation::validate() const new_parameters.validate(); } -} } // graphene::chain +} } // graphene::protocol -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::committee_member_create_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::committee_member_update_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::committee_member_update_global_parameters_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::committee_member_create_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::committee_member_update_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::committee_member_update_global_parameters_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::committee_member_create_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::committee_member_update_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::committee_member_update_global_parameters_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::committee_member_create_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::committee_member_update_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::committee_member_update_global_parameters_operation ) diff --git a/libraries/chain/protocol/confidential.cpp b/libraries/protocol/confidential.cpp similarity index 86% rename from libraries/chain/protocol/confidential.cpp rename to libraries/protocol/confidential.cpp index 2e8fbc68b..ce81b43b1 100644 --- a/libraries/chain/protocol/confidential.cpp +++ b/libraries/protocol/confidential.cpp @@ -21,14 +21,13 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include -#include -#include + +#include #include #include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { void transfer_to_blind_operation::validate()const { @@ -155,11 +154,11 @@ stealth_confirmation::stealth_confirmation( const std::string& base58 ) *this = fc::raw::unpack( fc::from_base58( base58 ) ); } -} } // graphene::chain +} } // graphene::protocol -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::transfer_to_blind_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::transfer_from_blind_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::blind_transfer_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::transfer_to_blind_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::transfer_from_blind_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::blind_transfer_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::transfer_to_blind_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::transfer_from_blind_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::blind_transfer_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::transfer_to_blind_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::transfer_from_blind_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::blind_transfer_operation ) diff --git a/libraries/chain/protocol/custom.cpp b/libraries/protocol/custom.cpp similarity index 82% rename from libraries/chain/protocol/custom.cpp rename to libraries/protocol/custom.cpp index 72f8dd44a..d4355014a 100644 --- a/libraries/chain/protocol/custom.cpp +++ b/libraries/protocol/custom.cpp @@ -21,11 +21,9 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include +#include -#include - -namespace graphene { namespace chain { +namespace graphene { namespace protocol { void custom_operation::validate()const { @@ -38,5 +36,5 @@ share_type custom_operation::calculate_fee(const fee_parameters_type& k)const } } -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::custom_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::custom_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::custom_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::custom_operation ) diff --git a/libraries/chain/protocol/custom_account_authority.cpp b/libraries/protocol/custom_account_authority.cpp similarity index 92% rename from libraries/chain/protocol/custom_account_authority.cpp rename to libraries/protocol/custom_account_authority.cpp index a74234d77..eaf939bc4 100644 --- a/libraries/chain/protocol/custom_account_authority.cpp +++ b/libraries/protocol/custom_account_authority.cpp @@ -1,9 +1,9 @@ -#include -#include +#include +#include namespace graphene { -namespace chain +namespace protocol { void custom_account_authority_create_operation::validate() const @@ -39,5 +39,5 @@ share_type custom_account_authority_create_operation::calculate_fee(const fee_pa return k.fee + calculate_data_fee( fc::raw::pack_size(*this), k.price_per_kbyte ); } -} // namespace chain +} // namespace protocol } // namespace graphene diff --git a/libraries/chain/protocol/custom_permission.cpp b/libraries/protocol/custom_permission.cpp similarity index 95% rename from libraries/chain/protocol/custom_permission.cpp rename to libraries/protocol/custom_permission.cpp index c0919cbde..5084bf0b1 100644 --- a/libraries/chain/protocol/custom_permission.cpp +++ b/libraries/protocol/custom_permission.cpp @@ -1,9 +1,9 @@ -#include -#include +#include +#include namespace graphene { -namespace chain +namespace protocol { bool is_valid_permission_name(const string &name) @@ -81,5 +81,5 @@ share_type custom_permission_create_operation::calculate_fee(const fee_parameter return k.fee + calculate_data_fee( fc::raw::pack_size(*this), k.price_per_kbyte ); } -} // namespace chain +} // namespace protocol } // namespace graphene diff --git a/libraries/chain/protocol/event.cpp b/libraries/protocol/event.cpp similarity index 93% rename from libraries/chain/protocol/event.cpp rename to libraries/protocol/event.cpp index 730e3fb64..7b492270c 100644 --- a/libraries/chain/protocol/event.cpp +++ b/libraries/protocol/event.cpp @@ -21,9 +21,9 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { void event_create_operation::validate() const { @@ -40,5 +40,5 @@ void event_update_status_operation::validate() const FC_ASSERT( fee.amount >= 0 ); } -} } // graphene::chain +} } // graphene::protocol diff --git a/libraries/chain/protocol/event_group.cpp b/libraries/protocol/event_group.cpp similarity index 92% rename from libraries/chain/protocol/event_group.cpp rename to libraries/protocol/event_group.cpp index 39fe0f3c5..dfa0a9045 100644 --- a/libraries/chain/protocol/event_group.cpp +++ b/libraries/protocol/event_group.cpp @@ -21,9 +21,9 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { void event_group_create_operation::validate() const { @@ -40,5 +40,5 @@ void event_group_delete_operation::validate() const FC_ASSERT( fee.amount >= 0 ); } -} } // graphene::chain +} } // graphene::protocol diff --git a/libraries/chain/protocol/fee_schedule.cpp b/libraries/protocol/fee_schedule.cpp similarity index 94% rename from libraries/chain/protocol/fee_schedule.cpp rename to libraries/protocol/fee_schedule.cpp index 122136eae..3e3330290 100644 --- a/libraries/chain/protocol/fee_schedule.cpp +++ b/libraries/protocol/fee_schedule.cpp @@ -22,13 +22,14 @@ * THE SOFTWARE. */ #include -#include +#include #include +#include #define MAX_FEE_STABILIZATION_ITERATION 4 -namespace graphene { namespace chain { +namespace graphene { namespace protocol { fee_schedule::fee_schedule() { @@ -116,14 +117,14 @@ namespace graphene { namespace chain { auto itr = parameters.find(params); if( itr != parameters.end() ) params = *itr; auto base_value = op.visit( calc_fee_visitor( params ) ); - auto scaled = fc::uint128(base_value) * scale; + auto scaled = fc::uint128_t(base_value) * scale; scaled /= GRAPHENE_100_PERCENT; FC_ASSERT( scaled <= GRAPHENE_MAX_SHARE_SUPPLY ); //idump( (base_value)(scaled)(core_exchange_rate) ); - auto result = asset( scaled.to_uint64(), asset_id_type(0) ) * core_exchange_rate; + auto result = asset( scaled, asset_id_type(0) ) * core_exchange_rate; //FC_ASSERT( result * core_exchange_rate >= asset( scaled.to_uint64()) ); - while( result * core_exchange_rate < asset( scaled.to_uint64()) ) + while( result * core_exchange_rate < asset(scaled) ) result.amount++; FC_ASSERT( result.amount <= GRAPHENE_MAX_SHARE_SUPPLY ); @@ -194,6 +195,6 @@ namespace graphene { namespace chain { } } -} } // graphene::chain +} } // graphene::protocol -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::fee_schedule ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::fee_schedule ) diff --git a/libraries/chain/include/graphene/chain/protocol/README.md b/libraries/protocol/include/graphene/protocol/README.md similarity index 100% rename from libraries/chain/include/graphene/chain/protocol/README.md rename to libraries/protocol/include/graphene/protocol/README.md diff --git a/libraries/chain/include/graphene/chain/protocol/account.hpp b/libraries/protocol/include/graphene/protocol/account.hpp similarity index 79% rename from libraries/chain/include/graphene/chain/protocol/account.hpp rename to libraries/protocol/include/graphene/protocol/account.hpp index 50ccb8aef..86a4772ab 100644 --- a/libraries/chain/include/graphene/chain/protocol/account.hpp +++ b/libraries/protocol/include/graphene/protocol/account.hpp @@ -22,14 +22,15 @@ * THE SOFTWARE. */ #pragma once -#include -#include -#include -#include -#include -#include -namespace graphene { namespace chain { +#include +#include +#include +#include +#include +#include + +namespace graphene { namespace protocol { bool is_valid_name( const string& s ); bool is_cheap_name( const string& n ); @@ -287,49 +288,50 @@ namespace graphene { namespace chain { void validate()const; }; -} } // graphene::chain +} } // graphene::protocol -FC_REFLECT(graphene::chain::account_options, (memo_key)(voting_account)(num_witness)(num_committee)(votes)(extensions)) -// FC_REFLECT_TYPENAME( graphene::chain::account_whitelist_operation::account_listing) -FC_REFLECT_ENUM( graphene::chain::account_whitelist_operation::account_listing, +FC_REFLECT(graphene::protocol::account_options, (memo_key)(voting_account)(num_witness)(num_committee)(votes)(extensions)) +FC_REFLECT_ENUM( graphene::protocol::account_whitelist_operation::account_listing, (no_listing)(white_listed)(black_listed)(white_and_black_listed)) -FC_REFLECT_ENUM( graphene::chain::app_tag, (bookie)(rps) ) -FC_REFLECT( graphene::chain::affiliate_reward_distribution, (_dist) ); -FC_REFLECT( graphene::chain::affiliate_reward_distributions, (_dists) ); +FC_REFLECT_ENUM( graphene::protocol::app_tag, (bookie)(rps) ) +FC_REFLECT( graphene::protocol::affiliate_reward_distribution, (_dist) ); +FC_REFLECT( graphene::protocol::affiliate_reward_distributions, (_dists) ); -FC_REFLECT(graphene::chain::account_create_operation::ext, (null_ext)(owner_special_authority)(active_special_authority)(buyback_options) ) -FC_REFLECT( graphene::chain::account_create_operation, +FC_REFLECT(graphene::protocol::account_create_operation::ext, (null_ext)(owner_special_authority)(active_special_authority)(buyback_options)(affiliate_distributions) ) +FC_REFLECT_TYPENAME(graphene::protocol::extension) +FC_REFLECT( graphene::protocol::account_create_operation, (fee)(registrar) (referrer)(referrer_percent) (name)(owner)(active)(options)(extensions) ) -FC_REFLECT(graphene::chain::account_update_operation::ext, (null_ext)(owner_special_authority)(active_special_authority)(update_last_voting_time) ) -FC_REFLECT( graphene::chain::account_update_operation, +FC_REFLECT(graphene::protocol::account_update_operation::ext, (null_ext)(owner_special_authority)(active_special_authority)(update_last_voting_time) ) +FC_REFLECT_TYPENAME(graphene::protocol::extension) +FC_REFLECT( graphene::protocol::account_update_operation, (fee)(account)(owner)(active)(new_options)(extensions) ) -FC_REFLECT( graphene::chain::account_upgrade_operation, +FC_REFLECT( graphene::protocol::account_upgrade_operation, (fee)(account_to_upgrade)(upgrade_to_lifetime_member)(extensions) ) -FC_REFLECT( graphene::chain::account_whitelist_operation, (fee)(authorizing_account)(account_to_list)(new_listing)(extensions)) - -FC_REFLECT( graphene::chain::account_create_operation::fee_parameters_type, (basic_fee)(premium_fee)(price_per_kbyte) ) -FC_REFLECT( graphene::chain::account_whitelist_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::account_update_operation::fee_parameters_type, (fee)(price_per_kbyte) ) -FC_REFLECT( graphene::chain::account_upgrade_operation::fee_parameters_type, (membership_annual_fee)(membership_lifetime_fee) ) -FC_REFLECT( graphene::chain::account_transfer_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::account_transfer_operation, (fee)(account_id)(new_owner)(extensions) ) - -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::account_options ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::account_create_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::account_whitelist_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::account_update_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::account_upgrade_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::account_transfer_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::account_create_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::account_whitelist_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::account_update_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::account_upgrade_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::account_transfer_operation ) +FC_REFLECT( graphene::protocol::account_whitelist_operation, (fee)(authorizing_account)(account_to_list)(new_listing)(extensions)) + +FC_REFLECT( graphene::protocol::account_create_operation::fee_parameters_type, (basic_fee)(premium_fee)(price_per_kbyte) ) +FC_REFLECT( graphene::protocol::account_whitelist_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::account_update_operation::fee_parameters_type, (fee)(price_per_kbyte) ) +FC_REFLECT( graphene::protocol::account_upgrade_operation::fee_parameters_type, (membership_annual_fee)(membership_lifetime_fee) ) +FC_REFLECT( graphene::protocol::account_transfer_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::account_transfer_operation, (fee)(account_id)(new_owner)(extensions) ) + +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::account_options ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::account_create_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::account_whitelist_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::account_update_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::account_upgrade_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::account_transfer_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::account_create_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::account_whitelist_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::account_update_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::account_upgrade_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::account_transfer_operation ) diff --git a/libraries/chain/include/graphene/chain/protocol/account_role.hpp b/libraries/protocol/include/graphene/protocol/account_role.hpp similarity index 71% rename from libraries/chain/include/graphene/chain/protocol/account_role.hpp rename to libraries/protocol/include/graphene/protocol/account_role.hpp index 6a532cb7d..62c302f7f 100644 --- a/libraries/chain/include/graphene/chain/protocol/account_role.hpp +++ b/libraries/protocol/include/graphene/protocol/account_role.hpp @@ -1,10 +1,10 @@ #pragma once -#include -#include +#include +#include namespace graphene { - namespace chain + namespace protocol { struct account_role_create_operation : public base_operation @@ -70,13 +70,13 @@ namespace graphene void validate() const; share_type calculate_fee(const fee_parameters_type &k) const { return k.fee; } }; - } // namespace chain + } // namespace protocol } // namespace graphene -FC_REFLECT(graphene::chain::account_role_create_operation::fee_parameters_type, (fee)(price_per_kbyte)) -FC_REFLECT(graphene::chain::account_role_update_operation::fee_parameters_type, (fee)(price_per_kbyte)) -FC_REFLECT(graphene::chain::account_role_delete_operation::fee_parameters_type, (fee)) +FC_REFLECT(graphene::protocol::account_role_create_operation::fee_parameters_type, (fee)(price_per_kbyte)) +FC_REFLECT(graphene::protocol::account_role_update_operation::fee_parameters_type, (fee)(price_per_kbyte)) +FC_REFLECT(graphene::protocol::account_role_delete_operation::fee_parameters_type, (fee)) -FC_REFLECT(graphene::chain::account_role_create_operation, (fee)(owner)(name)(metadata)(allowed_operations)(whitelisted_accounts)(valid_to)(extensions)) -FC_REFLECT(graphene::chain::account_role_update_operation, (fee)(owner)(account_role_id)(name)(metadata)(allowed_operations_to_add)(allowed_operations_to_remove)(accounts_to_add)(accounts_to_remove)(valid_to)(extensions)) -FC_REFLECT(graphene::chain::account_role_delete_operation, (fee)(owner)(account_role_id)(owner)(extensions)) +FC_REFLECT(graphene::protocol::account_role_create_operation, (fee)(owner)(name)(metadata)(allowed_operations)(whitelisted_accounts)(valid_to)(extensions)) +FC_REFLECT(graphene::protocol::account_role_update_operation, (fee)(owner)(account_role_id)(name)(metadata)(allowed_operations_to_add)(allowed_operations_to_remove)(accounts_to_add)(accounts_to_remove)(valid_to)(extensions)) +FC_REFLECT(graphene::protocol::account_role_delete_operation, (fee)(owner)(account_role_id)(owner)(extensions)) diff --git a/libraries/chain/include/graphene/chain/protocol/address.hpp b/libraries/protocol/include/graphene/protocol/address.hpp similarity index 77% rename from libraries/chain/include/graphene/chain/protocol/address.hpp rename to libraries/protocol/include/graphene/protocol/address.hpp index 8bf0fab66..48a3cc530 100644 --- a/libraries/chain/include/graphene/chain/protocol/address.hpp +++ b/libraries/protocol/include/graphene/protocol/address.hpp @@ -23,16 +23,14 @@ */ #pragma once -#include -#include -#include +#include +#include #include #include -namespace graphene { namespace chain { - - struct public_key_type; +namespace graphene { namespace protocol { + struct pts_address; /** * @brief a 160 bit hash of a public key @@ -70,28 +68,14 @@ namespace graphene { namespace chain { inline bool operator != ( const address& a, const address& b ) { return a.addr != b.addr; } inline bool operator < ( const address& a, const address& b ) { return a.addr < b.addr; } -} } // namespace graphene::chain +} } // namespace graphene::protocol namespace fc { - void to_variant( const graphene::chain::address& var, fc::variant& vo, uint32_t max_depth = 1 ); - void from_variant( const fc::variant& var, graphene::chain::address& vo, uint32_t max_depth = 1 ); -} - -namespace std -{ - template<> - struct hash - { - public: - size_t operator()(const graphene::chain::address &a) const - { - return (uint64_t(a.addr._hash[0])<<32) | uint64_t( a.addr._hash[0] ); - } - }; + void to_variant( const graphene::protocol::address& var, fc::variant& vo, uint32_t max_depth = 1 ); + void from_variant( const fc::variant& var, graphene::protocol::address& vo, uint32_t max_depth = 1 ); } -#include -FC_REFLECT( graphene::chain::address, (addr) ) +FC_REFLECT( graphene::protocol::address, (addr) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::address ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::address ) diff --git a/libraries/chain/include/graphene/chain/protocol/affiliate.hpp b/libraries/protocol/include/graphene/protocol/affiliate.hpp similarity index 82% rename from libraries/chain/include/graphene/chain/protocol/affiliate.hpp rename to libraries/protocol/include/graphene/protocol/affiliate.hpp index b2c3ee880..15509ee06 100644 --- a/libraries/chain/include/graphene/chain/protocol/affiliate.hpp +++ b/libraries/protocol/include/graphene/protocol/affiliate.hpp @@ -22,11 +22,13 @@ * THE SOFTWARE. */ #pragma once -#include -#include -#include -namespace graphene { namespace chain { +#include +#include +#include +#include + +namespace graphene { namespace protocol { /** * Virtual op generated when an affiliate receives payout. @@ -83,10 +85,10 @@ namespace graphene { namespace chain { { return 0; } }; -} } // graphene::chain +} } // graphene::protocol -FC_REFLECT( graphene::chain::affiliate_payout_operation::fee_parameters_type, ) -FC_REFLECT( graphene::chain::affiliate_referral_payout_operation::fee_parameters_type, ) +FC_REFLECT( graphene::protocol::affiliate_payout_operation::fee_parameters_type, ) +FC_REFLECT( graphene::protocol::affiliate_referral_payout_operation::fee_parameters_type, ) -FC_REFLECT( graphene::chain::affiliate_payout_operation, (fee)(affiliate)(tag)(payout) ) -FC_REFLECT( graphene::chain::affiliate_referral_payout_operation, (fee)(player)(payout) ) +FC_REFLECT( graphene::protocol::affiliate_payout_operation, (fee)(affiliate)(tag)(payout) ) +FC_REFLECT( graphene::protocol::affiliate_referral_payout_operation, (fee)(player)(payout) ) diff --git a/libraries/chain/include/graphene/chain/protocol/assert.hpp b/libraries/protocol/include/graphene/protocol/assert.hpp similarity index 80% rename from libraries/chain/include/graphene/chain/protocol/assert.hpp rename to libraries/protocol/include/graphene/protocol/assert.hpp index ce7588623..e12de0389 100644 --- a/libraries/chain/include/graphene/chain/protocol/assert.hpp +++ b/libraries/protocol/include/graphene/protocol/assert.hpp @@ -22,10 +22,11 @@ * THE SOFTWARE. */ #pragma once -#include -#include -namespace graphene { namespace chain { +#include +#include + +namespace graphene { namespace protocol { /** * Used to verify that account_id->name is equal to the given string literal. @@ -104,14 +105,14 @@ namespace graphene { namespace chain { share_type calculate_fee(const fee_parameters_type& k)const; }; -} } // graphene::chain +} } // graphene::protocol -FC_REFLECT( graphene::chain::assert_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::account_name_eq_lit_predicate, (account_id)(name) ) -FC_REFLECT( graphene::chain::asset_symbol_eq_lit_predicate, (asset_id)(symbol) ) -FC_REFLECT( graphene::chain::block_id_predicate, (id) ) -FC_REFLECT_TYPENAME( graphene::chain::predicate ) -FC_REFLECT( graphene::chain::assert_operation, (fee)(fee_paying_account)(predicates)(required_auths)(extensions) ) +FC_REFLECT( graphene::protocol::assert_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::account_name_eq_lit_predicate, (account_id)(name) ) +FC_REFLECT( graphene::protocol::asset_symbol_eq_lit_predicate, (asset_id)(symbol) ) +FC_REFLECT( graphene::protocol::block_id_predicate, (id) ) +FC_REFLECT_TYPENAME( graphene::protocol::predicate ) +FC_REFLECT( graphene::protocol::assert_operation, (fee)(fee_paying_account)(predicates)(required_auths)(extensions) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::assert_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::assert_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::assert_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::assert_operation ) diff --git a/libraries/chain/include/graphene/chain/protocol/asset.hpp b/libraries/protocol/include/graphene/protocol/asset.hpp similarity index 94% rename from libraries/chain/include/graphene/chain/protocol/asset.hpp rename to libraries/protocol/include/graphene/protocol/asset.hpp index 60bd3cd0b..726310213 100644 --- a/libraries/chain/include/graphene/chain/protocol/asset.hpp +++ b/libraries/protocol/include/graphene/protocol/asset.hpp @@ -22,10 +22,9 @@ * THE SOFTWARE. */ #pragma once -#include -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { extern const int64_t scaled_precision_lut[]; @@ -211,14 +210,14 @@ namespace graphene { namespace chain { } } -FC_REFLECT( graphene::chain::asset, (amount)(asset_id) ) -FC_REFLECT( graphene::chain::price, (base)(quote) ) +FC_REFLECT( graphene::protocol::asset, (amount)(asset_id) ) +FC_REFLECT( graphene::protocol::price, (base)(quote) ) #define GRAPHENE_PRICE_FEED_FIELDS (settlement_price)(maintenance_collateral_ratio)(maximum_short_squeeze_ratio) \ (core_exchange_rate) -FC_REFLECT( graphene::chain::price_feed, GRAPHENE_PRICE_FEED_FIELDS ) +FC_REFLECT( graphene::protocol::price_feed, GRAPHENE_PRICE_FEED_FIELDS ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::price ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::price_feed ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::price ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::price_feed ) diff --git a/libraries/chain/include/graphene/chain/protocol/asset_ops.hpp b/libraries/protocol/include/graphene/protocol/asset_ops.hpp similarity index 82% rename from libraries/chain/include/graphene/chain/protocol/asset_ops.hpp rename to libraries/protocol/include/graphene/protocol/asset_ops.hpp index ae5dc2118..836f29d91 100644 --- a/libraries/chain/include/graphene/chain/protocol/asset_ops.hpp +++ b/libraries/protocol/include/graphene/protocol/asset_ops.hpp @@ -22,12 +22,11 @@ * THE SOFTWARE. */ #pragma once -#include -#include - -namespace graphene { namespace chain { - class database; +#include +#include +#include +namespace graphene { namespace protocol { bool is_valid_symbol( const string& symbol ); struct benefactor { @@ -152,13 +151,13 @@ namespace graphene { namespace chain { /// the options are updated again. fc::optional payout_interval; /// Each dividend distribution incurs a fee that is based on the number of accounts - /// that hold the dividend asset, not as a percentage of the amount paid out. + /// that hold the dividend asset, not as a percentage of the amount paid out. /// This parameter prevents assets from being distributed unless the fee is less than /// the percentage here, to prevent a slow trickle of deposits to the account from being /// completely consumed. /// In other words, if you set this parameter to 10% and the fees work out to 100 BTS /// to share out, balances in the dividend distribution accounts will not be shared out - /// if the balance is less than 10000 BTS. + /// if the balance is less than 10000 BTS. uint64_t minimum_fee_percentage; /// Normally, pending dividend payments are calculated each maintenance interval in @@ -171,7 +170,7 @@ namespace graphene { namespace chain { /// /// Payouts will always occur at the next payout time whether or not it falls on a /// multiple of the distribution interval, and the timer on the distribution interval - /// are reset at payout time. So if you have the distribution interval at three days + /// are reset at payout time. So if you have the distribution interval at three days /// and the payout interval at one week, payouts will occur at days 3, 6, 7, 10, 13, 14... fc::optional minimum_distribution_interval; @@ -188,7 +187,7 @@ namespace graphene { namespace chain { */ struct asset_create_operation : public base_operation { - struct fee_parameters_type { + struct fee_parameters_type { uint64_t symbol3 = 500000 * GRAPHENE_BLOCKCHAIN_PRECISION; uint64_t symbol4 = 300000 * GRAPHENE_BLOCKCHAIN_PRECISION; uint64_t long_symbol = 5000 * GRAPHENE_BLOCKCHAIN_PRECISION; @@ -225,7 +224,7 @@ namespace graphene { namespace chain { ///Operation for creation of lottery struct lottery_asset_create_operation : public base_operation { - struct fee_parameters_type { + struct fee_parameters_type { uint64_t lottery_asset = 20 * GRAPHENE_BLOCKCHAIN_PRECISION; uint32_t price_per_kbyte = 10; /// only required for large lottery names. }; @@ -296,9 +295,9 @@ namespace graphene { namespace chain { */ struct asset_settle_operation : public base_operation { - struct fee_parameters_type { + struct fee_parameters_type { /** this fee should be high to encourage small settlement requests to - * be performed on the market rather than via forced settlement. + * be performed on the market rather than via forced settlement. * * Note that in the event of a black swan or prediction market close out * everyone will have to pay this fee. @@ -367,7 +366,7 @@ namespace graphene { namespace chain { * payments. */ uint64_t distribution_base_fee; - /** This fee is charged (in addition to the distribution_base_fee) for each + /** This fee is charged (in addition to the distribution_base_fee) for each * user the dividend payment is shared out amongst */ uint32_t distribution_fee_per_holder; @@ -429,7 +428,7 @@ namespace graphene { namespace chain { */ struct asset_update_operation : public base_operation { - struct fee_parameters_type { + struct fee_parameters_type { uint64_t fee = 500 * GRAPHENE_BLOCKCHAIN_PRECISION; uint32_t price_per_kbyte = 10; }; @@ -482,9 +481,9 @@ namespace graphene { namespace chain { * @brief Update options specific to dividend-paying assets * @ingroup operations * - * Dividend-paying assets have some options which are not relevant to other asset types. + * Dividend-paying assets have some options which are not relevant to other asset types. * This operation is used to update those options an an existing dividend-paying asset. - * This can also be used to convert a non-dividend-paying asset into a dividend-paying + * This can also be used to convert a non-dividend-paying asset into a dividend-paying * asset. * * @pre @ref issuer MUST be an existing account and MUST match asset_object::issuer on @ref asset_to_update @@ -573,8 +572,8 @@ namespace graphene { namespace chain { */ struct asset_issue_operation : public base_operation { - struct fee_parameters_type { - uint64_t fee = 20 * GRAPHENE_BLOCKCHAIN_PRECISION; + struct fee_parameters_type { + uint64_t fee = 20 * GRAPHENE_BLOCKCHAIN_PRECISION; uint32_t price_per_kbyte = GRAPHENE_BLOCKCHAIN_PRECISION; }; @@ -629,32 +628,32 @@ namespace graphene { namespace chain { account_id_type fee_payer()const { return issuer; } void validate()const; }; - + struct sweeps_vesting_claim_operation : public base_operation { struct fee_parameters_type { uint64_t fee = 20 * GRAPHENE_BLOCKCHAIN_PRECISION; }; - + asset fee; account_id_type account; asset amount_to_claim; extensions_type extensions; - - + + account_id_type fee_payer()const { return account; } void validate()const {}; }; -} } // graphene::chain +} } // graphene::protocol -FC_REFLECT( graphene::chain::sweeps_vesting_claim_operation, (fee)(account)(amount_to_claim)(extensions) ) -FC_REFLECT( graphene::chain::sweeps_vesting_claim_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::sweeps_vesting_claim_operation, (fee)(account)(amount_to_claim)(extensions) ) +FC_REFLECT( graphene::protocol::sweeps_vesting_claim_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::asset_claim_fees_operation, (fee)(issuer)(amount_to_claim)(extensions) ) -FC_REFLECT( graphene::chain::asset_claim_fees_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::asset_claim_fees_operation, (fee)(issuer)(amount_to_claim)(extensions) ) +FC_REFLECT( graphene::protocol::asset_claim_fees_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::asset_options, +FC_REFLECT( graphene::protocol::asset_options, (max_supply) (market_fee_percent) (max_market_fee) @@ -669,7 +668,7 @@ FC_REFLECT( graphene::chain::asset_options, (extensions) ) -FC_REFLECT( graphene::chain::dividend_asset_options, +FC_REFLECT( graphene::protocol::dividend_asset_options, (next_payout_time) (payout_interval) (minimum_fee_percentage) @@ -677,7 +676,7 @@ FC_REFLECT( graphene::chain::dividend_asset_options, (extensions) ) -FC_REFLECT( graphene::chain::bitasset_options, +FC_REFLECT( graphene::protocol::bitasset_options, (feed_lifetime_sec) (minimum_feeds) (force_settlement_delay_sec) @@ -687,27 +686,27 @@ FC_REFLECT( graphene::chain::bitasset_options, (extensions) ) -FC_REFLECT( graphene::chain::benefactor, (id)(share) ) +FC_REFLECT( graphene::protocol::benefactor, (id)(share) ) -FC_REFLECT( graphene::chain::lottery_asset_options, (benefactors)(owner)(winning_tickets)(ticket_price)(end_date)(ending_on_soldout)(is_active) ) +FC_REFLECT( graphene::protocol::lottery_asset_options, (benefactors)(owner)(winning_tickets)(ticket_price)(end_date)(ending_on_soldout)(is_active) ) -FC_REFLECT( graphene::chain::asset_create_operation::fee_parameters_type, (symbol3)(symbol4)(long_symbol)(price_per_kbyte) ) -FC_REFLECT( graphene::chain::lottery_asset_create_operation::fee_parameters_type, (lottery_asset)(price_per_kbyte) ) -FC_REFLECT( graphene::chain::asset_global_settle_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::asset_settle_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::asset_settle_cancel_operation::fee_parameters_type, ) -FC_REFLECT( graphene::chain::asset_fund_fee_pool_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::asset_update_operation::fee_parameters_type, (fee)(price_per_kbyte) ) -FC_REFLECT( graphene::chain::asset_update_bitasset_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::asset_update_dividend_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::asset_update_feed_producers_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::asset_publish_feed_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::asset_issue_operation::fee_parameters_type, (fee)(price_per_kbyte) ) -FC_REFLECT( graphene::chain::asset_reserve_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::asset_dividend_distribution_operation::fee_parameters_type, (distribution_base_fee)(distribution_fee_per_holder)) +FC_REFLECT( graphene::protocol::asset_create_operation::fee_parameters_type, (symbol3)(symbol4)(long_symbol)(price_per_kbyte) ) +FC_REFLECT( graphene::protocol::lottery_asset_create_operation::fee_parameters_type, (lottery_asset)(price_per_kbyte) ) +FC_REFLECT( graphene::protocol::asset_global_settle_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::asset_settle_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::asset_settle_cancel_operation::fee_parameters_type, ) +FC_REFLECT( graphene::protocol::asset_fund_fee_pool_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::asset_update_operation::fee_parameters_type, (fee)(price_per_kbyte) ) +FC_REFLECT( graphene::protocol::asset_update_bitasset_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::asset_update_dividend_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::asset_update_feed_producers_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::asset_publish_feed_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::asset_issue_operation::fee_parameters_type, (fee)(price_per_kbyte) ) +FC_REFLECT( graphene::protocol::asset_reserve_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::asset_dividend_distribution_operation::fee_parameters_type, (distribution_base_fee)(distribution_fee_per_holder)) -FC_REFLECT( graphene::chain::asset_create_operation, +FC_REFLECT( graphene::protocol::asset_create_operation, (fee) (issuer) (symbol) @@ -717,7 +716,7 @@ FC_REFLECT( graphene::chain::asset_create_operation, (is_prediction_market) (extensions) ) -FC_REFLECT( graphene::chain::lottery_asset_create_operation, +FC_REFLECT( graphene::protocol::lottery_asset_create_operation, (fee) (issuer) (symbol) @@ -727,7 +726,7 @@ FC_REFLECT( graphene::chain::lottery_asset_create_operation, (is_prediction_market) (extensions) ) -FC_REFLECT( graphene::chain::asset_update_operation, +FC_REFLECT( graphene::protocol::asset_update_operation, (fee) (issuer) (asset_to_update) @@ -735,59 +734,59 @@ FC_REFLECT( graphene::chain::asset_update_operation, (new_options) (extensions) ) -FC_REFLECT( graphene::chain::asset_update_bitasset_operation, +FC_REFLECT( graphene::protocol::asset_update_bitasset_operation, (fee) (issuer) (asset_to_update) (new_options) (extensions) ) -FC_REFLECT( graphene::chain::asset_update_dividend_operation, +FC_REFLECT( graphene::protocol::asset_update_dividend_operation, (fee) (issuer) (asset_to_update) (new_options) (extensions) ) -FC_REFLECT( graphene::chain::asset_update_feed_producers_operation, +FC_REFLECT( graphene::protocol::asset_update_feed_producers_operation, (fee)(issuer)(asset_to_update)(new_feed_producers)(extensions) ) -FC_REFLECT( graphene::chain::asset_publish_feed_operation, +FC_REFLECT( graphene::protocol::asset_publish_feed_operation, (fee)(publisher)(asset_id)(feed)(extensions) ) -FC_REFLECT( graphene::chain::asset_settle_operation, (fee)(account)(amount)(extensions) ) -FC_REFLECT( graphene::chain::asset_settle_cancel_operation, (fee)(settlement)(account)(amount)(extensions) ) -FC_REFLECT( graphene::chain::asset_global_settle_operation, (fee)(issuer)(asset_to_settle)(settle_price)(extensions) ) -FC_REFLECT( graphene::chain::asset_issue_operation, +FC_REFLECT( graphene::protocol::asset_settle_operation, (fee)(account)(amount)(extensions) ) +FC_REFLECT( graphene::protocol::asset_settle_cancel_operation, (fee)(settlement)(account)(amount)(extensions) ) +FC_REFLECT( graphene::protocol::asset_global_settle_operation, (fee)(issuer)(asset_to_settle)(settle_price)(extensions) ) +FC_REFLECT( graphene::protocol::asset_issue_operation, (fee)(issuer)(asset_to_issue)(issue_to_account)(memo)(extensions) ) -FC_REFLECT( graphene::chain::asset_reserve_operation, +FC_REFLECT( graphene::protocol::asset_reserve_operation, (fee)(payer)(amount_to_reserve)(extensions) ) -FC_REFLECT( graphene::chain::asset_fund_fee_pool_operation, (fee)(from_account)(asset_id)(amount)(extensions) ); -FC_REFLECT( graphene::chain::asset_dividend_distribution_operation, (fee)(dividend_asset_id)(account_id)(amounts)(extensions) ); - -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_options ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::bitasset_options ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_create_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_global_settle_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_settle_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_fund_fee_pool_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_dividend_distribution_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_claim_fees_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_update_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_update_bitasset_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_update_feed_producers_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_publish_feed_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_issue_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_reserve_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_create_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_global_settle_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_settle_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_settle_cancel_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_fund_fee_pool_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_claim_fees_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_update_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_update_bitasset_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_update_feed_producers_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_publish_feed_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_issue_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_reserve_operation ) +FC_REFLECT( graphene::protocol::asset_fund_fee_pool_operation, (fee)(from_account)(asset_id)(amount)(extensions) ); +FC_REFLECT( graphene::protocol::asset_dividend_distribution_operation, (fee)(dividend_asset_id)(account_id)(amounts)(extensions) ); + +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_options ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::bitasset_options ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_create_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_global_settle_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_settle_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_fund_fee_pool_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_dividend_distribution_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_claim_fees_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_update_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_update_bitasset_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_update_feed_producers_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_publish_feed_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_issue_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_reserve_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_create_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_global_settle_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_settle_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_settle_cancel_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_fund_fee_pool_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_claim_fees_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_update_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_update_bitasset_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_update_feed_producers_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_publish_feed_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_issue_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_reserve_operation ) diff --git a/libraries/chain/include/graphene/chain/protocol/authority.hpp b/libraries/protocol/include/graphene/protocol/authority.hpp similarity index 89% rename from libraries/chain/include/graphene/chain/protocol/authority.hpp rename to libraries/protocol/include/graphene/protocol/authority.hpp index d279402df..e3fb741eb 100644 --- a/libraries/chain/include/graphene/chain/protocol/authority.hpp +++ b/libraries/protocol/include/graphene/protocol/authority.hpp @@ -22,10 +22,10 @@ * THE SOFTWARE. */ #pragma once -#include -#include +#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * @class authority @@ -130,10 +130,9 @@ void add_authority_accounts( const authority& a ); -} } // namespace graphene::chain +} } // namespace graphene::protocol -FC_REFLECT( graphene::chain::authority, (weight_threshold)(account_auths)(key_auths)(address_auths) ) -// FC_REFLECT_TYPENAME( graphene::chain::authority::classification ) -FC_REFLECT_ENUM( graphene::chain::authority::classification, (owner)(active)(key) ) +FC_REFLECT( graphene::protocol::authority, (weight_threshold)(account_auths)(key_auths)(address_auths) ) +FC_REFLECT_ENUM( graphene::protocol::authority::classification, (owner)(active)(key) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::authority ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::authority ) diff --git a/libraries/chain/include/graphene/chain/protocol/balance.hpp b/libraries/protocol/include/graphene/protocol/balance.hpp similarity index 82% rename from libraries/chain/include/graphene/chain/protocol/balance.hpp rename to libraries/protocol/include/graphene/protocol/balance.hpp index 9d0b252f3..1ab1453a4 100644 --- a/libraries/chain/include/graphene/chain/protocol/balance.hpp +++ b/libraries/protocol/include/graphene/protocol/balance.hpp @@ -22,14 +22,14 @@ * THE SOFTWARE. */ #pragma once -#include -#include -#include +#include +#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** - * @brief Claim a balance in a @ref balanc_object + * @brief Claim a balance in a @ref balance_object * * This operation is used to claim the balance in a given @ref balance_object. If the balance object contains a * vesting balance, @ref total_claimed must not exceed @ref balance_object::available at the time of evaluation. If @@ -54,10 +54,10 @@ namespace graphene { namespace chain { } }; -} } // graphene::chain +} } // graphene::protocol -FC_REFLECT( graphene::chain::balance_claim_operation::fee_parameters_type, ) -FC_REFLECT( graphene::chain::balance_claim_operation, +FC_REFLECT( graphene::protocol::balance_claim_operation::fee_parameters_type, ) +FC_REFLECT( graphene::protocol::balance_claim_operation, (fee)(deposit_to_account)(balance_to_claim)(balance_owner_key)(total_claimed) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::balance_claim_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::balance_claim_operation ) diff --git a/libraries/chain/include/graphene/chain/protocol/base.hpp b/libraries/protocol/include/graphene/protocol/base.hpp similarity index 91% rename from libraries/chain/include/graphene/chain/protocol/base.hpp rename to libraries/protocol/include/graphene/protocol/base.hpp index 23c285d31..73d60eaba 100644 --- a/libraries/chain/include/graphene/chain/protocol/base.hpp +++ b/libraries/protocol/include/graphene/protocol/base.hpp @@ -23,13 +23,15 @@ */ #pragma once -#include -#include -#include +#include +#include +#include #include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { + struct asset; + struct authority; struct asset; struct authority; @@ -118,12 +120,12 @@ namespace graphene { namespace chain { * @note static_variant compares only the type tag and not the * content. */ - typedef flat_set extensions_type; + typedef future_extensions::flat_set_type extensions_type; ///@} -} } // graphene::chain +} } // graphene::protocol -FC_REFLECT_TYPENAME( graphene::chain::operation_result ) -FC_REFLECT_TYPENAME( graphene::chain::future_extensions ) -FC_REFLECT( graphene::chain::void_result, ) +FC_REFLECT_TYPENAME( graphene::protocol::operation_result ) +FC_REFLECT_TYPENAME( graphene::protocol::future_extensions ) +FC_REFLECT( graphene::protocol::void_result, ) diff --git a/libraries/chain/include/graphene/chain/protocol/betting_market.hpp b/libraries/protocol/include/graphene/protocol/betting_market.hpp similarity index 83% rename from libraries/chain/include/graphene/chain/protocol/betting_market.hpp rename to libraries/protocol/include/graphene/protocol/betting_market.hpp index 26b6f2637..e1d804d54 100644 --- a/libraries/chain/include/graphene/chain/protocol/betting_market.hpp +++ b/libraries/protocol/include/graphene/protocol/betting_market.hpp @@ -23,10 +23,10 @@ */ #pragma once -#include -#include +#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { struct betting_market_rules_create_operation : public base_operation { @@ -417,22 +417,22 @@ struct bet_adjusted_operation : public base_operation } } -FC_REFLECT( graphene::chain::betting_market_rules_create_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::betting_market_rules_create_operation, +FC_REFLECT( graphene::protocol::betting_market_rules_create_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::betting_market_rules_create_operation, (fee)(name)(description)(extensions) ) -FC_REFLECT( graphene::chain::betting_market_rules_update_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::betting_market_rules_update_operation, +FC_REFLECT( graphene::protocol::betting_market_rules_update_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::betting_market_rules_update_operation, (fee)(new_name)(new_description)(extensions)(betting_market_rules_id) ) -FC_REFLECT_ENUM( graphene::chain::betting_market_status, +FC_REFLECT_ENUM( graphene::protocol::betting_market_status, (unresolved) (frozen) (graded) (canceled) (settled) (BETTING_MARKET_STATUS_COUNT) ) -FC_REFLECT_ENUM( graphene::chain::betting_market_group_status, +FC_REFLECT_ENUM( graphene::protocol::betting_market_group_status, (upcoming) (in_play) (closed) @@ -443,51 +443,51 @@ FC_REFLECT_ENUM( graphene::chain::betting_market_group_status, (canceled) (BETTING_MARKET_GROUP_STATUS_COUNT) ) -FC_REFLECT( graphene::chain::betting_market_group_create_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::betting_market_group_create_operation, +FC_REFLECT( graphene::protocol::betting_market_group_create_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::betting_market_group_create_operation, (fee)(description)(event_id)(rules_id)(asset_id) (never_in_play)(delay_before_settling) (extensions) ) -FC_REFLECT( graphene::chain::betting_market_group_update_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::betting_market_group_update_operation, +FC_REFLECT( graphene::protocol::betting_market_group_update_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::betting_market_group_update_operation, (fee)(betting_market_group_id)(new_description)(new_rules_id)(status)(extensions) ) -FC_REFLECT( graphene::chain::betting_market_create_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::betting_market_create_operation, +FC_REFLECT( graphene::protocol::betting_market_create_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::betting_market_create_operation, (fee)(group_id)(description)(payout_condition)(extensions) ) -FC_REFLECT( graphene::chain::betting_market_update_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::betting_market_update_operation, +FC_REFLECT( graphene::protocol::betting_market_update_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::betting_market_update_operation, (fee)(betting_market_id)(new_group_id)(new_description)(new_payout_condition)(extensions) ) -FC_REFLECT_ENUM( graphene::chain::betting_market_resolution_type, (win)(not_win)(cancel)(BETTING_MARKET_RESOLUTION_COUNT) ) +FC_REFLECT_ENUM( graphene::protocol::betting_market_resolution_type, (win)(not_win)(cancel)(BETTING_MARKET_RESOLUTION_COUNT) ) -FC_REFLECT( graphene::chain::betting_market_group_resolve_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::betting_market_group_resolve_operation, +FC_REFLECT( graphene::protocol::betting_market_group_resolve_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::betting_market_group_resolve_operation, (fee)(betting_market_group_id)(resolutions)(extensions) ) -FC_REFLECT( graphene::chain::betting_market_group_resolved_operation::fee_parameters_type, ) -FC_REFLECT( graphene::chain::betting_market_group_resolved_operation, +FC_REFLECT( graphene::protocol::betting_market_group_resolved_operation::fee_parameters_type, ) +FC_REFLECT( graphene::protocol::betting_market_group_resolved_operation, (bettor_id)(betting_market_group_id)(resolutions)(winnings)(fees_paid)(fee) ) -FC_REFLECT( graphene::chain::betting_market_group_cancel_unmatched_bets_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::betting_market_group_cancel_unmatched_bets_operation, +FC_REFLECT( graphene::protocol::betting_market_group_cancel_unmatched_bets_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::betting_market_group_cancel_unmatched_bets_operation, (fee)(betting_market_group_id)(extensions) ) -FC_REFLECT_ENUM( graphene::chain::bet_type, (back)(lay) ) -FC_REFLECT( graphene::chain::bet_place_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::bet_place_operation, +FC_REFLECT_ENUM( graphene::protocol::bet_type, (back)(lay) ) +FC_REFLECT( graphene::protocol::bet_place_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::bet_place_operation, (fee)(bettor_id)(betting_market_id)(amount_to_bet)(backer_multiplier)(back_or_lay)(extensions) ) -FC_REFLECT( graphene::chain::bet_matched_operation::fee_parameters_type, ) -FC_REFLECT( graphene::chain::bet_matched_operation, (bettor_id)(bet_id)(amount_bet)(backer_multiplier)(guaranteed_winnings_returned) ) +FC_REFLECT( graphene::protocol::bet_matched_operation::fee_parameters_type, ) +FC_REFLECT( graphene::protocol::bet_matched_operation, (fee)(bettor_id)(bet_id)(amount_bet)(backer_multiplier)(guaranteed_winnings_returned) ) -FC_REFLECT( graphene::chain::bet_cancel_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::bet_cancel_operation, (fee) (bettor_id) (bet_to_cancel) (extensions) ) +FC_REFLECT( graphene::protocol::bet_cancel_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::bet_cancel_operation, (fee) (bettor_id) (bet_to_cancel) (extensions) ) -FC_REFLECT( graphene::chain::bet_canceled_operation::fee_parameters_type, ) -FC_REFLECT( graphene::chain::bet_canceled_operation, (bettor_id)(bet_id)(stake_returned) ) +FC_REFLECT( graphene::protocol::bet_canceled_operation::fee_parameters_type, ) +FC_REFLECT( graphene::protocol::bet_canceled_operation, (fee)(bettor_id)(bet_id)(stake_returned) ) -FC_REFLECT( graphene::chain::bet_adjusted_operation::fee_parameters_type, ) -FC_REFLECT( graphene::chain::bet_adjusted_operation, (bettor_id)(bet_id)(stake_returned) ) +FC_REFLECT( graphene::protocol::bet_adjusted_operation::fee_parameters_type, ) +FC_REFLECT( graphene::protocol::bet_adjusted_operation, (fee) (bettor_id)(bet_id)(stake_returned) ) diff --git a/libraries/chain/include/graphene/chain/protocol/block.hpp b/libraries/protocol/include/graphene/protocol/block.hpp similarity index 80% rename from libraries/chain/include/graphene/chain/protocol/block.hpp rename to libraries/protocol/include/graphene/protocol/block.hpp index ad5b03279..67c633ede 100644 --- a/libraries/chain/include/graphene/chain/protocol/block.hpp +++ b/libraries/protocol/include/graphene/protocol/block.hpp @@ -22,9 +22,9 @@ * THE SOFTWARE. */ #pragma once -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { struct block_header { @@ -57,9 +57,9 @@ namespace graphene { namespace chain { vector transactions; }; -} } // graphene::chain +} } // graphene::protocol -FC_REFLECT( graphene::chain::block_header, +FC_REFLECT( graphene::protocol::block_header, (previous) (timestamp) (witness) @@ -67,10 +67,10 @@ FC_REFLECT( graphene::chain::block_header, (previous_secret) (transaction_merkle_root) (extensions) ) -FC_REFLECT_DERIVED( graphene::chain::signed_block_header, (graphene::chain::block_header), (witness_signature) ) -FC_REFLECT_DERIVED( graphene::chain::signed_block, (graphene::chain::signed_block_header), (transactions) ) +FC_REFLECT_DERIVED( graphene::protocol::signed_block_header, (graphene::protocol::block_header), (witness_signature) ) +FC_REFLECT_DERIVED( graphene::protocol::signed_block, (graphene::protocol::signed_block_header), (transactions) ) -GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::chain::block_header) -GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::chain::signed_block_header) -GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::chain::signed_block) +GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::protocol::block_header) +GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::protocol::signed_block_header) +GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::protocol::signed_block) diff --git a/libraries/chain/include/graphene/chain/protocol/buyback.hpp b/libraries/protocol/include/graphene/protocol/buyback.hpp similarity index 85% rename from libraries/chain/include/graphene/chain/protocol/buyback.hpp rename to libraries/protocol/include/graphene/protocol/buyback.hpp index 4a51e8c75..9f58beca9 100644 --- a/libraries/chain/include/graphene/chain/protocol/buyback.hpp +++ b/libraries/protocol/include/graphene/protocol/buyback.hpp @@ -23,9 +23,9 @@ */ #pragma once -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { struct buyback_account_options { @@ -49,6 +49,6 @@ struct buyback_account_options } } -FC_REFLECT( graphene::chain::buyback_account_options, (asset_to_buy)(asset_to_buy_issuer)(markets) ); +FC_REFLECT( graphene::protocol::buyback_account_options, (asset_to_buy)(asset_to_buy_issuer)(markets) ); -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::buyback_account_options ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::buyback_account_options ) diff --git a/libraries/chain/include/graphene/chain/protocol/chain_parameters.hpp b/libraries/protocol/include/graphene/protocol/chain_parameters.hpp similarity index 96% rename from libraries/chain/include/graphene/chain/protocol/chain_parameters.hpp rename to libraries/protocol/include/graphene/protocol/chain_parameters.hpp index c24a05760..0330b6c95 100644 --- a/libraries/chain/include/graphene/chain/protocol/chain_parameters.hpp +++ b/libraries/protocol/include/graphene/protocol/chain_parameters.hpp @@ -22,18 +22,15 @@ * THE SOFTWARE. */ #pragma once -#include -#include -#include -#include -#include -#include <../hardfork.d/GPOS.hf> +#include +#include + #include -namespace graphene { namespace chain { struct fee_schedule; } } +namespace graphene { namespace protocol { + struct fee_schedule; -namespace graphene { namespace chain { struct parameter_extension { optional< bet_multiplier_type > min_bet_multiplier; @@ -47,7 +44,7 @@ namespace graphene { namespace chain { /* gpos parameters */ optional < uint32_t > gpos_period = GPOS_PERIOD; optional < uint32_t > gpos_subperiod = GPOS_SUBPERIOD; - optional < uint32_t > gpos_period_start = HARDFORK_GPOS_TIME.sec_since_epoch(); + optional < uint32_t > gpos_period_start = GPOS_PERIOD_START.sec_since_epoch(); optional < uint32_t > gpos_vesting_lockin_period = GPOS_VESTING_LOCKIN_PERIOD; /* rbac parameters */ optional < uint16_t > rbac_max_permissions_per_account = RBAC_MAX_PERMISSIONS_PER_ACCOUNT; @@ -77,7 +74,7 @@ namespace graphene { namespace chain { chain_parameters(chain_parameters&& other); chain_parameters& operator=(const chain_parameters& other); chain_parameters& operator=(chain_parameters&& other); - /** using a smart ref breaks the circular dependency created between operations and the fee schedule */ + /** using a shared_ptr breaks the circular dependency created between operations and the fee schedule */ std::shared_ptr current_fees; ///< current schedule of fees uint8_t block_interval = GRAPHENE_DEFAULT_BLOCK_INTERVAL; ///< interval in seconds between blocks uint32_t maintenance_interval = GRAPHENE_DEFAULT_MAINTENANCE_INTERVAL; ///< interval in sections between blockchain maintenance events @@ -159,7 +156,7 @@ namespace graphene { namespace chain { return extensions.value.gpos_subperiod.valid() ? *extensions.value.gpos_subperiod : GPOS_SUBPERIOD; /// gpos_period % gpos_subperiod = 0 } inline uint32_t gpos_period_start()const { - return extensions.value.gpos_period_start.valid() ? *extensions.value.gpos_period_start : HARDFORK_GPOS_TIME.sec_since_epoch(); /// current period start date + return extensions.value.gpos_period_start.valid() ? *extensions.value.gpos_period_start : GPOS_PERIOD_START.sec_since_epoch(); /// current period start date } inline uint32_t gpos_vesting_lockin_period()const { return extensions.value.gpos_vesting_lockin_period.valid() ? *extensions.value.gpos_vesting_lockin_period : GPOS_VESTING_LOCKIN_PERIOD; /// GPOS vesting lockin period @@ -216,9 +213,9 @@ namespace graphene { namespace chain { static void safe_copy(chain_parameters& to, const chain_parameters& from); }; -} } // graphene::chain +} } // graphene::protocol -FC_REFLECT( graphene::chain::parameter_extension, +FC_REFLECT( graphene::protocol::parameter_extension, (min_bet_multiplier) (max_bet_multiplier) (betting_rake_fee_percentage) @@ -249,7 +246,7 @@ FC_REFLECT( graphene::chain::parameter_extension, (maximum_son_count) ) -FC_REFLECT( graphene::chain::chain_parameters, +FC_REFLECT( graphene::protocol::chain_parameters, (current_fees) (block_interval) (maintenance_interval) @@ -295,4 +292,4 @@ FC_REFLECT( graphene::chain::chain_parameters, (extensions) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::chain_parameters ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::chain_parameters ) diff --git a/libraries/chain/include/graphene/chain/protocol/committee_member.hpp b/libraries/protocol/include/graphene/protocol/committee_member.hpp similarity index 74% rename from libraries/chain/include/graphene/chain/protocol/committee_member.hpp rename to libraries/protocol/include/graphene/protocol/committee_member.hpp index 8aaed7487..5e63e9632 100644 --- a/libraries/chain/include/graphene/chain/protocol/committee_member.hpp +++ b/libraries/protocol/include/graphene/protocol/committee_member.hpp @@ -22,10 +22,11 @@ * THE SOFTWARE. */ #pragma once -#include -#include +#include +#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * @brief Create a committee_member object, as a bid to hold a committee_member seat on the network. @@ -93,21 +94,21 @@ namespace graphene { namespace chain { /// TODO: committee_member_resign_operation : public base_operation -} } // graphene::chain -FC_REFLECT( graphene::chain::committee_member_create_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::committee_member_update_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::committee_member_update_global_parameters_operation::fee_parameters_type, (fee) ) +} } // graphene::protocol +FC_REFLECT( graphene::protocol::committee_member_create_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::committee_member_update_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::committee_member_update_global_parameters_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::committee_member_create_operation, +FC_REFLECT( graphene::protocol::committee_member_create_operation, (fee)(committee_member_account)(url) ) -FC_REFLECT( graphene::chain::committee_member_update_operation, +FC_REFLECT( graphene::protocol::committee_member_update_operation, (fee)(committee_member)(committee_member_account)(new_url) ) -FC_REFLECT( graphene::chain::committee_member_update_global_parameters_operation, (fee)(new_parameters) ); +FC_REFLECT( graphene::protocol::committee_member_update_global_parameters_operation, (fee)(new_parameters) ); -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::committee_member_create_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::committee_member_update_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::committee_member_update_global_parameters_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::committee_member_create_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::committee_member_update_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::committee_member_update_global_parameters_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::committee_member_create_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::committee_member_update_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::committee_member_update_global_parameters_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::committee_member_create_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::committee_member_update_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::committee_member_update_global_parameters_operation ) diff --git a/libraries/chain/include/graphene/chain/protocol/confidential.hpp b/libraries/protocol/include/graphene/protocol/confidential.hpp similarity index 86% rename from libraries/chain/include/graphene/chain/protocol/confidential.hpp rename to libraries/protocol/include/graphene/protocol/confidential.hpp index 697ef35b6..fbb0a5b20 100644 --- a/libraries/chain/include/graphene/chain/protocol/confidential.hpp +++ b/libraries/protocol/include/graphene/protocol/confidential.hpp @@ -23,9 +23,11 @@ */ #pragma once -#include +#include +#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { using fc::ecc::blind_factor_type; @@ -258,33 +260,33 @@ struct blind_transfer_operation : public base_operation ///@} endgroup stealth -} } // graphene::chain +} } // graphene::protocol -FC_REFLECT( graphene::chain::stealth_confirmation, +FC_REFLECT( graphene::protocol::stealth_confirmation, (one_time_key)(to)(encrypted_memo) ) -FC_REFLECT( graphene::chain::stealth_confirmation::memo_data, +FC_REFLECT( graphene::protocol::stealth_confirmation::memo_data, (from)(amount)(blinding_factor)(commitment)(check) ); -FC_REFLECT( graphene::chain::blind_memo, +FC_REFLECT( graphene::protocol::blind_memo, (from)(amount)(message)(check) ) -FC_REFLECT( graphene::chain::blind_input, +FC_REFLECT( graphene::protocol::blind_input, (commitment)(owner) ) -FC_REFLECT( graphene::chain::blind_output, +FC_REFLECT( graphene::protocol::blind_output, (commitment)(range_proof)(owner)(stealth_memo) ) -FC_REFLECT( graphene::chain::transfer_to_blind_operation, +FC_REFLECT( graphene::protocol::transfer_to_blind_operation, (fee)(amount)(from)(blinding_factor)(outputs) ) -FC_REFLECT( graphene::chain::transfer_from_blind_operation, +FC_REFLECT( graphene::protocol::transfer_from_blind_operation, (fee)(amount)(to)(blinding_factor)(inputs) ) -FC_REFLECT( graphene::chain::blind_transfer_operation, +FC_REFLECT( graphene::protocol::blind_transfer_operation, (fee)(inputs)(outputs) ) -FC_REFLECT( graphene::chain::transfer_to_blind_operation::fee_parameters_type, (fee)(price_per_output) ) -FC_REFLECT( graphene::chain::transfer_from_blind_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::blind_transfer_operation::fee_parameters_type, (fee)(price_per_output) ) +FC_REFLECT( graphene::protocol::transfer_to_blind_operation::fee_parameters_type, (fee)(price_per_output) ) +FC_REFLECT( graphene::protocol::transfer_from_blind_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::blind_transfer_operation::fee_parameters_type, (fee)(price_per_output) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::transfer_to_blind_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::transfer_from_blind_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::blind_transfer_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::transfer_to_blind_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::transfer_from_blind_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::blind_transfer_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::transfer_to_blind_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::transfer_from_blind_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::blind_transfer_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::transfer_to_blind_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::transfer_from_blind_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::blind_transfer_operation ) diff --git a/libraries/protocol/include/graphene/protocol/config.hpp b/libraries/protocol/include/graphene/protocol/config.hpp new file mode 100644 index 000000000..44ae8cdbc --- /dev/null +++ b/libraries/protocol/include/graphene/protocol/config.hpp @@ -0,0 +1,252 @@ +/* + * Copyright (c) 2015 Cryptonomex, Inc., and contributors. + * + * The MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#pragma once + +#define GRAPHENE_SYMBOL "TEST" +#define GRAPHENE_ADDRESS_PREFIX "TEST" + +#define GRAPHENE_MIN_ACCOUNT_NAME_LENGTH 1 +#define GRAPHENE_MAX_ACCOUNT_NAME_LENGTH 63 + +#define GRAPHENE_MIN_ASSET_SYMBOL_LENGTH 3 +#define GRAPHENE_MAX_ASSET_SYMBOL_LENGTH 16 + +#define GRAPHENE_MAX_SHARE_SUPPLY int64_t(1000000000000000ll) +#define GRAPHENE_MAX_PAY_RATE 10000 /* 100% */ +#define GRAPHENE_MAX_SIG_CHECK_DEPTH 2 +/** + * Don't allow the committee_members to publish a limit that would + * make the network unable to operate. + */ +#define GRAPHENE_MIN_TRANSACTION_SIZE_LIMIT 1024 +#define GRAPHENE_MIN_BLOCK_INTERVAL 1 /* seconds */ +#define GRAPHENE_MAX_BLOCK_INTERVAL 30 /* seconds */ + +#define GRAPHENE_DEFAULT_BLOCK_INTERVAL 3 /* seconds */ +#define GRAPHENE_DEFAULT_MAX_TRANSACTION_SIZE 2048 +#define GRAPHENE_DEFAULT_MAX_BLOCK_SIZE (GRAPHENE_DEFAULT_MAX_TRANSACTION_SIZE*GRAPHENE_DEFAULT_BLOCK_INTERVAL*200000) +#define GRAPHENE_DEFAULT_MAX_TIME_UNTIL_EXPIRATION (60*60*24) // seconds, aka: 1 day +#define GRAPHENE_DEFAULT_MAINTENANCE_INTERVAL (60*60*24) // seconds, aka: 1 day +#define GRAPHENE_DEFAULT_MAINTENANCE_SKIP_SLOTS 3 // number of slots to skip for maintenance interval + +#define GRAPHENE_MIN_BLOCK_SIZE_LIMIT (GRAPHENE_MIN_TRANSACTION_SIZE_LIMIT*5) // 5 transactions per block +#define GRAPHENE_MIN_TRANSACTION_EXPIRATION_LIMIT (GRAPHENE_MAX_BLOCK_INTERVAL * 5) // 5 transactions per block +#define GRAPHENE_BLOCKCHAIN_PRECISION uint64_t( 100000 ) + +#define GRAPHENE_BLOCKCHAIN_PRECISION_DIGITS 5 +#define GRAPHENE_DEFAULT_TRANSFER_FEE (1*GRAPHENE_BLOCKCHAIN_PRECISION) +#define GRAPHENE_MAX_INSTANCE_ID (uint64_t(-1)>>16) +/** percentage fields are fixed point with a denominator of 10,000 */ +#define GRAPHENE_100_PERCENT 10000 +#define GRAPHENE_1_PERCENT (GRAPHENE_100_PERCENT/100) +/** NOTE: making this a power of 2 (say 2^15) would greatly accelerate fee calcs */ +#define GRAPHENE_MAX_MARKET_FEE_PERCENT GRAPHENE_100_PERCENT +#define GRAPHENE_DEFAULT_FORCE_SETTLEMENT_DELAY (60*60*24) ///< 1 day +#define GRAPHENE_DEFAULT_FORCE_SETTLEMENT_OFFSET 0 ///< 1% +#define GRAPHENE_DEFAULT_FORCE_SETTLEMENT_MAX_VOLUME (20* GRAPHENE_1_PERCENT) ///< 20% +#define GRAPHENE_DEFAULT_PRICE_FEED_LIFETIME (60*60*24) ///< 1 day +#define GRAPHENE_MAX_FEED_PRODUCERS 200 +#define GRAPHENE_DEFAULT_MAX_AUTHORITY_MEMBERSHIP 10 +#define GRAPHENE_DEFAULT_MAX_ASSET_WHITELIST_AUTHORITIES 10 +#define GRAPHENE_DEFAULT_MAX_ASSET_FEED_PUBLISHERS 10 + +/** + * These ratios are fixed point numbers with a denominator of GRAPHENE_COLLATERAL_RATIO_DENOM, the + * minimum maitenance collateral is therefore 1.001x and the default + * maintenance ratio is 1.75x + */ +///@{ +#define GRAPHENE_COLLATERAL_RATIO_DENOM 1000 +#define GRAPHENE_MIN_COLLATERAL_RATIO 1001 ///< lower than this could result in divide by 0 +#define GRAPHENE_MAX_COLLATERAL_RATIO 32000 ///< higher than this is unnecessary and may exceed int16 storage +#define GRAPHENE_DEFAULT_MAINTENANCE_COLLATERAL_RATIO 1750 ///< Call when collateral only pays off 175% the debt +#define GRAPHENE_DEFAULT_MAX_SHORT_SQUEEZE_RATIO 1500 ///< Stop calling when collateral only pays off 150% of the debt +///@} +#define GRAPHENE_DEFAULT_MARGIN_PERIOD_SEC (30*60*60*24) + +#define GRAPHENE_DEFAULT_MIN_WITNESS_COUNT (11) +#define GRAPHENE_DEFAULT_MIN_COMMITTEE_MEMBER_COUNT (11) +#define GRAPHENE_DEFAULT_MIN_SON_COUNT (5) +#define GRAPHENE_DEFAULT_MAX_WITNESSES (1001) // SHOULD BE ODD +#define GRAPHENE_DEFAULT_MAX_COMMITTEE (1001) // SHOULD BE ODD +#define GRAPHENE_DEFAULT_MAX_SONS (15) +#define GRAPHENE_DEFAULT_MAX_PROPOSAL_LIFETIME_SEC (60*60*24*7*4) // Four weeks +#define GRAPHENE_DEFAULT_COMMITTEE_PROPOSAL_REVIEW_PERIOD_SEC (60*60*24*7*2) // Two weeks +#define GRAPHENE_DEFAULT_NETWORK_PERCENT_OF_FEE (20*GRAPHENE_1_PERCENT) +#define GRAPHENE_DEFAULT_LIFETIME_REFERRER_PERCENT_OF_FEE (30*GRAPHENE_1_PERCENT) +#define GRAPHENE_DEFAULT_MAX_BULK_DISCOUNT_PERCENT (50*GRAPHENE_1_PERCENT) +#define GRAPHENE_DEFAULT_BULK_DISCOUNT_THRESHOLD_MIN ( GRAPHENE_BLOCKCHAIN_PRECISION*int64_t(1000) ) +#define GRAPHENE_DEFAULT_BULK_DISCOUNT_THRESHOLD_MAX ( GRAPHENE_DEFAULT_BULK_DISCOUNT_THRESHOLD_MIN*int64_t(100) ) +#define GRAPHENE_DEFAULT_CASHBACK_VESTING_PERIOD_SEC (60*60*24*365) ///< 1 year +#define GRAPHENE_DEFAULT_CASHBACK_VESTING_THRESHOLD (GRAPHENE_BLOCKCHAIN_PRECISION*int64_t(100)) +#define GRAPHENE_DEFAULT_BURN_PERCENT_OF_FEE (20*GRAPHENE_1_PERCENT) +#define GRAPHENE_WITNESS_PAY_PERCENT_PRECISION (1000000000) +#define GRAPHENE_DEFAULT_MAX_ASSERT_OPCODE 1 +#define GRAPHENE_DEFAULT_FEE_LIQUIDATION_THRESHOLD GRAPHENE_BLOCKCHAIN_PRECISION * 100; +#define GRAPHENE_DEFAULT_ACCOUNTS_PER_FEE_SCALE 1000 +#define GRAPHENE_DEFAULT_ACCOUNT_FEE_SCALE_BITSHIFTS 4 +#define GRAPHENE_DEFAULT_MAX_BUYBACK_MARKETS 4 + +#define GRAPHENE_MAX_WORKER_NAME_LENGTH 63 + +#define GRAPHENE_MAX_URL_LENGTH 127 + +#define GRAPHENE_WITNESS_SHUFFLED_ALGORITHM 0 +#define GRAPHENE_WITNESS_SCHEDULED_ALGORITHM 1 + +// counter initialization values used to derive near and far future seeds for shuffling witnesses +// we use the fractional bits of sqrt(2) in hex +#define GRAPHENE_NEAR_SCHEDULE_CTR_IV ( (uint64_t( 0x6a09 ) << 0x30) \ + | (uint64_t( 0xe667 ) << 0x20) \ + | (uint64_t( 0xf3bc ) << 0x10) \ + | (uint64_t( 0xc908 ) ) ) + +// and the fractional bits of sqrt(3) in hex +#define GRAPHENE_FAR_SCHEDULE_CTR_IV ( (uint64_t( 0xbb67 ) << 0x30) \ + | (uint64_t( 0xae85 ) << 0x20) \ + | (uint64_t( 0x84ca ) << 0x10) \ + | (uint64_t( 0xa73b ) ) ) + +// counter used to determine bits of entropy +// must be less than or equal to secret_hash_type::data_length() +#define GRAPHENE_RNG_SEED_LENGTH (160 / 8) + +/** + * every second, the fraction of burned core asset which cycles is + * GRAPHENE_CORE_ASSET_CYCLE_RATE / (1 << GRAPHENE_CORE_ASSET_CYCLE_RATE_BITS) + */ +#define GRAPHENE_CORE_ASSET_CYCLE_RATE 17 +#define GRAPHENE_CORE_ASSET_CYCLE_RATE_BITS 32 + +#define GRAPHENE_DEFAULT_WITNESS_PAY_PER_BLOCK (GRAPHENE_BLOCKCHAIN_PRECISION * int64_t( 10) ) +#define GRAPHENE_DEFAULT_WITNESS_PAY_VESTING_SECONDS (60*60*24) +#define GRAPHENE_DEFAULT_WORKER_BUDGET_PER_DAY (GRAPHENE_BLOCKCHAIN_PRECISION * int64_t(500) * 1000 ) + +#define GRAPHENE_DEFAULT_MINIMUM_FEEDS 7 + +#define GRAPHENE_MAX_INTEREST_APR uint16_t( 10000 ) + +#define GRAPHENE_IRREVERSIBLE_THRESHOLD (70 * GRAPHENE_1_PERCENT) + +/** + * Reserved Account IDs with special meaning + */ +///@{ +/// Represents the current committee members, two-week review period +#define GRAPHENE_COMMITTEE_ACCOUNT (graphene::protocol::account_id_type(0)) +/// Represents the current witnesses +#define GRAPHENE_WITNESS_ACCOUNT (graphene::protocol::account_id_type(1)) +/// Represents the current committee members +#define GRAPHENE_RELAXED_COMMITTEE_ACCOUNT (graphene::protocol::account_id_type(2)) +/// Represents the canonical account with NO authority (nobody can access funds in null account) +#define GRAPHENE_NULL_ACCOUNT (graphene::protocol::account_id_type(3)) +/// Represents the canonical account with WILDCARD authority (anybody can access funds in temp account) +#define GRAPHENE_TEMP_ACCOUNT (graphene::protocol::account_id_type(4)) +/// Represents the canonical account for specifying you will vote directly (as opposed to a proxy) +#define GRAPHENE_PROXY_TO_SELF_ACCOUNT (graphene::protocol::account_id_type(5)) +/// +#define GRAPHENE_RAKE_FEE_ACCOUNT_ID (graphene::protocol::account_id_type(6)) +/// Sentinel value used in the scheduler. +#define GRAPHENE_NULL_WITNESS (graphene::protocol::witness_id_type(0)) +///@} + +#define GRAPHENE_FBA_STEALTH_DESIGNATED_ASSET (asset_id_type(743)) + +#define GRAPHENE_DEFAULT_RAKE_FEE_PERCENTAGE (3*GRAPHENE_1_PERCENT) + +/** + * Betting-related constants. + * + * We store bet multipliers as fixed-precision uint32_t. These values are + * the maximum power-of-ten bet we can have on a "symmetric" market: + * (decimal) 1.0001 - 10001 + * (fractional) 1:10000 - 10000:1 + */ +///@{ +/// betting odds (multipliers) are stored as fixed-precision, divide by this to get the actual multiplier +#define GRAPHENE_BETTING_ODDS_PRECISION 10000 +/// the smallest bet multiplier we will accept +#define GRAPHENE_BETTING_MIN_MULTIPLIER 10001 +/// the largest bet multiplier we will accept +#define GRAPHENE_BETTING_MAX_MULTIPLIER 100010000 +///@} +#define GRAPHENE_DEFAULT_MIN_BET_MULTIPLIER 10100 +#define GRAPHENE_DEFAULT_MAX_BET_MULTIPLIER 10000000 +#define GRAPHENE_DEFAULT_PERMITTED_BETTING_ODDS_INCREMENTS { { 20000, 100}, /* <= 2: 0.01 */ \ + { 30000, 200}, /* <= 3: 0.02 */ \ + { 40000, 500}, /* <= 4: 0.05 */ \ + { 60000, 1000}, /* <= 6: 0.10 */ \ + { 100000, 2000}, /* <= 10: 0.20 */ \ + { 200000, 5000}, /* <= 20: 0.50 */ \ + { 300000, 10000}, /* <= 30: 1.00 */ \ + { 500000, 20000}, /* <= 50: 2.00 */ \ + { 1000000, 50000}, /* <= 100: 5.00 */ \ + { 10000000, 100000} } /* <= 1000: 10.00 */ +#define GRAPHENE_DEFAULT_BETTING_PERCENT_FEE (2 * GRAPHENE_1_PERCENT) +#define GRAPHENE_DEFAULT_LIVE_BETTING_DELAY_TIME 5 // seconds +#define TOURNAMENT_MIN_ROUND_DELAY 0 +#define TOURNAMENT_MAX_ROUND_DELAY 600 +#define TOURNAMENT_MIN_TIME_PER_COMMIT_MOVE 0 +#define TOURNAMENT_MAN_TIME_PER_COMMIT_MOVE 600 +#define TOURNAMENT_MIN_TIME_PER_REVEAL_MOVE 0 +#define TOURNAMENT_MAX_TIME_PER_REVEAL_MOVE 600 +#define TOURNAMENT_DEFAULT_RAKE_FEE_PERCENTAGE (3*GRAPHENE_1_PERCENT) +#define TOURNAMENT_MINIMAL_RAKE_FEE_PERCENTAGE (1*GRAPHENE_1_PERCENT) +#define TOURNAMENT_MAXIMAL_RAKE_FEE_PERCENTAGE (20*GRAPHENE_1_PERCENT) +#define TOURNAMENT_MAXIMAL_REGISTRATION_DEADLINE (60*60*24*30) // seconds, 30 days +#define TOURNAMENT_MAX_NUMBER_OF_WINS 100 +#define TOURNAMENT_MAX_PLAYERS_NUMBER 256 +#define TOURNAMENT_MAX_WHITELIST_LENGTH 1000 +#define TOURNAMENT_MAX_START_TIME_IN_FUTURE (60*60*24*7*4) // 1 month +#define TOURNAMENT_MAX_START_DELAY (60*60*24*7) // 1 week +#define SON_VESTING_AMOUNT (50*GRAPHENE_BLOCKCHAIN_PRECISION) // 50 PPY +#define SON_VESTING_PERIOD (60*60*24*2) // 2 days +#define SON_DEREGISTER_TIME (60*60*12) // 12 Hours in seconds +#define SON_HEARTBEAT_FREQUENCY (60*3) // 3 minutes in seconds +#define SON_DOWN_TIME (60*3*2) // 2 Heartbeats in seconds +#define SON_BITCOIN_MIN_TX_CONFIRMATIONS (1) +#define SON_PAY_TIME (60*60*24) // 1 day +#define SON_PAY_MAX (GRAPHENE_BLOCKCHAIN_PRECISION * int64_t(200)) +#define SWEEPS_DEFAULT_DISTRIBUTION_PERCENTAGE (2*GRAPHENE_1_PERCENT) +#define SWEEPS_DEFAULT_DISTRIBUTION_ASSET (graphene::protocol::asset_id_type(0)) +#define SWEEPS_VESTING_BALANCE_MULTIPLIER 100000000 +#define SWEEPS_ACCUMULATOR_ACCOUNT (graphene::protocol::account_id_type(0)) +#define GPOS_PERIOD_START (fc::time_point_sec(1578272400)) +#define GPOS_PERIOD (60*60*24*30*6) // 6 months +#define GPOS_SUBPERIOD (60*60*24*30) // 1 month +#define GPOS_VESTING_LOCKIN_PERIOD (60*60*24*30) // 1 month + +#define RBAC_MIN_PERMISSION_NAME_LENGTH 3 +#define RBAC_MAX_PERMISSION_NAME_LENGTH 10 +#define RBAC_MAX_PERMISSIONS_PER_ACCOUNT 5 // 5 per account +#define RBAC_MAX_ACCOUNT_AUTHORITY_LIFETIME 180*24*60*60 // 6 months +#define RBAC_MAX_AUTHS_PER_PERMISSION 15 // 15 ops linked per permission + +#define NFT_TOKEN_MIN_LENGTH 3 +#define NFT_TOKEN_MAX_LENGTH 15 +#define NFT_URI_MAX_LENGTH GRAPHENE_MAX_URL_LENGTH + +#define ACCOUNT_ROLES_MAX_PER_ACCOUNT 20 // Max 20 roles can be created by a resource owner +#define ACCOUNT_ROLES_MAX_LIFETIME 365*24*60*60 // 1 Year + diff --git a/libraries/chain/include/graphene/chain/protocol/custom.hpp b/libraries/protocol/include/graphene/protocol/custom.hpp similarity index 81% rename from libraries/chain/include/graphene/chain/protocol/custom.hpp rename to libraries/protocol/include/graphene/protocol/custom.hpp index 6c3af9262..871d708c2 100644 --- a/libraries/chain/include/graphene/chain/protocol/custom.hpp +++ b/libraries/protocol/include/graphene/protocol/custom.hpp @@ -23,9 +23,10 @@ */ #pragma once -#include +#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * @brief provides a generic way to add higher level protocols on top of witness consensus @@ -55,10 +56,10 @@ namespace graphene { namespace chain { } }; -} } // namespace graphene::chain +} } // namespace graphene::protocol -FC_REFLECT( graphene::chain::custom_operation::fee_parameters_type, (fee)(price_per_kbyte) ) -FC_REFLECT( graphene::chain::custom_operation, (fee)(payer)(required_auths)(id)(data) ) +FC_REFLECT( graphene::protocol::custom_operation::fee_parameters_type, (fee)(price_per_kbyte) ) +FC_REFLECT( graphene::protocol::custom_operation, (fee)(payer)(required_auths)(id)(data) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::custom_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::custom_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::custom_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::custom_operation ) diff --git a/libraries/chain/include/graphene/chain/protocol/custom_account_authority.hpp b/libraries/protocol/include/graphene/protocol/custom_account_authority.hpp similarity index 67% rename from libraries/chain/include/graphene/chain/protocol/custom_account_authority.hpp rename to libraries/protocol/include/graphene/protocol/custom_account_authority.hpp index b3fe29037..90b5bf4dd 100644 --- a/libraries/chain/include/graphene/chain/protocol/custom_account_authority.hpp +++ b/libraries/protocol/include/graphene/protocol/custom_account_authority.hpp @@ -1,9 +1,9 @@ #pragma once -#include +#include namespace graphene { -namespace chain +namespace protocol { struct custom_account_authority_create_operation : public base_operation @@ -63,14 +63,14 @@ struct custom_account_authority_delete_operation : public base_operation share_type calculate_fee(const fee_parameters_type &k) const { return k.fee; } }; -} // namespace chain +} // namespace protocol } // namespace graphene -FC_REFLECT(graphene::chain::custom_account_authority_create_operation::fee_parameters_type, (fee)(price_per_kbyte)) -FC_REFLECT(graphene::chain::custom_account_authority_create_operation, (fee)(permission_id)(operation_type)(valid_from)(valid_to)(owner_account)(extensions)) +FC_REFLECT(graphene::protocol::custom_account_authority_create_operation::fee_parameters_type, (fee)(price_per_kbyte)) +FC_REFLECT(graphene::protocol::custom_account_authority_create_operation, (fee)(permission_id)(operation_type)(valid_from)(valid_to)(owner_account)(extensions)) -FC_REFLECT(graphene::chain::custom_account_authority_update_operation::fee_parameters_type, (fee)) -FC_REFLECT(graphene::chain::custom_account_authority_update_operation, (fee)(auth_id)(new_valid_from)(new_valid_to)(owner_account)(extensions)) +FC_REFLECT(graphene::protocol::custom_account_authority_update_operation::fee_parameters_type, (fee)) +FC_REFLECT(graphene::protocol::custom_account_authority_update_operation, (fee)(auth_id)(new_valid_from)(new_valid_to)(owner_account)(extensions)) -FC_REFLECT(graphene::chain::custom_account_authority_delete_operation::fee_parameters_type, (fee)) -FC_REFLECT(graphene::chain::custom_account_authority_delete_operation, (fee)(auth_id)(owner_account)(extensions)) +FC_REFLECT(graphene::protocol::custom_account_authority_delete_operation::fee_parameters_type, (fee)) +FC_REFLECT(graphene::protocol::custom_account_authority_delete_operation, (fee)(auth_id)(owner_account)(extensions)) diff --git a/libraries/chain/include/graphene/chain/protocol/custom_permission.hpp b/libraries/protocol/include/graphene/protocol/custom_permission.hpp similarity index 66% rename from libraries/chain/include/graphene/chain/protocol/custom_permission.hpp rename to libraries/protocol/include/graphene/protocol/custom_permission.hpp index d61384c20..442b8bf27 100644 --- a/libraries/chain/include/graphene/chain/protocol/custom_permission.hpp +++ b/libraries/protocol/include/graphene/protocol/custom_permission.hpp @@ -1,9 +1,10 @@ #pragma once -#include +#include +#include namespace graphene { -namespace chain +namespace protocol { struct custom_permission_create_operation : public base_operation @@ -60,14 +61,14 @@ struct custom_permission_delete_operation : public base_operation share_type calculate_fee(const fee_parameters_type &k) const { return k.fee; } }; -} // namespace chain +} // namespace protocol } // namespace graphene -FC_REFLECT(graphene::chain::custom_permission_create_operation::fee_parameters_type, (fee)(price_per_kbyte)) -FC_REFLECT(graphene::chain::custom_permission_create_operation, (fee)(owner_account)(permission_name)(auth)(extensions)) +FC_REFLECT(graphene::protocol::custom_permission_create_operation::fee_parameters_type, (fee)(price_per_kbyte)) +FC_REFLECT(graphene::protocol::custom_permission_create_operation, (fee)(owner_account)(permission_name)(auth)(extensions)) -FC_REFLECT(graphene::chain::custom_permission_update_operation::fee_parameters_type, (fee)) -FC_REFLECT(graphene::chain::custom_permission_update_operation, (fee)(permission_id)(new_auth)(owner_account)(extensions)) +FC_REFLECT(graphene::protocol::custom_permission_update_operation::fee_parameters_type, (fee)) +FC_REFLECT(graphene::protocol::custom_permission_update_operation, (fee)(permission_id)(new_auth)(owner_account)(extensions)) -FC_REFLECT(graphene::chain::custom_permission_delete_operation::fee_parameters_type, (fee)) -FC_REFLECT(graphene::chain::custom_permission_delete_operation, (fee)(permission_id)(owner_account)(extensions)) +FC_REFLECT(graphene::protocol::custom_permission_delete_operation::fee_parameters_type, (fee)) +FC_REFLECT(graphene::protocol::custom_permission_delete_operation, (fee)(permission_id)(owner_account)(extensions)) diff --git a/libraries/chain/include/graphene/chain/protocol/event.hpp b/libraries/protocol/include/graphene/protocol/event.hpp similarity index 87% rename from libraries/chain/include/graphene/chain/protocol/event.hpp rename to libraries/protocol/include/graphene/protocol/event.hpp index 5934ad897..75012733f 100644 --- a/libraries/chain/include/graphene/chain/protocol/event.hpp +++ b/libraries/protocol/include/graphene/protocol/event.hpp @@ -23,10 +23,10 @@ */ #pragma once -#include -#include +#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { struct event_create_operation : public base_operation { @@ -132,16 +132,16 @@ struct event_update_status_operation : public base_operation } } -FC_REFLECT( graphene::chain::event_create_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::event_create_operation, +FC_REFLECT( graphene::protocol::event_create_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::event_create_operation, (fee)(name)(season)(start_time)(event_group_id)(extensions) ) -FC_REFLECT( graphene::chain::event_update_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::event_update_operation, +FC_REFLECT( graphene::protocol::event_update_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::event_update_operation, (fee)(event_id)(new_event_group_id)(new_name)(new_season)(new_start_time)(new_status)(extensions) ) -FC_REFLECT_ENUM( graphene::chain::event_status, (upcoming)(in_progress)(frozen)(finished)(canceled)(settled)(STATUS_COUNT) ) -FC_REFLECT( graphene::chain::event_update_status_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::event_update_status_operation, +FC_REFLECT_ENUM( graphene::protocol::event_status, (upcoming)(in_progress)(frozen)(finished)(canceled)(settled)(STATUS_COUNT) ) +FC_REFLECT( graphene::protocol::event_update_status_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::event_update_status_operation, (fee)(event_id)(status)(scores)(extensions) ) diff --git a/libraries/chain/include/graphene/chain/protocol/event_group.hpp b/libraries/protocol/include/graphene/protocol/event_group.hpp similarity index 83% rename from libraries/chain/include/graphene/chain/protocol/event_group.hpp rename to libraries/protocol/include/graphene/protocol/event_group.hpp index ad88ed351..daf8676da 100644 --- a/libraries/chain/include/graphene/chain/protocol/event_group.hpp +++ b/libraries/protocol/include/graphene/protocol/event_group.hpp @@ -23,10 +23,10 @@ */ #pragma once -#include -#include +#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { struct event_group_create_operation : public base_operation { @@ -86,14 +86,14 @@ struct event_group_delete_operation : public base_operation } } -FC_REFLECT( graphene::chain::event_group_create_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::event_group_create_operation, +FC_REFLECT( graphene::protocol::event_group_create_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::event_group_create_operation, (fee)(name)(sport_id)(extensions) ) -FC_REFLECT( graphene::chain::event_group_update_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::event_group_update_operation, +FC_REFLECT( graphene::protocol::event_group_update_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::event_group_update_operation, (fee)(new_sport_id)(new_name)(event_group_id)(extensions) ) -FC_REFLECT( graphene::chain::event_group_delete_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::event_group_delete_operation, +FC_REFLECT( graphene::protocol::event_group_delete_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::event_group_delete_operation, (fee)(event_group_id)(extensions) ) diff --git a/libraries/protocol/include/graphene/protocol/exceptions.hpp b/libraries/protocol/include/graphene/protocol/exceptions.hpp new file mode 100644 index 000000000..21a6e95bc --- /dev/null +++ b/libraries/protocol/include/graphene/protocol/exceptions.hpp @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2015 Cryptonomex, Inc., and contributors. + * + * The MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#pragma once + +#include + +#define GRAPHENE_ASSERT( expr, exc_type, FORMAT, ... ) \ + FC_MULTILINE_MACRO_BEGIN \ + if( !(expr) ) \ + FC_THROW_EXCEPTION( exc_type, FORMAT, __VA_ARGS__ ); \ + FC_MULTILINE_MACRO_END + +namespace graphene { namespace protocol { + + FC_DECLARE_EXCEPTION( protocol_exception, 4000000 ) + + FC_DECLARE_DERIVED_EXCEPTION( transaction_exception, graphene::protocol::protocol_exception, 4010000 ) + + FC_DECLARE_DERIVED_EXCEPTION( tx_missing_active_auth, graphene::protocol::transaction_exception, 4010001 ) + FC_DECLARE_DERIVED_EXCEPTION( tx_missing_owner_auth, graphene::protocol::transaction_exception, 4010002 ) + FC_DECLARE_DERIVED_EXCEPTION( tx_missing_other_auth, graphene::protocol::transaction_exception, 4010003 ) + FC_DECLARE_DERIVED_EXCEPTION( tx_irrelevant_sig, graphene::protocol::transaction_exception, 4010004 ) + FC_DECLARE_DERIVED_EXCEPTION( tx_duplicate_sig, graphene::protocol::transaction_exception, 4010005 ) + FC_DECLARE_DERIVED_EXCEPTION( invalid_committee_approval, graphene::protocol::transaction_exception, 4010006 ) + FC_DECLARE_DERIVED_EXCEPTION( insufficient_fee, graphene::protocol::transaction_exception, 4010007 ) + +} } // graphene::protocol diff --git a/libraries/chain/include/graphene/chain/protocol/ext.hpp b/libraries/protocol/include/graphene/protocol/ext.hpp similarity index 69% rename from libraries/chain/include/graphene/chain/protocol/ext.hpp rename to libraries/protocol/include/graphene/protocol/ext.hpp index 6c9746305..7cb47cfc1 100644 --- a/libraries/chain/include/graphene/chain/protocol/ext.hpp +++ b/libraries/protocol/include/graphene/protocol/ext.hpp @@ -26,8 +26,11 @@ #include #include #include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { + +using fc::unsigned_int; template< typename T > struct extension @@ -55,15 +58,19 @@ struct graphene_extension_pack_count_visitor template< typename Stream, typename T > struct graphene_extension_pack_read_visitor { - graphene_extension_pack_read_visitor( Stream& s, const T& v ) : stream(s), value(v) {} + graphene_extension_pack_read_visitor( Stream& s, const T& v, uint32_t _max_depth ) + : stream(s), value(v), max_depth(_max_depth - 1) + { + FC_ASSERT( _max_depth > 0 ); + } template void operator()( const char* name )const { if( (value.*member).valid() ) { - fc::raw::pack( stream, unsigned_int( which ) ); - fc::raw::pack( stream, *(value.*member) ); + fc::raw::pack( stream, unsigned_int( which ), max_depth ); + fc::raw::pack( stream, *(value.*member), max_depth ); } ++which; } @@ -71,27 +78,19 @@ struct graphene_extension_pack_read_visitor Stream& stream; const T& value; mutable uint32_t which = 0; + const uint32_t max_depth; }; -template< typename Stream, class T > -void operator<<( Stream& stream, const graphene::chain::extension& value ) -{ - graphene_extension_pack_count_visitor count_vtor( value.value ); - fc::reflector::visit( count_vtor ); - fc::raw::pack( stream, unsigned_int( count_vtor.count ) ); - graphene_extension_pack_read_visitor read_vtor( stream, value.value ); - fc::reflector::visit( read_vtor ); -} - - template< typename Stream, typename T > struct graphene_extension_unpack_visitor { - graphene_extension_unpack_visitor( Stream& s, T& v ) : stream(s), value(v) + graphene_extension_unpack_visitor( Stream& s, T& v, uint32_t _max_depth ) + : stream(s), value(v), max_depth(_max_depth - 1) { + FC_ASSERT( _max_depth > 0 ); unsigned_int c; - fc::raw::unpack( stream, c ); + fc::raw::unpack( stream, c, max_depth ); count_left = c.value; maybe_read_next_which(); } @@ -101,7 +100,7 @@ struct graphene_extension_unpack_visitor if( count_left > 0 ) { unsigned_int w; - fc::raw::unpack( stream, w ); + fc::raw::unpack( stream, w, max_depth ); next_which = w.value; } } @@ -112,7 +111,7 @@ struct graphene_extension_unpack_visitor if( (count_left > 0) && (which == next_which) ) { typename Member::value_type temp; - fc::raw::unpack( stream, temp ); + fc::raw::unpack( stream, temp, max_depth ); (value.*member) = temp; --count_left; maybe_read_next_which(); @@ -128,18 +127,10 @@ struct graphene_extension_unpack_visitor Stream& stream; T& value; + const uint32_t max_depth; }; -template< typename Stream, typename T > -void operator>>( Stream& s, graphene::chain::extension& value ) -{ - value = graphene::chain::extension(); - graphene_extension_unpack_visitor vtor( s, value.value ); - fc::reflector::visit( vtor ); - FC_ASSERT( vtor.count_left == 0 ); // unrecognized extension throws here -} - -} } // graphene::chain +} } // graphene::protocol namespace fc { @@ -172,9 +163,9 @@ struct graphene_extension_from_variant_visitor }; template< typename T > -void from_variant( const fc::variant& var, graphene::chain::extension& value, uint32_t max_depth ) +void from_variant( const fc::variant& var, graphene::protocol::extension& value, uint32_t max_depth ) { - value = graphene::chain::extension(); + value = graphene::protocol::extension(); if( var.is_null() ) return; if( var.is_array() ) @@ -205,11 +196,49 @@ struct graphene_extension_to_variant_visitor }; template< typename T > -void to_variant( const graphene::chain::extension& value, fc::variant& var, uint32_t max_depth ) +void to_variant( const graphene::protocol::extension& value, fc::variant& var, uint32_t max_depth ) { graphene_extension_to_variant_visitor vtor( value.value, max_depth ); fc::reflector::visit( vtor ); var = vtor.mvo; } +namespace raw { + +template< typename Stream, typename T > +void pack( Stream& stream, const graphene::protocol::extension& value, uint32_t _max_depth=FC_PACK_MAX_DEPTH ) +{ + FC_ASSERT( _max_depth > 0 ); + --_max_depth; + graphene::protocol::graphene_extension_pack_count_visitor count_vtor( value.value ); + fc::reflector::visit( count_vtor ); + fc::raw::pack( stream, unsigned_int( count_vtor.count ), _max_depth ); + graphene::protocol::graphene_extension_pack_read_visitor read_vtor( stream, value.value, _max_depth ); + fc::reflector::visit( read_vtor ); +} + + +template< typename Stream, typename T > +void unpack( Stream& s, graphene::protocol::extension& value, uint32_t _max_depth=FC_PACK_MAX_DEPTH ) +{ + FC_ASSERT( _max_depth > 0 ); + --_max_depth; + value = graphene::protocol::extension(); + graphene::protocol::graphene_extension_unpack_visitor vtor( s, value.value, _max_depth ); + fc::reflector::visit( vtor ); + FC_ASSERT( vtor.count_left == 0 ); // unrecognized extension throws here +} + +} // fc::raw + +template struct get_typename< graphene::protocol::extension > +{ + static const char* name() + { + static std::string n = std::string("graphene::protocol::extension<") + + fc::get_typename::name() + std::string(">"); + return n.c_str(); + } +}; + } // fc diff --git a/libraries/chain/include/graphene/chain/protocol/fba.hpp b/libraries/protocol/include/graphene/protocol/fba.hpp similarity index 78% rename from libraries/chain/include/graphene/chain/protocol/fba.hpp rename to libraries/protocol/include/graphene/protocol/fba.hpp index dc672436f..1b48e77e2 100644 --- a/libraries/chain/include/graphene/chain/protocol/fba.hpp +++ b/libraries/protocol/include/graphene/protocol/fba.hpp @@ -22,10 +22,10 @@ * THE SOFTWARE. */ #pragma once -#include -#include +#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { struct fba_distribute_operation : public base_operation { @@ -33,7 +33,7 @@ struct fba_distribute_operation : public base_operation asset fee; // always zero account_id_type account_id; - fba_accumulator_id_type fba_id; + object_id_type fba_id; share_type amount; account_id_type fee_payer()const { return account_id; } @@ -43,8 +43,7 @@ struct fba_distribute_operation : public base_operation } } -FC_REFLECT( graphene::chain::fba_distribute_operation::fee_parameters_type, ) +FC_REFLECT( graphene::protocol::fba_distribute_operation::fee_parameters_type, ) +FC_REFLECT( graphene::protocol::fba_distribute_operation, (fee)(account_id)(fba_id)(amount) ) -FC_REFLECT( graphene::chain::fba_distribute_operation, (fee)(account_id)(fba_id)(amount) ) - -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::fba_distribute_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::fba_distribute_operation ) diff --git a/libraries/chain/include/graphene/chain/protocol/fee_schedule.hpp b/libraries/protocol/include/graphene/protocol/fee_schedule.hpp similarity index 85% rename from libraries/chain/include/graphene/chain/protocol/fee_schedule.hpp rename to libraries/protocol/include/graphene/protocol/fee_schedule.hpp index 28a7e0528..3c523663e 100644 --- a/libraries/chain/include/graphene/chain/protocol/fee_schedule.hpp +++ b/libraries/protocol/include/graphene/protocol/fee_schedule.hpp @@ -22,9 +22,9 @@ * THE SOFTWARE. */ #pragma once -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { template struct transform_to_fee_parameters; template @@ -75,19 +75,15 @@ namespace graphene { namespace chain { /** * @note must be sorted by fee_parameters.which() and have no duplicates */ - flat_set parameters; + fee_parameters::flat_set_type parameters; uint32_t scale = GRAPHENE_100_PERCENT; ///< fee * scale / GRAPHENE_100_PERCENT }; typedef fee_schedule fee_schedule_type; -} } // graphene::chain +} } // graphene::protocol -namespace fc { - template<> struct get_typename> { static const char* name() { return "shared_ptr"; } }; -} +FC_REFLECT_TYPENAME( graphene::protocol::fee_parameters ) +FC_REFLECT( graphene::protocol::fee_schedule, (parameters)(scale) ) -FC_REFLECT_TYPENAME( graphene::chain::fee_parameters ) -FC_REFLECT( graphene::chain::fee_schedule, (parameters)(scale) ) - -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::fee_schedule ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::fee_schedule ) diff --git a/libraries/chain/include/graphene/chain/protocol/lottery_ops.hpp b/libraries/protocol/include/graphene/protocol/lottery_ops.hpp similarity index 86% rename from libraries/chain/include/graphene/chain/protocol/lottery_ops.hpp rename to libraries/protocol/include/graphene/protocol/lottery_ops.hpp index 4f512bce9..22e81d44d 100644 --- a/libraries/chain/include/graphene/chain/protocol/lottery_ops.hpp +++ b/libraries/protocol/include/graphene/protocol/lottery_ops.hpp @@ -22,10 +22,9 @@ * THE SOFTWARE. */ #pragma once -#include -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * @ingroup operations @@ -104,9 +103,9 @@ namespace graphene { namespace chain { share_type calculate_fee( const fee_parameters_type& k )const { return k.fee; } }; -} } // graphene::chain +} } // graphene::protocol -FC_REFLECT( graphene::chain::ticket_purchase_operation, +FC_REFLECT( graphene::protocol::ticket_purchase_operation, (fee) (lottery) (buyer) @@ -114,10 +113,10 @@ FC_REFLECT( graphene::chain::ticket_purchase_operation, (amount) (extensions) ) -FC_REFLECT( graphene::chain::ticket_purchase_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::ticket_purchase_operation::fee_parameters_type, (fee) ) -FC_REFLECT_TYPENAME( graphene::chain::ticket_num ) -FC_REFLECT( graphene::chain::lottery_reward_operation, +FC_REFLECT_TYPENAME( graphene::protocol::ticket_num ) +FC_REFLECT( graphene::protocol::lottery_reward_operation, (fee) (lottery) (winner) @@ -126,13 +125,13 @@ FC_REFLECT( graphene::chain::lottery_reward_operation, (is_benefactor_reward) (winner_ticket_id) ) -FC_REFLECT( graphene::chain::lottery_reward_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::lottery_reward_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::lottery_end_operation, +FC_REFLECT( graphene::protocol::lottery_end_operation, (fee) (lottery) (participants) (extensions) ) -FC_REFLECT( graphene::chain::lottery_end_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::lottery_end_operation::fee_parameters_type, (fee) ) diff --git a/libraries/chain/include/graphene/chain/protocol/market.hpp b/libraries/protocol/include/graphene/protocol/market.hpp similarity index 79% rename from libraries/chain/include/graphene/chain/protocol/market.hpp rename to libraries/protocol/include/graphene/protocol/market.hpp index 2bff8c560..3e3b9c219 100644 --- a/libraries/chain/include/graphene/chain/protocol/market.hpp +++ b/libraries/protocol/include/graphene/protocol/market.hpp @@ -22,10 +22,10 @@ * THE SOFTWARE. */ #pragma once -#include -#include +#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * @class limit_order_create_operation @@ -73,7 +73,6 @@ namespace graphene { namespace chain { price get_price()const { return amount_to_sell / min_to_receive; } }; - /** * @ingroup operations * Used to cancel an existing limit order. Both fee_pay_account and the @@ -159,22 +158,21 @@ namespace graphene { namespace chain { share_type calculate_fee(const fee_parameters_type& k)const { return 0; } }; -} } // graphene::chain - -FC_REFLECT( graphene::chain::limit_order_create_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::limit_order_cancel_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::call_order_update_operation::fee_parameters_type, (fee) ) -/// THIS IS THE ONLY VIRTUAL OPERATION THUS FAR... -FC_REFLECT( graphene::chain::fill_order_operation::fee_parameters_type, ) -FC_REFLECT( graphene::chain::limit_order_create_operation,(fee)(seller)(amount_to_sell)(min_to_receive)(expiration)(fill_or_kill)(extensions)) -FC_REFLECT( graphene::chain::limit_order_cancel_operation,(fee)(fee_paying_account)(order)(extensions) ) -FC_REFLECT( graphene::chain::call_order_update_operation, (fee)(funding_account)(delta_collateral)(delta_debt)(extensions) ) -FC_REFLECT( graphene::chain::fill_order_operation, (fee)(order_id)(account_id)(pays)(receives) ) - -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::limit_order_create_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::limit_order_cancel_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::call_order_update_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::limit_order_create_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::limit_order_cancel_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::call_order_update_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::fill_order_operation ) +} } // graphene::protocol + +FC_REFLECT( graphene::protocol::limit_order_create_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::limit_order_cancel_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::call_order_update_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::fill_order_operation::fee_parameters_type, ) // VIRTUAL +FC_REFLECT( graphene::protocol::limit_order_create_operation,(fee)(seller)(amount_to_sell)(min_to_receive)(expiration)(fill_or_kill)(extensions)) +FC_REFLECT( graphene::protocol::limit_order_cancel_operation,(fee)(fee_paying_account)(order)(extensions) ) +FC_REFLECT( graphene::protocol::call_order_update_operation, (fee)(funding_account)(delta_collateral)(delta_debt)(extensions) ) +FC_REFLECT( graphene::protocol::fill_order_operation, (fee)(order_id)(account_id)(pays)(receives) ) + +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::limit_order_create_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::limit_order_cancel_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::call_order_update_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::limit_order_create_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::limit_order_cancel_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::call_order_update_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::fill_order_operation ) diff --git a/libraries/chain/include/graphene/chain/protocol/memo.hpp b/libraries/protocol/include/graphene/protocol/memo.hpp similarity index 89% rename from libraries/chain/include/graphene/chain/protocol/memo.hpp rename to libraries/protocol/include/graphene/protocol/memo.hpp index 6c5b69fba..d0ef21155 100644 --- a/libraries/chain/include/graphene/chain/protocol/memo.hpp +++ b/libraries/protocol/include/graphene/protocol/memo.hpp @@ -22,9 +22,9 @@ * THE SOFTWARE. */ #pragma once -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * @brief defines the keys used to derive the shared secret @@ -85,10 +85,10 @@ namespace graphene { namespace chain { static memo_message deserialize(const string& serial); }; -} } // namespace graphene::chain +} } // namespace graphene::protocol -FC_REFLECT( graphene::chain::memo_message, (checksum)(text) ) -FC_REFLECT( graphene::chain::memo_data, (from)(to)(nonce)(message) ) +FC_REFLECT( graphene::protocol::memo_message, (checksum)(text) ) +FC_REFLECT( graphene::protocol::memo_data, (from)(to)(nonce)(message) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::memo_message ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::memo_data ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::memo_message ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::memo_data ) diff --git a/libraries/chain/include/graphene/chain/protocol/nft_ops.hpp b/libraries/protocol/include/graphene/protocol/nft_ops.hpp similarity index 70% rename from libraries/chain/include/graphene/chain/protocol/nft_ops.hpp rename to libraries/protocol/include/graphene/protocol/nft_ops.hpp index 4facf51aa..d5ebb983c 100644 --- a/libraries/chain/include/graphene/chain/protocol/nft_ops.hpp +++ b/libraries/protocol/include/graphene/protocol/nft_ops.hpp @@ -1,8 +1,8 @@ #pragma once -#include -#include +#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { struct nft_metadata_create_operation : public base_operation { @@ -131,18 +131,19 @@ namespace graphene { namespace chain { share_type calculate_fee(const fee_parameters_type &k) const; }; -} } // graphene::chain - -FC_REFLECT( graphene::chain::nft_metadata_create_operation::fee_parameters_type, (fee) (price_per_kbyte) ) -FC_REFLECT( graphene::chain::nft_metadata_update_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::nft_mint_operation::fee_parameters_type, (fee) (price_per_kbyte) ) -FC_REFLECT( graphene::chain::nft_safe_transfer_from_operation::fee_parameters_type, (fee) (price_per_kbyte) ) -FC_REFLECT( graphene::chain::nft_approve_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::nft_set_approval_for_all_operation::fee_parameters_type, (fee) ) - -FC_REFLECT( graphene::chain::nft_metadata_create_operation, (fee) (owner) (name) (symbol) (base_uri) (revenue_partner) (revenue_split) (is_transferable) (is_sellable) (account_role) (extensions) ) -FC_REFLECT( graphene::chain::nft_metadata_update_operation, (fee) (owner) (nft_metadata_id) (name) (symbol) (base_uri) (revenue_partner) (revenue_split) (is_transferable) (is_sellable) (account_role) (extensions) ) -FC_REFLECT( graphene::chain::nft_mint_operation, (fee) (payer) (nft_metadata_id) (owner) (approved) (approved_operators) (token_uri) (extensions) ) -FC_REFLECT( graphene::chain::nft_safe_transfer_from_operation, (fee) (operator_) (from) (to) (token_id) (data) (extensions) ) -FC_REFLECT( graphene::chain::nft_approve_operation, (fee) (operator_) (approved) (token_id) (extensions) ) -FC_REFLECT( graphene::chain::nft_set_approval_for_all_operation, (fee) (owner) (operator_) (approved) (extensions) ) +} } // graphene::protocol + +FC_REFLECT( graphene::protocol::nft_metadata_create_operation::fee_parameters_type, (fee) (price_per_kbyte) ) +FC_REFLECT( graphene::protocol::nft_metadata_update_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::nft_mint_operation::fee_parameters_type, (fee) (price_per_kbyte) ) +FC_REFLECT( graphene::protocol::nft_safe_transfer_from_operation::fee_parameters_type, (fee) (price_per_kbyte) ) +FC_REFLECT( graphene::protocol::nft_approve_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::nft_set_approval_for_all_operation::fee_parameters_type, (fee) ) + +FC_REFLECT( graphene::protocol::nft_metadata_create_operation, (fee) (owner) (name) (symbol) (base_uri) (revenue_partner) (revenue_split) (is_transferable) (is_sellable) (account_role) (extensions) ) +FC_REFLECT( graphene::protocol::nft_metadata_update_operation, (fee) (owner) (nft_metadata_id) (name) (symbol) (base_uri) (revenue_partner) (revenue_split) (is_transferable) (is_sellable) (account_role) (extensions) ) +FC_REFLECT( graphene::protocol::nft_mint_operation, (fee) (payer) (nft_metadata_id) (owner) (approved) (approved_operators) (token_uri) (extensions) ) +FC_REFLECT( graphene::protocol::nft_safe_transfer_from_operation, (fee) (operator_) (from) (to) (token_id) (data) (extensions) ) +FC_REFLECT( graphene::protocol::nft_approve_operation, (fee) (operator_) (approved) (token_id) (extensions) ) +FC_REFLECT( graphene::protocol::nft_set_approval_for_all_operation, (fee) (owner) (operator_) (approved) (extensions) ) + diff --git a/libraries/db/include/graphene/db/object_id.hpp b/libraries/protocol/include/graphene/protocol/object_id.hpp similarity index 80% rename from libraries/db/include/graphene/db/object_id.hpp rename to libraries/protocol/include/graphene/protocol/object_id.hpp index 255ef0486..b641e7602 100644 --- a/libraries/db/include/graphene/db/object_id.hpp +++ b/libraries/protocol/include/graphene/protocol/object_id.hpp @@ -34,7 +34,6 @@ namespace graphene { namespace db { using fc::flat_map; using fc::variant; using fc::unsigned_int; - using fc::signed_int; struct object_id_type { @@ -93,14 +92,26 @@ namespace graphene { namespace db { class object; class object_database; - template + /// This template is used to downcast a generic object type to a specific xyz_object type. + template + struct object_downcast { using type = object; }; + // This macro specializes the above template for a specific xyz_object type +#define MAP_OBJECT_ID_TO_TYPE(OBJECT) \ + namespace graphene { namespace db { \ + template<> \ + struct object_downcast> { using type = OBJECT; }; \ + } } + template + using object_downcast_t = typename object_downcast::type; + + template struct object_id { - typedef T type; static const uint8_t space_id = SpaceID; static const uint8_t type_id = TypeID; - object_id(){} + object_id() = default; object_id( unsigned_int i ):instance(i){} explicit object_id( uint64_t i ):instance(i) { @@ -117,14 +128,18 @@ namespace graphene { namespace db { explicit operator uint64_t()const { return object_id_type( *this ).number; } template - const T& operator()(const DB& db)const { return db.get(*this); } + auto operator()(const DB& db)const -> const decltype(db.get(*this))& { return db.get(*this); } friend bool operator == ( const object_id& a, const object_id& b ) { return a.instance == b.instance; } friend bool operator != ( const object_id& a, const object_id& b ) { return a.instance != b.instance; } friend bool operator == ( const object_id_type& a, const object_id& b ) { return a == object_id_type(b); } friend bool operator != ( const object_id_type& a, const object_id& b ) { return a != object_id_type(b); } - friend bool operator == ( const object_id& b, const object_id_type& a ) { return a == object_id_type(b); } - friend bool operator != ( const object_id& b, const object_id_type& a ) { return a != object_id_type(b); } + friend bool operator == ( const object_id& a, const object_id_type& b ) { return object_id_type(a) == b; } + friend bool operator != ( const object_id& a, const object_id_type& b ) { return object_id_type(a) != b; } + friend bool operator == ( const object_id& a, const fc::unsigned_int& b ) { return a.instance == b; } + friend bool operator != ( const object_id& a, const fc::unsigned_int& b ) { return a.instance != b; } + friend bool operator == ( const fc::unsigned_int& a, const object_id& b ) { return a == b.instance; } + friend bool operator != ( const fc::unsigned_int& a, const object_id& b ) { return a != b.instance; } friend bool operator < ( const object_id& a, const object_id& b ) { return a.instance.value < b.instance.value; } friend bool operator > ( const object_id& a, const object_id& b ) { return a.instance.value > b.instance.value; } @@ -140,8 +155,8 @@ FC_REFLECT( graphene::db::object_id_type, (number) ) // REFLECT object_id manually because it has 2 template params namespace fc { -template -struct get_typename> +template +struct get_typename> { static const char* name() { return typeid(get_typename).name(); @@ -150,12 +165,11 @@ struct get_typename> } }; -template -struct reflector > +template +struct reflector > { - typedef graphene::db::object_id type; - typedef fc::true_type is_defined; - typedef fc::false_type is_enum; + typedef graphene::db::object_id type; + typedef std::true_type is_defined; enum member_count_enum { local_member_count = 1, total_member_count = 1 @@ -190,13 +204,13 @@ struct reflector > FC_ASSERT( type_id <= 0xff ); vo.number |= (space_id << 56) | (type_id << 48); } FC_CAPTURE_AND_RETHROW( (var) ) } - template - void to_variant( const graphene::db::object_id& var, fc::variant& vo, uint32_t max_depth = 1 ) + template + void to_variant( const graphene::db::object_id& var, fc::variant& vo, uint32_t max_depth = 1 ) { vo = fc::to_string(SpaceID) + "." + fc::to_string(TypeID) + "." + fc::to_string(var.instance.value); } - template - void from_variant( const fc::variant& var, graphene::db::object_id& vo, uint32_t max_depth = 1 ) + template + void from_variant( const fc::variant& var, graphene::db::object_id& vo, uint32_t max_depth = 1 ) { try { const auto& s = var.get_string(); auto first_dot = s.find('.'); diff --git a/libraries/chain/include/graphene/chain/protocol/offer.hpp b/libraries/protocol/include/graphene/protocol/offer.hpp similarity index 84% rename from libraries/chain/include/graphene/chain/protocol/offer.hpp rename to libraries/protocol/include/graphene/protocol/offer.hpp index 2bf3dfc2f..d5a890fdf 100644 --- a/libraries/chain/include/graphene/chain/protocol/offer.hpp +++ b/libraries/protocol/include/graphene/protocol/offer.hpp @@ -1,10 +1,10 @@ #pragma once -#include -#include +#include +#include namespace graphene { - namespace chain + namespace protocol { /* @@ -118,26 +118,26 @@ namespace graphene share_type calculate_fee(const fee_parameters_type &k) const; }; - } // namespace chain + } // namespace protocol } // namespace graphene -FC_REFLECT(graphene::chain::offer_operation::fee_parameters_type, +FC_REFLECT(graphene::protocol::offer_operation::fee_parameters_type, (fee)(price_per_kbyte)); -FC_REFLECT(graphene::chain::offer_operation, +FC_REFLECT(graphene::protocol::offer_operation, (fee)(item_ids)(issuer)(minimum_price)(maximum_price)(buying_item)(offer_expiration_date)(memo)(extensions)); -FC_REFLECT(graphene::chain::bid_operation::fee_parameters_type, +FC_REFLECT(graphene::protocol::bid_operation::fee_parameters_type, (fee)); -FC_REFLECT(graphene::chain::bid_operation, +FC_REFLECT(graphene::protocol::bid_operation, (fee)(bidder)(bid_price)(offer_id)(extensions)); -FC_REFLECT(graphene::chain::cancel_offer_operation::fee_parameters_type, +FC_REFLECT(graphene::protocol::cancel_offer_operation::fee_parameters_type, (fee)); -FC_REFLECT(graphene::chain::cancel_offer_operation, +FC_REFLECT(graphene::protocol::cancel_offer_operation, (fee)(issuer)(offer_id)(extensions)); -FC_REFLECT_ENUM(graphene::chain::result_type, (Expired)(ExpiredNoBid)(Cancelled)); -FC_REFLECT(graphene::chain::finalize_offer_operation::fee_parameters_type, +FC_REFLECT_ENUM(graphene::protocol::result_type, (Expired)(ExpiredNoBid)(Cancelled)); +FC_REFLECT(graphene::protocol::finalize_offer_operation::fee_parameters_type, (fee)); -FC_REFLECT(graphene::chain::finalize_offer_operation, +FC_REFLECT(graphene::protocol::finalize_offer_operation, (fee)(fee_paying_account)(offer_id)(result)(extensions)); diff --git a/libraries/chain/include/graphene/chain/protocol/operations.hpp b/libraries/protocol/include/graphene/protocol/operations.hpp similarity index 79% rename from libraries/chain/include/graphene/chain/protocol/operations.hpp rename to libraries/protocol/include/graphene/protocol/operations.hpp index 1a1222a54..9dd18c99e 100644 --- a/libraries/chain/include/graphene/chain/protocol/operations.hpp +++ b/libraries/protocol/include/graphene/protocol/operations.hpp @@ -22,42 +22,42 @@ * THE SOFTWARE. */ #pragma once -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * @ingroup operations @@ -213,9 +213,9 @@ namespace graphene { namespace chain { operation op; }; -} } // graphene::chain +} } // graphene::protocol -FC_REFLECT_TYPENAME( graphene::chain::operation ) -FC_REFLECT( graphene::chain::op_wrapper, (op) ) +FC_REFLECT_TYPENAME( graphene::protocol::operation ) +FC_REFLECT( graphene::protocol::op_wrapper, (op) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::op_wrapper ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::op_wrapper ) diff --git a/libraries/chain/include/graphene/chain/protocol/proposal.hpp b/libraries/protocol/include/graphene/protocol/proposal.hpp similarity index 87% rename from libraries/chain/include/graphene/chain/protocol/proposal.hpp rename to libraries/protocol/include/graphene/protocol/proposal.hpp index 141ec35fe..43d377226 100644 --- a/libraries/chain/include/graphene/chain/protocol/proposal.hpp +++ b/libraries/protocol/include/graphene/protocol/proposal.hpp @@ -22,10 +22,10 @@ * THE SOFTWARE. */ #pragma once -#include -#include +#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * @defgroup proposed_transactions The Graphene Transaction Proposal Protocol * @ingroup operations @@ -168,22 +168,22 @@ namespace graphene { namespace chain { }; ///@} -}} // graphene::chain +}} // graphene::protocol -FC_REFLECT( graphene::chain::proposal_create_operation::fee_parameters_type, (fee)(price_per_kbyte) ) -FC_REFLECT( graphene::chain::proposal_update_operation::fee_parameters_type, (fee)(price_per_kbyte) ) -FC_REFLECT( graphene::chain::proposal_delete_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::proposal_create_operation::fee_parameters_type, (fee)(price_per_kbyte) ) +FC_REFLECT( graphene::protocol::proposal_update_operation::fee_parameters_type, (fee)(price_per_kbyte) ) +FC_REFLECT( graphene::protocol::proposal_delete_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::proposal_create_operation, (fee)(fee_paying_account)(expiration_time) +FC_REFLECT( graphene::protocol::proposal_create_operation, (fee)(fee_paying_account)(expiration_time) (proposed_ops)(review_period_seconds)(extensions) ) -FC_REFLECT( graphene::chain::proposal_update_operation, (fee)(fee_paying_account)(proposal) +FC_REFLECT( graphene::protocol::proposal_update_operation, (fee)(fee_paying_account)(proposal) (active_approvals_to_add)(active_approvals_to_remove)(owner_approvals_to_add)(owner_approvals_to_remove) (key_approvals_to_add)(key_approvals_to_remove)(extensions) ) -FC_REFLECT( graphene::chain::proposal_delete_operation, (fee)(fee_paying_account)(using_owner_authority)(proposal)(extensions) ) +FC_REFLECT( graphene::protocol::proposal_delete_operation, (fee)(fee_paying_account)(using_owner_authority)(proposal)(extensions) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::proposal_create_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::proposal_update_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::proposal_delete_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::proposal_create_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::proposal_update_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::proposal_delete_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::proposal_create_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::proposal_update_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::proposal_delete_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::proposal_create_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::proposal_update_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::proposal_delete_operation ) diff --git a/libraries/chain/include/graphene/chain/protocol/protocol.hpp b/libraries/protocol/include/graphene/protocol/protocol.hpp similarity index 92% rename from libraries/chain/include/graphene/chain/protocol/protocol.hpp rename to libraries/protocol/include/graphene/protocol/protocol.hpp index faf6bdc20..3932639f0 100644 --- a/libraries/chain/include/graphene/chain/protocol/protocol.hpp +++ b/libraries/protocol/include/graphene/protocol/protocol.hpp @@ -22,5 +22,5 @@ * THE SOFTWARE. */ #pragma once -#include -#include +#include +#include diff --git a/libraries/chain/include/graphene/chain/pts_address.hpp b/libraries/protocol/include/graphene/protocol/pts_address.hpp similarity index 76% rename from libraries/chain/include/graphene/chain/pts_address.hpp rename to libraries/protocol/include/graphene/protocol/pts_address.hpp index c0bc80ff7..403f086a9 100644 --- a/libraries/chain/include/graphene/chain/pts_address.hpp +++ b/libraries/protocol/include/graphene/protocol/pts_address.hpp @@ -23,14 +23,19 @@ */ #pragma once -#include +#include +#include #include #include #include +#include +#include +#include + namespace fc { namespace ecc { class public_key; } } -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * Implements address stringification and validation from PTS @@ -46,42 +51,44 @@ namespace graphene { namespace chain { operator std::string()const; ///< converts to base58 + checksum - fc::array addr; ///< binary representation of address + std::array addr; ///< binary representation of address }; inline bool operator == ( const pts_address& a, const pts_address& b ) { return a.addr == b.addr; } inline bool operator != ( const pts_address& a, const pts_address& b ) { return a.addr != b.addr; } inline bool operator < ( const pts_address& a, const pts_address& b ) { return a.addr < b.addr; } -} } // namespace graphene::chain +} } // namespace graphene::protocol namespace std { template<> - struct hash + struct hash { public: - size_t operator()(const graphene::chain::pts_address &a) const + size_t operator()(const graphene::protocol::pts_address &a) const { size_t s; - memcpy( (char*)&s, &a.addr.data[sizeof(a)-sizeof(s)], sizeof(s) ); + std::memcpy( (char*)&s, a.addr.data() + a.addr.size() - sizeof(s), sizeof(s) ); return s; } }; } #include -FC_REFLECT( graphene::chain::pts_address, (addr) ) +FC_REFLECT( graphene::protocol::pts_address, (addr) ) namespace fc { - void to_variant( const graphene::chain::pts_address& var, fc::variant& vo, uint32_t max_depth = 1 ); - void from_variant( const fc::variant& var, graphene::chain::pts_address& vo, uint32_t max_depth = 1 ); + void to_variant( const graphene::protocol::pts_address& var, fc::variant& vo, uint32_t max_depth = 1 ); + void from_variant( const fc::variant& var, graphene::protocol::pts_address& vo, uint32_t max_depth = 1 ); + namespace raw { - extern template void pack( datastream& s, const graphene::chain::pts_address& tx, + extern template void pack( datastream& s, const graphene::protocol::pts_address& tx, uint32_t _max_depth=FC_PACK_MAX_DEPTH ); - extern template void pack( datastream& s, const graphene::chain::pts_address& tx, + extern template void pack( datastream& s, const graphene::protocol::pts_address& tx, uint32_t _max_depth=FC_PACK_MAX_DEPTH ); - extern template void unpack( datastream& s, graphene::chain::pts_address& tx, + extern template void unpack( datastream& s, graphene::protocol::pts_address& tx, uint32_t _max_depth=FC_PACK_MAX_DEPTH ); } } // fc::raw + diff --git a/libraries/chain/include/graphene/chain/protocol/rock_paper_scissors.hpp b/libraries/protocol/include/graphene/protocol/rock_paper_scissors.hpp similarity index 79% rename from libraries/chain/include/graphene/chain/protocol/rock_paper_scissors.hpp rename to libraries/protocol/include/graphene/protocol/rock_paper_scissors.hpp index 1dff56cca..0ed1b56c5 100644 --- a/libraries/chain/include/graphene/chain/protocol/rock_paper_scissors.hpp +++ b/libraries/protocol/include/graphene/protocol/rock_paper_scissors.hpp @@ -30,8 +30,9 @@ #include #include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { struct rock_paper_scissors_game_options { @@ -69,14 +70,17 @@ namespace graphene { namespace chain { uint64_t nonce1; uint64_t nonce2; rock_paper_scissors_gesture gesture; - fc::sha256 calculate_hash() const; + fc::sha256 calculate_hash() const { + std::vector full_throw_packed(fc::raw::pack(*this)); + return fc::sha256::hash(full_throw_packed.data(), full_throw_packed.size()); + } }; struct rock_paper_scissors_throw_commit { uint64_t nonce1; fc::sha256 throw_hash; - bool operator<(const graphene::chain::rock_paper_scissors_throw_commit& rhs) const + bool operator<(const graphene::protocol::rock_paper_scissors_throw_commit& rhs) const { return std::tie(nonce1, throw_hash) < std::tie(rhs.nonce1, rhs.throw_hash); } @@ -92,25 +96,25 @@ namespace graphene { namespace chain { } } -FC_REFLECT( graphene::chain::rock_paper_scissors_game_options, (insurance_enabled)(time_per_commit_move)(time_per_reveal_move)(number_of_gestures) ) +FC_REFLECT( graphene::protocol::rock_paper_scissors_game_options, (insurance_enabled)(time_per_commit_move)(time_per_reveal_move)(number_of_gestures) ) -// FC_REFLECT_TYPENAME( graphene::chain::rock_paper_scissors_gesture) -FC_REFLECT_ENUM( graphene::chain::rock_paper_scissors_gesture, +// FC_REFLECT_TYPENAME( graphene::protocol::rock_paper_scissors_gesture) +FC_REFLECT_ENUM( graphene::protocol::rock_paper_scissors_gesture, (rock) (paper) (scissors) (spock) (lizard)) -FC_REFLECT( graphene::chain::rock_paper_scissors_throw, +FC_REFLECT( graphene::protocol::rock_paper_scissors_throw, (nonce1) (nonce2) (gesture) ) -FC_REFLECT( graphene::chain::rock_paper_scissors_throw_commit, +FC_REFLECT( graphene::protocol::rock_paper_scissors_throw_commit, (nonce1) (throw_hash) ) -FC_REFLECT( graphene::chain::rock_paper_scissors_throw_reveal, +FC_REFLECT( graphene::protocol::rock_paper_scissors_throw_reveal, (nonce2)(gesture) ) diff --git a/libraries/chain/include/graphene/chain/protocol/sidechain_address.hpp b/libraries/protocol/include/graphene/protocol/sidechain_address.hpp similarity index 78% rename from libraries/chain/include/graphene/chain/protocol/sidechain_address.hpp rename to libraries/protocol/include/graphene/protocol/sidechain_address.hpp index a5e12a03a..1a1caefc7 100644 --- a/libraries/chain/include/graphene/chain/protocol/sidechain_address.hpp +++ b/libraries/protocol/include/graphene/protocol/sidechain_address.hpp @@ -1,9 +1,8 @@ #pragma once -#include +#include +#include -#include - -namespace graphene { namespace chain { +namespace graphene { namespace protocol { struct sidechain_address_add_operation : public base_operation { @@ -59,22 +58,22 @@ namespace graphene { namespace chain { share_type calculate_fee(const fee_parameters_type& k)const { return 0; } }; -} } // namespace graphene::chain +} } // namespace graphene::protocol -FC_REFLECT(graphene::chain::sidechain_address_add_operation::fee_parameters_type, (fee) ) -FC_REFLECT(graphene::chain::sidechain_address_add_operation, (fee)(payer) +FC_REFLECT(graphene::protocol::sidechain_address_add_operation::fee_parameters_type, (fee) ) +FC_REFLECT(graphene::protocol::sidechain_address_add_operation, (fee)(payer) (sidechain_address_account)(sidechain) (deposit_public_key)(deposit_address)(deposit_address_data) (withdraw_public_key)(withdraw_address) ) -FC_REFLECT(graphene::chain::sidechain_address_update_operation::fee_parameters_type, (fee) ) -FC_REFLECT(graphene::chain::sidechain_address_update_operation, (fee)(payer) +FC_REFLECT(graphene::protocol::sidechain_address_update_operation::fee_parameters_type, (fee) ) +FC_REFLECT(graphene::protocol::sidechain_address_update_operation, (fee)(payer) (sidechain_address_id) (sidechain_address_account)(sidechain) (deposit_public_key)(deposit_address)(deposit_address_data) (withdraw_public_key)(withdraw_address) ) -FC_REFLECT(graphene::chain::sidechain_address_delete_operation::fee_parameters_type, (fee) ) -FC_REFLECT(graphene::chain::sidechain_address_delete_operation, (fee)(payer) +FC_REFLECT(graphene::protocol::sidechain_address_delete_operation::fee_parameters_type, (fee) ) +FC_REFLECT(graphene::protocol::sidechain_address_delete_operation, (fee)(payer) (sidechain_address_id) (sidechain_address_account)(sidechain) ) diff --git a/libraries/chain/include/graphene/chain/sidechain_defs.hpp b/libraries/protocol/include/graphene/protocol/sidechain_defs.hpp similarity index 71% rename from libraries/chain/include/graphene/chain/sidechain_defs.hpp rename to libraries/protocol/include/graphene/protocol/sidechain_defs.hpp index 6bbc8b5c3..aa3cd6e64 100644 --- a/libraries/chain/include/graphene/chain/sidechain_defs.hpp +++ b/libraries/protocol/include/graphene/protocol/sidechain_defs.hpp @@ -2,7 +2,7 @@ #include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { enum class sidechain_type { unknown, @@ -14,7 +14,7 @@ enum class sidechain_type { } } -FC_REFLECT_ENUM(graphene::chain::sidechain_type, +FC_REFLECT_ENUM(graphene::protocol::sidechain_type, (unknown) (bitcoin) (ethereum) diff --git a/libraries/chain/include/graphene/chain/protocol/sidechain_transaction.hpp b/libraries/protocol/include/graphene/protocol/sidechain_transaction.hpp similarity index 67% rename from libraries/chain/include/graphene/chain/protocol/sidechain_transaction.hpp rename to libraries/protocol/include/graphene/protocol/sidechain_transaction.hpp index 01a4ce741..331b54bb0 100644 --- a/libraries/chain/include/graphene/chain/protocol/sidechain_transaction.hpp +++ b/libraries/protocol/include/graphene/protocol/sidechain_transaction.hpp @@ -1,10 +1,10 @@ #pragma once -#include -#include -#include -#include +#include +#include +#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { struct sidechain_transaction_create_operation : public base_operation { @@ -64,25 +64,25 @@ namespace graphene { namespace chain { share_type calculate_fee( const fee_parameters_type& k )const { return 0; } }; -} } // graphene::chain +} } // graphene::protocol -FC_REFLECT( graphene::chain::sidechain_transaction_create_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::sidechain_transaction_create_operation, (fee)(payer) +FC_REFLECT( graphene::protocol::sidechain_transaction_create_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::sidechain_transaction_create_operation, (fee)(payer) (sidechain) (object_id) (transaction) (signers) ) -FC_REFLECT( graphene::chain::sidechain_transaction_sign_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::sidechain_transaction_sign_operation, (fee)(signer)(payer) +FC_REFLECT( graphene::protocol::sidechain_transaction_sign_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::sidechain_transaction_sign_operation, (fee)(signer)(payer) (sidechain_transaction_id) (signature) ) -FC_REFLECT( graphene::chain::sidechain_transaction_send_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::sidechain_transaction_send_operation, (fee)(payer) +FC_REFLECT( graphene::protocol::sidechain_transaction_send_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::sidechain_transaction_send_operation, (fee)(payer) (sidechain_transaction_id) (sidechain_transaction) ) -FC_REFLECT( graphene::chain::sidechain_transaction_settle_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::sidechain_transaction_settle_operation, (fee)(payer) +FC_REFLECT( graphene::protocol::sidechain_transaction_settle_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::sidechain_transaction_settle_operation, (fee)(payer) (sidechain_transaction_id) ) diff --git a/libraries/chain/include/graphene/chain/protocol/son.hpp b/libraries/protocol/include/graphene/protocol/son.hpp similarity index 69% rename from libraries/chain/include/graphene/chain/protocol/son.hpp rename to libraries/protocol/include/graphene/protocol/son.hpp index 10a754123..7bcf71800 100644 --- a/libraries/chain/include/graphene/chain/protocol/son.hpp +++ b/libraries/protocol/include/graphene/protocol/son.hpp @@ -1,8 +1,8 @@ #pragma once -#include -#include +#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { struct son_create_operation : public base_operation { @@ -95,25 +95,25 @@ namespace graphene { namespace chain { share_type calculate_fee(const fee_parameters_type& k)const { return 0; } }; -} } // namespace graphene::chain +} } // namespace graphene::protocol -FC_REFLECT(graphene::chain::son_create_operation::fee_parameters_type, (fee) ) -FC_REFLECT(graphene::chain::son_create_operation, (fee)(owner_account)(url)(deposit)(signing_key)(sidechain_public_keys) +FC_REFLECT(graphene::protocol::son_create_operation::fee_parameters_type, (fee) ) +FC_REFLECT(graphene::protocol::son_create_operation, (fee)(owner_account)(url)(deposit)(signing_key)(sidechain_public_keys) (pay_vb) ) -FC_REFLECT(graphene::chain::son_update_operation::fee_parameters_type, (fee) ) -FC_REFLECT(graphene::chain::son_update_operation, (fee)(son_id)(owner_account)(new_url)(new_deposit) +FC_REFLECT(graphene::protocol::son_update_operation::fee_parameters_type, (fee) ) +FC_REFLECT(graphene::protocol::son_update_operation, (fee)(son_id)(owner_account)(new_url)(new_deposit) (new_signing_key)(new_sidechain_public_keys)(new_pay_vb) ) -FC_REFLECT(graphene::chain::son_deregister_operation::fee_parameters_type, (fee) ) -FC_REFLECT(graphene::chain::son_deregister_operation, (fee)(son_id)(payer) ) +FC_REFLECT(graphene::protocol::son_deregister_operation::fee_parameters_type, (fee) ) +FC_REFLECT(graphene::protocol::son_deregister_operation, (fee)(son_id)(payer) ) -FC_REFLECT(graphene::chain::son_heartbeat_operation::fee_parameters_type, (fee) ) -FC_REFLECT(graphene::chain::son_heartbeat_operation, (fee)(son_id)(owner_account)(ts) ) +FC_REFLECT(graphene::protocol::son_heartbeat_operation::fee_parameters_type, (fee) ) +FC_REFLECT(graphene::protocol::son_heartbeat_operation, (fee)(son_id)(owner_account)(ts) ) -FC_REFLECT(graphene::chain::son_report_down_operation::fee_parameters_type, (fee) ) -FC_REFLECT(graphene::chain::son_report_down_operation, (fee)(son_id)(payer)(down_ts) ) +FC_REFLECT(graphene::protocol::son_report_down_operation::fee_parameters_type, (fee) ) +FC_REFLECT(graphene::protocol::son_report_down_operation, (fee)(son_id)(payer)(down_ts) ) -FC_REFLECT_ENUM( graphene::chain::son_maintenance_request_type, (request_maintenance)(cancel_request_maintenance) ) -FC_REFLECT(graphene::chain::son_maintenance_operation::fee_parameters_type, (fee) ) -FC_REFLECT(graphene::chain::son_maintenance_operation, (fee)(son_id)(owner_account)(request_type) ) +FC_REFLECT_ENUM( graphene::protocol::son_maintenance_request_type, (request_maintenance)(cancel_request_maintenance) ) +FC_REFLECT(graphene::protocol::son_maintenance_operation::fee_parameters_type, (fee) ) +FC_REFLECT(graphene::protocol::son_maintenance_operation, (fee)(son_id)(owner_account)(request_type) ) diff --git a/libraries/chain/include/graphene/chain/son_info.hpp b/libraries/protocol/include/graphene/protocol/son_info.hpp similarity index 89% rename from libraries/chain/include/graphene/chain/son_info.hpp rename to libraries/protocol/include/graphene/protocol/son_info.hpp index 2bfecac44..5d86d520b 100644 --- a/libraries/chain/include/graphene/chain/son_info.hpp +++ b/libraries/protocol/include/graphene/protocol/son_info.hpp @@ -1,8 +1,8 @@ #pragma once -#include -#include +#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { using namespace graphene::db; /** @@ -40,7 +40,7 @@ namespace graphene { namespace chain { } } -FC_REFLECT( graphene::chain::son_info, +FC_REFLECT( graphene::protocol::son_info, (son_id) (weight) (signing_key) diff --git a/libraries/chain/include/graphene/chain/protocol/son_wallet.hpp b/libraries/protocol/include/graphene/protocol/son_wallet.hpp similarity index 60% rename from libraries/chain/include/graphene/chain/protocol/son_wallet.hpp rename to libraries/protocol/include/graphene/protocol/son_wallet.hpp index 5194bed2c..a89137ff7 100644 --- a/libraries/chain/include/graphene/chain/protocol/son_wallet.hpp +++ b/libraries/protocol/include/graphene/protocol/son_wallet.hpp @@ -1,8 +1,8 @@ #pragma once -#include -#include +#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { struct son_wallet_recreate_operation : public base_operation { @@ -32,9 +32,9 @@ namespace graphene { namespace chain { share_type calculate_fee(const fee_parameters_type& k)const { return 0; } }; -} } // namespace graphene::chain +} } // namespace graphene::protocol -FC_REFLECT(graphene::chain::son_wallet_recreate_operation::fee_parameters_type, (fee) ) -FC_REFLECT(graphene::chain::son_wallet_recreate_operation, (fee)(payer)(sons) ) -FC_REFLECT(graphene::chain::son_wallet_update_operation::fee_parameters_type, (fee) ) -FC_REFLECT(graphene::chain::son_wallet_update_operation, (fee)(payer)(son_wallet_id)(sidechain)(address) ) +FC_REFLECT(graphene::protocol::son_wallet_recreate_operation::fee_parameters_type, (fee) ) +FC_REFLECT(graphene::protocol::son_wallet_recreate_operation, (fee)(payer)(sons) ) +FC_REFLECT(graphene::protocol::son_wallet_update_operation::fee_parameters_type, (fee) ) +FC_REFLECT(graphene::protocol::son_wallet_update_operation, (fee)(payer)(son_wallet_id)(sidechain)(address) ) diff --git a/libraries/chain/include/graphene/chain/protocol/son_wallet_deposit.hpp b/libraries/protocol/include/graphene/protocol/son_wallet_deposit.hpp similarity index 68% rename from libraries/chain/include/graphene/chain/protocol/son_wallet_deposit.hpp rename to libraries/protocol/include/graphene/protocol/son_wallet_deposit.hpp index 1b6a02c77..9bbf0c2d7 100644 --- a/libraries/chain/include/graphene/chain/protocol/son_wallet_deposit.hpp +++ b/libraries/protocol/include/graphene/protocol/son_wallet_deposit.hpp @@ -1,10 +1,10 @@ #pragma once -#include -#include +#include +#include #include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { struct son_wallet_deposit_create_operation : public base_operation { @@ -23,9 +23,9 @@ namespace graphene { namespace chain { std::string sidechain_to; std::string sidechain_currency; fc::safe sidechain_amount; - chain::account_id_type peerplays_from; - chain::account_id_type peerplays_to; - chain::asset peerplays_asset; + account_id_type peerplays_from; + account_id_type peerplays_to; + asset peerplays_asset; account_id_type fee_payer()const { return payer; } share_type calculate_fee(const fee_parameters_type& k)const { return 0; } @@ -44,14 +44,14 @@ namespace graphene { namespace chain { share_type calculate_fee(const fee_parameters_type& k)const { return 0; } }; -} } // namespace graphene::chain +} } // namespace graphene::protocol -FC_REFLECT(graphene::chain::son_wallet_deposit_create_operation::fee_parameters_type, (fee) ) -FC_REFLECT(graphene::chain::son_wallet_deposit_create_operation, (fee)(payer) +FC_REFLECT(graphene::protocol::son_wallet_deposit_create_operation::fee_parameters_type, (fee) ) +FC_REFLECT(graphene::protocol::son_wallet_deposit_create_operation, (fee)(payer) (son_id) (timestamp) (block_num) (sidechain) (sidechain_uid) (sidechain_transaction_id) (sidechain_from) (sidechain_to) (sidechain_currency) (sidechain_amount) (peerplays_from) (peerplays_to) (peerplays_asset) ) -FC_REFLECT(graphene::chain::son_wallet_deposit_process_operation::fee_parameters_type, (fee) ) -FC_REFLECT(graphene::chain::son_wallet_deposit_process_operation, (fee)(payer) +FC_REFLECT(graphene::protocol::son_wallet_deposit_process_operation::fee_parameters_type, (fee) ) +FC_REFLECT(graphene::protocol::son_wallet_deposit_process_operation, (fee)(payer) (son_wallet_deposit_id) ) diff --git a/libraries/chain/include/graphene/chain/protocol/son_wallet_withdraw.hpp b/libraries/protocol/include/graphene/protocol/son_wallet_withdraw.hpp similarity index 70% rename from libraries/chain/include/graphene/chain/protocol/son_wallet_withdraw.hpp rename to libraries/protocol/include/graphene/protocol/son_wallet_withdraw.hpp index 0461d4b23..ae334e458 100644 --- a/libraries/chain/include/graphene/chain/protocol/son_wallet_withdraw.hpp +++ b/libraries/protocol/include/graphene/protocol/son_wallet_withdraw.hpp @@ -1,10 +1,10 @@ #pragma once -#include -#include +#include +#include #include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { struct son_wallet_withdraw_create_operation : public base_operation { @@ -19,8 +19,8 @@ namespace graphene { namespace chain { sidechain_type sidechain; std::string peerplays_uid; std::string peerplays_transaction_id; - chain::account_id_type peerplays_from; - chain::asset peerplays_asset; + account_id_type peerplays_from; + asset peerplays_asset; sidechain_type withdraw_sidechain; std::string withdraw_address; std::string withdraw_currency; @@ -43,14 +43,14 @@ namespace graphene { namespace chain { share_type calculate_fee(const fee_parameters_type& k)const { return 0; } }; -} } // namespace graphene::chain +} } // namespace graphene::protocol -FC_REFLECT(graphene::chain::son_wallet_withdraw_create_operation::fee_parameters_type, (fee) ) -FC_REFLECT(graphene::chain::son_wallet_withdraw_create_operation, (fee)(payer) +FC_REFLECT(graphene::protocol::son_wallet_withdraw_create_operation::fee_parameters_type, (fee) ) +FC_REFLECT(graphene::protocol::son_wallet_withdraw_create_operation, (fee)(payer) (son_id) (timestamp) (block_num) (sidechain) (peerplays_uid) (peerplays_transaction_id) (peerplays_from) (peerplays_asset) (withdraw_sidechain) (withdraw_address) (withdraw_currency) (withdraw_amount) ) -FC_REFLECT(graphene::chain::son_wallet_withdraw_process_operation::fee_parameters_type, (fee) ) -FC_REFLECT(graphene::chain::son_wallet_withdraw_process_operation, (fee)(payer) +FC_REFLECT(graphene::protocol::son_wallet_withdraw_process_operation::fee_parameters_type, (fee) ) +FC_REFLECT(graphene::protocol::son_wallet_withdraw_process_operation, (fee)(payer) (son_wallet_withdraw_id) ) diff --git a/libraries/chain/include/graphene/chain/protocol/special_authority.hpp b/libraries/protocol/include/graphene/protocol/special_authority.hpp similarity index 77% rename from libraries/chain/include/graphene/chain/protocol/special_authority.hpp rename to libraries/protocol/include/graphene/protocol/special_authority.hpp index 05a80719c..4ac6e34f2 100644 --- a/libraries/chain/include/graphene/chain/protocol/special_authority.hpp +++ b/libraries/protocol/include/graphene/protocol/special_authority.hpp @@ -23,10 +23,9 @@ */ #pragma once -#include -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { struct no_special_authority {}; @@ -43,10 +42,10 @@ typedef static_variant< void validate_special_authority( const special_authority& auth ); -} } // graphene::chain +} } // graphene::protocol -FC_REFLECT( graphene::chain::no_special_authority, ) -FC_REFLECT( graphene::chain::top_holders_special_authority, (asset)(num_top_holders) ) -FC_REFLECT_TYPENAME( graphene::chain::special_authority ) +FC_REFLECT( graphene::protocol::no_special_authority, ) +FC_REFLECT( graphene::protocol::top_holders_special_authority, (asset)(num_top_holders) ) +FC_REFLECT_TYPENAME( graphene::protocol::special_authority ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::top_holders_special_authority ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::top_holders_special_authority ) diff --git a/libraries/chain/include/graphene/chain/protocol/sport.hpp b/libraries/protocol/include/graphene/protocol/sport.hpp similarity index 82% rename from libraries/chain/include/graphene/chain/protocol/sport.hpp rename to libraries/protocol/include/graphene/protocol/sport.hpp index a33e70e91..cdb649847 100644 --- a/libraries/chain/include/graphene/chain/protocol/sport.hpp +++ b/libraries/protocol/include/graphene/protocol/sport.hpp @@ -23,10 +23,10 @@ */ #pragma once -#include -#include +#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { struct sport_create_operation : public base_operation { @@ -74,14 +74,14 @@ struct sport_delete_operation : public base_operation } } -FC_REFLECT( graphene::chain::sport_create_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::sport_create_operation, +FC_REFLECT( graphene::protocol::sport_create_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::sport_create_operation, (fee)(name)(extensions) ) -FC_REFLECT( graphene::chain::sport_update_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::sport_update_operation, +FC_REFLECT( graphene::protocol::sport_update_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::sport_update_operation, (fee)(sport_id)(new_name)(extensions) ) -FC_REFLECT( graphene::chain::sport_delete_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::sport_delete_operation, +FC_REFLECT( graphene::protocol::sport_delete_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::sport_delete_operation, (fee)(sport_id)(extensions) ) diff --git a/libraries/chain/include/graphene/chain/protocol/tournament.hpp b/libraries/protocol/include/graphene/protocol/tournament.hpp similarity index 88% rename from libraries/chain/include/graphene/chain/protocol/tournament.hpp rename to libraries/protocol/include/graphene/protocol/tournament.hpp index 5c9398d75..6eebece2a 100644 --- a/libraries/chain/include/graphene/chain/protocol/tournament.hpp +++ b/libraries/protocol/include/graphene/protocol/tournament.hpp @@ -30,11 +30,10 @@ #include #include -#include -#include -#include +#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { enum class payout_type { @@ -220,15 +219,15 @@ namespace graphene { namespace chain { } } -FC_REFLECT_ENUM(graphene::chain::payout_type, +FC_REFLECT_ENUM(graphene::protocol::payout_type, (prize_award) (buyin_refund) (rake_fee) ) -FC_REFLECT_TYPENAME( graphene::chain::game_specific_options ) -FC_REFLECT_TYPENAME( graphene::chain::game_specific_moves ) -FC_REFLECT( graphene::chain::tournament_options, +FC_REFLECT_TYPENAME( graphene::protocol::game_specific_options ) +FC_REFLECT_TYPENAME( graphene::protocol::game_specific_moves ) +FC_REFLECT( graphene::protocol::tournament_options, (registration_deadline) (number_of_players) (buy_in) @@ -239,31 +238,31 @@ FC_REFLECT( graphene::chain::tournament_options, (number_of_wins) (meta) (game_options)) -FC_REFLECT( graphene::chain::tournament_create_operation, +FC_REFLECT( graphene::protocol::tournament_create_operation, (fee) (creator) (options) (extensions)) -FC_REFLECT( graphene::chain::tournament_join_operation, +FC_REFLECT( graphene::protocol::tournament_join_operation, (fee) (payer_account_id) (player_account_id) (tournament_id) (buy_in) (extensions)) -FC_REFLECT( graphene::chain::tournament_leave_operation, +FC_REFLECT( graphene::protocol::tournament_leave_operation, (fee) (canceling_account_id) (player_account_id) (tournament_id) (extensions)) -FC_REFLECT( graphene::chain::game_move_operation, +FC_REFLECT( graphene::protocol::game_move_operation, (fee) (game_id) (player_account_id) (move) (extensions)) -FC_REFLECT( graphene::chain::tournament_payout_operation, +FC_REFLECT( graphene::protocol::tournament_payout_operation, (fee) (payout_account_id) (tournament_id) @@ -271,9 +270,9 @@ FC_REFLECT( graphene::chain::tournament_payout_operation, (type) (extensions)) -FC_REFLECT( graphene::chain::tournament_create_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::tournament_join_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::tournament_leave_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::game_move_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::tournament_payout_operation::fee_parameters_type, ) +FC_REFLECT( graphene::protocol::tournament_create_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::tournament_join_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::tournament_leave_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::game_move_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::tournament_payout_operation::fee_parameters_type, ) diff --git a/libraries/chain/include/graphene/chain/protocol/transaction.hpp b/libraries/protocol/include/graphene/protocol/transaction.hpp similarity index 93% rename from libraries/chain/include/graphene/chain/protocol/transaction.hpp rename to libraries/protocol/include/graphene/protocol/transaction.hpp index 5dbb77525..e150d1383 100644 --- a/libraries/chain/include/graphene/chain/protocol/transaction.hpp +++ b/libraries/protocol/include/graphene/protocol/transaction.hpp @@ -22,12 +22,9 @@ * THE SOFTWARE. */ #pragma once -#include -#include +#include -#include - -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * @defgroup transactions Transactions @@ -234,14 +231,15 @@ namespace graphene { namespace chain { /// @} transactions group -} } // graphene::chain +} } // graphene::protocol -FC_REFLECT( graphene::chain::transaction, (ref_block_num)(ref_block_prefix)(expiration)(operations)(extensions) ) +FC_REFLECT( graphene::protocol::transaction, (ref_block_num)(ref_block_prefix)(expiration)(operations)(extensions) ) // Note: not reflecting signees field for backward compatibility; in addition, it should not be in p2p messages -FC_REFLECT_DERIVED( graphene::chain::signed_transaction, (graphene::chain::transaction), (signatures) ) -FC_REFLECT_DERIVED( graphene::chain::processed_transaction, (graphene::chain::signed_transaction), (operation_results) ) +FC_REFLECT_DERIVED( graphene::protocol::signed_transaction, (graphene::protocol::transaction), (signatures) ) +FC_REFLECT_DERIVED( graphene::protocol::processed_transaction, (graphene::protocol::signed_transaction), + (operation_results) ) -GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::chain::transaction) -GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::chain::signed_transaction) -GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::chain::processed_transaction) +GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::protocol::transaction) +GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::protocol::signed_transaction) +GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::protocol::processed_transaction) diff --git a/libraries/chain/include/graphene/chain/protocol/transfer.hpp b/libraries/protocol/include/graphene/protocol/transfer.hpp similarity index 78% rename from libraries/chain/include/graphene/chain/protocol/transfer.hpp rename to libraries/protocol/include/graphene/protocol/transfer.hpp index 5366a7abf..bd8a0353a 100644 --- a/libraries/chain/include/graphene/chain/protocol/transfer.hpp +++ b/libraries/protocol/include/graphene/protocol/transfer.hpp @@ -22,11 +22,11 @@ * THE SOFTWARE. */ #pragma once -#include -#include -#include +#include +#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * @ingroup operations @@ -99,15 +99,15 @@ namespace graphene { namespace chain { share_type calculate_fee(const fee_parameters_type& k)const; }; -}} // graphene::chain +}} // graphene::protocol -FC_REFLECT( graphene::chain::transfer_operation::fee_parameters_type, (fee)(price_per_kbyte) ) -FC_REFLECT( graphene::chain::override_transfer_operation::fee_parameters_type, (fee)(price_per_kbyte) ) +FC_REFLECT( graphene::protocol::transfer_operation::fee_parameters_type, (fee)(price_per_kbyte) ) +FC_REFLECT( graphene::protocol::override_transfer_operation::fee_parameters_type, (fee)(price_per_kbyte) ) -FC_REFLECT( graphene::chain::override_transfer_operation, (fee)(issuer)(from)(to)(amount)(memo)(extensions) ) -FC_REFLECT( graphene::chain::transfer_operation, (fee)(from)(to)(amount)(memo)(extensions) ) +FC_REFLECT( graphene::protocol::override_transfer_operation, (fee)(issuer)(from)(to)(amount)(memo)(extensions) ) +FC_REFLECT( graphene::protocol::transfer_operation, (fee)(from)(to)(amount)(memo)(extensions) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::transfer_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::override_transfer_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::transfer_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::override_transfer_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::transfer_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::override_transfer_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::transfer_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::override_transfer_operation ) diff --git a/libraries/protocol/include/graphene/protocol/types.hpp b/libraries/protocol/include/graphene/protocol/types.hpp new file mode 100644 index 000000000..ee6b653ca --- /dev/null +++ b/libraries/protocol/include/graphene/protocol/types.hpp @@ -0,0 +1,300 @@ +/* + * Copyright (c) 2015 Cryptonomex, Inc., and contributors. + * + * The MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#pragma once + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +#include +#include + +#include + +#define GRAPHENE_EXTERNAL_SERIALIZATION(ext, type) \ +namespace fc { \ + ext template void from_variant( const variant& v, type& vo, uint32_t max_depth ); \ + ext template void to_variant( const type& v, variant& vo, uint32_t max_depth ); \ +namespace raw { \ + ext template void pack< datastream, type >( datastream& s, const type& tx, uint32_t _max_depth=FC_PACK_MAX_DEPTH ); \ + ext template void pack< sha256::encoder, type >( sha256::encoder& s, const type& tx, uint32_t _max_depth=FC_PACK_MAX_DEPTH ); \ + ext template void pack< datastream, type >( datastream& s, const type& tx, uint32_t _max_depth=FC_PACK_MAX_DEPTH ); \ + ext template void unpack< datastream, type >( datastream& s, type& tx, uint32_t _max_depth=FC_PACK_MAX_DEPTH ); \ +} } // fc::raw + +#define GRAPHENE_NAME_TO_OBJECT_TYPE(x, prefix, name) BOOST_PP_CAT(prefix, BOOST_PP_CAT(name, _object_type)) +#define GRAPHENE_NAME_TO_ID_TYPE(x, y, name) BOOST_PP_CAT(name, _id_type) +#define GRAPHENE_DECLARE_ID(x, space_prefix_seq, name) \ + using BOOST_PP_CAT(name, _id_type) = object_id; +#define GRAPHENE_REFLECT_ID(x, id_namespace, name) FC_REFLECT_TYPENAME(graphene::id_namespace::name) + +#define GRAPHENE_DEFINE_IDS(id_namespace, object_space, object_type_prefix, names_seq) \ + namespace graphene { namespace id_namespace { \ + \ + enum BOOST_PP_CAT(object_type_prefix, object_type) { \ + BOOST_PP_SEQ_ENUM(BOOST_PP_SEQ_TRANSFORM(GRAPHENE_NAME_TO_OBJECT_TYPE, object_type_prefix, names_seq)) \ + }; \ + \ + BOOST_PP_SEQ_FOR_EACH(GRAPHENE_DECLARE_ID, (object_space, object_type_prefix), names_seq) \ + \ + } } \ + \ + FC_REFLECT_ENUM(graphene::id_namespace::BOOST_PP_CAT(object_type_prefix, object_type), \ + BOOST_PP_SEQ_TRANSFORM(GRAPHENE_NAME_TO_OBJECT_TYPE, object_type_prefix, names_seq)) \ + BOOST_PP_SEQ_FOR_EACH(GRAPHENE_REFLECT_ID, id_namespace, BOOST_PP_SEQ_TRANSFORM(GRAPHENE_NAME_TO_ID_TYPE, , names_seq)) + +namespace graphene { namespace protocol { +using namespace graphene::db; + +using std::map; +using std::vector; +using std::unordered_map; +using std::string; +using std::deque; +using std::shared_ptr; +using std::weak_ptr; +using std::unique_ptr; +using std::set; +using std::pair; +using std::enable_shared_from_this; +using std::tie; +using std::make_pair; + +using fc::variant_object; +using fc::variant; +using fc::enum_type; +using fc::optional; +using fc::unsigned_int; +using fc::time_point_sec; +using fc::time_point; +using fc::safe; +using fc::flat_map; +using fc::flat_set; +using fc::static_variant; +using fc::ecc::range_proof_type; +using fc::ecc::range_proof_info; +using fc::ecc::commitment_type; +struct void_t{}; + +using private_key_type = fc::ecc::private_key; +using chain_id_type = fc::sha256; +using ratio_type = boost::rational; + +enum asset_issuer_permission_flags { + charge_market_fee = 0x01, /**< an issuer-specified percentage of all market trades in this asset is paid to the issuer */ + white_list = 0x02, /**< accounts must be whitelisted in order to hold this asset */ + override_authority = 0x04, /**< issuer may transfer asset back to himself */ + transfer_restricted = 0x08, /**< require the issuer to be one party to every transfer */ + disable_force_settle = 0x10, /**< disable force settling */ + global_settle = 0x20, /**< allow the bitasset issuer to force a global settling -- this may be set in permissions, but not flags */ + disable_confidential = 0x40, /**< allow the asset to be used with confidential transactions */ + witness_fed_asset = 0x80, /**< allow the asset to be fed by witnesses */ + committee_fed_asset = 0x100 /**< allow the asset to be fed by the committee */ +}; +const static uint32_t ASSET_ISSUER_PERMISSION_MASK = + charge_market_fee + | white_list + | override_authority + | transfer_restricted + | disable_force_settle + | global_settle + | disable_confidential + | witness_fed_asset + | committee_fed_asset; +const static uint32_t UIA_ASSET_ISSUER_PERMISSION_MASK = + charge_market_fee + | white_list + | override_authority + | transfer_restricted + | disable_confidential; + +enum reserved_spaces { + relative_protocol_ids = 0, + protocol_ids = 1, + implementation_ids = 2 +}; + +inline bool is_relative(object_id_type o) { return o.space() == 0; } + +using block_id_type = fc::ripemd160; +using checksum_type = fc::ripemd160; +using transaction_id_type = fc::ripemd160; +using digest_type = fc::sha256; +using signature_type = fc::ecc::compact_signature; +using share_type = safe; +using weight_type = uint16_t; +using secret_hash_type = fc::ripemd160; +using bet_multiplier_type = uint32_t; +using internationalized_string_type = flat_map; + +struct public_key_type { + struct binary_key { + binary_key() = default; + uint32_t check = 0; + fc::ecc::public_key_data data; + }; + fc::ecc::public_key_data key_data; + public_key_type(); + public_key_type(const fc::ecc::public_key_data& data); + public_key_type(const fc::ecc::public_key& pubkey); + explicit public_key_type(const std::string& base58str); + operator fc::ecc::public_key_data() const; + operator fc::ecc::public_key() const; + explicit operator std::string() const; + friend bool operator == (const public_key_type& p1, const fc::ecc::public_key& p2); + friend bool operator == (const public_key_type& p1, const public_key_type& p2); + friend bool operator != (const public_key_type& p1, const public_key_type& p2); + // TODO: This is temporary for testing + bool is_valid_v1( const std::string& base58str ); + bool is_valid_muse( const std::string& base58str ); +}; + +class pubkey_comparator { +public: + inline bool operator()(const public_key_type& a, const public_key_type& b) const { + return a.key_data < b.key_data; + } +}; + +struct fee_schedule; +} } // graphene::protocol + +namespace fc { +void to_variant(const graphene::protocol::public_key_type& var, fc::variant& vo, uint32_t max_depth = 2); +void from_variant(const fc::variant& var, graphene::protocol::public_key_type& vo, uint32_t max_depth = 2); + + +template<> +struct get_typename> { static const char* name() { + return "shared_ptr"; +} }; +template<> +struct get_typename> { static const char* name() { + return "shared_ptr"; +} }; +void from_variant( const fc::variant& var, std::shared_ptr& vo, + uint32_t max_depth = 2 ); + +} // fc::raw + +GRAPHENE_DEFINE_IDS(protocol, protocol_ids, /*protocol objects are not prefixed*/, + (null) + (base) + (account) + (asset) + (force_settlement) + (committee_member) + (witness) + (limit_order) + (call_order) + (custom) + (proposal) + (operation_history) + (withdraw_permission) + (vesting_balance) + (worker) + (balance) + (tournament) + (tournament_details) + (match) + (game) + (sport) + (event_group) + (event) + (betting_market_rules) + (betting_market_group) + (betting_market) + (bet) + (custom_permission) + (custom_account_authority) + (offer) + (nft_metadata) + (nft) + (account_role) + (son) + (son_proposal) + (son_wallet) + (son_wallet_deposit) + (son_wallet_withdraw) + (sidechain_address) + (sidechain_transaction)) + +FC_REFLECT(graphene::protocol::public_key_type, (key_data)) +FC_REFLECT(graphene::protocol::public_key_type::binary_key, (data)(check)) + +FC_REFLECT_TYPENAME(graphene::protocol::share_type) +FC_REFLECT(graphene::protocol::void_t,) + +FC_REFLECT_ENUM(graphene::protocol::asset_issuer_permission_flags, + (charge_market_fee) + (white_list) + (transfer_restricted) + (override_authority) + (disable_force_settle) + (global_settle) + (disable_confidential) + (witness_fed_asset) + (committee_fed_asset)) + +namespace fc { namespace raw { + extern template void pack( datastream& s, const graphene::protocol::public_key_type& tx, + uint32_t _max_depth=FC_PACK_MAX_DEPTH ); + extern template void pack( datastream& s, const graphene::protocol::public_key_type& tx, + uint32_t _max_depth=FC_PACK_MAX_DEPTH ); + extern template void unpack( datastream& s, graphene::protocol::public_key_type& tx, + uint32_t _max_depth=FC_PACK_MAX_DEPTH ); +} } // fc::raw diff --git a/libraries/chain/include/graphene/chain/protocol/vesting.hpp b/libraries/protocol/include/graphene/protocol/vesting.hpp similarity index 76% rename from libraries/chain/include/graphene/chain/protocol/vesting.hpp rename to libraries/protocol/include/graphene/protocol/vesting.hpp index 9bde10089..979bd2fc3 100644 --- a/libraries/chain/include/graphene/chain/protocol/vesting.hpp +++ b/libraries/protocol/include/graphene/protocol/vesting.hpp @@ -22,10 +22,11 @@ * THE SOFTWARE. */ #pragma once -#include -#include -namespace graphene { namespace chain { +#include +#include + +namespace graphene { namespace protocol { enum class vesting_balance_type { normal, gpos, son }; @@ -124,22 +125,22 @@ namespace graphene { namespace chain { } }; -} } // graphene::chain +} } // graphene::protocol -FC_REFLECT( graphene::chain::vesting_balance_create_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::vesting_balance_withdraw_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::vesting_balance_create_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::vesting_balance_withdraw_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::vesting_balance_create_operation, (fee)(creator)(owner)(amount)(policy)(balance_type) ) -FC_REFLECT( graphene::chain::vesting_balance_withdraw_operation, (fee)(vesting_balance)(owner)(amount) ) +FC_REFLECT( graphene::protocol::vesting_balance_create_operation, (fee)(creator)(owner)(amount)(policy)(balance_type) ) +FC_REFLECT( graphene::protocol::vesting_balance_withdraw_operation, (fee)(vesting_balance)(owner)(amount) ) -FC_REFLECT(graphene::chain::linear_vesting_policy_initializer, (begin_timestamp)(vesting_cliff_seconds)(vesting_duration_seconds) ) -FC_REFLECT(graphene::chain::cdd_vesting_policy_initializer, (start_claim)(vesting_seconds) ) -FC_REFLECT(graphene::chain::dormant_vesting_policy_initializer, ) -FC_REFLECT_TYPENAME( graphene::chain::vesting_policy_initializer ) +FC_REFLECT(graphene::protocol::linear_vesting_policy_initializer, (begin_timestamp)(vesting_cliff_seconds)(vesting_duration_seconds) ) +FC_REFLECT(graphene::protocol::cdd_vesting_policy_initializer, (start_claim)(vesting_seconds) ) +FC_REFLECT(graphene::protocol::dormant_vesting_policy_initializer, ) +FC_REFLECT_TYPENAME( graphene::protocol::vesting_policy_initializer ) -FC_REFLECT_ENUM( graphene::chain::vesting_balance_type, (normal)(gpos)(son) ) +FC_REFLECT_ENUM( graphene::protocol::vesting_balance_type, (normal)(gpos)(son) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::vesting_balance_create_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::vesting_balance_withdraw_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::vesting_balance_create_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::vesting_balance_withdraw_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::vesting_balance_create_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::vesting_balance_withdraw_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::vesting_balance_create_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::vesting_balance_withdraw_operation ) diff --git a/libraries/chain/include/graphene/chain/protocol/vote.hpp b/libraries/protocol/include/graphene/protocol/vote.hpp similarity index 85% rename from libraries/chain/include/graphene/chain/protocol/vote.hpp rename to libraries/protocol/include/graphene/protocol/vote.hpp index 8a46954d3..df6028744 100644 --- a/libraries/chain/include/graphene/chain/protocol/vote.hpp +++ b/libraries/protocol/include/graphene/protocol/vote.hpp @@ -24,9 +24,9 @@ #pragma once -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * @brief An ID for some votable object @@ -126,25 +126,21 @@ struct vote_id_type } }; -class global_property_object; - -vote_id_type get_next_vote_id( global_property_object& gpo, vote_id_type::vote_type type ); - -} } // graphene::chain +} } // graphene::protocol namespace fc { class variant; -void to_variant( const graphene::chain::vote_id_type& var, fc::variant& vo, uint32_t max_depth = 1 ); -void from_variant( const fc::variant& var, graphene::chain::vote_id_type& vo, uint32_t max_depth = 1 ); +void to_variant( const graphene::protocol::vote_id_type& var, fc::variant& vo, uint32_t max_depth = 1 ); +void from_variant( const fc::variant& var, graphene::protocol::vote_id_type& vo, uint32_t max_depth = 1 ); } // fc -FC_REFLECT_TYPENAME( fc::flat_set ) +FC_REFLECT_TYPENAME( fc::flat_set ) -FC_REFLECT_ENUM( graphene::chain::vote_id_type::vote_type, (witness)(committee)(worker)(son)(VOTE_TYPE_COUNT) ) -FC_REFLECT( graphene::chain::vote_id_type, (content) ) +FC_REFLECT_ENUM( graphene::protocol::vote_id_type::vote_type, (witness)(committee)(worker)(son)(VOTE_TYPE_COUNT) ) +FC_REFLECT( graphene::protocol::vote_id_type, (content) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::vote_id_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::vote_id_type ) diff --git a/libraries/chain/include/graphene/chain/protocol/withdraw_permission.hpp b/libraries/protocol/include/graphene/protocol/withdraw_permission.hpp similarity index 81% rename from libraries/chain/include/graphene/chain/protocol/withdraw_permission.hpp rename to libraries/protocol/include/graphene/protocol/withdraw_permission.hpp index 7963e99f9..01b4207f7 100644 --- a/libraries/chain/include/graphene/chain/protocol/withdraw_permission.hpp +++ b/libraries/protocol/include/graphene/protocol/withdraw_permission.hpp @@ -22,11 +22,11 @@ * THE SOFTWARE. */ #pragma once -#include -#include -#include +#include +#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * @brief Create a new withdrawal permission @@ -166,26 +166,26 @@ namespace graphene { namespace chain { void validate()const; }; -} } // graphene::chain +} } // graphene::protocol -FC_REFLECT( graphene::chain::withdraw_permission_create_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::withdraw_permission_update_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::withdraw_permission_claim_operation::fee_parameters_type, (fee)(price_per_kbyte) ) -FC_REFLECT( graphene::chain::withdraw_permission_delete_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::withdraw_permission_create_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::withdraw_permission_update_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::withdraw_permission_claim_operation::fee_parameters_type, (fee)(price_per_kbyte) ) +FC_REFLECT( graphene::protocol::withdraw_permission_delete_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::withdraw_permission_create_operation, (fee)(withdraw_from_account)(authorized_account) +FC_REFLECT( graphene::protocol::withdraw_permission_create_operation, (fee)(withdraw_from_account)(authorized_account) (withdrawal_limit)(withdrawal_period_sec)(periods_until_expiration)(period_start_time) ) -FC_REFLECT( graphene::chain::withdraw_permission_update_operation, (fee)(withdraw_from_account)(authorized_account) +FC_REFLECT( graphene::protocol::withdraw_permission_update_operation, (fee)(withdraw_from_account)(authorized_account) (permission_to_update)(withdrawal_limit)(withdrawal_period_sec)(period_start_time)(periods_until_expiration) ) -FC_REFLECT( graphene::chain::withdraw_permission_claim_operation, (fee)(withdraw_permission)(withdraw_from_account)(withdraw_to_account)(amount_to_withdraw)(memo) ); -FC_REFLECT( graphene::chain::withdraw_permission_delete_operation, (fee)(withdraw_from_account)(authorized_account) +FC_REFLECT( graphene::protocol::withdraw_permission_claim_operation, (fee)(withdraw_permission)(withdraw_from_account)(withdraw_to_account)(amount_to_withdraw)(memo) ); +FC_REFLECT( graphene::protocol::withdraw_permission_delete_operation, (fee)(withdraw_from_account)(authorized_account) (withdrawal_permission) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::withdraw_permission_create_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::withdraw_permission_update_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::withdraw_permission_claim_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::withdraw_permission_delete_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::withdraw_permission_create_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::withdraw_permission_update_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::withdraw_permission_claim_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::withdraw_permission_delete_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::withdraw_permission_create_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::withdraw_permission_update_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::withdraw_permission_claim_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::withdraw_permission_delete_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::withdraw_permission_create_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::withdraw_permission_update_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::withdraw_permission_claim_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::withdraw_permission_delete_operation ) diff --git a/libraries/chain/include/graphene/chain/protocol/witness.hpp b/libraries/protocol/include/graphene/protocol/witness.hpp similarity index 75% rename from libraries/chain/include/graphene/chain/protocol/witness.hpp rename to libraries/protocol/include/graphene/protocol/witness.hpp index 2b5e88b04..7c5c94ee9 100644 --- a/libraries/chain/include/graphene/chain/protocol/witness.hpp +++ b/libraries/protocol/include/graphene/protocol/witness.hpp @@ -22,10 +22,10 @@ * THE SOFTWARE. */ #pragma once -#include -#include +#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * @brief Create a witness object, as a bid to hold a witness position on the network. @@ -78,15 +78,15 @@ namespace graphene { namespace chain { /// TODO: witness_resign_operation : public base_operation -} } // graphene::chain +} } // graphene::protocol -FC_REFLECT( graphene::chain::witness_create_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::witness_create_operation, (fee)(witness_account)(url)(block_signing_key)(initial_secret) ) +FC_REFLECT( graphene::protocol::witness_create_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::witness_create_operation, (fee)(witness_account)(url)(block_signing_key)(initial_secret) ) -FC_REFLECT( graphene::chain::witness_update_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::witness_update_operation, (fee)(witness)(witness_account)(new_url)(new_signing_key)(new_initial_secret) ) +FC_REFLECT( graphene::protocol::witness_update_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::witness_update_operation, (fee)(witness)(witness_account)(new_url)(new_signing_key)(new_initial_secret) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::witness_create_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::witness_update_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::witness_create_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::witness_update_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::witness_create_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::witness_update_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::witness_create_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::witness_update_operation ) diff --git a/libraries/chain/include/graphene/chain/protocol/worker.hpp b/libraries/protocol/include/graphene/protocol/worker.hpp similarity index 84% rename from libraries/chain/include/graphene/chain/protocol/worker.hpp rename to libraries/protocol/include/graphene/protocol/worker.hpp index 11e0aa051..eb02155d7 100644 --- a/libraries/chain/include/graphene/chain/protocol/worker.hpp +++ b/libraries/protocol/include/graphene/protocol/worker.hpp @@ -22,10 +22,10 @@ * THE SOFTWARE. */ #pragma once -#include -#include +#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * @defgroup workers The Blockchain Worker System @@ -96,14 +96,14 @@ namespace graphene { namespace chain { } } -FC_REFLECT( graphene::chain::vesting_balance_worker_initializer, (pay_vesting_period_days) ) -FC_REFLECT( graphene::chain::burn_worker_initializer, ) -FC_REFLECT( graphene::chain::refund_worker_initializer, ) -FC_REFLECT_TYPENAME( graphene::chain::worker_initializer ) +FC_REFLECT( graphene::protocol::vesting_balance_worker_initializer, (pay_vesting_period_days) ) +FC_REFLECT( graphene::protocol::burn_worker_initializer, ) +FC_REFLECT( graphene::protocol::refund_worker_initializer, ) +FC_REFLECT_TYPENAME( graphene::protocol::worker_initializer ) -FC_REFLECT( graphene::chain::worker_create_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::worker_create_operation, +FC_REFLECT( graphene::protocol::worker_create_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::worker_create_operation, (fee)(owner)(work_begin_date)(work_end_date)(daily_pay)(name)(url)(initializer) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::worker_create_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::worker_create_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::worker_create_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::worker_create_operation ) diff --git a/libraries/chain/protocol/lottery_ops.cpp b/libraries/protocol/lottery_ops.cpp similarity index 91% rename from libraries/chain/protocol/lottery_ops.cpp rename to libraries/protocol/lottery_ops.cpp index d4f11fc41..090ab5562 100644 --- a/libraries/chain/protocol/lottery_ops.cpp +++ b/libraries/protocol/lottery_ops.cpp @@ -21,9 +21,9 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { void ticket_purchase_operation::validate() const { @@ -36,4 +36,4 @@ share_type ticket_purchase_operation::calculate_fee( const fee_parameters_type& return k.fee; } -} } // namespace graphene::chain +} } // namespace graphene::protocol diff --git a/libraries/chain/protocol/market.cpp b/libraries/protocol/market.cpp similarity index 66% rename from libraries/chain/protocol/market.cpp rename to libraries/protocol/market.cpp index ae0a3a68b..87efa0b90 100644 --- a/libraries/chain/protocol/market.cpp +++ b/libraries/protocol/market.cpp @@ -21,10 +21,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include #include +#include -namespace graphene { namespace chain { +#include + +namespace graphene { namespace protocol { void limit_order_create_operation::validate()const { @@ -46,12 +48,13 @@ void call_order_update_operation::validate()const FC_ASSERT( delta_collateral.amount != 0 || delta_debt.amount != 0 ); } FC_CAPTURE_AND_RETHROW((*this)) } -} } // graphene::chain +} } // graphene::protocol + +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::limit_order_create_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::limit_order_cancel_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::call_order_update_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::limit_order_create_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::limit_order_cancel_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::call_order_update_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::fill_order_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::limit_order_create_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::limit_order_cancel_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::call_order_update_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::limit_order_create_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::limit_order_cancel_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::call_order_update_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::fill_order_operation ) diff --git a/libraries/chain/protocol/memo.cpp b/libraries/protocol/memo.cpp similarity index 83% rename from libraries/chain/protocol/memo.cpp rename to libraries/protocol/memo.cpp index afa0b486a..6780cadda 100644 --- a/libraries/chain/protocol/memo.cpp +++ b/libraries/protocol/memo.cpp @@ -21,11 +21,15 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include + +#include + #include #include -namespace graphene { namespace chain { +#include + +namespace graphene { namespace protocol { void memo_data::set_message(const fc::ecc::private_key& priv, const fc::ecc::public_key& pub, const string& msg, uint64_t custom_nonce) @@ -36,7 +40,7 @@ void memo_data::set_message(const fc::ecc::private_key& priv, const fc::ecc::pub to = pub; if( custom_nonce == 0 ) { - uint64_t entropy = fc::sha224::hash(fc::ecc::private_key::generate())._hash[0]; + uint64_t entropy = fc::sha224::hash(fc::ecc::private_key::generate())._hash[0].value(); entropy <<= 32; entropy &= 0xff00000000000000; nonce = (fc::time_point::now().time_since_epoch().count() & 0x00ffffffffffffff) | entropy; @@ -44,7 +48,7 @@ void memo_data::set_message(const fc::ecc::private_key& priv, const fc::ecc::pub nonce = custom_nonce; auto secret = priv.get_shared_secret(pub); auto nonce_plus_secret = fc::sha512::hash(fc::to_string(nonce) + secret.str()); - string text = memo_message(digest_type::hash(msg)._hash[0], msg).serialize(); + string text = memo_message(digest_type::hash(msg)._hash[0].value(), msg).serialize(); message = fc::aes_encrypt( nonce_plus_secret, vector(text.begin(), text.end()) ); } else @@ -63,7 +67,7 @@ string memo_data::get_message(const fc::ecc::private_key& priv, auto nonce_plus_secret = fc::sha512::hash(fc::to_string(nonce) + secret.str()); auto plain_text = fc::aes_decrypt( nonce_plus_secret, message ); auto result = memo_message::deserialize(string(plain_text.begin(), plain_text.end())); - FC_ASSERT( result.checksum == uint32_t(digest_type::hash(result.text)._hash[0]) ); + FC_ASSERT( result.checksum == (uint32_t)digest_type::hash(result.text)._hash[0].value() ); return result.text; } else @@ -75,7 +79,7 @@ string memo_data::get_message(const fc::ecc::private_key& priv, string memo_message::serialize() const { auto serial_checksum = string(sizeof(checksum), ' '); - (uint32_t&)(*serial_checksum.data()) = checksum; + (uint32_t&)(*serial_checksum.data()) = boost::endian::native_to_little(checksum); return serial_checksum + text; } @@ -83,12 +87,12 @@ memo_message memo_message::deserialize(const string& serial) { memo_message result; FC_ASSERT( serial.size() >= sizeof(result.checksum) ); - result.checksum = ((uint32_t&)(*serial.data())); + result.checksum = boost::endian::little_to_native((uint32_t&)(*serial.data())); result.text = serial.substr(sizeof(result.checksum)); return result; } -} } // graphene::chain +} } // graphene::protocol -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::memo_message ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::memo_data ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::memo_message ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::memo_data ) diff --git a/libraries/chain/protocol/nft.cpp b/libraries/protocol/nft.cpp similarity index 95% rename from libraries/chain/protocol/nft.cpp rename to libraries/protocol/nft.cpp index 4a66f330b..5c730d14a 100644 --- a/libraries/chain/protocol/nft.cpp +++ b/libraries/protocol/nft.cpp @@ -1,9 +1,9 @@ -#include -#include +#include +#include namespace graphene { -namespace chain +namespace protocol { bool is_valid_nft_token_name(const string &name) @@ -91,5 +91,5 @@ share_type nft_set_approval_for_all_operation::calculate_fee(const fee_parameter return k.fee; } -} // namespace chain +} // namespace protocol } // namespace graphene diff --git a/libraries/chain/protocol/offer.cpp b/libraries/protocol/offer.cpp similarity index 93% rename from libraries/chain/protocol/offer.cpp rename to libraries/protocol/offer.cpp index e83af3f83..aefb813e7 100644 --- a/libraries/chain/protocol/offer.cpp +++ b/libraries/protocol/offer.cpp @@ -1,9 +1,9 @@ -#include +#include #include namespace graphene { - namespace chain + namespace protocol { share_type offer_operation::calculate_fee(const fee_parameters_type &schedule) const { @@ -53,5 +53,5 @@ namespace graphene return core_fee_required; } - } // namespace chain -} // namespace graphene \ No newline at end of file + } // namespace protocol +} // namespace graphene diff --git a/libraries/chain/protocol/operations.cpp b/libraries/protocol/operations.cpp similarity index 90% rename from libraries/chain/protocol/operations.cpp rename to libraries/protocol/operations.cpp index 99c8a3761..68f02b330 100644 --- a/libraries/chain/protocol/operations.cpp +++ b/libraries/protocol/operations.cpp @@ -21,17 +21,18 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include -#include +#include + #include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { uint64_t base_operation::calculate_data_fee( uint64_t bytes, uint64_t price_per_kbyte ) { - auto result = (fc::uint128(bytes) * price_per_kbyte) / 1024; + auto result = (fc::uint128_t(bytes) * price_per_kbyte) / 1024; FC_ASSERT( result <= GRAPHENE_MAX_SHARE_SUPPLY ); - return result.to_uint64(); + return result; } void balance_claim_operation::validate()const @@ -100,6 +101,6 @@ void operation_get_required_authorities( const operation& op, op.visit( operation_get_required_auth( active, owner, other, ignore_custom_operation_required_auths ) ); } -} } // namespace graphene::chain +} } // namespace graphene::protocol -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::op_wrapper ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::op_wrapper ) diff --git a/libraries/chain/protocol/proposal.cpp b/libraries/protocol/proposal.cpp similarity index 83% rename from libraries/chain/protocol/proposal.cpp rename to libraries/protocol/proposal.cpp index f14f057a9..a1a401872 100644 --- a/libraries/chain/protocol/proposal.cpp +++ b/libraries/protocol/proposal.cpp @@ -21,12 +21,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include -#include +#include +#include #include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { proposal_create_operation proposal_create_operation::committee_proposal(const chain_parameters& global_params, fc::time_point_sec head_block_time ) { @@ -105,11 +105,11 @@ void proposal_update_operation::get_required_owner_authorities( flat_set -#include +#include #include #include @@ -30,23 +29,20 @@ #include #include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { pts_address::pts_address() { - memset( addr.data, 0, sizeof(addr.data) ); + memset( addr.data(), 0, addr.size() ); } pts_address::pts_address( const std::string& base58str ) { std::vector v = fc::from_base58( fc::string(base58str) ); if( v.size() ) - memcpy( addr.data, v.data(), std::min( v.size(), sizeof(addr) ) ); + memcpy( addr.data(), v.data(), std::min( v.size(), addr.size() ) ); - if( !is_valid() ) - { - FC_THROW_EXCEPTION( invalid_pts_address, "invalid pts_address ${a}", ("a", base58str) ); - } + FC_ASSERT(is_valid(), "invalid pts_address ${a}", ("a", base58str)); } pts_address::pts_address( const fc::ecc::public_key& pub, bool compressed, uint8_t version ) @@ -55,19 +51,19 @@ namespace graphene { namespace chain { if( compressed ) { auto dat = pub.serialize(); - sha2 = fc::sha256::hash(dat.data, sizeof(dat) ); + sha2 = fc::sha256::hash((char*) dat.data(), dat.size() ); } else { auto dat = pub.serialize_ecc_point(); - sha2 = fc::sha256::hash(dat.data, sizeof(dat) ); + sha2 = fc::sha256::hash((char*) dat.data(), dat.size() ); } auto rep = fc::ripemd160::hash((char*)&sha2,sizeof(sha2)); - addr.data[0] = version; - memcpy( addr.data+1, (char*)&rep, sizeof(rep) ); - auto check = fc::sha256::hash( addr.data, sizeof(rep)+1 ); + addr[0] = version; + memcpy( addr.data() + 1, (char*)&rep, sizeof(rep) ); + auto check = fc::sha256::hash( addr.data(), sizeof(rep)+1 ); check = fc::sha256::hash(check); - memcpy( addr.data+1+sizeof(rep), (char*)&check, 4 ); + memcpy( addr.data() + 1 + sizeof(rep), (char*)&check, 4 ); } /** @@ -76,34 +72,34 @@ namespace graphene { namespace chain { */ bool pts_address::is_valid()const { - auto check = fc::sha256::hash( addr.data, sizeof(fc::ripemd160)+1 ); + auto check = fc::sha256::hash( addr.data(), sizeof(fc::ripemd160)+1 ); check = fc::sha256::hash(check); - return memcmp( addr.data+1+sizeof(fc::ripemd160), (char*)&check, 4 ) == 0; + return memcmp( addr.data() + 1 + sizeof(fc::ripemd160), (char*)&check, 4 ) == 0; } pts_address::operator std::string()const { - return fc::to_base58( addr.data, sizeof(addr) ); + return fc::to_base58( addr.data(), addr.size() ); } } } // namespace graphene namespace fc { - void to_variant( const graphene::chain::pts_address& var, variant& vo, uint32_t max_depth ) + void to_variant( const graphene::protocol::pts_address& var, variant& vo, uint32_t max_depth ) { vo = std::string(var); } - void from_variant( const variant& var, graphene::chain::pts_address& vo, uint32_t max_depth ) + void from_variant( const variant& var, graphene::protocol::pts_address& vo, uint32_t max_depth ) { - vo = graphene::chain::pts_address( var.as_string() ); + vo = graphene::protocol::pts_address( var.as_string() ); } namespace raw { - template void pack( datastream& s, const graphene::chain::pts_address& tx, + template void pack( datastream& s, const graphene::protocol::pts_address& tx, uint32_t _max_depth=FC_PACK_MAX_DEPTH ); - template void pack( datastream& s, const graphene::chain::pts_address& tx, + template void pack( datastream& s, const graphene::protocol::pts_address& tx, uint32_t _max_depth=FC_PACK_MAX_DEPTH ); - template void unpack( datastream& s, graphene::chain::pts_address& tx, + template void unpack( datastream& s, graphene::protocol::pts_address& tx, uint32_t _max_depth=FC_PACK_MAX_DEPTH ); } } // fc::raw diff --git a/libraries/protocol/small_ops.cpp b/libraries/protocol/small_ops.cpp new file mode 100644 index 000000000..c0ced4312 --- /dev/null +++ b/libraries/protocol/small_ops.cpp @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2019 BitShares Blockchain Foundation, and contributors. + * + * The MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace graphene { namespace protocol { + +FC_IMPLEMENT_EXCEPTION( protocol_exception, 4000000, "protocol exception" ) + +FC_IMPLEMENT_DERIVED_EXCEPTION( transaction_exception, protocol_exception, 4010000, + "transaction validation exception" ) + +FC_IMPLEMENT_DERIVED_EXCEPTION( tx_missing_active_auth, transaction_exception, 4010001, + "missing required active authority" ) +FC_IMPLEMENT_DERIVED_EXCEPTION( tx_missing_owner_auth, transaction_exception, 4010002, + "missing required owner authority" ) +FC_IMPLEMENT_DERIVED_EXCEPTION( tx_missing_other_auth, transaction_exception, 4010003, + "missing required other authority" ) +FC_IMPLEMENT_DERIVED_EXCEPTION( tx_irrelevant_sig, transaction_exception, 4010004, + "irrelevant signature included" ) +FC_IMPLEMENT_DERIVED_EXCEPTION( tx_duplicate_sig, transaction_exception, 4010005, + "duplicate signature included" ) +FC_IMPLEMENT_DERIVED_EXCEPTION( invalid_committee_approval, transaction_exception, 4010006, + "committee account cannot directly approve transaction" ) +FC_IMPLEMENT_DERIVED_EXCEPTION( insufficient_fee, transaction_exception, 4010007, "insufficient fee" ) + +} } // graphene::protocol + +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::balance_claim_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::buyback_account_options ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::fba_distribute_operation ) + +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::vesting_balance_create_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::vesting_balance_withdraw_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::vesting_balance_create_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::vesting_balance_withdraw_operation ) + +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::chain_parameters ) + diff --git a/libraries/chain/protocol/vote.cpp b/libraries/protocol/special_authority.cpp similarity index 62% rename from libraries/chain/protocol/vote.cpp rename to libraries/protocol/special_authority.cpp index 68f476f55..26d0c4fc6 100644 --- a/libraries/chain/protocol/vote.cpp +++ b/libraries/protocol/special_authority.cpp @@ -22,32 +22,30 @@ * THE SOFTWARE. */ -#include -#include -#include +#include -namespace graphene { namespace chain { +#include -vote_id_type get_next_vote_id( global_property_object& gpo, vote_id_type::vote_type type ) -{ - return vote_id_type( type, gpo.next_available_vote_id++ ); -} - -} } // graphene::chain +namespace graphene { namespace protocol { -namespace fc +struct special_authority_validate_visitor { + typedef void result_type; -void to_variant( const graphene::chain::vote_id_type& var, variant& vo, uint32_t max_depth ) -{ - vo = string(var); -} + void operator()( const no_special_authority& a ) {} + + void operator()( const top_holders_special_authority& a ) + { + FC_ASSERT( a.num_top_holders > 0 ); + } +}; -void from_variant( const variant& var, graphene::chain::vote_id_type& vo, uint32_t max_depth ) +void validate_special_authority( const special_authority& a ) { - vo = graphene::chain::vote_id_type(var.as_string()); + special_authority_validate_visitor vtor; + a.visit( vtor ); } -} // fc +} } // graphene::protocol -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::vote_id_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::top_holders_special_authority ) diff --git a/libraries/chain/protocol/sport.cpp b/libraries/protocol/sport.cpp similarity index 93% rename from libraries/chain/protocol/sport.cpp rename to libraries/protocol/sport.cpp index a8fdbf2a0..a7d52f8dc 100644 --- a/libraries/chain/protocol/sport.cpp +++ b/libraries/protocol/sport.cpp @@ -21,9 +21,9 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { void sport_create_operation::validate() const { @@ -40,5 +40,5 @@ void sport_delete_operation::validate() const FC_ASSERT( fee.amount >= 0 ); } -} } // graphene::chain +} } // graphene::protocol diff --git a/libraries/chain/protocol/tournament.cpp b/libraries/protocol/tournament.cpp similarity index 94% rename from libraries/chain/protocol/tournament.cpp rename to libraries/protocol/tournament.cpp index 78ab4c01a..33ca25de7 100644 --- a/libraries/chain/protocol/tournament.cpp +++ b/libraries/protocol/tournament.cpp @@ -21,10 +21,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include +#include #include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { void tournament_options::validate() const { @@ -73,4 +73,4 @@ void game_move_operation::validate()const { } -} } // namespace graphene::chain +} } // namespace graphene::protocol diff --git a/libraries/chain/protocol/transaction.cpp b/libraries/protocol/transaction.cpp similarity index 91% rename from libraries/chain/protocol/transaction.cpp rename to libraries/protocol/transaction.cpp index 4c0684bd6..6c98ce16c 100644 --- a/libraries/chain/protocol/transaction.cpp +++ b/libraries/protocol/transaction.cpp @@ -21,14 +21,18 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include -#include + +#include +#include +#include +#include +#include + #include -#include #include #include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { digest_type processed_transaction::merkle_digest()const { @@ -59,7 +63,7 @@ void transaction::validate() const operation_validate(op); } -graphene::chain::transaction_id_type graphene::chain::transaction::id() const +graphene::protocol::transaction_id_type graphene::protocol::transaction::id() const { auto h = digest(); transaction_id_type result; @@ -67,7 +71,7 @@ graphene::chain::transaction_id_type graphene::chain::transaction::id() const return result; } -const signature_type& graphene::chain::signed_transaction::sign(const private_key_type& key, const chain_id_type& chain_id) +const signature_type& graphene::protocol::signed_transaction::sign(const private_key_type& key, const chain_id_type& chain_id) { digest_type h = sig_digest( chain_id ); signatures.push_back(key.sign_compact(h)); @@ -75,7 +79,7 @@ const signature_type& graphene::chain::signed_transaction::sign(const private_ke return signatures.back(); } -signature_type graphene::chain::signed_transaction::sign(const private_key_type& key, const chain_id_type& chain_id)const +signature_type graphene::protocol::signed_transaction::sign(const private_key_type& key, const chain_id_type& chain_id)const { digest_type::encoder enc; fc::raw::pack( enc, chain_id ); @@ -90,8 +94,8 @@ void transaction::set_expiration( fc::time_point_sec expiration_time ) void transaction::set_reference_block( const block_id_type& reference_block ) { - ref_block_num = fc::endian_reverse_u32(reference_block._hash[0]); - ref_block_prefix = reference_block._hash[1]; + ref_block_num = boost::endian::endian_reverse(reference_block._hash[0].value()); + ref_block_prefix = reference_block._hash[1].value(); } void transaction::get_required_authorities( flat_set& active, @@ -261,8 +265,9 @@ void verify_authority( const vector& ops, const flat_set required_active; flat_set required_owner; vector other; + flat_set available_keys; - sign_state s(sigs,get_active); + sign_state s(sigs,get_active, available_keys); s.max_recursion = max_recursion_depth; for( auto& id : active_aprovals ) s.approved_by.insert( id ); @@ -426,8 +431,8 @@ set signed_transaction::minimize_required_signatures( result.erase( k ); try { - graphene::chain::verify_authority( operations, result, get_active, get_owner, get_custom, - ignore_custom_operation_required_auths, max_recursion ); + graphene::protocol::verify_authority( operations, result, get_active, get_owner, get_custom, + ignore_custom_operation_required_auths, max_recursion ); continue; // element stays erased if verify_authority is ok } catch( const tx_missing_owner_auth& e ) {} @@ -446,11 +451,12 @@ void signed_transaction::verify_authority( bool ignore_custom_operation_required_auths, uint32_t max_recursion )const { try { - graphene::chain::verify_authority( operations, get_signature_keys( chain_id ), get_active, get_owner, get_custom, ignore_custom_operation_required_auths, max_recursion ); + graphene::protocol::verify_authority( operations, get_signature_keys( chain_id ), get_active, get_owner, + get_custom, ignore_custom_operation_required_auths, max_recursion ); } FC_CAPTURE_AND_RETHROW( (*this) ) } -} } // graphene::chain +} } // graphene::protocol -GRAPHENE_EXTERNAL_SERIALIZATION(/*not extern*/, graphene::chain::transaction) -GRAPHENE_EXTERNAL_SERIALIZATION(/*not extern*/, graphene::chain::signed_transaction) -GRAPHENE_EXTERNAL_SERIALIZATION(/*not extern*/, graphene::chain::processed_transaction) +GRAPHENE_EXTERNAL_SERIALIZATION(/*not extern*/, graphene::protocol::transaction) +GRAPHENE_EXTERNAL_SERIALIZATION(/*not extern*/, graphene::protocol::signed_transaction) +GRAPHENE_EXTERNAL_SERIALIZATION(/*not extern*/, graphene::protocol::processed_transaction) diff --git a/libraries/chain/protocol/transfer.cpp b/libraries/protocol/transfer.cpp similarity index 79% rename from libraries/chain/protocol/transfer.cpp rename to libraries/protocol/transfer.cpp index 0fb0aefa1..cc63146bd 100644 --- a/libraries/chain/protocol/transfer.cpp +++ b/libraries/protocol/transfer.cpp @@ -21,11 +21,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include +#include #include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { share_type transfer_operation::calculate_fee( const fee_parameters_type& schedule )const { @@ -62,9 +62,9 @@ void override_transfer_operation::validate()const FC_ASSERT( issuer != from ); } -} } // graphene::chain +} } // graphene::protocol -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::transfer_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::override_transfer_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::transfer_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::override_transfer_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::transfer_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::override_transfer_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::transfer_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::override_transfer_operation ) diff --git a/libraries/protocol/types.cpp b/libraries/protocol/types.cpp new file mode 100644 index 000000000..88f224e39 --- /dev/null +++ b/libraries/protocol/types.cpp @@ -0,0 +1,170 @@ +/* + * Copyright (c) 2015 Cryptonomex, Inc., and contributors. + * + * The MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include + +#include +#include +#include +#include + +namespace graphene { namespace protocol { + + public_key_type::public_key_type():key_data(){}; + + public_key_type::public_key_type( const fc::ecc::public_key_data& data ) + :key_data( data ) {}; + + public_key_type::public_key_type( const fc::ecc::public_key& pubkey ) + :key_data( pubkey ) {}; + + public_key_type::public_key_type( const std::string& base58str ) + { + // TODO: Refactor syntactic checks into static is_valid() + // to make public_key_type API more similar to address API + std::string prefix( GRAPHENE_ADDRESS_PREFIX ); + + // TODO: This is temporary for testing + try + { + if( is_valid_v1( base58str ) ) + prefix = std::string( "BTS" ); + } + catch( ... ) + { + } + + try + { + if( is_valid_muse( base58str ) ) + prefix = std::string( "MUSE" ); + } + catch( ... ) + { + } + + const size_t prefix_len = prefix.size(); + FC_ASSERT( base58str.size() > prefix_len ); + FC_ASSERT( base58str.substr( 0, prefix_len ) == prefix , "", ("base58str", base58str) ); + auto bin = fc::from_base58( base58str.substr( prefix_len ) ); + auto bin_key = fc::raw::unpack(bin); + key_data = bin_key.data; + FC_ASSERT( fc::ripemd160::hash( (char*)key_data.data(), key_data.size() )._hash[0].value() == bin_key.check ); + }; + + bool public_key_type::is_valid_muse( const std::string& base58str ) + { + std::string prefix( "MUSE" ); + + const size_t prefix_len = prefix.size(); + FC_ASSERT( base58str.size() > prefix_len ); + FC_ASSERT( base58str.substr( 0, prefix_len ) == prefix , "", ("base58str", base58str) ); + auto bin = fc::from_base58( base58str.substr( prefix_len ) ); + auto bin_key = fc::raw::unpack(bin); + key_data = bin_key.data; + FC_ASSERT( fc::ripemd160::hash( (char*)key_data.data(), key_data.size() )._hash[0].value() == bin_key.check ); + return true; + } + + // TODO: This is temporary for testing + bool public_key_type::is_valid_v1( const std::string& base58str ) + { + std::string prefix( "BTS" ); + const size_t prefix_len = prefix.size(); + FC_ASSERT( base58str.size() > prefix_len ); + FC_ASSERT( base58str.substr( 0, prefix_len ) == prefix , "", ("base58str", base58str) ); + auto bin = fc::from_base58( base58str.substr( prefix_len ) ); + auto bin_key = fc::raw::unpack(bin); + fc::ecc::public_key_data key_data = bin_key.data; + FC_ASSERT( fc::ripemd160::hash( (char*)key_data.data(), key_data.size() )._hash[0].value() == bin_key.check ); + return true; + } + + public_key_type::operator fc::ecc::public_key_data() const + { + return key_data; + }; + + public_key_type::operator fc::ecc::public_key() const + { + return fc::ecc::public_key( key_data ); + }; + + public_key_type::operator std::string() const + { + binary_key k; + k.data = key_data; + k.check = fc::ripemd160::hash( (char*)k.data.data(), k.data.size() )._hash[0].value(); + auto data = fc::raw::pack( k ); + return GRAPHENE_ADDRESS_PREFIX + fc::to_base58( data.data(), data.size() ); + } + + bool operator == ( const public_key_type& p1, const fc::ecc::public_key& p2) + { + return p1.key_data == p2.serialize(); + } + + bool operator == ( const public_key_type& p1, const public_key_type& p2) + { + return p1.key_data == p2.key_data; + } + + bool operator != ( const public_key_type& p1, const public_key_type& p2) + { + return p1.key_data != p2.key_data; + } + +} } // graphene::protocol + +namespace fc +{ + using namespace std; + void to_variant( const graphene::protocol::public_key_type& var, fc::variant& vo, uint32_t max_depth ) + { + vo = std::string( var ); + } + + void from_variant( const fc::variant& var, graphene::protocol::public_key_type& vo, uint32_t max_depth ) + { + vo = graphene::protocol::public_key_type( var.as_string() ); + } + + void from_variant( const fc::variant& var, std::shared_ptr& vo, + uint32_t max_depth ) { + // If it's null, just make a new one + if (!vo) vo = std::make_shared(); + // Convert the non-const shared_ptr to a non-const fee_schedule& so we can write it + // Don't decrement max_depth since we're not actually deserializing at this step + from_variant(var, const_cast(*vo), max_depth); + } + +namespace raw { + template void pack( datastream& s, const graphene::protocol::public_key_type& tx, + uint32_t _max_depth=FC_PACK_MAX_DEPTH ); + template void pack( datastream& s, const graphene::protocol::public_key_type& tx, + uint32_t _max_depth=FC_PACK_MAX_DEPTH ); + template void unpack( datastream& s, graphene::protocol::public_key_type& tx, + uint32_t _max_depth=FC_PACK_MAX_DEPTH ); +} } // fc::raw diff --git a/libraries/chain/include/graphene/chain/protocol/config.hpp b/libraries/protocol/vote.cpp similarity index 72% rename from libraries/chain/include/graphene/chain/protocol/config.hpp rename to libraries/protocol/vote.cpp index 870b08fe3..1f94fd89d 100644 --- a/libraries/chain/include/graphene/chain/protocol/config.hpp +++ b/libraries/protocol/vote.cpp @@ -21,5 +21,22 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#pragma once -#include + +#include + +namespace fc +{ + +void to_variant( const graphene::protocol::vote_id_type& var, variant& vo, uint32_t max_depth ) +{ + vo = string(var); +} + +void from_variant( const variant& var, graphene::protocol::vote_id_type& vo, uint32_t max_depth ) +{ + vo = graphene::protocol::vote_id_type(var.as_string()); +} + +} // fc + +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::vote_id_type ) diff --git a/libraries/chain/protocol/withdraw_permission.cpp b/libraries/protocol/withdraw_permission.cpp similarity index 69% rename from libraries/chain/protocol/withdraw_permission.cpp rename to libraries/protocol/withdraw_permission.cpp index b36c378df..1155e3d57 100644 --- a/libraries/chain/protocol/withdraw_permission.cpp +++ b/libraries/protocol/withdraw_permission.cpp @@ -21,11 +21,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include +#include #include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { void withdraw_permission_update_operation::validate()const { @@ -67,13 +67,13 @@ void withdraw_permission_delete_operation::validate() const FC_ASSERT( withdraw_from_account != authorized_account ); } -} } // graphene::chain +} } // graphene::protocol -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::withdraw_permission_create_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::withdraw_permission_update_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::withdraw_permission_claim_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::withdraw_permission_delete_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::withdraw_permission_create_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::withdraw_permission_update_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::withdraw_permission_claim_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::withdraw_permission_delete_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::withdraw_permission_create_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::withdraw_permission_update_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::withdraw_permission_claim_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::withdraw_permission_delete_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::withdraw_permission_create_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::withdraw_permission_update_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::withdraw_permission_claim_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::withdraw_permission_delete_operation ) diff --git a/libraries/chain/protocol/witness.cpp b/libraries/protocol/witness.cpp similarity index 73% rename from libraries/chain/protocol/witness.cpp rename to libraries/protocol/witness.cpp index 90583cd84..919153239 100644 --- a/libraries/chain/protocol/witness.cpp +++ b/libraries/protocol/witness.cpp @@ -21,10 +21,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include +#include + #include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { void witness_create_operation::validate() const { @@ -39,9 +40,9 @@ void witness_update_operation::validate() const FC_ASSERT(new_url->size() < GRAPHENE_MAX_URL_LENGTH ); } -} } // graphene::chain +} } // graphene::protocol -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::witness_create_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::witness_update_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::witness_create_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::witness_update_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::witness_create_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::witness_update_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::witness_create_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::witness_update_operation ) diff --git a/libraries/chain/protocol/worker.cpp b/libraries/protocol/worker.cpp similarity index 82% rename from libraries/chain/protocol/worker.cpp rename to libraries/protocol/worker.cpp index 932148ec1..10ed156f0 100644 --- a/libraries/chain/protocol/worker.cpp +++ b/libraries/protocol/worker.cpp @@ -21,10 +21,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include #include +#include -namespace graphene { namespace chain { +#include + +namespace graphene { namespace protocol { void worker_create_operation::validate() const { @@ -38,5 +40,5 @@ void worker_create_operation::validate() const } } -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::worker_create_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::worker_create_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::worker_create_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::worker_create_operation ) diff --git a/libraries/time/CMakeLists.txt b/libraries/time/CMakeLists.txt deleted file mode 100644 index cc8a909d2..000000000 --- a/libraries/time/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -file(GLOB HEADERS "include/graphene/time/*.hpp") - -add_library( graphene_time - time.cpp - ) - -target_link_libraries( graphene_time fc ) -target_include_directories( graphene_time - PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) - -install( TARGETS - graphene_time - - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib -) diff --git a/libraries/time/include/graphene/time/time.hpp b/libraries/time/include/graphene/time/time.hpp deleted file mode 100644 index 2979369ce..000000000 --- a/libraries/time/include/graphene/time/time.hpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2015 Cryptonomex, Inc., and contributors. - * - * The MIT License - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#pragma once - -#include -#include -#include - -namespace graphene { namespace time { - - typedef fc::signal time_discontinuity_signal_type; - extern time_discontinuity_signal_type time_discontinuity_signal; - - fc::optional ntp_time(); - fc::time_point now(); - fc::time_point nonblocking_now(); // identical to now() but guaranteed not to block - void update_ntp_time(); - fc::microseconds ntp_error(); - void shutdown_ntp_time(); - - void start_simulated_time( const fc::time_point sim_time ); - void advance_simulated_time_to( const fc::time_point sim_time ); - void advance_time( int32_t delta_seconds ); - -} } // graphene::time diff --git a/libraries/time/time.cpp b/libraries/time/time.cpp deleted file mode 100644 index 6ba0c126b..000000000 --- a/libraries/time/time.cpp +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (c) 2015 Cryptonomex, Inc., and contributors. - * - * The MIT License - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#include - -#include -#include -#include -#include - -#include - -namespace graphene { namespace time { - -static int32_t simulated_time = 0; -static int32_t adjusted_time_sec = 0; - -time_discontinuity_signal_type time_discontinuity_signal; - -namespace detail -{ - std::atomic ntp_service(nullptr); - fc::mutex ntp_service_initialization_mutex; -} - -fc::optional ntp_time() -{ - fc::ntp* actual_ntp_service = detail::ntp_service.load(); - if (!actual_ntp_service) - { - fc::scoped_lock lock(detail::ntp_service_initialization_mutex); - actual_ntp_service = detail::ntp_service.load(); - if (!actual_ntp_service) - { - actual_ntp_service = new fc::ntp; - detail::ntp_service.store(actual_ntp_service); - } - } - return actual_ntp_service->get_time(); -} - -void shutdown_ntp_time() -{ - fc::ntp* actual_ntp_service = detail::ntp_service.exchange(nullptr); - delete actual_ntp_service; -} - -fc::time_point now() -{ - if( simulated_time ) - return fc::time_point() + fc::seconds( simulated_time + adjusted_time_sec ); - - fc::optional current_ntp_time = ntp_time(); - if( current_ntp_time.valid() ) - return *current_ntp_time + fc::seconds( adjusted_time_sec ); - else - return fc::time_point::now() + fc::seconds( adjusted_time_sec ); -} - -fc::time_point nonblocking_now() -{ - if (simulated_time) - return fc::time_point() + fc::seconds(simulated_time + adjusted_time_sec); - - fc::ntp* actual_ntp_service = detail::ntp_service.load(); - fc::optional current_ntp_time; - if (actual_ntp_service) - current_ntp_time = actual_ntp_service->get_time(); - - if (current_ntp_time) - return *current_ntp_time + fc::seconds(adjusted_time_sec); - else - return fc::time_point::now() + fc::seconds(adjusted_time_sec); -} - -void update_ntp_time() -{ - detail::ntp_service.load()->request_now(); -} - -fc::microseconds ntp_error() -{ - fc::optional current_ntp_time = ntp_time(); - FC_ASSERT( current_ntp_time, "We don't have NTP time!" ); - return *current_ntp_time - fc::time_point::now(); -} - -void start_simulated_time( const fc::time_point sim_time ) -{ - simulated_time = sim_time.sec_since_epoch(); - adjusted_time_sec = 0; -} -void advance_simulated_time_to( const fc::time_point sim_time ) -{ - simulated_time = sim_time.sec_since_epoch(); - adjusted_time_sec = 0; -} - -void advance_time( int32_t delta_seconds ) -{ - adjusted_time_sec += delta_seconds; - time_discontinuity_signal(); -} - -} } // graphene::time diff --git a/libraries/wallet/include/graphene/wallet/reflect_util.hpp b/libraries/wallet/include/graphene/wallet/reflect_util.hpp index 44c0f412b..284733913 100644 --- a/libraries/wallet/include/graphene/wallet/reflect_util.hpp +++ b/libraries/wallet/include/graphene/wallet/reflect_util.hpp @@ -39,9 +39,9 @@ namespace impl { std::string clean_name( const std::string& name ) { - const static std::string prefix = "graphene::chain::"; + const static std::string prefix = "graphene::protocol::"; const static std::string suffix = "_operation"; - // graphene::chain::.*_operation + // graphene::protocol::.*_operation if( (name.size() >= prefix.size() + suffix.size()) && (name.substr( 0, prefix.size() ) == prefix) && (name.substr( name.size()-suffix.size(), suffix.size() ) == suffix ) diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 98dc122c6..dc560edd1 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -63,20 +63,26 @@ #include #include #include +#include +#include +#include #include #include +#include #include #include #include -#include +#include #include #include -#include -#include +#include +#include +#include +#include #include #include #include @@ -165,7 +171,7 @@ optional maybe_id( const string& name_or_id ) string address_to_shorthash( const address& addr ) { - uint32_t x = addr.addr._hash[0]; + uint32_t x = addr.addr._hash[0].value(); static const char hd[] = "0123456789abcdef"; string result; @@ -369,7 +375,7 @@ class wallet_api_impl // return true if any of my_accounts are players in this tournament bool tournament_is_relevant_to_my_accounts(const tournament_object& tournament_obj) { - tournament_details_object tournament_details = get_object(tournament_obj.tournament_details_id); + tournament_details_object tournament_details = get_object(tournament_obj.tournament_details_id); for (const account_object& account_obj : _wallet.my_accounts) if (tournament_details.registered_players.find(account_obj.id) != tournament_details.registered_players.end()) return true; @@ -654,11 +660,11 @@ class wallet_api_impl return _checksum == fc::sha512(); } - template - T get_object(object_id id)const + template + graphene::db::object_downcast_t get_object(ID id)const { auto ob = _remote_db->get_objects({id}).front(); - return ob.template as( GRAPHENE_MAX_NESTED_OBJECTS ); + return ob.template as>( GRAPHENE_MAX_NESTED_OBJECTS ); } void set_operation_fees( signed_transaction& tx, std::shared_ptr s ) @@ -680,7 +686,9 @@ class wallet_api_impl " old"); result["next_maintenance_time"] = fc::get_approximate_relative_time_string(dynamic_props.next_maintenance_time); result["chain_id"] = chain_props.chain_id; - result["participation"] = (100*dynamic_props.recent_slots_filled.popcount()) / 128.0; + stringstream participation; + participation << fixed << std::setprecision(2) << (100.0*fc::popcount(dynamic_props.recent_slots_filled)) / 128.0; + result["participation"] = participation.str(); result["active_witnesses"] = fc::variant(global_props.active_witnesses, GRAPHENE_MAX_NESTED_OBJECTS); result["active_committee_members"] = fc::variant(global_props.active_committee_members, GRAPHENE_MAX_NESTED_OBJECTS); result["active_sons"] = fc::variant(global_props.active_sons, GRAPHENE_MAX_NESTED_OBJECTS); @@ -962,7 +970,7 @@ class wallet_api_impl ("match", match_obj.id)("account", get_account(account_id).name)); for (const game_id_type& game_id : match_obj.games) { - game_object game_obj = get_object(game_id); + game_object game_obj = get_object(game_id); auto insert_result = game_cache.insert(game_obj); if (insert_result.second) game_in_new_state(game_obj); @@ -976,10 +984,10 @@ class wallet_api_impl // updates on those matches void monitor_matches_in_tournament(const tournament_object& tournament_obj) { try { - tournament_details_object tournament_details = get_object(tournament_obj.tournament_details_id); + tournament_details_object tournament_details = get_object(tournament_obj.tournament_details_id); for (const match_id_type& match_id : tournament_details.matches) { - match_object match_obj = get_object(match_id); + match_object match_obj = get_object(match_id); auto insert_result = match_cache.insert(match_obj); if (insert_result.second) match_in_new_state(match_obj); @@ -1001,7 +1009,7 @@ class wallet_api_impl { try { - tournament_object tournament = get_object(tournament_id); + tournament_object tournament = get_object(tournament_id); auto insert_result = tournament_cache.insert(tournament); if (insert_result.second) { @@ -1186,7 +1194,7 @@ class wallet_api_impl total_fee += gprops.current_fees->set_fee( op, fee_asset_obj.options.core_exchange_rate ); FC_ASSERT((total_fee * fee_asset_obj.options.core_exchange_rate).amount <= - get_object(fee_asset_obj.dynamic_asset_data_id).fee_pool, + get_object(fee_asset_obj.dynamic_asset_data_id).fee_pool, "Cannot pay fees in ${asset}, as this asset's fee pool is insufficiently funded.", ("asset", fee_asset_obj.symbol)); } else { @@ -2335,7 +2343,7 @@ class wallet_api_impl if( vbid ) { - result.emplace_back( get_object(*vbid), now ); + result.emplace_back( get_object(*vbid), now ); return result; } @@ -2370,7 +2378,7 @@ class wallet_api_impl FC_THROW("Account ${account} has no core Token ${TOKEN} vested and thus its not allowed to withdraw.", ("account", witness_name)("TOKEN", GRAPHENE_SYMBOL)); } - vesting_balance_object vbo = get_object< vesting_balance_object >( *vbid ); + vesting_balance_object vbo = get_object( *vbid ); if(vbo.balance_type == vesting_balance_type::gpos) FC_THROW("Allowed to withdraw only Normal and Son type vest balances with this method"); @@ -2415,7 +2423,7 @@ class wallet_api_impl //whether it is a witness or user, keep it in a container and iterate over to process all vesting balances and types if(!vbos.size()) - vbos.emplace_back( get_object(*vbid) ); + vbos.emplace_back( get_object(*vbid) ); for (const vesting_balance_object& vesting_balance_obj: vbos) { if(vesting_balance_obj.balance_type == vesting_balance_type::gpos) @@ -2943,14 +2951,13 @@ class wallet_api_impl return sign_transaction(trx, broadcast); } - signed_transaction cancel_order(object_id_type order_id, bool broadcast = false) + signed_transaction cancel_order(limit_order_id_type order_id, bool broadcast = false) { try { FC_ASSERT(!is_locked()); - FC_ASSERT(order_id.space() == protocol_ids, "Invalid order ID ${id}", ("id", order_id)); signed_transaction trx; limit_order_cancel_operation op; - op.fee_paying_account = get_object(order_id).seller; + op.fee_paying_account = get_object(order_id).seller; op.order = order_id; trx.operations = {op}; set_operation_fees( trx, _remote_db->get_global_properties().parameters.current_fees); @@ -3266,7 +3273,7 @@ class wallet_api_impl std::string player_name; if (round == num_rounds) { - match_object match = get_object(tournament_details.matches[num_matches - 1]); + match_object match = get_object(tournament_details.matches[num_matches - 1]); if (match.get_state() == match_state::match_complete && !match.match_winners.empty()) { @@ -3276,7 +3283,7 @@ class wallet_api_impl } else { - match_object match = get_object(tournament_details.matches[match_number]); + match_object match = get_object(tournament_details.matches[match_number]); if (!match.players.empty()) { if (player_in_match < match.players.size()) @@ -3314,7 +3321,7 @@ class wallet_api_impl return ss.str(); }; - m["get_order_book"] = [this](variant result, const fc::variants& a) + m["get_order_book"] = [](variant result, const fc::variants&) { auto orders = result.as( GRAPHENE_MAX_NESTED_OBJECTS ); auto bids = orders.bids; @@ -4467,7 +4474,7 @@ asset_bitasset_data_object wallet_api::get_bitasset_data(string asset_name_or_id { auto asset = get_asset(asset_name_or_id); FC_ASSERT(asset.is_market_issued() && asset.bitasset_data_id); - return my->get_object(*asset.bitasset_data_id); + return my->get_object(*asset.bitasset_data_id); } account_id_type wallet_api::get_account_id(string account_name_or_id) const @@ -5270,7 +5277,7 @@ string wallet_api::help()const { std::vector method_names = my->method_documentation.get_method_names(); std::stringstream ss; - for (const std::string method_name : method_names) + for (const std::string& method_name : method_names) { try { @@ -5883,7 +5890,7 @@ blind_confirmation wallet_api::blind_transfer_help( string from_key_or_label, conf_output.decrypted_memo.amount = change; conf_output.decrypted_memo.blinding_factor = change_blind_factor; conf_output.decrypted_memo.commitment = change_out.commitment; - conf_output.decrypted_memo.check = from_secret._hash[0]; + conf_output.decrypted_memo.check = from_secret._hash[0].value(); conf_output.confirmation.one_time_key = one_time_key.get_public_key(); conf_output.confirmation.to = from_key; conf_output.confirmation.encrypted_memo = fc::aes_encrypt( from_secret, fc::raw::pack( conf_output.decrypted_memo ) ); @@ -5901,7 +5908,7 @@ blind_confirmation wallet_api::blind_transfer_help( string from_key_or_label, conf_output.decrypted_memo.amount = amount; conf_output.decrypted_memo.blinding_factor = blind_factor; conf_output.decrypted_memo.commitment = to_out.commitment; - conf_output.decrypted_memo.check = secret._hash[0]; + conf_output.decrypted_memo.check = secret._hash[0].value(); conf_output.confirmation.one_time_key = one_time_key.get_public_key(); conf_output.confirmation.to = to_key; conf_output.confirmation.encrypted_memo = fc::aes_encrypt( secret, fc::raw::pack( conf_output.decrypted_memo ) ); @@ -5989,7 +5996,7 @@ blind_confirmation wallet_api::transfer_to_blind( string from_account_id_or_name conf_output.decrypted_memo.amount = amount; conf_output.decrypted_memo.blinding_factor = blind_factor; conf_output.decrypted_memo.commitment = out.commitment; - conf_output.decrypted_memo.check = secret._hash[0]; + conf_output.decrypted_memo.check = secret._hash[0].value(); conf_output.confirmation.one_time_key = one_time_key.get_public_key(); conf_output.confirmation.to = to_key; conf_output.confirmation.encrypted_memo = fc::aes_encrypt( secret, fc::raw::pack( conf_output.decrypted_memo ) ); @@ -6793,9 +6800,9 @@ signed_transaction wallet_api::rps_throw(game_id_type game_id, FC_ASSERT( !is_locked() ); // check whether the gesture is appropriate for the game we're playing - graphene::chain::game_object game_obj = my->get_object(game_id); - graphene::chain::match_object match_obj = my->get_object(game_obj.match_id); - graphene::chain::tournament_object tournament_obj = my->get_object(match_obj.tournament_id); + graphene::chain::game_object game_obj = my->get_object(game_id); + graphene::chain::match_object match_obj = my->get_object(game_obj.match_id); + graphene::chain::tournament_object tournament_obj = my->get_object(match_obj.tournament_id); graphene::chain::rock_paper_scissors_game_options game_options = tournament_obj.options.game_options.get(); if ((int)gesture >= game_options.number_of_gestures) diff --git a/programs/build_helpers/check_reflect.py b/programs/build_helpers/check_reflect.py index 0f41f355f..58b2851c2 100755 --- a/programs/build_helpers/check_reflect.py +++ b/programs/build_helpers/check_reflect.py @@ -108,8 +108,8 @@ def validate_members(name2members_ref, name2members_test): error_items.append(name) print("") print("error in", name) - print("doxygen:", name2members_ref[name]) - print("fc :", name2members_test[name]) + print("doxygen:", sorted(name2members_ref[name])) + print("fc :", sorted(name2members_test[name])) else: ok_items.append(name) return diff --git a/programs/build_helpers/member_enumerator.cpp b/programs/build_helpers/member_enumerator.cpp index d956af388..232d994f7 100644 --- a/programs/build_helpers/member_enumerator.cpp +++ b/programs/build_helpers/member_enumerator.cpp @@ -18,8 +18,8 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -#include -#include +#include +#include #include #include #include @@ -109,7 +109,7 @@ void class_processor::process_class( const static_variant< T... >* dummy ) } } -template +template struct if_enum { template< typename T > @@ -130,7 +130,7 @@ struct if_enum }; template<> -struct if_enum +struct if_enum { template< typename T > static void process_class( class_processor* proc, const T* dummy ) @@ -140,7 +140,7 @@ struct if_enum } }; -template +template struct if_reflected { template< typename T > @@ -152,12 +152,12 @@ struct if_reflected }; template<> -struct if_reflected +struct if_reflected { template< typename T > static void process_class( class_processor* proc, const T* dummy ) { - if_enum< typename fc::reflector::is_enum >::process_class(proc, dummy); + if_enum< std::is_enum::value >::process_class(proc, dummy); } }; @@ -216,7 +216,7 @@ int main( int argc, char** argv ) graphene::member_enumerator::class_processor::process_class(result); fc::mutable_variant_object mvo; - for( const std::pair< std::string, std::vector< std::string > >& e : result ) + for( const auto& e : result ) { variant v; to_variant( e.second, v , 1); diff --git a/programs/cli_wallet/main.cpp b/programs/cli_wallet/main.cpp index bb7afa1a9..adf6dc941 100644 --- a/programs/cli_wallet/main.cpp +++ b/programs/cli_wallet/main.cpp @@ -29,15 +29,13 @@ #include #include -#include #include #include -#include #include #include #include -#include +#include #include #include #include @@ -80,7 +78,8 @@ int main( int argc, char** argv ) ("rpc-endpoint,r", bpo::value()->implicit_value("127.0.0.1:8091"), "Endpoint for wallet websocket RPC to listen on") ("rpc-tls-endpoint,t", bpo::value()->implicit_value("127.0.0.1:8092"), "Endpoint for wallet websocket TLS RPC to listen on") ("rpc-tls-certificate,c", bpo::value()->implicit_value("server.pem"), "PEM certificate for wallet websocket TLS RPC") - ("rpc-http-endpoint,H", bpo::value()->implicit_value("127.0.0.1:8093"), "Endpoint for wallet HTTP RPC to listen on") + ("rpc-http-endpoint,H", bpo::value()->implicit_value("127.0.0.1:8093"), + "Endpoint for wallet HTTP RPC to listen on (DEPRECATED, use rpc-endpoint instead)") ("daemon,d", "Run the wallet in daemon mode" ) ("wallet-file,w", bpo::value()->implicit_value("wallet.json"), "wallet to load") ("chain-id", bpo::value(), "chain ID to connect to"); @@ -219,7 +218,7 @@ int main( int argc, char** argv ) wsc->register_api(wapi); c->set_session_data( wsc ); }); - ilog( "Listening for incoming RPC requests on ${p}", ("p", options.at("rpc-endpoint").as() )); + ilog( "Listening for incoming HTTP and WS RPC requests on ${p}", ("p", options.at("rpc-endpoint").as() )); _websocket_server->listen( fc::ip::endpoint::from_string(options.at("rpc-endpoint").as()) ); _websocket_server->start_accept(); } @@ -228,36 +227,32 @@ int main( int argc, char** argv ) if( options.count( "rpc-tls-certificate" ) ) cert_pem = options.at("rpc-tls-certificate").as(); - std::shared_ptr _websocket_tls_server; + auto _websocket_tls_server = std::make_shared(cert_pem, ""); if( options.count("rpc-tls-endpoint") ) { - _websocket_tls_server = std::make_shared(cert_pem); _websocket_tls_server->on_connection([&]( const fc::http::websocket_connection_ptr& c ){ auto wsc = std::make_shared(c, GRAPHENE_MAX_NESTED_OBJECTS); wsc->register_api(wapi); c->set_session_data( wsc ); }); - ilog( "Listening for incoming TLS RPC requests on ${p}", ("p", options.at("rpc-tls-endpoint").as() )); + ilog( "Listening for incoming HTTPS and WSS RPC requests on ${p}", + ("p", options.at("rpc-tls-endpoint").as()) ); _websocket_tls_server->listen( fc::ip::endpoint::from_string(options.at("rpc-tls-endpoint").as()) ); _websocket_tls_server->start_accept(); } - auto _http_server = std::make_shared(); + auto _http_ws_server = std::make_shared(); if( options.count("rpc-http-endpoint" ) ) { - ilog( "Listening for incoming HTTP RPC requests on ${p}", ("p", options.at("rpc-http-endpoint").as() ) ); - _http_server->listen( fc::ip::endpoint::from_string( options.at( "rpc-http-endpoint" ).as() ) ); - // - // due to implementation, on_request() must come AFTER listen() - // - _http_server->on_request( - [&wapi]( const fc::http::request& req, const fc::http::server::response& resp ) - { - std::shared_ptr< fc::rpc::http_api_connection > conn = - std::make_shared< fc::rpc::http_api_connection >( GRAPHENE_MAX_NESTED_OBJECTS ); - conn->register_api( wapi ); - conn->on_request( req, resp ); - } ); + ilog( "Listening for incoming HTTP and WS RPC requests on ${p}", + ("p", options.at("rpc-http-endpoint").as()) ); + _http_ws_server->on_connection([&wapi]( const fc::http::websocket_connection_ptr& c ){ + auto wsc = std::make_shared(c, GRAPHENE_MAX_NESTED_OBJECTS); + wsc->register_api(wapi); + c->set_session_data( wsc ); + }); + _http_ws_server->listen( fc::ip::endpoint::from_string(options.at("rpc-http-endpoint").as()) ); + _http_ws_server->start_accept(); } if( !options.count( "daemon" ) ) @@ -268,7 +263,7 @@ int main( int argc, char** argv ) } else { - fc::promise::ptr exit_promise = new fc::promise("UNIX Signal Handler"); + fc::promise::ptr exit_promise = fc::promise::create("UNIX Signal Handler"); fc::set_signal_handler([&exit_promise](int signal) { exit_promise->set_value(signal); }, SIGINT); diff --git a/programs/debug_node/main.cpp b/programs/debug_node/main.cpp index c94d3fd2a..c93909b6a 100644 --- a/programs/debug_node/main.cpp +++ b/programs/debug_node/main.cpp @@ -164,7 +164,7 @@ int main(int argc, char** argv) { node->startup(); node->startup_plugins(); - fc::promise::ptr exit_promise = new fc::promise("UNIX Signal Handler"); + fc::promise::ptr exit_promise = fc::promise::create("UNIX Signal Handler"); fc::set_signal_handler([&exit_promise](int signal) { elog( "Caught SIGINT attempting to exit cleanly" ); diff --git a/programs/delayed_node/main.cpp b/programs/delayed_node/main.cpp index 3e058b64c..c9be9e79e 100644 --- a/programs/delayed_node/main.cpp +++ b/programs/delayed_node/main.cpp @@ -179,7 +179,7 @@ int main(int argc, char** argv) { node.startup(); node.startup_plugins(); - fc::promise::ptr exit_promise = new fc::promise("UNIX Signal Handler"); + fc::promise::ptr exit_promise = fc::promise::create("UNIX Signal Handler"); fc::set_signal_handler([&exit_promise](int signal) { exit_promise->set_value(signal); }, SIGINT); diff --git a/programs/genesis_util/convert_address.cpp b/programs/genesis_util/convert_address.cpp index 7f73acdb1..f8224cc8e 100644 --- a/programs/genesis_util/convert_address.cpp +++ b/programs/genesis_util/convert_address.cpp @@ -26,13 +26,13 @@ * Convert BTC / PTS addresses to a Graphene address. */ -#include -#include +#include +#include #include #include -using namespace graphene::chain; +using namespace graphene::protocol; int main(int argc, char** argv) { diff --git a/programs/genesis_util/genesis_update.cpp b/programs/genesis_util/genesis_update.cpp index 4df7091f3..136603a4b 100644 --- a/programs/genesis_util/genesis_update.cpp +++ b/programs/genesis_util/genesis_update.cpp @@ -32,8 +32,7 @@ #include #include -#include -#include +#include #include #include diff --git a/programs/genesis_util/get_dev_key.cpp b/programs/genesis_util/get_dev_key.cpp index ea7cdf9f0..4fc6a42f2 100644 --- a/programs/genesis_util/get_dev_key.cpp +++ b/programs/genesis_util/get_dev_key.cpp @@ -28,8 +28,8 @@ #include #include -#include -#include +#include +#include #include #ifndef WIN32 @@ -73,10 +73,10 @@ int main( int argc, char** argv ) auto show_key = [&comma]( const fc::ecc::private_key& priv_key ) { fc::limited_mutable_variant_object mvo(5); - graphene::chain::public_key_type pub_key = priv_key.get_public_key(); + graphene::protocol::public_key_type pub_key = priv_key.get_public_key(); mvo( "private_key", graphene::utilities::key_to_wif( priv_key ) ) ( "public_key", std::string( pub_key ) ) - ( "address", graphene::chain::address( pub_key ) ) + ( "address", graphene::protocol::address( pub_key ) ) ; if( comma ) std::cout << ",\n"; diff --git a/programs/js_operation_serializer/main.cpp b/programs/js_operation_serializer/main.cpp index 797a32a1e..b5b00daa0 100644 --- a/programs/js_operation_serializer/main.cpp +++ b/programs/js_operation_serializer/main.cpp @@ -21,8 +21,9 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include -#include + +#include +#include #include #include @@ -120,12 +121,13 @@ bool register_serializer( const string& name, std::function sr ) template struct js_name { static std::string name(){ return remove_namespace(fc::get_typename::name()); }; }; template -struct js_name> +struct js_name> { - static std::string name(){ return "fixed_array "+ fc::to_string(N) + ", " + remove_namespace(fc::get_typename::name()); }; + static std::string name(){ return "fixed_array "+ fc::to_string(N) + ", " + + remove_namespace(fc::get_typename::name()); }; }; -template struct js_name> { static std::string name(){ return "bytes "+ fc::to_string(N); }; }; -template struct js_name> { static std::string name(){ return "bytes "+ fc::to_string(N); }; }; +template struct js_name> { static std::string name(){ return "bytes "+ fc::to_string(N); }; }; +template struct js_name>{ static std::string name(){ return "bytes "+ fc::to_string(N); }; }; template struct js_name< fc::optional > { static std::string name(){ return "optional " + js_name::name(); } }; template<> struct js_name< object_id_type > { static std::string name(){ return "object_id_type"; } }; template struct js_name< fc::flat_set > { static std::string name(){ return "set " + js_name::name(); } }; @@ -138,15 +140,15 @@ template<> struct js_name { static std::string name(){ retu template<> struct js_name { static std::string name(){ return "bytes 28"; } }; template<> struct js_name { static std::string name(){ return "bytes 32"; } }; template<> struct js_name { static std::string name(){ return "varuint32"; } }; -template<> struct js_name { static std::string name(){ return "varint32"; } }; template<> struct js_name< vote_id_type > { static std::string name(){ return "vote_id"; } }; template<> struct js_name< time_point_sec > { static std::string name(){ return "time_point_sec"; } }; -template -struct js_name > +template +struct js_name > { static std::string name(){ - return "protocol_id_type \"" + remove_namespace(fc::get_typename::name()) + "\""; + return "protocol_id_type(\"" + + remove_namespace(fc::get_typename>>::name()) + "\")"; }; }; @@ -242,7 +244,7 @@ struct serializer }; template -struct serializer,false> +struct serializer,false> { static void init() { serializer::init(); } static void generate() {} @@ -289,8 +291,8 @@ struct serializer,false> static void generate(){} }; -template -struct serializer< graphene::db::object_id ,true> +template +struct serializer< graphene::db::object_id ,true> { static void init() {} static void generate() {} @@ -351,14 +353,15 @@ class register_member_visitor } }; -template +template ()> struct serializer_init_helper { static void init() { auto name = js_name::name(); if( st.find(name) == st.end() ) { - fc::reflector::visit( register_member_visitor() ); + register_member_visitor visitor; + fc::reflector::visit( visitor ); register_serializer( name, [=](){ generate(); } ); } } @@ -370,14 +373,15 @@ struct serializer_init_helper { << " = new Serializer( \n" << " \"" + name + "\"\n"; - fc::reflector::visit( serialize_member_visitor() ); + serialize_member_visitor visitor; + fc::reflector::visit( visitor ); std::cout <<")\n\n"; } }; template -struct serializer_init_helper { +struct serializer_init_helper { static void init() { } @@ -390,7 +394,7 @@ struct serializer static void init() { - serializer_init_helper< T, typename fc::reflector::is_enum >::init(); + serializer_init_helper< T >::init(); } }; diff --git a/programs/size_checker/main.cpp b/programs/size_checker/main.cpp index 188e88e40..a7c09308f 100644 --- a/programs/size_checker/main.cpp +++ b/programs/size_checker/main.cpp @@ -23,10 +23,12 @@ */ #include +#include #include #include -#include +#include +#include #include #include @@ -34,7 +36,7 @@ #include #include -using namespace graphene::chain; +using namespace graphene::protocol; vector< fc::variant_object > g_op_types; @@ -67,7 +69,7 @@ int main( int argc, char** argv ) { try { - graphene::chain::operation op; + graphene::protocol::operation op; vector witnesses; witnesses.resize(50); diff --git a/programs/witness_node/main.cpp b/programs/witness_node/main.cpp index 7823fed3e..432db901f 100644 --- a/programs/witness_node/main.cpp +++ b/programs/witness_node/main.cpp @@ -165,7 +165,7 @@ int main(int argc, char** argv) { node->startup(); node->startup_plugins(); - fc::promise::ptr exit_promise = new fc::promise("UNIX Signal Handler"); + fc::promise::ptr exit_promise = fc::promise::create("UNIX Signal Handler"); fc::set_signal_handler([&exit_promise](int signal) { elog( "Caught SIGINT attempting to exit cleanly" ); diff --git a/tests/benchmarks/main.cpp b/tests/benchmarks/main.cpp index 706318d62..479fb3371 100644 --- a/tests/benchmarks/main.cpp +++ b/tests/benchmarks/main.cpp @@ -23,3 +23,4 @@ */ #define BOOST_TEST_MODULE "C++ Benchmarks for Graphene Blockchain Database" #include + diff --git a/tests/betting/betting_tests.cpp b/tests/betting/betting_tests.cpp index 7dff8b823..fee27249a 100644 --- a/tests/betting/betting_tests.cpp +++ b/tests/betting/betting_tests.cpp @@ -35,7 +35,7 @@ #include #include -#include +#include #include #include @@ -132,114 +132,6 @@ using namespace graphene::chain::keywords; // 1.58 50:29 | 2.34 50:67 | 4.6 5:18 | 25 1:24 | 430 1:429 | // 1.59 100:59 | 2.36 25:34 | 4.7 10:37 -#define CREATE_ICE_HOCKEY_BETTING_MARKET(never_in_play, delay_before_settling) \ - create_sport({{"en", "Ice Hockey"}, {"zh_Hans", "冰球"}, {"ja", "アイスホッケー"}}); \ - generate_blocks(1); \ - const sport_object& ice_hockey = *db.get_index_type().indices().get().rbegin(); \ - create_event_group({{"en", "NHL"}, {"zh_Hans", "國家冰球聯盟"}, {"ja", "ナショナルホッケーリーグ"}}, ice_hockey.id); \ - generate_blocks(1); \ - const event_group_object& nhl = *db.get_index_type().indices().get().rbegin(); \ - create_event({{"en", "Washington Capitals/Chicago Blackhawks"}, {"zh_Hans", "華盛頓首都隊/芝加哥黑鷹"}, {"ja", "ワシントン・キャピタルズ/シカゴ・ブラックホークス"}}, {{"en", "2016-17"}}, nhl.id); \ - generate_blocks(1); \ - const event_object& capitals_vs_blackhawks = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market_rules({{"en", "NHL Rules v1.0"}}, {{"en", "The winner will be the team with the most points at the end of the game. The team with fewer points will not be the winner."}}); \ - generate_blocks(1); \ - const betting_market_rules_object& betting_market_rules = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market_group({{"en", "Moneyline"}}, capitals_vs_blackhawks.id, betting_market_rules.id, asset_id_type(), never_in_play, delay_before_settling); \ - generate_blocks(1); \ - const betting_market_group_object& moneyline_betting_markets = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(moneyline_betting_markets.id, {{"en", "Washington Capitals win"}}); \ - generate_blocks(1); \ - const betting_market_object& capitals_win_market = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(moneyline_betting_markets.id, {{"en", "Chicago Blackhawks win"}}); \ - generate_blocks(1); \ - const betting_market_object& blackhawks_win_market = *db.get_index_type().indices().get().rbegin(); \ - (void)capitals_win_market; (void)blackhawks_win_market; - -// create the basic betting market, plus groups for the first, second, and third period results -#define CREATE_EXTENDED_ICE_HOCKEY_BETTING_MARKET(never_in_play, delay_before_settling) \ - CREATE_ICE_HOCKEY_BETTING_MARKET(never_in_play, delay_before_settling) \ - create_betting_market_group({{"en", "First Period Result"}}, capitals_vs_blackhawks.id, betting_market_rules.id, asset_id_type(), never_in_play, delay_before_settling); \ - generate_blocks(1); \ - const betting_market_group_object& first_period_result_betting_markets = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(first_period_result_betting_markets.id, {{"en", "Washington Capitals win"}}); \ - generate_blocks(1); \ - const betting_market_object& first_period_capitals_win_market = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(first_period_result_betting_markets.id, {{"en", "Chicago Blackhawks win"}}); \ - generate_blocks(1); \ - const betting_market_object& first_period_blackhawks_win_market = *db.get_index_type().indices().get().rbegin(); \ - (void)first_period_capitals_win_market; (void)first_period_blackhawks_win_market; \ - \ - create_betting_market_group({{"en", "Second Period Result"}}, capitals_vs_blackhawks.id, betting_market_rules.id, asset_id_type(), never_in_play, delay_before_settling); \ - generate_blocks(1); \ - const betting_market_group_object& second_period_result_betting_markets = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(second_period_result_betting_markets.id, {{"en", "Washington Capitals win"}}); \ - generate_blocks(1); \ - const betting_market_object& second_period_capitals_win_market = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(second_period_result_betting_markets.id, {{"en", "Chicago Blackhawks win"}}); \ - generate_blocks(1); \ - const betting_market_object& second_period_blackhawks_win_market = *db.get_index_type().indices().get().rbegin(); \ - (void)second_period_capitals_win_market; (void)second_period_blackhawks_win_market; \ - \ - create_betting_market_group({{"en", "Third Period Result"}}, capitals_vs_blackhawks.id, betting_market_rules.id, asset_id_type(), never_in_play, delay_before_settling); \ - generate_blocks(1); \ - const betting_market_group_object& third_period_result_betting_markets = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(third_period_result_betting_markets.id, {{"en", "Washington Capitals win"}}); \ - generate_blocks(1); \ - const betting_market_object& third_period_capitals_win_market = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(third_period_result_betting_markets.id, {{"en", "Chicago Blackhawks win"}}); \ - generate_blocks(1); \ - const betting_market_object& third_period_blackhawks_win_market = *db.get_index_type().indices().get().rbegin(); \ - (void)third_period_capitals_win_market; (void)third_period_blackhawks_win_market; - -#define CREATE_TENNIS_BETTING_MARKET() \ - create_betting_market_rules({{"en", "Tennis Rules v1.0"}}, {{"en", "The winner is the player who wins the last ball in the match."}}); \ - generate_blocks(1); \ - const betting_market_rules_object& tennis_rules = *db.get_index_type().indices().get().rbegin(); \ - create_sport({{"en", "Tennis"}}); \ - generate_blocks(1); \ - const sport_object& tennis = *db.get_index_type().indices().get().rbegin(); \ - create_event_group({{"en", "Wimbledon"}}, tennis.id); \ - generate_blocks(1); \ - const event_group_object& wimbledon = *db.get_index_type().indices().get().rbegin(); \ - create_event({{"en", "R. Federer/T. Berdych"}}, {{"en", "2017"}}, wimbledon.id); \ - generate_blocks(1); \ - const event_object& berdych_vs_federer = *db.get_index_type().indices().get().rbegin(); \ - create_event({{"en", "M. Cilic/S. Querrye"}}, {{"en", "2017"}}, wimbledon.id); \ - generate_blocks(1); \ - const event_object& cilic_vs_querrey = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market_group({{"en", "Moneyline 1st sf"}}, berdych_vs_federer.id, tennis_rules.id, asset_id_type(), false, 0); \ - generate_blocks(1); \ - const betting_market_group_object& moneyline_berdych_vs_federer = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market_group({{"en", "Moneyline 2nd sf"}}, cilic_vs_querrey.id, tennis_rules.id, asset_id_type(), false, 0); \ - generate_blocks(1); \ - const betting_market_group_object& moneyline_cilic_vs_querrey = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(moneyline_berdych_vs_federer.id, {{"en", "T. Berdych defeats R. Federer"}}); \ - generate_blocks(1); \ - const betting_market_object& berdych_wins_market = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(moneyline_berdych_vs_federer.id, {{"en", "R. Federer defeats T. Berdych"}}); \ - generate_blocks(1); \ - const betting_market_object& federer_wins_market = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(moneyline_cilic_vs_querrey.id, {{"en", "M. Cilic defeats S. Querrey"}}); \ - generate_blocks(1); \ - const betting_market_object& cilic_wins_market = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(moneyline_cilic_vs_querrey.id, {{"en", "S. Querrey defeats M. Cilic"}});\ - generate_blocks(1); \ - const betting_market_object& querrey_wins_market = *db.get_index_type().indices().get().rbegin(); \ - create_event({{"en", "R. Federer/M. Cilic"}}, {{"en", "2017"}}, wimbledon.id); \ - generate_blocks(1); \ - const event_object& cilic_vs_federer = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market_group({{"en", "Moneyline final"}}, cilic_vs_federer.id, tennis_rules.id, asset_id_type(), false, 0); \ - generate_blocks(1); \ - const betting_market_group_object& moneyline_cilic_vs_federer = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(moneyline_cilic_vs_federer.id, {{"en", "R. Federer defeats M. Cilic"}}); \ - generate_blocks(1); \ - const betting_market_object& federer_wins_final_market = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(moneyline_cilic_vs_federer.id, {{"en", "M. Cilic defeats R. Federer"}}); \ - generate_blocks(1); \ - const betting_market_object& cilic_wins_final_market = *db.get_index_type().indices().get().rbegin(); \ - (void)federer_wins_market;(void)cilic_wins_market;(void)federer_wins_final_market; (void)cilic_wins_final_market; (void)berdych_wins_market; (void)querrey_wins_market; - BOOST_FIXTURE_TEST_SUITE( betting_tests, database_fixture ) BOOST_AUTO_TEST_CASE(try_create_sport) @@ -309,12 +201,12 @@ BOOST_AUTO_TEST_CASE(simple_bet_win) transfer(account_id_type(), bob_id, asset(10000)); // place bets at 10:1 - place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(100, asset_id_type()), 11 * GRAPHENE_BETTING_ODDS_PRECISION); - place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(1000, asset_id_type()), 11 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(bob_id, capitals_win_market_id, bet_type::lay, asset(100, asset_id_type()), 11 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(1000, asset_id_type()), 11 * GRAPHENE_BETTING_ODDS_PRECISION); // reverse positions at 1:1 - place_bet(bob_id, capitals_win_market.id, bet_type::back, asset(1100, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); - place_bet(alice_id, capitals_win_market.id, bet_type::lay, asset(1100, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(bob_id, capitals_win_market_id, bet_type::back, asset(1100, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(alice_id, capitals_win_market_id, bet_type::lay, asset(1100, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); } FC_LOG_AND_RETHROW() } @@ -332,23 +224,23 @@ BOOST_AUTO_TEST_CASE(binned_order_books) transfer(account_id_type(), bob_id, asset(10000)); // place back bets at decimal odds of 1.55, 1.6, 1.65, 1.66, and 1.67 - place_bet(bob_id, capitals_win_market.id, bet_type::back, asset(100, asset_id_type()), 155 * GRAPHENE_BETTING_ODDS_PRECISION / 100); - place_bet(bob_id, capitals_win_market.id, bet_type::back, asset(100, asset_id_type()), 16 * GRAPHENE_BETTING_ODDS_PRECISION / 10); - place_bet(bob_id, capitals_win_market.id, bet_type::back, asset(100, asset_id_type()), 165 * GRAPHENE_BETTING_ODDS_PRECISION / 100); - place_bet(bob_id, capitals_win_market.id, bet_type::back, asset(100, asset_id_type()), 166 * GRAPHENE_BETTING_ODDS_PRECISION / 100); - place_bet(bob_id, capitals_win_market.id, bet_type::back, asset(100, asset_id_type()), 167 * GRAPHENE_BETTING_ODDS_PRECISION / 100); + place_bet(bob_id, capitals_win_market_id, bet_type::back, asset(100, asset_id_type()), 155 * GRAPHENE_BETTING_ODDS_PRECISION / 100); + place_bet(bob_id, capitals_win_market_id, bet_type::back, asset(100, asset_id_type()), 16 * GRAPHENE_BETTING_ODDS_PRECISION / 10); + place_bet(bob_id, capitals_win_market_id, bet_type::back, asset(100, asset_id_type()), 165 * GRAPHENE_BETTING_ODDS_PRECISION / 100); + place_bet(bob_id, capitals_win_market_id, bet_type::back, asset(100, asset_id_type()), 166 * GRAPHENE_BETTING_ODDS_PRECISION / 100); + place_bet(bob_id, capitals_win_market_id, bet_type::back, asset(100, asset_id_type()), 167 * GRAPHENE_BETTING_ODDS_PRECISION / 100); const auto& bet_odds_idx = db.get_index_type().indices().get(); - auto bet_iter = bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market.id)); + auto bet_iter = bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market_id)); while (bet_iter != bet_odds_idx.end() && - bet_iter->betting_market_id == capitals_win_market.id) + bet_iter->betting_market_id == capitals_win_market_id) { idump((*bet_iter)); ++bet_iter; } - graphene::bookie::binned_order_book binned_orders_point_one = bookie_api.get_binned_order_book(capitals_win_market.id, 1); + graphene::bookie::binned_order_book binned_orders_point_one = bookie_api.get_binned_order_book(capitals_win_market_id, 1); idump((binned_orders_point_one)); // the binned orders returned should be chosen so that we if we assume those orders are real and we place @@ -362,28 +254,28 @@ BOOST_AUTO_TEST_CASE(binned_order_books) // compute the matching lay order share_type lay_amount = bet_object::get_approximate_matching_amount(binned_order.amount_to_bet, binned_order.backer_multiplier, bet_type::back, true /* round up */); ilog("Alice is laying with ${lay_amount} at odds ${odds} to match the binned back amount ${back_amount}", ("lay_amount", lay_amount)("odds", binned_order.backer_multiplier)("back_amount", binned_order.amount_to_bet)); - place_bet(alice_id, capitals_win_market.id, bet_type::lay, asset(lay_amount, asset_id_type()), binned_order.backer_multiplier); + place_bet(alice_id, capitals_win_market_id, bet_type::lay, asset(lay_amount, asset_id_type()), binned_order.backer_multiplier); } - bet_iter = bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market.id)); + bet_iter = bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market_id)); while (bet_iter != bet_odds_idx.end() && - bet_iter->betting_market_id == capitals_win_market.id) + bet_iter->betting_market_id == capitals_win_market_id) { idump((*bet_iter)); ++bet_iter; } - BOOST_CHECK(bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market.id)) == bet_odds_idx.end()); + BOOST_CHECK(bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market_id)) == bet_odds_idx.end()); // place lay bets at decimal odds of 1.55, 1.6, 1.65, 1.66, and 1.67 // these bets will get rounded down, actual amounts are 99, 99, 91, 99, and 67 -// place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(100, asset_id_type()), 155 * GRAPHENE_BETTING_ODDS_PRECISION / 100); -// place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(100, asset_id_type()), 155 * GRAPHENE_BETTING_ODDS_PRECISION / 100); -// place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(100, asset_id_type()), 165 * GRAPHENE_BETTING_ODDS_PRECISION / 100); -// place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(100, asset_id_type()), 165 * GRAPHENE_BETTING_ODDS_PRECISION / 100); -// place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(100, asset_id_type()), 165 * GRAPHENE_BETTING_ODDS_PRECISION / 100); +// place_bet(bob_id, capitals_win_market_id, bet_type::lay, asset(100, asset_id_type()), 155 * GRAPHENE_BETTING_ODDS_PRECISION / 100); +// place_bet(bob_id, capitals_win_market_id, bet_type::lay, asset(100, asset_id_type()), 155 * GRAPHENE_BETTING_ODDS_PRECISION / 100); +// place_bet(bob_id, capitals_win_market_id, bet_type::lay, asset(100, asset_id_type()), 165 * GRAPHENE_BETTING_ODDS_PRECISION / 100); +// place_bet(bob_id, capitals_win_market_id, bet_type::lay, asset(100, asset_id_type()), 165 * GRAPHENE_BETTING_ODDS_PRECISION / 100); +// place_bet(bob_id, capitals_win_market_id, bet_type::lay, asset(100, asset_id_type()), 165 * GRAPHENE_BETTING_ODDS_PRECISION / 100); // -// binned_orders_point_one = bookie_api.get_binned_order_book(capitals_win_market.id, 1); +// binned_orders_point_one = bookie_api.get_binned_order_book(capitals_win_market_id, 1); // idump((binned_orders_point_one)); // // // the binned orders returned should be chosen so that we if we assume those orders are real and we place @@ -397,20 +289,20 @@ BOOST_AUTO_TEST_CASE(binned_order_books) // // compute the matching lay order // share_type back_amount = bet_object::get_approximate_matching_amount(binned_order.amount_to_bet, binned_order.backer_multiplier, bet_type::lay, true /* round up */); // ilog("Alice is backing with ${back_amount} at odds ${odds} to match the binned lay amount ${lay_amount}", ("back_amount", back_amount)("odds", binned_order.backer_multiplier)("lay_amount", binned_order.amount_to_bet)); -// place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(back_amount, asset_id_type()), binned_order.backer_multiplier); +// place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(back_amount, asset_id_type()), binned_order.backer_multiplier); // // } // // -// bet_iter = bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market.id)); +// bet_iter = bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market_id)); // while (bet_iter != bet_odds_idx.end() && -// bet_iter->betting_market_id == capitals_win_market.id) +// bet_iter->betting_market_id == capitals_win_market_id) // { // idump((*bet_iter)); // ++bet_iter; // } // -// BOOST_CHECK(bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market.id)) == bet_odds_idx.end()); +// BOOST_CHECK(bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market_id)) == bet_odds_idx.end()); // } FC_LOG_AND_RETHROW() } @@ -427,19 +319,19 @@ BOOST_AUTO_TEST_CASE( peerplays_sport_create_test ) transfer(account_id_type(), bob_id, asset(10000000)); // have bob lay a bet for 1M (+20k fees) at 1:1 odds - place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(bob_id, capitals_win_market_id, bet_type::lay, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); // have alice back a matching bet at 1:1 odds (also costing 1.02M) - place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); BOOST_CHECK_EQUAL(get_balance(alice_id, asset_id_type()), 10000000 - 1000000); BOOST_CHECK_EQUAL(get_balance(bob_id, asset_id_type()), 10000000 - 1000000); - update_betting_market_group(moneyline_betting_markets.id, _status = betting_market_group_status::closed); + update_betting_market_group(moneyline_betting_markets_id, _status = betting_market_group_status::closed); // caps win - resolve_betting_market_group(moneyline_betting_markets.id, - {{capitals_win_market.id, betting_market_resolution_type::win}, - {blackhawks_win_market.id, betting_market_resolution_type::not_win}}); + resolve_betting_market_group(moneyline_betting_markets_id, + {{capitals_win_market_id, betting_market_resolution_type::win}, + {blackhawks_win_market_id, betting_market_resolution_type::not_win}}); generate_blocks(1); @@ -464,18 +356,18 @@ BOOST_AUTO_TEST_CASE( cancel_unmatched_in_betting_group_test ) transfer(account_id_type(), bob_id, asset(10000000)); // have bob lay a bet for 1M (+20k fees) at 1:1 odds - place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(bob_id, capitals_win_market_id, bet_type::lay, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); // have alice back a matching bet at 1:1 odds (also costing 1.02M) - place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); // place unmatched - place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(500, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); - place_bet(bob_id, blackhawks_win_market.id, bet_type::lay, asset(600, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(500, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(bob_id, blackhawks_win_market_id, bet_type::lay, asset(600, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); BOOST_CHECK_EQUAL(get_balance(alice_id, asset_id_type()), 10000000 - 1000000 - 500); BOOST_CHECK_EQUAL(get_balance(bob_id, asset_id_type()), 10000000 - 1000000 - 600); // cancel unmatched - cancel_unmatched_bets(moneyline_betting_markets.id); + cancel_unmatched_bets(moneyline_betting_markets_id); BOOST_CHECK_EQUAL(get_balance(alice_id, asset_id_type()), 10000000 - 1000000); BOOST_CHECK_EQUAL(get_balance(bob_id, asset_id_type()), 10000000 - 1000000); @@ -498,19 +390,19 @@ BOOST_AUTO_TEST_CASE(match_using_takers_expected_amounts) // lay 46 at 1.94 odds (50:47) -- this is too small to be placed on the books and there's // nothing for it to match, so it should be canceled BOOST_TEST_MESSAGE("lay 46 at 1.94 odds (50:47) -- this is too small to be placed on the books and there's nothing for it to match, so it should be canceled"); - place_bet(alice_id, capitals_win_market.id, bet_type::lay, asset(46, asset_id_type()), 194 * GRAPHENE_BETTING_ODDS_PRECISION / 100); + place_bet(alice_id, capitals_win_market_id, bet_type::lay, asset(46, asset_id_type()), 194 * GRAPHENE_BETTING_ODDS_PRECISION / 100); BOOST_TEST_MESSAGE("alice's balance should be " << alice_expected_balance.value); BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), alice_expected_balance.value); ilog("message"); // lay 47 at 1.94 odds (50:47) -- this is an exact amount, nothing surprising should happen here BOOST_TEST_MESSAGE("alice lays 470 at 1.94 odds (50:47) -- this is an exact amount, nothing surprising should happen here"); - place_bet(alice_id, capitals_win_market.id, bet_type::lay, asset(47, asset_id_type()), 194 * GRAPHENE_BETTING_ODDS_PRECISION / 100); + place_bet(alice_id, capitals_win_market_id, bet_type::lay, asset(47, asset_id_type()), 194 * GRAPHENE_BETTING_ODDS_PRECISION / 100); alice_expected_balance -= 47; BOOST_TEST_MESSAGE("alice's balance should be " << alice_expected_balance.value); BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), alice_expected_balance.value); // lay 100 at 1.91 odds (100:91) -- this is an inexact match, we should get refunded 9 and leave a bet for 91 on the books - place_bet(alice_id, capitals_win_market.id, bet_type::lay, asset(100, asset_id_type()), 191 * GRAPHENE_BETTING_ODDS_PRECISION / 100); + place_bet(alice_id, capitals_win_market_id, bet_type::lay, asset(100, asset_id_type()), 191 * GRAPHENE_BETTING_ODDS_PRECISION / 100); alice_expected_balance -= 91; BOOST_TEST_MESSAGE("alice's balance should be " << alice_expected_balance.value); BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), alice_expected_balance.value); @@ -528,7 +420,7 @@ ilog("message"); // bob's balance goes down by 300 (150 is matched, 150 is still on the books) // leaves a back bet of 150 @ 1.5 on the books BOOST_TEST_MESSAGE("now have bob match it with a back of 300 at 1.5"); - place_bet(bob_id, capitals_win_market.id, bet_type::back, asset(300, asset_id_type()), 15 * GRAPHENE_BETTING_ODDS_PRECISION / 10); + place_bet(bob_id, capitals_win_market_id, bet_type::back, asset(300, asset_id_type()), 15 * GRAPHENE_BETTING_ODDS_PRECISION / 10); bob_expected_balance -= 300; BOOST_TEST_MESSAGE("bob's balance should be " << bob_expected_balance.value); BOOST_REQUIRE_EQUAL(get_balance(bob_id, asset_id_type()), bob_expected_balance.value); @@ -550,7 +442,7 @@ BOOST_AUTO_TEST_CASE(match_using_takers_expected_amounts2) // lay 470 at 1.94 odds (50:47) -- this is an exact amount, nothing surprising should happen here BOOST_TEST_MESSAGE("alice lays 470 at 1.94 odds (50:47) -- this is an exact amount, nothing surprising should happen here"); - place_bet(alice_id, capitals_win_market.id, bet_type::lay, asset(470, asset_id_type()), 194 * GRAPHENE_BETTING_ODDS_PRECISION / 100); + place_bet(alice_id, capitals_win_market_id, bet_type::lay, asset(470, asset_id_type()), 194 * GRAPHENE_BETTING_ODDS_PRECISION / 100); alice_expected_balance -= 470; BOOST_TEST_MESSAGE("alice's balance should be " << alice_expected_balance.value); BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), alice_expected_balance.value); @@ -565,7 +457,7 @@ BOOST_AUTO_TEST_CASE(match_using_takers_expected_amounts2) // bob's balance goes down by the 900 he paid (500 matched, 400 unmatched) // alice's bet is completely removed from the books. BOOST_TEST_MESSAGE("now have bob match it with a back of 900 at 1.5"); - place_bet(bob_id, capitals_win_market.id, bet_type::back, asset(900, asset_id_type()), 15 * GRAPHENE_BETTING_ODDS_PRECISION / 10); + place_bet(bob_id, capitals_win_market_id, bet_type::back, asset(900, asset_id_type()), 15 * GRAPHENE_BETTING_ODDS_PRECISION / 10); bob_expected_balance -= 900; BOOST_TEST_MESSAGE("bob's balance should be " << bob_expected_balance.value); @@ -587,7 +479,7 @@ BOOST_AUTO_TEST_CASE(match_using_takers_expected_amounts3) BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), alice_expected_balance.value); // lay 470 at 1.94 odds (50:47) -- this is an exact amount, nothing surprising should happen here - place_bet(alice_id, capitals_win_market.id, bet_type::lay, asset(470, asset_id_type()), 194 * GRAPHENE_BETTING_ODDS_PRECISION / 100); + place_bet(alice_id, capitals_win_market_id, bet_type::lay, asset(470, asset_id_type()), 194 * GRAPHENE_BETTING_ODDS_PRECISION / 100); alice_expected_balance -= 470; BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), alice_expected_balance.value); @@ -600,7 +492,7 @@ BOOST_AUTO_TEST_CASE(match_using_takers_expected_amounts3) // match all of the 470 @ 1.94 with 500, and leave 500 left on the books // bob's balance goes down by the 1000 he paid, 500 matching, 500 unmatching // alice's bet is removed from the books - place_bet(bob_id, capitals_win_market.id, bet_type::back, asset(1000, asset_id_type()), 15 * GRAPHENE_BETTING_ODDS_PRECISION / 10); + place_bet(bob_id, capitals_win_market_id, bet_type::back, asset(1000, asset_id_type()), 15 * GRAPHENE_BETTING_ODDS_PRECISION / 10); bob_expected_balance -= 1000; BOOST_REQUIRE_EQUAL(get_balance(bob_id, asset_id_type()), bob_expected_balance.value); } @@ -620,12 +512,12 @@ BOOST_AUTO_TEST_CASE(match_using_takers_expected_amounts4) BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), alice_expected_balance.value); // back 1000 at 1.89 odds (100:89) -- this is an exact amount, nothing surprising should happen here - place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(1000, asset_id_type()), 189 * GRAPHENE_BETTING_ODDS_PRECISION / 100); + place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(1000, asset_id_type()), 189 * GRAPHENE_BETTING_ODDS_PRECISION / 100); alice_expected_balance -= 1000; BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), alice_expected_balance.value); // back 1000 at 1.97 odds (100:97) -- again, this is an exact amount, nothing surprising should happen here - place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(1000, asset_id_type()), 197 * GRAPHENE_BETTING_ODDS_PRECISION / 100); + place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(1000, asset_id_type()), 197 * GRAPHENE_BETTING_ODDS_PRECISION / 100); alice_expected_balance -= 1000; BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), alice_expected_balance.value); @@ -655,7 +547,7 @@ BOOST_AUTO_TEST_CASE(match_using_takers_expected_amounts4) // * alice's top bet on the books is reduced 200 @ 1.97 // * Bob now has as much of a position as he was willing to buy. We refund // the remainder of his bet, which is 552 - place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(3000, asset_id_type()), 266 * GRAPHENE_BETTING_ODDS_PRECISION / 100); + place_bet(bob_id, capitals_win_market_id, bet_type::lay, asset(3000, asset_id_type()), 266 * GRAPHENE_BETTING_ODDS_PRECISION / 100); bob_expected_balance -= 3000 - 12 - 770 - 552; BOOST_REQUIRE_EQUAL(get_balance(bob_id, asset_id_type()), bob_expected_balance.value); } @@ -675,7 +567,7 @@ BOOST_AUTO_TEST_CASE(match_using_takers_expected_amounts5) BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), alice_expected_balance.value); // back 1100 at 1.86 odds (50:43) -- this is an exact amount, nothing surprising should happen here - place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(1100, asset_id_type()), 186 * GRAPHENE_BETTING_ODDS_PRECISION / 100); + place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(1100, asset_id_type()), 186 * GRAPHENE_BETTING_ODDS_PRECISION / 100); alice_expected_balance -= 1100; BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), alice_expected_balance.value); @@ -699,7 +591,7 @@ BOOST_AUTO_TEST_CASE(match_using_takers_expected_amounts5) // * bob's bet is fully matched, he is refunded the remaining 132 and his // bet is complete // * bob's balance is reduced by the 946 he paid - place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(1100, asset_id_type()), 198 * GRAPHENE_BETTING_ODDS_PRECISION / 100); + place_bet(bob_id, capitals_win_market_id, bet_type::lay, asset(1100, asset_id_type()), 198 * GRAPHENE_BETTING_ODDS_PRECISION / 100); bob_expected_balance -= 1100 - 22 - 132; BOOST_REQUIRE_EQUAL(get_balance(bob_id, asset_id_type()), bob_expected_balance.value); } @@ -720,40 +612,40 @@ BOOST_AUTO_TEST_CASE(match_using_takers_expected_amounts6) share_type alice_expected_balance = 1000000000; BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), alice_expected_balance.value); - place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(10000000, asset_id_type()), 13 * GRAPHENE_BETTING_ODDS_PRECISION / 10); - place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(10000000, asset_id_type()), 15 * GRAPHENE_BETTING_ODDS_PRECISION / 10); - place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(10000000, asset_id_type()), 16 * GRAPHENE_BETTING_ODDS_PRECISION / 10); + place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(10000000, asset_id_type()), 13 * GRAPHENE_BETTING_ODDS_PRECISION / 10); + place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(10000000, asset_id_type()), 15 * GRAPHENE_BETTING_ODDS_PRECISION / 10); + place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(10000000, asset_id_type()), 16 * GRAPHENE_BETTING_ODDS_PRECISION / 10); alice_expected_balance -= 30000000; BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), alice_expected_balance.value); // check order books to see they match the bets we placed const auto& bet_odds_idx = db.get_index_type().indices().get(); - auto bet_iter = bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market.id)); + auto bet_iter = bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market_id)); BOOST_REQUIRE(bet_iter != bet_odds_idx.end()); - BOOST_REQUIRE(bet_iter->betting_market_id == capitals_win_market.id); + BOOST_REQUIRE(bet_iter->betting_market_id == capitals_win_market_id); BOOST_REQUIRE(bet_iter->bettor_id == alice_id); BOOST_REQUIRE(bet_iter->amount_to_bet == asset(10000000, asset_id_type())); BOOST_REQUIRE(bet_iter->backer_multiplier == 13 * GRAPHENE_BETTING_ODDS_PRECISION / 10); BOOST_REQUIRE(bet_iter->back_or_lay == bet_type::back); ++bet_iter; BOOST_REQUIRE(bet_iter != bet_odds_idx.end()); - BOOST_REQUIRE(bet_iter->betting_market_id == capitals_win_market.id); + BOOST_REQUIRE(bet_iter->betting_market_id == capitals_win_market_id); BOOST_REQUIRE(bet_iter->bettor_id == alice_id); BOOST_REQUIRE(bet_iter->amount_to_bet == asset(10000000, asset_id_type())); BOOST_REQUIRE(bet_iter->backer_multiplier == 15 * GRAPHENE_BETTING_ODDS_PRECISION / 10); BOOST_REQUIRE(bet_iter->back_or_lay == bet_type::back); ++bet_iter; BOOST_REQUIRE(bet_iter != bet_odds_idx.end()); - BOOST_REQUIRE(bet_iter->betting_market_id == capitals_win_market.id); + BOOST_REQUIRE(bet_iter->betting_market_id == capitals_win_market_id); BOOST_REQUIRE(bet_iter->bettor_id == alice_id); BOOST_REQUIRE(bet_iter->amount_to_bet == asset(10000000, asset_id_type())); BOOST_REQUIRE(bet_iter->backer_multiplier == 16 * GRAPHENE_BETTING_ODDS_PRECISION / 10); BOOST_REQUIRE(bet_iter->back_or_lay == bet_type::back); ++bet_iter; - BOOST_REQUIRE(bet_iter == bet_odds_idx.end() || bet_iter->betting_market_id != capitals_win_market.id); + BOOST_REQUIRE(bet_iter == bet_odds_idx.end() || bet_iter->betting_market_id != capitals_win_market_id); // check the binned order books from the bookie plugin to make sure they match - graphene::bookie::binned_order_book binned_orders_point_one = bookie_api.get_binned_order_book(capitals_win_market.id, 1); + graphene::bookie::binned_order_book binned_orders_point_one = bookie_api.get_binned_order_book(capitals_win_market_id, 1); auto aggregated_back_bets_iter = binned_orders_point_one.aggregated_back_bets.begin(); BOOST_REQUIRE(aggregated_back_bets_iter != binned_orders_point_one.aggregated_back_bets.end()); BOOST_REQUIRE(aggregated_back_bets_iter->amount_to_bet.value == 10000000); @@ -774,11 +666,11 @@ BOOST_AUTO_TEST_CASE(match_using_takers_expected_amounts6) share_type bob_expected_balance = 1000000000; BOOST_REQUIRE_EQUAL(get_balance(bob_id, asset_id_type()), bob_expected_balance.value); - place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(5000000, asset_id_type()), 15 * GRAPHENE_BETTING_ODDS_PRECISION / 10); + place_bet(bob_id, capitals_win_market_id, bet_type::lay, asset(5000000, asset_id_type()), 15 * GRAPHENE_BETTING_ODDS_PRECISION / 10); ilog("Order books after bob's matching lay bet:"); - bet_iter = bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market.id)); + bet_iter = bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market_id)); while (bet_iter != bet_odds_idx.end() && - bet_iter->betting_market_id == capitals_win_market.id) + bet_iter->betting_market_id == capitals_win_market_id) { idump((*bet_iter)); ++bet_iter; @@ -788,25 +680,25 @@ BOOST_AUTO_TEST_CASE(match_using_takers_expected_amounts6) BOOST_REQUIRE_EQUAL(get_balance(bob_id, asset_id_type()), bob_expected_balance.value); // check order books to see they match after bob's bet matched - bet_iter = bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market.id)); + bet_iter = bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market_id)); BOOST_REQUIRE(bet_iter != bet_odds_idx.end()); - BOOST_REQUIRE(bet_iter->betting_market_id == capitals_win_market.id); + BOOST_REQUIRE(bet_iter->betting_market_id == capitals_win_market_id); BOOST_REQUIRE(bet_iter->bettor_id == alice_id); BOOST_REQUIRE(bet_iter->amount_to_bet == asset(10000000, asset_id_type())); BOOST_REQUIRE(bet_iter->backer_multiplier == 15 * GRAPHENE_BETTING_ODDS_PRECISION / 10); BOOST_REQUIRE(bet_iter->back_or_lay == bet_type::back); ++bet_iter; BOOST_REQUIRE(bet_iter != bet_odds_idx.end()); - BOOST_REQUIRE(bet_iter->betting_market_id == capitals_win_market.id); + BOOST_REQUIRE(bet_iter->betting_market_id == capitals_win_market_id); BOOST_REQUIRE(bet_iter->bettor_id == alice_id); BOOST_REQUIRE(bet_iter->amount_to_bet == asset(10000000, asset_id_type())); BOOST_REQUIRE(bet_iter->backer_multiplier == 16 * GRAPHENE_BETTING_ODDS_PRECISION / 10); BOOST_REQUIRE(bet_iter->back_or_lay == bet_type::back); ++bet_iter; - BOOST_REQUIRE(bet_iter == bet_odds_idx.end() || bet_iter->betting_market_id != capitals_win_market.id); + BOOST_REQUIRE(bet_iter == bet_odds_idx.end() || bet_iter->betting_market_id != capitals_win_market_id); // check the binned order books from the bookie plugin to make sure they match - binned_orders_point_one = bookie_api.get_binned_order_book(capitals_win_market.id, 1); + binned_orders_point_one = bookie_api.get_binned_order_book(capitals_win_market_id, 1); aggregated_back_bets_iter = binned_orders_point_one.aggregated_back_bets.begin(); BOOST_REQUIRE(aggregated_back_bets_iter != binned_orders_point_one.aggregated_back_bets.end()); BOOST_REQUIRE(aggregated_back_bets_iter->amount_to_bet.value == 10000000); @@ -838,16 +730,16 @@ BOOST_AUTO_TEST_CASE(inexact_odds) // lay 46 at 1.94 odds (50:47) -- this is too small to be placed on the books and there's // nothing for it to match, so it should be canceled - place_bet(alice_id, capitals_win_market.id, bet_type::lay, asset(46, asset_id_type()), 194 * GRAPHENE_BETTING_ODDS_PRECISION / 100); + place_bet(alice_id, capitals_win_market_id, bet_type::lay, asset(46, asset_id_type()), 194 * GRAPHENE_BETTING_ODDS_PRECISION / 100); BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), alice_expected_balance.value); // lay 47 at 1.94 odds (50:47) -- this is an exact amount, nothing surprising should happen here - place_bet(alice_id, capitals_win_market.id, bet_type::lay, asset(47, asset_id_type()), 194 * GRAPHENE_BETTING_ODDS_PRECISION / 100); + place_bet(alice_id, capitals_win_market_id, bet_type::lay, asset(47, asset_id_type()), 194 * GRAPHENE_BETTING_ODDS_PRECISION / 100); alice_expected_balance -= 47; BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), alice_expected_balance.value); // lay 100 at 1.91 odds (100:91) -- this is an inexact match, we should get refunded 9 and leave a bet for 91 on the books - place_bet(alice_id, capitals_win_market.id, bet_type::lay, asset(100, asset_id_type()), 191 * GRAPHENE_BETTING_ODDS_PRECISION / 100); + place_bet(alice_id, capitals_win_market_id, bet_type::lay, asset(100, asset_id_type()), 191 * GRAPHENE_BETTING_ODDS_PRECISION / 100); alice_expected_balance -= 91; BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), alice_expected_balance.value); @@ -863,7 +755,7 @@ BOOST_AUTO_TEST_CASE(inexact_odds) // leaving 150 // back bets at 100:91 must be a multiple of 100, so refund 50 // leaves a back bet of 100 @ 1.91 on the books - place_bet(bob_id, capitals_win_market.id, bet_type::back, asset(300, asset_id_type()), 191 * GRAPHENE_BETTING_ODDS_PRECISION / 100); + place_bet(bob_id, capitals_win_market_id, bet_type::back, asset(300, asset_id_type()), 191 * GRAPHENE_BETTING_ODDS_PRECISION / 100); bob_expected_balance -= 250; BOOST_REQUIRE_EQUAL(get_balance(bob_id, asset_id_type()), bob_expected_balance.value); } @@ -884,15 +776,15 @@ BOOST_AUTO_TEST_CASE(bet_reversal_test) BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), alice_expected_balance.value); // back with our entire balance - place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(10000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(10000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), 0); // reverse the bet - place_bet(alice_id, capitals_win_market.id, bet_type::lay, asset(20000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(alice_id, capitals_win_market_id, bet_type::lay, asset(20000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), 0); // try to re-reverse it, but go too far - BOOST_CHECK_THROW( place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(30000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION), fc::exception); + BOOST_CHECK_THROW( place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(30000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION), fc::exception); BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), 0); } FC_LOG_AND_RETHROW() @@ -916,21 +808,21 @@ BOOST_AUTO_TEST_CASE(bet_reversal_test) // BOOST_REQUIRE_EQUAL(get_balance(bob_id, asset_id_type()), bob_expected_balance); // // // back with alice's entire balance -// place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(10000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); +// place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(10000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); // alice_expected_balance -= 10000000; // BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), alice_expected_balance); // // // lay with bob's entire balance, which fully matches bob's bet -// place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(10000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); +// place_bet(bob_id, capitals_win_market_id, bet_type::lay, asset(10000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); // bob_expected_balance -= 10000000; // BOOST_REQUIRE_EQUAL(get_balance(bob_id, asset_id_type()), bob_expected_balance); // // // reverse the bet -// place_bet(alice_id, capitals_win_market.id, bet_type::lay, asset(20000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); +// place_bet(alice_id, capitals_win_market_id, bet_type::lay, asset(20000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); // BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), alice_expected_balance); // // // try to re-reverse it, but go too far -// BOOST_CHECK_THROW( place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(30000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION), fc::exception); +// BOOST_CHECK_THROW( place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(30000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION), fc::exception); // BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), alice_expected_balance); // } // FC_LOG_AND_RETHROW() @@ -952,11 +844,11 @@ BOOST_AUTO_TEST_CASE(persistent_objects_test) BOOST_REQUIRE_EQUAL(get_balance(bob_id, asset_id_type()), bob_expected_balance.value); BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), alice_expected_balance.value); - idump((capitals_win_market.get_status())); + idump((capitals_win_market_id(db).get_status())); // lay 46 at 1.94 odds (50:47) -- this is too small to be placed on the books and there's // nothing for it to match, so it should be canceled - bet_id_type automatically_canceled_bet_id = place_bet(alice_id, capitals_win_market.id, bet_type::lay, asset(46, asset_id_type()), 194 * GRAPHENE_BETTING_ODDS_PRECISION / 100); + bet_id_type automatically_canceled_bet_id = place_bet(alice_id, capitals_win_market_id, bet_type::lay, asset(46, asset_id_type()), 194 * GRAPHENE_BETTING_ODDS_PRECISION / 100); generate_blocks(1); BOOST_CHECK_MESSAGE(!db.find(automatically_canceled_bet_id), "Bet should have been canceled, but the blockchain still knows about it"); fc::variants objects_from_bookie = bookie_api.get_objects({automatically_canceled_bet_id}); @@ -965,7 +857,7 @@ BOOST_AUTO_TEST_CASE(persistent_objects_test) BOOST_CHECK_MESSAGE(objects_from_bookie[0]["id"].as(1) == automatically_canceled_bet_id, "Bookie Plugin didn't return a deleted bet it"); // lay 47 at 1.94 odds (50:47) -- this bet should go on the order books normally - bet_id_type first_bet_on_books = place_bet(alice_id, capitals_win_market.id, bet_type::lay, asset(47, asset_id_type()), 194 * GRAPHENE_BETTING_ODDS_PRECISION / 100); + bet_id_type first_bet_on_books = place_bet(alice_id, capitals_win_market_id, bet_type::lay, asset(47, asset_id_type()), 194 * GRAPHENE_BETTING_ODDS_PRECISION / 100); generate_blocks(1); BOOST_CHECK_MESSAGE(db.find(first_bet_on_books), "Bet should exist on the blockchain"); objects_from_bookie = bookie_api.get_objects({first_bet_on_books}); @@ -974,7 +866,7 @@ BOOST_AUTO_TEST_CASE(persistent_objects_test) BOOST_CHECK_MESSAGE(objects_from_bookie[0]["id"].as(1) == first_bet_on_books, "Bookie Plugin didn't return a bet that is currently on the books"); // place a bet that exactly matches 'first_bet_on_books', should result in empty books (thus, no bet_objects from the blockchain) - bet_id_type matching_bet = place_bet(bob_id, capitals_win_market.id, bet_type::back, asset(50, asset_id_type()), 194 * GRAPHENE_BETTING_ODDS_PRECISION / 100); + bet_id_type matching_bet = place_bet(bob_id, capitals_win_market_id, bet_type::back, asset(50, asset_id_type()), 194 * GRAPHENE_BETTING_ODDS_PRECISION / 100); BOOST_CHECK_MESSAGE(!db.find(first_bet_on_books), "Bet should have been filled, but the blockchain still knows about it"); BOOST_CHECK_MESSAGE(!db.find(matching_bet), "Bet should have been filled, but the blockchain still knows about it"); generate_blocks(1); // the bookie plugin doesn't detect matches until a block is generated @@ -985,17 +877,11 @@ BOOST_AUTO_TEST_CASE(persistent_objects_test) BOOST_CHECK_MESSAGE(objects_from_bookie[0]["id"].as(1) == first_bet_on_books, "Bookie Plugin didn't return a bet that has been filled"); BOOST_CHECK_MESSAGE(objects_from_bookie[1]["id"].as(1) == matching_bet, "Bookie Plugin didn't return a bet that has been filled"); - update_betting_market_group(moneyline_betting_markets.id, _status = betting_market_group_status::closed); + update_betting_market_group(moneyline_betting_markets_id, _status = betting_market_group_status::closed); - resolve_betting_market_group(moneyline_betting_markets.id, - {{capitals_win_market.id, betting_market_resolution_type::cancel}, - {blackhawks_win_market.id, betting_market_resolution_type::cancel}}); - - // as soon as the market is resolved during the generate_block(), these markets - // should be deleted and our references will go out of scope. Save the - // market ids here so we can verify that they were really deleted - betting_market_id_type capitals_win_market_id = capitals_win_market.id; - betting_market_id_type blackhawks_win_market_id = blackhawks_win_market.id; + resolve_betting_market_group(moneyline_betting_markets_id, + {{capitals_win_market_id, betting_market_resolution_type::cancel}, + {blackhawks_win_market_id, betting_market_resolution_type::cancel}}); generate_blocks(1); @@ -1049,25 +935,19 @@ BOOST_AUTO_TEST_CASE(test_settled_market_states) BOOST_REQUIRE_EQUAL(get_balance(bob_id, asset_id_type()), bob_expected_balance.value); BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), alice_expected_balance.value); - idump((capitals_win_market.get_status())); + idump((capitals_win_market_id(db).get_status())); BOOST_TEST_MESSAGE("setting the event to in_progress"); - update_event(capitals_vs_blackhawks.id, _status = event_status::in_progress); + update_event(capitals_vs_blackhawks_id, _status = event_status::in_progress); generate_blocks(1); BOOST_TEST_MESSAGE("setting the event to finished"); - update_event(capitals_vs_blackhawks.id, _status = event_status::finished); + update_event(capitals_vs_blackhawks_id, _status = event_status::finished); generate_blocks(1); - resolve_betting_market_group(moneyline_betting_markets.id, - {{capitals_win_market.id, betting_market_resolution_type::win}, - {blackhawks_win_market.id, betting_market_resolution_type::not_win}}); - - // as soon as the market is resolved during the generate_block(), these markets - // should be deleted and our references will go out of scope. Save the - // market ids here so we can verify that they were really deleted - betting_market_id_type capitals_win_market_id = capitals_win_market.id; - betting_market_id_type blackhawks_win_market_id = blackhawks_win_market.id; + resolve_betting_market_group(moneyline_betting_markets_id, + {{capitals_win_market_id, betting_market_resolution_type::win}, + {blackhawks_win_market_id, betting_market_resolution_type::not_win}}); generate_blocks(1); @@ -1098,7 +978,7 @@ BOOST_AUTO_TEST_CASE(delayed_bets_test) // test live betting generate_blocks(1); - update_betting_market_group(moneyline_betting_markets.id, _status = betting_market_group_status::in_play); + update_betting_market_group(moneyline_betting_markets_id, _status = betting_market_group_status::in_play); generate_blocks(1); transfer(account_id_type(), alice_id, asset(10000000)); @@ -1113,17 +993,17 @@ BOOST_AUTO_TEST_CASE(delayed_bets_test) // test live betting BOOST_TEST_MESSAGE("Testing basic delayed bet mechanics"); // alice backs 100 at odds 2 BOOST_TEST_MESSAGE("Alice places a back bet of 100 at odds 2.0"); - bet_id_type delayed_back_bet = place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(100, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + bet_id_type delayed_back_bet = place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(100, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); generate_blocks(1); // verify the bet hasn't been placed in the active book - auto first_bet_in_market = bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market.id)); + auto first_bet_in_market = bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market_id)); BOOST_CHECK(first_bet_in_market == bet_odds_idx.end()); // after 3 blocks, the delay should have expired and it will be promoted to the active book generate_blocks(2); - first_bet_in_market = bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market.id)); - auto last_bet_in_market = bet_odds_idx.upper_bound(std::make_tuple(capitals_win_market.id)); + first_bet_in_market = bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market_id)); + auto last_bet_in_market = bet_odds_idx.upper_bound(std::make_tuple(capitals_win_market_id)); BOOST_CHECK(first_bet_in_market != bet_odds_idx.end()); BOOST_CHECK(std::distance(first_bet_in_market, last_bet_in_market) == 1); @@ -1131,19 +1011,19 @@ BOOST_AUTO_TEST_CASE(delayed_bets_test) // test live betting edump((bet)); // bob lays 100 at odds 2 to match alice's bet currently on the books BOOST_TEST_MESSAGE("Bob places a lay bet of 100 at odds 2.0"); - /* bet_id_type delayed_lay_bet = */ place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(100, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + /* bet_id_type delayed_lay_bet = */ place_bet(bob_id, capitals_win_market_id, bet_type::lay, asset(100, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); edump((db.get_global_properties().parameters.block_interval)(db.head_block_time())); // the bet should not enter the order books before a block has been generated - first_bet_in_market = bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market.id)); - last_bet_in_market = bet_odds_idx.upper_bound(std::make_tuple(capitals_win_market.id)); + first_bet_in_market = bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market_id)); + last_bet_in_market = bet_odds_idx.upper_bound(std::make_tuple(capitals_win_market_id)); for (const auto& bet : bet_odds_idx) edump((bet)); generate_blocks(1); // bob's bet will still be delayed, so the active order book will only contain alice's bet - first_bet_in_market = bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market.id)); - last_bet_in_market = bet_odds_idx.upper_bound(std::make_tuple(capitals_win_market.id)); + first_bet_in_market = bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market_id)); + last_bet_in_market = bet_odds_idx.upper_bound(std::make_tuple(capitals_win_market_id)); // edump((std::distance(first_bet_in_market, last_bet_in_market))); BOOST_CHECK(std::distance(first_bet_in_market, last_bet_in_market) == 1); for (const auto& bet : boost::make_iterator_range(first_bet_in_market, last_bet_in_market)) @@ -1156,13 +1036,13 @@ BOOST_AUTO_TEST_CASE(delayed_bets_test) // test live betting // now test that when we cancel all bets on a market, delayed bets get canceled too BOOST_TEST_MESSAGE("Alice places a back bet of 100 at odds 2.0"); - delayed_back_bet = place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(100, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + delayed_back_bet = place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(100, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); generate_blocks(1); - first_bet_in_market = bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market.id)); + first_bet_in_market = bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market_id)); BOOST_CHECK(!bet_odds_idx.empty()); BOOST_CHECK(first_bet_in_market == bet_odds_idx.end()); BOOST_TEST_MESSAGE("Cancel all bets"); - cancel_unmatched_bets(moneyline_betting_markets.id); + cancel_unmatched_bets(moneyline_betting_markets_id); BOOST_CHECK(bet_odds_idx.empty()); } FC_LOG_AND_RETHROW() @@ -1283,28 +1163,28 @@ BOOST_AUTO_TEST_CASE( testnet_witness_block_production_error ) try { CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0); - create_betting_market_group({{"en", "Unused"}}, capitals_vs_blackhawks.id, betting_market_rules.id, asset_id_type(), false, 0); + create_betting_market_group({{"en", "Unused"}}, capitals_vs_blackhawks_id, betting_market_rules_id, asset_id_type(), false, 0); generate_blocks(1); const betting_market_group_object& unused_betting_markets = *db.get_index_type().indices().get().rbegin(); BOOST_TEST_MESSAGE("setting the event in progress"); - update_event(capitals_vs_blackhawks.id, _status = event_status::in_progress); + update_event(capitals_vs_blackhawks_id, _status = event_status::in_progress); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::in_progress); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::in_play); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::in_progress); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::in_play); BOOST_CHECK(unused_betting_markets.get_status() == betting_market_group_status::in_play); BOOST_TEST_MESSAGE("setting the event to finished"); - update_event(capitals_vs_blackhawks.id, _status = event_status::finished); + update_event(capitals_vs_blackhawks_id, _status = event_status::finished); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::finished); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::closed); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::finished); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::closed); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); BOOST_CHECK(unused_betting_markets.get_status() == betting_market_group_status::closed); BOOST_TEST_MESSAGE("setting the event to canceled"); - update_event(capitals_vs_blackhawks.id, _status = event_status::canceled); + update_event(capitals_vs_blackhawks_id, _status = event_status::canceled); generate_blocks(1); } FC_LOG_AND_RETHROW() } @@ -1318,10 +1198,10 @@ BOOST_AUTO_TEST_CASE( cancel_one_event_in_group ) CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0); // create a second event in the same betting market group - create_event({{"en", "Boston Bruins/Pittsburgh Penguins"}}, {{"en", "2016-17"}}, nhl.id); + create_event({{"en", "Boston Bruins/Pittsburgh Penguins"}}, {{"en", "2016-17"}}, nhl_id); generate_blocks(1); const event_object& bruins_vs_penguins = *db.get_index_type().indices().get().rbegin(); - create_betting_market_group({{"en", "Moneyline"}}, bruins_vs_penguins.id, betting_market_rules.id, asset_id_type(), false, 0); + create_betting_market_group({{"en", "Moneyline"}}, bruins_vs_penguins.id, betting_market_rules_id, asset_id_type(), false, 0); generate_blocks(1); const betting_market_group_object& bruins_penguins_moneyline_betting_markets = *db.get_index_type().indices().get().rbegin(); create_betting_market(bruins_penguins_moneyline_betting_markets.id, {{"en", "Boston Bruins win"}}); @@ -1333,14 +1213,14 @@ BOOST_AUTO_TEST_CASE( cancel_one_event_in_group ) (void)bruins_win_market; (void)penguins_win_market; // check the initial state - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::upcoming); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::upcoming); BOOST_CHECK(bruins_vs_penguins.get_status() == event_status::upcoming); BOOST_TEST_MESSAGE("setting the capitals_vs_blackhawks event to in-progress, leaving bruins_vs_penguins in upcoming"); - update_event(capitals_vs_blackhawks.id, _status = event_status::in_progress); + update_event(capitals_vs_blackhawks_id, _status = event_status::in_progress); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::in_progress); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::in_play); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::in_progress); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::in_play); BOOST_CHECK(bruins_vs_penguins.get_status() == event_status::upcoming); BOOST_CHECK(bruins_penguins_moneyline_betting_markets.get_status() == betting_market_group_status::upcoming); @@ -1348,19 +1228,19 @@ BOOST_AUTO_TEST_CASE( cancel_one_event_in_group ) BOOST_CHECK(penguins_win_market.get_status() == betting_market_status::unresolved); BOOST_TEST_MESSAGE("setting the capitals_vs_blackhawks event to finished"); - update_event(capitals_vs_blackhawks.id, _status = event_status::finished); + update_event(capitals_vs_blackhawks_id, _status = event_status::finished); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::finished); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::closed); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::finished); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::closed); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); BOOST_CHECK(bruins_vs_penguins.get_status() == event_status::upcoming); BOOST_CHECK(bruins_penguins_moneyline_betting_markets.get_status() == betting_market_group_status::upcoming); BOOST_CHECK(bruins_win_market.get_status() == betting_market_status::unresolved); BOOST_CHECK(penguins_win_market.get_status() == betting_market_status::unresolved); BOOST_TEST_MESSAGE("setting the capitals_vs_blackhawks event to canceled"); - update_event(capitals_vs_blackhawks.id, _status = event_status::canceled); + update_event(capitals_vs_blackhawks_id, _status = event_status::canceled); generate_blocks(1); BOOST_CHECK(bruins_vs_penguins.get_status() == event_status::upcoming); BOOST_CHECK(bruins_penguins_moneyline_betting_markets.get_status() == betting_market_group_status::upcoming); @@ -1456,23 +1336,23 @@ struct simple_bet_test_fixture_2 : database_fixture { transfer(account_id_type(), bob_id, asset(10000)); // alice backs 1000 at 1:1, matches - place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(1000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); - place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(1000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(1000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(bob_id, capitals_win_market_id, bet_type::lay, asset(1000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); // now alice lays at 2500 at 1:1. This should require a deposit of 500, with the remaining 200 being funded from exposure - place_bet(alice_id, capitals_win_market.id, bet_type::lay, asset(2500, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(alice_id, capitals_win_market_id, bet_type::lay, asset(2500, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); // match the bet bit by bit. bob matches 500 of alice's 2500 bet. This effectively cancels half of bob's lay position // so he immediately gets 500 back. It reduces alice's back position, but doesn't return any money to her (all 2000 of her exposure // was already "promised" to her lay bet, so the 500 she would have received is placed in her refundable_unmatched_bets) - place_bet(bob_id, capitals_win_market.id, bet_type::back, asset(500, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(bob_id, capitals_win_market_id, bet_type::back, asset(500, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); // match another 500, which will fully cancel bob's lay position and return the other 500 he had locked up in his position. // alice's back position is now canceled, 1500 remains of her unmatched lay bet, and the 500 from canceling her position has // been moved to her refundable_unmatched_bets - place_bet(bob_id, capitals_win_market.id, bet_type::back, asset(500, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(bob_id, capitals_win_market_id, bet_type::back, asset(500, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); - capitals_win_betting_market_id = capitals_win_market.id; + capitals_win_betting_market_id = capitals_win_market_id; } }; @@ -1484,10 +1364,10 @@ BOOST_AUTO_TEST_CASE(sport_update_test) { ACTORS( (alice) ); CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0); - update_sport(ice_hockey.id, {{"en", "Hockey on Ice"}, {"zh_Hans", "冰"}, {"ja", "アイスホッケ"}}); + update_sport(ice_hockey_id, {{"en", "Hockey on Ice"}, {"zh_Hans", "冰"}, {"ja", "アイスホッケ"}}); transfer(account_id_type(), alice_id, asset(10000000)); - place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); BOOST_CHECK_EQUAL(get_balance(alice_id, asset_id_type()), 10000000 - 1000000); @@ -1500,13 +1380,13 @@ BOOST_AUTO_TEST_CASE(sport_delete_test) { CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0); - const auto& event_group_1 = create_event_group({{"en", "group1"}}, ice_hockey.id); - const auto& event_group_2 = create_event_group({{"en", "group2"}}, ice_hockey.id); + const auto& event_group_1 = create_event_group({{"en", "group1"}}, ice_hockey_id); + const auto& event_group_2 = create_event_group({{"en", "group2"}}, ice_hockey_id); - delete_sport(ice_hockey.id); + delete_sport(ice_hockey_id); const auto& sport_by_id = db.get_index_type().indices().get(); - BOOST_CHECK(sport_by_id.end() == sport_by_id.find(ice_hockey.id)); + BOOST_CHECK(sport_by_id.end() == sport_by_id.find(ice_hockey_id)); const auto& event_group_by_id = db.get_index_type().indices().get(); BOOST_CHECK(event_group_by_id.end() == event_group_by_id.find(event_group_1.id)); @@ -1521,7 +1401,7 @@ BOOST_AUTO_TEST_CASE(sport_delete_test_not_proposal) CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0); sport_delete_operation sport_delete_op; - sport_delete_op.sport_id = ice_hockey.id; + sport_delete_op.sport_id = ice_hockey_id; BOOST_CHECK_THROW(force_operation_by_witnesses(sport_delete_op), fc::exception); } FC_LOG_AND_RETHROW() @@ -1534,9 +1414,9 @@ BOOST_AUTO_TEST_CASE(sport_delete_test_not_proposal) // { // CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0); // -// delete_sport(ice_hockey.id); +// delete_sport(ice_hockey_id); // -// BOOST_CHECK_THROW(delete_sport(ice_hockey.id), fc::exception); +// BOOST_CHECK_THROW(delete_sport(ice_hockey_id), fc::exception); // } FC_LOG_AND_RETHROW() // } @@ -1550,28 +1430,28 @@ BOOST_AUTO_TEST_CASE(event_group_update_test) transfer(account_id_type(), alice_id, asset(10000000)); transfer(account_id_type(), bob_id, asset(10000000)); - place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); const sport_object& ice_on_hockey = create_sport({{"en", "Hockey on Ice"}, {"zh_Hans", "冰球"}, {"ja", "アイスホッケー"}}); \ fc::optional sport_id = ice_on_hockey.id; fc::optional name = internationalized_string_type({{"en", "IBM"}, {"zh_Hans", "國家冰球聯"}, {"ja", "ナショナルホッケーリー"}}); - update_event_group(nhl.id, fc::optional(), name); - update_event_group(nhl.id, sport_id, fc::optional()); - update_event_group(nhl.id, sport_id, name); + update_event_group(nhl_id, fc::optional(), name); + update_event_group(nhl_id, sport_id, fc::optional()); + update_event_group(nhl_id, sport_id, name); - place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(bob_id, capitals_win_market_id, bet_type::lay, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); BOOST_CHECK_EQUAL(get_balance(alice_id, asset_id_type()), 10000000 - 1000000); BOOST_CHECK_EQUAL(get_balance(bob_id, asset_id_type()), 10000000 - 1000000); - update_betting_market_group(moneyline_betting_markets.id, _status = betting_market_group_status::closed); + update_betting_market_group(moneyline_betting_markets_id, _status = betting_market_group_status::closed); // caps win - resolve_betting_market_group(moneyline_betting_markets.id, - {{capitals_win_market.id, betting_market_resolution_type::win}, - {blackhawks_win_market.id, betting_market_resolution_type::not_win}}); + resolve_betting_market_group(moneyline_betting_markets_id, + {{capitals_win_market_id, betting_market_resolution_type::win}, + {blackhawks_win_market_id, betting_market_resolution_type::not_win}}); generate_blocks(1); @@ -1760,9 +1640,9 @@ BOOST_AUTO_TEST_CASE(event_group_delete_test) transfer(account_id_type(), alice_id, asset(initialAccountAsset)); transfer(account_id_type(), bob_id, asset(initialAccountAsset)); - const auto& event = create_event({{"en", "event"}}, {{"en", "2016-17"}}, nhl.id); + const auto& event = create_event({{"en", "event"}}, {{"en", "2016-17"}}, nhl_id); - const auto& market_group = create_betting_market_group({{"en", "market group"}}, event.id, betting_market_rules.id, asset_id_type(), false, 0); + const auto& market_group = create_betting_market_group({{"en", "market group"}}, event.id, betting_market_rules_id, asset_id_type(), false, 0); //to make bets be not removed immediately update_betting_market_group_impl(market_group.id, fc::optional(), @@ -1772,17 +1652,17 @@ BOOST_AUTO_TEST_CASE(event_group_delete_test) const auto& market = create_betting_market(market_group.id, {{"en", "market"}}); - test_events events(*this, nhl.id); - test_markets_groups markets_groups(*this, event.id, betting_market_rules.id); + test_events events(*this, nhl_id); + test_markets_groups markets_groups(*this, event.id, betting_market_rules_id); test_markets markets(*this, market_group.id); const auto& bet_1_id = place_bet(alice_id, market.id, bet_type::back, asset(betAsset, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); const auto& bet_2_id = place_bet(bob_id, market.id, bet_type::lay, asset(betAsset, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); - delete_event_group(nhl.id); + delete_event_group(nhl_id); const auto& event_group_by_id = db.get_index_type().indices().get(); - BOOST_CHECK(event_group_by_id.end() == event_group_by_id.find(nhl.id)); + BOOST_CHECK(event_group_by_id.end() == event_group_by_id.find(nhl_id)); BOOST_CHECK(event_status::canceled == event.get_status()); @@ -1838,10 +1718,10 @@ BOOST_AUTO_TEST_CASE(event_group_delete_test_with_matched_bets) transfer(account_id_type(), bob_id, asset(initialAccountAsset)); generate_blocks(1); - const auto& event = create_event({{"en", "event"}}, {{"en", "2016-17"}}, nhl.id); + const auto& event = create_event({{"en", "event"}}, {{"en", "2016-17"}}, nhl_id); generate_blocks(1); - const auto& market_group = create_betting_market_group({{"en", "market group"}}, event.id, betting_market_rules.id, asset_id_type(), false, 0); + const auto& market_group = create_betting_market_group({{"en", "market group"}}, event.id, betting_market_rules_id, asset_id_type(), false, 0); generate_blocks(1); const auto& market = create_betting_market(market_group.id, {{"en", "market"}}); @@ -1851,7 +1731,7 @@ BOOST_AUTO_TEST_CASE(event_group_delete_test_with_matched_bets) place_bet(bob_id, market.id, bet_type::lay, asset(betAsset, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); generate_blocks(1); - delete_event_group(nhl.id); + delete_event_group(nhl_id); generate_blocks(1); BOOST_CHECK_EQUAL(get_balance(alice_id, asset_id_type()), initialAccountAsset); @@ -1866,7 +1746,7 @@ BOOST_AUTO_TEST_CASE(event_group_delete_test_not_proposal) CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0); event_group_delete_operation event_group_delete_op; - event_group_delete_op.event_group_id = nhl.id; + event_group_delete_op.event_group_id = nhl_id; BOOST_CHECK_THROW(force_operation_by_witnesses(event_group_delete_op), fc::exception); } FC_LOG_AND_RETHROW() @@ -1877,9 +1757,7 @@ BOOST_AUTO_TEST_CASE(event_group_delete_test_not_existed_event_group) try { CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0); - event_group_id_type nhl_id = nhl.id; - delete_event_group(nhl_id); - + delete_event_group(nhl_id); BOOST_CHECK_THROW(delete_event_group(nhl_id), fc::exception); } FC_LOG_AND_RETHROW() @@ -1895,31 +1773,31 @@ BOOST_AUTO_TEST_CASE(event_update_test) transfer(account_id_type(), alice_id, asset(10000000)); transfer(account_id_type(), bob_id, asset(10000000)); - place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); fc::optional name = internationalized_string_type({{"en", "Washington Capitals vs. Chicago Blackhawks"}, {"zh_Hans", "華盛頓首都隊/芝加哥黑"}, {"ja", "ワシントン・キャピタルズ/シカゴ・ブラックホーク"}}); fc::optional season = internationalized_string_type({{"en", "2017-18"}}); - update_event(capitals_vs_blackhawks.id, _name = name); - update_event(capitals_vs_blackhawks.id, _season = season); - update_event(capitals_vs_blackhawks.id, _name = name, _season = season); + update_event(capitals_vs_blackhawks_id, _name = name); + update_event(capitals_vs_blackhawks_id, _season = season); + update_event(capitals_vs_blackhawks_id, _name = name, _season = season); const sport_object& ice_on_hockey = create_sport({{"en", "Hockey on Ice"}, {"zh_Hans", "冰球"}, {"ja", "アイスホッケー"}}); const event_group_object& nhl2 = create_event_group({{"en", "NHL2"}, {"zh_Hans", "國家冰球聯盟"}, {"ja", "ナショナルホッケーリーグ"}}, ice_on_hockey.id); - update_event(capitals_vs_blackhawks.id, _event_group_id = nhl2.id); + update_event(capitals_vs_blackhawks_id, _event_group_id = nhl2.id); - place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(bob_id, capitals_win_market_id, bet_type::lay, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); BOOST_CHECK_EQUAL(get_balance(alice_id, asset_id_type()), 10000000 - 1000000); BOOST_CHECK_EQUAL(get_balance(bob_id, asset_id_type()), 10000000 - 1000000); - update_betting_market_group(moneyline_betting_markets.id, _status = betting_market_group_status::closed); + update_betting_market_group(moneyline_betting_markets_id, _status = betting_market_group_status::closed); // caps win - resolve_betting_market_group(moneyline_betting_markets.id, - {{capitals_win_market.id, betting_market_resolution_type::win}, - {blackhawks_win_market.id, betting_market_resolution_type::not_win}}); + resolve_betting_market_group(moneyline_betting_markets_id, + {{capitals_win_market_id, betting_market_resolution_type::win}, + {blackhawks_win_market_id, betting_market_resolution_type::not_win}}); generate_blocks(1); @@ -1944,12 +1822,12 @@ BOOST_AUTO_TEST_CASE(betting_market_rules_update_test) fc::optional name = internationalized_string_type({{"en", "NHL Rules v1.1"}}); fc::optional desc = internationalized_string_type({{"en", "The winner will be the team with the most points at the end of the game. The team with fewer points will not be the winner."}}); - update_betting_market_rules(betting_market_rules.id, name, empty); - update_betting_market_rules(betting_market_rules.id, empty, desc); - update_betting_market_rules(betting_market_rules.id, name, desc); + update_betting_market_rules(betting_market_rules_id, name, empty); + update_betting_market_rules(betting_market_rules_id, empty, desc); + update_betting_market_rules(betting_market_rules_id, name, desc); transfer(account_id_type(), alice_id, asset(10000000)); - place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); BOOST_CHECK_EQUAL(get_balance(alice_id, asset_id_type()), 10000000 - 1000000); @@ -1964,28 +1842,28 @@ BOOST_AUTO_TEST_CASE(betting_market_group_update_test) CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0); transfer(account_id_type(), alice_id, asset(10000000)); - place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); internationalized_string_type new_description = internationalized_string_type({{"en", "Money line"}}); const betting_market_rules_object& new_betting_market_rules = create_betting_market_rules({{"en", "NHL Rules v2.0"}}, {{"en", "The winner will be the team with the most points at the end of the game. The team with fewer points will not be the winner."}}); fc::optional new_rule = new_betting_market_rules.id; - update_betting_market_group(moneyline_betting_markets.id, _description = new_description); - update_betting_market_group(moneyline_betting_markets.id, _rules_id = new_betting_market_rules.id); - update_betting_market_group(moneyline_betting_markets.id, _description = new_description, _rules_id = new_betting_market_rules.id); + update_betting_market_group(moneyline_betting_markets_id, _description = new_description); + update_betting_market_group(moneyline_betting_markets_id, _rules_id = new_betting_market_rules.id); + update_betting_market_group(moneyline_betting_markets_id, _description = new_description, _rules_id = new_betting_market_rules.id); transfer(account_id_type(), bob_id, asset(10000000)); - place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(bob_id, capitals_win_market_id, bet_type::lay, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); BOOST_CHECK_EQUAL(get_balance(alice_id, asset_id_type()), 10000000 - 1000000); BOOST_CHECK_EQUAL(get_balance(bob_id, asset_id_type()), 10000000 - 1000000); - update_betting_market_group(moneyline_betting_markets.id, _status = betting_market_group_status::closed); + update_betting_market_group(moneyline_betting_markets_id, _status = betting_market_group_status::closed); // caps win - resolve_betting_market_group(moneyline_betting_markets.id, - {{capitals_win_market.id, betting_market_resolution_type::win}, - {blackhawks_win_market.id, betting_market_resolution_type::not_win}}); + resolve_betting_market_group(moneyline_betting_markets_id, + {{capitals_win_market_id, betting_market_resolution_type::win}, + {blackhawks_win_market_id, betting_market_resolution_type::not_win}}); generate_blocks(1); @@ -2006,24 +1884,24 @@ BOOST_AUTO_TEST_CASE(betting_market_update_test) CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0); transfer(account_id_type(), alice_id, asset(10000000)); - place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); fc::optional payout_condition = internationalized_string_type({{"en", "Washington Capitals lose"}}); // update the payout condition - update_betting_market(capitals_win_market.id, fc::optional(), payout_condition); + update_betting_market(capitals_win_market_id, fc::optional(), payout_condition); transfer(account_id_type(), bob_id, asset(10000000)); - place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(bob_id, capitals_win_market_id, bet_type::lay, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); BOOST_CHECK_EQUAL(get_balance(alice_id, asset_id_type()), 10000000 - 1000000); BOOST_CHECK_EQUAL(get_balance(bob_id, asset_id_type()), 10000000 - 1000000); - update_betting_market_group(moneyline_betting_markets.id, _status = betting_market_group_status::closed); + update_betting_market_group(moneyline_betting_markets_id, _status = betting_market_group_status::closed); // caps win - resolve_betting_market_group(moneyline_betting_markets.id, - {{capitals_win_market.id, betting_market_resolution_type::win}, - {blackhawks_win_market.id, betting_market_resolution_type::not_win}}); + resolve_betting_market_group(moneyline_betting_markets_id, + {{capitals_win_market_id, betting_market_resolution_type::win}, + {blackhawks_win_market_id, betting_market_resolution_type::not_win}}); generate_blocks(1); uint16_t rake_fee_percentage = db.get_global_properties().parameters.betting_rake_fee_percentage(); @@ -2050,27 +1928,25 @@ BOOST_AUTO_TEST_CASE(event_driven_standard_progression_1) { CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0); graphene::bookie::bookie_api bookie_api(app); - // save the event id for checking after it is deleted - event_id_type capitals_vs_blackhawks_id = capitals_vs_blackhawks.id; BOOST_TEST_MESSAGE("verify everything is in the correct initial state"); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::upcoming); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::upcoming); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::upcoming); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::upcoming); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); BOOST_TEST_MESSAGE("setting the event to finished"); - update_event(capitals_vs_blackhawks.id, _status = event_status::finished); + update_event(capitals_vs_blackhawks_id, _status = event_status::finished); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::finished); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::closed); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::finished); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::closed); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); BOOST_TEST_MESSAGE("grading betting market"); - resolve_betting_market_group(moneyline_betting_markets.id, - {{capitals_win_market.id, betting_market_resolution_type::win}, - {blackhawks_win_market.id, betting_market_resolution_type::not_win}}); + resolve_betting_market_group(moneyline_betting_markets_id, + {{capitals_win_market_id, betting_market_resolution_type::win}, + {blackhawks_win_market_id, betting_market_resolution_type::not_win}}); generate_blocks(1); // as soon as a block is generated, the betting market group will settle, and the market @@ -2094,40 +1970,33 @@ BOOST_AUTO_TEST_CASE(event_driven_standard_progression_1_with_delay) CREATE_ICE_HOCKEY_BETTING_MARKET(false, 60 /* seconds */); graphene::bookie::bookie_api bookie_api(app); - // save the ids for checking after it is deleted - event_id_type capitals_vs_blackhawks_id = capitals_vs_blackhawks.id; - betting_market_group_id_type moneyline_betting_markets_id = moneyline_betting_markets.id; - betting_market_id_type capitals_win_market_id = capitals_win_market.id; - betting_market_id_type blackhawks_win_market_id = blackhawks_win_market.id; - - BOOST_TEST_MESSAGE("verify everything is in the correct initial state"); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::upcoming); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::upcoming); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::upcoming); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::upcoming); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); BOOST_TEST_MESSAGE("setting the event to finished"); - update_event(capitals_vs_blackhawks.id, _status = event_status::finished); + update_event(capitals_vs_blackhawks_id, _status = event_status::finished); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::finished); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::closed); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::finished); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::closed); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); BOOST_TEST_MESSAGE("grading betting market"); - resolve_betting_market_group(moneyline_betting_markets.id, - {{capitals_win_market.id, betting_market_resolution_type::win}, - {blackhawks_win_market.id, betting_market_resolution_type::not_win}}); + resolve_betting_market_group(moneyline_betting_markets_id, + {{capitals_win_market_id, betting_market_resolution_type::win}, + {blackhawks_win_market_id, betting_market_resolution_type::not_win}}); generate_blocks(1); // it should be waiting 60 seconds before it settles - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::finished); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::graded); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::graded); - BOOST_CHECK(capitals_win_market.resolution == betting_market_resolution_type::win); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::graded); - BOOST_CHECK(blackhawks_win_market.resolution == betting_market_resolution_type::not_win); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::finished); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::graded); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::graded); + BOOST_CHECK(capitals_win_market_id(db).resolution == betting_market_resolution_type::win); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::graded); + BOOST_CHECK(blackhawks_win_market_id(db).resolution == betting_market_resolution_type::not_win); generate_blocks(60); // as soon as a block is generated, the betting market group will settle, and the market @@ -2165,65 +2034,63 @@ BOOST_AUTO_TEST_CASE(event_driven_standard_progression_2) CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0); graphene::bookie::bookie_api bookie_api(app); - // save the event id for checking after it is deleted - event_id_type capitals_vs_blackhawks_id = capitals_vs_blackhawks.id; BOOST_TEST_MESSAGE("verify everything is in the correct initial state"); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::upcoming); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::upcoming); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::upcoming); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::upcoming); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); BOOST_TEST_MESSAGE("setting the event frozen"); - update_event(capitals_vs_blackhawks.id, _status = event_status::frozen); + update_event(capitals_vs_blackhawks_id, _status = event_status::frozen); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::frozen); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::frozen); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::frozen); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::frozen); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::frozen); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::frozen); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::frozen); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::frozen); BOOST_TEST_MESSAGE("setting the event back to upcoming"); - update_event(capitals_vs_blackhawks.id, _status = event_status::upcoming); + update_event(capitals_vs_blackhawks_id, _status = event_status::upcoming); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::upcoming); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::upcoming); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::upcoming); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::upcoming); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); BOOST_TEST_MESSAGE("setting the event in-progress"); - update_event(capitals_vs_blackhawks.id, _status = event_status::in_progress); + update_event(capitals_vs_blackhawks_id, _status = event_status::in_progress); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::in_progress); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::in_play); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::in_progress); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::in_play); BOOST_TEST_MESSAGE("setting the event frozen"); - update_event(capitals_vs_blackhawks.id, _status = event_status::frozen); + update_event(capitals_vs_blackhawks_id, _status = event_status::frozen); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::frozen); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::frozen); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::frozen); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::frozen); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::frozen); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::frozen); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::frozen); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::frozen); BOOST_TEST_MESSAGE("setting the event back in-progress"); - update_event(capitals_vs_blackhawks.id, _status = event_status::in_progress); + update_event(capitals_vs_blackhawks_id, _status = event_status::in_progress); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::in_progress); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::in_play); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::in_progress); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::in_play); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); BOOST_TEST_MESSAGE("setting the event to finished"); - update_event(capitals_vs_blackhawks.id, _status = event_status::finished); + update_event(capitals_vs_blackhawks_id, _status = event_status::finished); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::finished); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::closed); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::finished); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::closed); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); BOOST_TEST_MESSAGE("grading betting market"); - resolve_betting_market_group(moneyline_betting_markets.id, - {{capitals_win_market.id, betting_market_resolution_type::win}, - {blackhawks_win_market.id, betting_market_resolution_type::not_win}}); + resolve_betting_market_group(moneyline_betting_markets_id, + {{capitals_win_market_id, betting_market_resolution_type::win}, + {blackhawks_win_market_id, betting_market_resolution_type::not_win}}); generate_blocks(1); // as soon as a block is generated, the betting market group will settle, and the market @@ -2253,65 +2120,63 @@ BOOST_AUTO_TEST_CASE(event_driven_standard_progression_2_never_in_play) CREATE_ICE_HOCKEY_BETTING_MARKET(true, 0); graphene::bookie::bookie_api bookie_api(app); - // save the event id for checking after it is deleted - event_id_type capitals_vs_blackhawks_id = capitals_vs_blackhawks.id; BOOST_TEST_MESSAGE("verify everything is in the correct initial state"); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::upcoming); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::upcoming); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::upcoming); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::upcoming); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); BOOST_TEST_MESSAGE("setting the event frozen"); - update_event(capitals_vs_blackhawks.id, _status = event_status::frozen); + update_event(capitals_vs_blackhawks_id, _status = event_status::frozen); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::frozen); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::frozen); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::frozen); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::frozen); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::frozen); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::frozen); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::frozen); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::frozen); BOOST_TEST_MESSAGE("setting the event back to upcoming"); - update_event(capitals_vs_blackhawks.id, _status = event_status::upcoming); + update_event(capitals_vs_blackhawks_id, _status = event_status::upcoming); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::upcoming); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::upcoming); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::upcoming); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::upcoming); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); BOOST_TEST_MESSAGE("setting the event in-progress"); - update_event(capitals_vs_blackhawks.id, _status = event_status::in_progress); + update_event(capitals_vs_blackhawks_id, _status = event_status::in_progress); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::in_progress); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::upcoming); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::in_progress); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::upcoming); BOOST_TEST_MESSAGE("setting the event frozen"); - update_event(capitals_vs_blackhawks.id, _status = event_status::frozen); + update_event(capitals_vs_blackhawks_id, _status = event_status::frozen); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::frozen); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::frozen); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::frozen); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::frozen); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::frozen); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::frozen); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::frozen); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::frozen); BOOST_TEST_MESSAGE("setting the event back in-progress"); - update_event(capitals_vs_blackhawks.id, _status = event_status::in_progress); + update_event(capitals_vs_blackhawks_id, _status = event_status::in_progress); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::in_progress); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::upcoming); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::in_progress); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::upcoming); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); BOOST_TEST_MESSAGE("setting the event to finished"); - update_event(capitals_vs_blackhawks.id, _status = event_status::finished); + update_event(capitals_vs_blackhawks_id, _status = event_status::finished); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::finished); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::closed); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::finished); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::closed); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); BOOST_TEST_MESSAGE("grading betting market"); - resolve_betting_market_group(moneyline_betting_markets.id, - {{capitals_win_market.id, betting_market_resolution_type::win}, - {blackhawks_win_market.id, betting_market_resolution_type::not_win}}); + resolve_betting_market_group(moneyline_betting_markets_id, + {{capitals_win_market_id, betting_market_resolution_type::win}, + {blackhawks_win_market_id, betting_market_resolution_type::not_win}}); generate_blocks(1); // as soon as a block is generated, the betting market group will settle, and the market @@ -2339,55 +2204,53 @@ BOOST_AUTO_TEST_CASE(event_driven_standard_progression_3) CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0); graphene::bookie::bookie_api bookie_api(app); - // save the event id for checking after it is deleted - event_id_type capitals_vs_blackhawks_id = capitals_vs_blackhawks.id; BOOST_TEST_MESSAGE("verify everything is in the correct initial state"); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::upcoming); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::upcoming); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::upcoming); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::upcoming); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); BOOST_TEST_MESSAGE("setting the event frozen"); - update_event(capitals_vs_blackhawks.id, _status = event_status::frozen); + update_event(capitals_vs_blackhawks_id, _status = event_status::frozen); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::frozen); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::frozen); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::frozen); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::frozen); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::frozen); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::frozen); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::frozen); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::frozen); BOOST_TEST_MESSAGE("setting the event in progress"); - update_event(capitals_vs_blackhawks.id, _status = event_status::in_progress); + update_event(capitals_vs_blackhawks_id, _status = event_status::in_progress); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::in_progress); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::in_play); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::in_progress); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::in_play); BOOST_TEST_MESSAGE("setting the event frozen"); - update_event(capitals_vs_blackhawks.id, _status = event_status::frozen); + update_event(capitals_vs_blackhawks_id, _status = event_status::frozen); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::frozen); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::frozen); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::frozen); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::frozen); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::frozen); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::frozen); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::frozen); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::frozen); BOOST_TEST_MESSAGE("setting the event back in-progress"); - update_event(capitals_vs_blackhawks.id, _status = event_status::in_progress); + update_event(capitals_vs_blackhawks_id, _status = event_status::in_progress); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::in_progress); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::in_play); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::in_progress); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::in_play); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); BOOST_TEST_MESSAGE("setting the event to finished"); - update_event(capitals_vs_blackhawks.id, _status = event_status::finished); + update_event(capitals_vs_blackhawks_id, _status = event_status::finished); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::finished); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::closed); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::finished); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::closed); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); BOOST_TEST_MESSAGE("setting the event to canceled"); - update_event(capitals_vs_blackhawks.id, _status = event_status::canceled); + update_event(capitals_vs_blackhawks_id, _status = event_status::canceled); generate_blocks(1); // as soon as a block is generated, the betting market group will cancel, and the market @@ -2412,80 +2275,78 @@ BOOST_AUTO_TEST_CASE(event_driven_progression_errors_1) CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0); graphene::bookie::bookie_api bookie_api(app); - // save the event id for checking after it is deleted - event_id_type capitals_vs_blackhawks_id = capitals_vs_blackhawks.id; BOOST_TEST_MESSAGE("verify everything is in the correct initial state"); - BOOST_REQUIRE(capitals_vs_blackhawks.get_status() == event_status::upcoming); - BOOST_REQUIRE(moneyline_betting_markets.get_status() == betting_market_group_status::upcoming); - BOOST_REQUIRE(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_REQUIRE(blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_REQUIRE(capitals_vs_blackhawks_id(db).get_status() == event_status::upcoming); + BOOST_REQUIRE(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::upcoming); + BOOST_REQUIRE(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_REQUIRE(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); // settled is the only illegal transition from upcoming BOOST_TEST_MESSAGE("verifying we can't jump to settled"); - BOOST_CHECK_THROW(update_event(capitals_vs_blackhawks.id, _status = event_status::settled, _force = true), fc::exception); + BOOST_CHECK_THROW(update_event(capitals_vs_blackhawks_id, _status = event_status::settled, _force = true), fc::exception); BOOST_TEST_MESSAGE("setting the event frozen"); - update_event(capitals_vs_blackhawks.id, _status = event_status::frozen); + update_event(capitals_vs_blackhawks_id, _status = event_status::frozen); generate_blocks(1); - BOOST_REQUIRE(capitals_vs_blackhawks.get_status() == event_status::frozen); - BOOST_REQUIRE(moneyline_betting_markets.get_status() == betting_market_group_status::frozen); - BOOST_REQUIRE(capitals_win_market.get_status() == betting_market_status::frozen); - BOOST_REQUIRE(blackhawks_win_market.get_status() == betting_market_status::frozen); + BOOST_REQUIRE(capitals_vs_blackhawks_id(db).get_status() == event_status::frozen); + BOOST_REQUIRE(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::frozen); + BOOST_REQUIRE(capitals_win_market_id(db).get_status() == betting_market_status::frozen); + BOOST_REQUIRE(blackhawks_win_market_id(db).get_status() == betting_market_status::frozen); // settled is the only illegal transition from this frozen event BOOST_TEST_MESSAGE("verifying we can't jump to settled"); - BOOST_CHECK_THROW(update_event(capitals_vs_blackhawks.id, _status = event_status::settled, _force = true), fc::exception); + BOOST_CHECK_THROW(update_event(capitals_vs_blackhawks_id, _status = event_status::settled, _force = true), fc::exception); BOOST_TEST_MESSAGE("setting the event in progress"); - update_event(capitals_vs_blackhawks.id, _status = event_status::in_progress); + update_event(capitals_vs_blackhawks_id, _status = event_status::in_progress); generate_blocks(1); - BOOST_REQUIRE(capitals_vs_blackhawks.get_status() == event_status::in_progress); - BOOST_REQUIRE(moneyline_betting_markets.get_status() == betting_market_group_status::in_play); + BOOST_REQUIRE(capitals_vs_blackhawks_id(db).get_status() == event_status::in_progress); + BOOST_REQUIRE(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::in_play); // we can't go back to upcoming from in_progress. // settled is disallowed everywhere BOOST_TEST_MESSAGE("verifying we can't jump to upcoming"); - BOOST_CHECK_THROW(update_event(capitals_vs_blackhawks.id, _status = event_status::upcoming, _force = true), fc::exception); + BOOST_CHECK_THROW(update_event(capitals_vs_blackhawks_id, _status = event_status::upcoming, _force = true), fc::exception); BOOST_TEST_MESSAGE("verifying we can't jump to settled"); - BOOST_CHECK_THROW(update_event(capitals_vs_blackhawks.id, _status = event_status::settled, _force = true), fc::exception); + BOOST_CHECK_THROW(update_event(capitals_vs_blackhawks_id, _status = event_status::settled, _force = true), fc::exception); BOOST_TEST_MESSAGE("setting the event frozen"); - update_event(capitals_vs_blackhawks.id, _status = event_status::frozen); + update_event(capitals_vs_blackhawks_id, _status = event_status::frozen); generate_blocks(1); - BOOST_REQUIRE(capitals_vs_blackhawks.get_status() == event_status::frozen); - BOOST_REQUIRE(moneyline_betting_markets.get_status() == betting_market_group_status::frozen); - BOOST_REQUIRE(capitals_win_market.get_status() == betting_market_status::frozen); - BOOST_REQUIRE(blackhawks_win_market.get_status() == betting_market_status::frozen); + BOOST_REQUIRE(capitals_vs_blackhawks_id(db).get_status() == event_status::frozen); + BOOST_REQUIRE(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::frozen); + BOOST_REQUIRE(capitals_win_market_id(db).get_status() == betting_market_status::frozen); + BOOST_REQUIRE(blackhawks_win_market_id(db).get_status() == betting_market_status::frozen); // we can't go back to upcoming from frozen once we've gone in_progress. // settled is disallowed everywhere BOOST_TEST_MESSAGE("verifying we can't jump to upcoming"); - BOOST_CHECK_THROW(update_event(capitals_vs_blackhawks.id, _status = event_status::upcoming, _force = true), fc::exception); + BOOST_CHECK_THROW(update_event(capitals_vs_blackhawks_id, _status = event_status::upcoming, _force = true), fc::exception); BOOST_TEST_MESSAGE("verifying we can't jump to settled"); - BOOST_CHECK_THROW(update_event(capitals_vs_blackhawks.id, _status = event_status::settled, _force = true), fc::exception); + BOOST_CHECK_THROW(update_event(capitals_vs_blackhawks_id, _status = event_status::settled, _force = true), fc::exception); BOOST_TEST_MESSAGE("setting the event to finished"); - update_event(capitals_vs_blackhawks.id, _status = event_status::finished); + update_event(capitals_vs_blackhawks_id, _status = event_status::finished); generate_blocks(1); - BOOST_REQUIRE(capitals_vs_blackhawks.get_status() == event_status::finished); - BOOST_REQUIRE(moneyline_betting_markets.get_status() == betting_market_group_status::closed); - BOOST_REQUIRE(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_REQUIRE(blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_REQUIRE(capitals_vs_blackhawks_id(db).get_status() == event_status::finished); + BOOST_REQUIRE(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::closed); + BOOST_REQUIRE(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_REQUIRE(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); // we can't go back to upcoming, in_progress, or frozen once we're finished. // settled is disallowed everywhere BOOST_TEST_MESSAGE("verifying we can't jump to upcoming"); - BOOST_CHECK_THROW(update_event(capitals_vs_blackhawks.id, _status = event_status::upcoming, _force = true), fc::exception); + BOOST_CHECK_THROW(update_event(capitals_vs_blackhawks_id, _status = event_status::upcoming, _force = true), fc::exception); BOOST_TEST_MESSAGE("verifying we can't jump to in_progress"); - BOOST_CHECK_THROW(update_event(capitals_vs_blackhawks.id, _status = event_status::in_progress, _force = true), fc::exception); + BOOST_CHECK_THROW(update_event(capitals_vs_blackhawks_id, _status = event_status::in_progress, _force = true), fc::exception); BOOST_TEST_MESSAGE("verifying we can't jump to frozen"); - BOOST_CHECK_THROW(update_event(capitals_vs_blackhawks.id, _status = event_status::frozen, _force = true), fc::exception); + BOOST_CHECK_THROW(update_event(capitals_vs_blackhawks_id, _status = event_status::frozen, _force = true), fc::exception); BOOST_TEST_MESSAGE("verifying we can't jump to settled"); - BOOST_CHECK_THROW(update_event(capitals_vs_blackhawks.id, _status = event_status::settled, _force = true), fc::exception); + BOOST_CHECK_THROW(update_event(capitals_vs_blackhawks_id, _status = event_status::settled, _force = true), fc::exception); BOOST_TEST_MESSAGE("setting the event to canceled"); - update_event(capitals_vs_blackhawks.id, _status = event_status::canceled); + update_event(capitals_vs_blackhawks_id, _status = event_status::canceled); generate_blocks(1); fc::variants objects_from_bookie = bookie_api.get_objects({capitals_vs_blackhawks_id}); @@ -2515,32 +2376,31 @@ BOOST_AUTO_TEST_CASE(event_driven_progression_errors_2) CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0); graphene::bookie::bookie_api bookie_api(app); - // save the event id for checking after it is deleted - event_id_type capitals_vs_blackhawks_id = capitals_vs_blackhawks.id; BOOST_TEST_MESSAGE("verify everything is in the correct initial state"); - BOOST_REQUIRE(capitals_vs_blackhawks.get_status() == event_status::upcoming); - BOOST_REQUIRE(moneyline_betting_markets.get_status() == betting_market_group_status::upcoming); - BOOST_REQUIRE(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_REQUIRE(blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_REQUIRE(capitals_vs_blackhawks_id(db).get_status() == event_status::upcoming); + BOOST_REQUIRE(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::upcoming); + BOOST_REQUIRE(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_REQUIRE(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); BOOST_TEST_MESSAGE("setting the event to finished"); - update_event(capitals_vs_blackhawks.id, _status = event_status::finished); + update_event(capitals_vs_blackhawks_id, _status = event_status::finished); generate_blocks(1); - BOOST_REQUIRE(capitals_vs_blackhawks.get_status() == event_status::finished); - BOOST_REQUIRE(moneyline_betting_markets.get_status() == betting_market_group_status::closed); - BOOST_REQUIRE(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_REQUIRE(blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_REQUIRE(capitals_vs_blackhawks_id(db).get_status() == event_status::finished); + BOOST_REQUIRE(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::closed); + BOOST_REQUIRE(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_REQUIRE(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); BOOST_TEST_MESSAGE("grading betting market"); - resolve_betting_market_group(moneyline_betting_markets.id, - {{capitals_win_market.id, betting_market_resolution_type::win}, - {blackhawks_win_market.id, betting_market_resolution_type::not_win}}); + resolve_betting_market_group(moneyline_betting_markets_id, + {{capitals_win_market_id, betting_market_resolution_type::win}, + {blackhawks_win_market_id, betting_market_resolution_type::not_win}}); generate_blocks(1); // as soon as a block is generated, the betting market group will settle, and the market // and group will cease to exist. The event should transition to "settled", then removed fc::variants objects_from_bookie = bookie_api.get_objects({capitals_vs_blackhawks_id}); + wdump((objects_from_bookie)(capitals_vs_blackhawks_id(db))); BOOST_CHECK_EQUAL(objects_from_bookie[0]["status"].as(1), "settled"); // we can't go back to upcoming, in_progress, frozen, or finished once we're canceled. @@ -2567,47 +2427,45 @@ BOOST_AUTO_TEST_CASE(betting_market_group_driven_standard_progression) CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0); graphene::bookie::bookie_api bookie_api(app); - // save the event id for checking after it is deleted - event_id_type capitals_vs_blackhawks_id = capitals_vs_blackhawks.id; BOOST_TEST_MESSAGE("verify everything is in the correct initial state"); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::upcoming); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::upcoming); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::upcoming); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::upcoming); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); BOOST_TEST_MESSAGE("setting betting market to frozen"); // the event should stay in the upcoming state - update_betting_market_group(moneyline_betting_markets.id, _status = betting_market_group_status::frozen); + update_betting_market_group(moneyline_betting_markets_id, _status = betting_market_group_status::frozen); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::upcoming); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::frozen); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::frozen); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::frozen); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::upcoming); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::frozen); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::frozen); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::frozen); BOOST_TEST_MESSAGE("setting the event frozen"); // this should only change the status of the event, just verify that nothing weird happens when // we try to set the bmg to frozen when it's already frozen - update_event(capitals_vs_blackhawks.id, _status = event_status::frozen); + update_event(capitals_vs_blackhawks_id, _status = event_status::frozen); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::frozen); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::frozen); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::frozen); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::frozen); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::frozen); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::frozen); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::frozen); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::frozen); BOOST_TEST_MESSAGE("setting betting market to closed"); // the event should go to finished automatically - update_betting_market_group(moneyline_betting_markets.id, _status = betting_market_group_status::closed); + update_betting_market_group(moneyline_betting_markets_id, _status = betting_market_group_status::closed); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::finished); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::closed); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::finished); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::closed); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); BOOST_TEST_MESSAGE("grading betting market"); - resolve_betting_market_group(moneyline_betting_markets.id, - {{capitals_win_market.id, betting_market_resolution_type::win}, - {blackhawks_win_market.id, betting_market_resolution_type::not_win}}); + resolve_betting_market_group(moneyline_betting_markets_id, + {{capitals_win_market_id, betting_market_resolution_type::win}, + {blackhawks_win_market_id, betting_market_resolution_type::not_win}}); generate_blocks(1); // as soon as a block is generated, the betting market group will settle, and the market @@ -2626,99 +2484,97 @@ BOOST_AUTO_TEST_CASE(multi_betting_market_group_driven_standard_progression) CREATE_EXTENDED_ICE_HOCKEY_BETTING_MARKET(false, 0); graphene::bookie::bookie_api bookie_api(app); - // save the event id for checking after it is deleted - event_id_type capitals_vs_blackhawks_id = capitals_vs_blackhawks.id; BOOST_TEST_MESSAGE("verify everything is in the correct initial state"); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::upcoming); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::upcoming); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(first_period_result_betting_markets.get_status() == betting_market_group_status::upcoming); - BOOST_CHECK(first_period_capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(first_period_blackhawks_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(second_period_result_betting_markets.get_status() == betting_market_group_status::upcoming); - BOOST_CHECK(second_period_capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(second_period_blackhawks_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(third_period_result_betting_markets.get_status() == betting_market_group_status::upcoming); - BOOST_CHECK(third_period_capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(third_period_blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::upcoming); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::upcoming); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(first_period_result_betting_markets_id(db).get_status() == betting_market_group_status::upcoming); + BOOST_CHECK(first_period_capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(first_period_blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(second_period_result_betting_markets_id(db).get_status() == betting_market_group_status::upcoming); + BOOST_CHECK(second_period_capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(second_period_blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(third_period_result_betting_markets_id(db).get_status() == betting_market_group_status::upcoming); + BOOST_CHECK(third_period_capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(third_period_blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); BOOST_TEST_MESSAGE("the game is starting, setting the main betting market and the first period to in_play"); // the event should stay in the upcoming state - update_betting_market_group(moneyline_betting_markets.id, _status = betting_market_group_status::in_play); - update_betting_market_group(first_period_result_betting_markets.id, _status = betting_market_group_status::in_play); + update_betting_market_group(moneyline_betting_markets_id, _status = betting_market_group_status::in_play); + update_betting_market_group(first_period_result_betting_markets_id, _status = betting_market_group_status::in_play); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::upcoming); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::in_play); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(first_period_result_betting_markets.get_status() == betting_market_group_status::in_play); - BOOST_CHECK(first_period_capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(first_period_blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::upcoming); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::in_play); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(first_period_result_betting_markets_id(db).get_status() == betting_market_group_status::in_play); + BOOST_CHECK(first_period_capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(first_period_blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); BOOST_TEST_MESSAGE("the first period is over, starting the second period"); - update_betting_market_group(first_period_result_betting_markets.id, _status = betting_market_group_status::closed); - update_betting_market_group(second_period_result_betting_markets.id, _status = betting_market_group_status::in_play); - generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::upcoming); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::in_play); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(first_period_result_betting_markets.get_status() == betting_market_group_status::closed); - BOOST_CHECK(first_period_capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(first_period_blackhawks_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(second_period_result_betting_markets.get_status() == betting_market_group_status::in_play); - BOOST_CHECK(second_period_capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(second_period_blackhawks_win_market.get_status() == betting_market_status::unresolved); + update_betting_market_group(first_period_result_betting_markets_id, _status = betting_market_group_status::closed); + update_betting_market_group(second_period_result_betting_markets_id, _status = betting_market_group_status::in_play); + generate_blocks(1); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::upcoming); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::in_play); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(first_period_result_betting_markets_id(db).get_status() == betting_market_group_status::closed); + BOOST_CHECK(first_period_capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(first_period_blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(second_period_result_betting_markets_id(db).get_status() == betting_market_group_status::in_play); + BOOST_CHECK(second_period_capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(second_period_blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); BOOST_TEST_MESSAGE("grading the first period market"); - resolve_betting_market_group(first_period_result_betting_markets.id, - {{first_period_capitals_win_market.id, betting_market_resolution_type::win}, - {first_period_blackhawks_win_market.id, betting_market_resolution_type::not_win}}); + resolve_betting_market_group(first_period_result_betting_markets_id, + {{first_period_capitals_win_market_id, betting_market_resolution_type::win}, + {first_period_blackhawks_win_market_id, betting_market_resolution_type::not_win}}); generate_blocks(1); BOOST_TEST_MESSAGE("the second period is over, starting the third period"); - update_betting_market_group(second_period_result_betting_markets.id, _status = betting_market_group_status::closed); - update_betting_market_group(third_period_result_betting_markets.id, _status = betting_market_group_status::in_play); - generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::upcoming); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::in_play); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(second_period_result_betting_markets.get_status() == betting_market_group_status::closed); - BOOST_CHECK(second_period_capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(second_period_blackhawks_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(third_period_result_betting_markets.get_status() == betting_market_group_status::in_play); - BOOST_CHECK(third_period_capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(third_period_blackhawks_win_market.get_status() == betting_market_status::unresolved); + update_betting_market_group(second_period_result_betting_markets_id, _status = betting_market_group_status::closed); + update_betting_market_group(third_period_result_betting_markets_id, _status = betting_market_group_status::in_play); + generate_blocks(1); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::upcoming); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::in_play); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(second_period_result_betting_markets_id(db).get_status() == betting_market_group_status::closed); + BOOST_CHECK(second_period_capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(second_period_blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(third_period_result_betting_markets_id(db).get_status() == betting_market_group_status::in_play); + BOOST_CHECK(third_period_capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(third_period_blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); BOOST_TEST_MESSAGE("grading the second period market"); - resolve_betting_market_group(second_period_result_betting_markets.id, - {{second_period_capitals_win_market.id, betting_market_resolution_type::win}, - {second_period_blackhawks_win_market.id, betting_market_resolution_type::not_win}}); + resolve_betting_market_group(second_period_result_betting_markets_id, + {{second_period_capitals_win_market_id, betting_market_resolution_type::win}, + {second_period_blackhawks_win_market_id, betting_market_resolution_type::not_win}}); generate_blocks(1); BOOST_TEST_MESSAGE("the game is over, closing 3rd period and game"); - update_betting_market_group(third_period_result_betting_markets.id, _status = betting_market_group_status::closed); - update_betting_market_group(moneyline_betting_markets.id, _status = betting_market_group_status::closed); + update_betting_market_group(third_period_result_betting_markets_id, _status = betting_market_group_status::closed); + update_betting_market_group(moneyline_betting_markets_id, _status = betting_market_group_status::closed); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::finished); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::closed); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(third_period_result_betting_markets.get_status() == betting_market_group_status::closed); - BOOST_CHECK(third_period_capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(third_period_blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::finished); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::closed); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(third_period_result_betting_markets_id(db).get_status() == betting_market_group_status::closed); + BOOST_CHECK(third_period_capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(third_period_blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); BOOST_TEST_MESSAGE("grading the third period and game"); - resolve_betting_market_group(third_period_result_betting_markets.id, - {{third_period_capitals_win_market.id, betting_market_resolution_type::win}, - {third_period_blackhawks_win_market.id, betting_market_resolution_type::not_win}}); - resolve_betting_market_group(moneyline_betting_markets.id, - {{capitals_win_market.id, betting_market_resolution_type::win}, - {blackhawks_win_market.id, betting_market_resolution_type::not_win}}); + resolve_betting_market_group(third_period_result_betting_markets_id, + {{third_period_capitals_win_market_id, betting_market_resolution_type::win}, + {third_period_blackhawks_win_market_id, betting_market_resolution_type::not_win}}); + resolve_betting_market_group(moneyline_betting_markets_id, + {{capitals_win_market_id, betting_market_resolution_type::win}, + {blackhawks_win_market_id, betting_market_resolution_type::not_win}}); generate_blocks(1); // as soon as a block is generated, the two betting market groups will settle, and the market @@ -2767,47 +2623,47 @@ BOOST_FIXTURE_TEST_CASE( another_event_group_update_test, database_fixture) transfer(account_id_type(), alice_id, asset(10000000)); transfer(account_id_type(), bob_id, asset(10000000)); - place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); fc::optional name = internationalized_string_type({{"en", "IBM"}, {"zh_Hans", "國家冰球聯"}, {"ja", "ナショナルホッケーリー"}}); const sport_object& ice_on_hockey = create_sport({{"en", "Hockey on Ice"}, {"zh_Hans", "冰球"}, {"ja", "アイスホッケー"}}); \ fc::optional sport_id = ice_on_hockey.id; - update_event_group(nhl.id, fc::optional(), name); - update_event_group(nhl.id, sport_id, fc::optional()); - update_event_group(nhl.id, sport_id, name); + update_event_group(nhl_id, fc::optional(), name); + update_event_group(nhl_id, sport_id, fc::optional()); + update_event_group(nhl_id, sport_id, name); //Disabling the below 4 TRY_EXPECT_THROW lines to not throw anything beacuse functioning as expected // trx_state->_is_proposed_trx - //GRAPHENE_REQUIRE_THROW(try_update_event_group(nhl.id, fc::optional(), fc::optional(), true), fc::exception); - // TRY_EXPECT_THROW(try_update_event_group(nhl.id, fc::optional(), fc::optional(), true), fc::exception, "_is_proposed_trx"); + //GRAPHENE_REQUIRE_THROW(try_update_event_group(nhl_id, fc::optional(), fc::optional(), true), fc::exception); + // TRY_EXPECT_THROW(try_update_event_group(nhl_id, fc::optional(), fc::optional(), true), fc::exception, "_is_proposed_trx"); // #! nothing to change - //GRAPHENE_REQUIRE_THROW(try_update_event_group(nhl.id, fc::optional(), fc::optional()), fc::exception); - //TRY_EXPECT_THROW(try_update_event_group(nhl.id, fc::optional(), fc::optional()), fc::exception, "nothing to change"); + //GRAPHENE_REQUIRE_THROW(try_update_event_group(nhl_id, fc::optional(), fc::optional()), fc::exception); + //TRY_EXPECT_THROW(try_update_event_group(nhl_id, fc::optional(), fc::optional()), fc::exception, "nothing to change"); // #! sport_id must refer to a sport_id_type - sport_id = capitals_win_market.id; - //GRAPHENE_REQUIRE_THROW(try_update_event_group(nhl.id, sport_id, fc::optional()), fc::exception); - //TRY_EXPECT_THROW(try_update_event_group(nhl.id, sport_id, fc::optional()), fc::exception, "sport_id must refer to a sport_id_type"); + sport_id = capitals_win_market_id; + //GRAPHENE_REQUIRE_THROW(try_update_event_group(nhl_id, sport_id, fc::optional()), fc::exception); + //TRY_EXPECT_THROW(try_update_event_group(nhl_id, sport_id, fc::optional()), fc::exception, "sport_id must refer to a sport_id_type"); // #! invalid sport specified sport_id = sport_id_type(13); - //GRAPHENE_REQUIRE_THROW(try_update_event_group(nhl.id, sport_id, fc::optional()), fc::exception); - //TRY_EXPECT_THROW(try_update_event_group(nhl.id, sport_id, fc::optional()), fc::exception, "invalid sport specified"); + //GRAPHENE_REQUIRE_THROW(try_update_event_group(nhl_id, sport_id, fc::optional()), fc::exception); + //TRY_EXPECT_THROW(try_update_event_group(nhl_id, sport_id, fc::optional()), fc::exception, "invalid sport specified"); - place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(bob_id, capitals_win_market_id, bet_type::lay, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); BOOST_CHECK_EQUAL(get_balance(alice_id, asset_id_type()), 10000000 - 1000000); BOOST_CHECK_EQUAL(get_balance(bob_id, asset_id_type()), 10000000 - 1000000); - update_betting_market_group(moneyline_betting_markets.id, _status = betting_market_group_status::closed); + update_betting_market_group(moneyline_betting_markets_id, _status = betting_market_group_status::closed); // caps win - resolve_betting_market_group(moneyline_betting_markets.id, - {{capitals_win_market.id, betting_market_resolution_type::win}, - {blackhawks_win_market.id, betting_market_resolution_type::not_win}}); + resolve_betting_market_group(moneyline_betting_markets_id, + {{capitals_win_market_id, betting_market_resolution_type::win}, + {blackhawks_win_market_id, betting_market_resolution_type::not_win}}); generate_blocks(1); uint16_t rake_fee_percentage = db.get_global_properties().parameters.betting_rake_fee_percentage(); @@ -2835,31 +2691,31 @@ BOOST_AUTO_TEST_CASE( wimbledon_2017_gentelmen_singles_sf_test ) transfer(account_id_type(), alice_id, asset(10000000)); transfer(account_id_type(), bob_id, asset(10000000)); - BOOST_TEST_MESSAGE("moneyline_berdych_vs_federer " << fc::variant(moneyline_berdych_vs_federer.id, 1).as(1)); - BOOST_TEST_MESSAGE("moneyline_cilic_vs_querrey " << fc::variant(moneyline_cilic_vs_querrey.id, 1).as(1)); + BOOST_TEST_MESSAGE("moneyline_berdych_vs_federer " << fc::variant(moneyline_berdych_vs_federer_id, 1).as(1)); + BOOST_TEST_MESSAGE("moneyline_cilic_vs_querrey " << fc::variant(moneyline_cilic_vs_querrey_id, 1).as(1)); - BOOST_TEST_MESSAGE("berdych_wins_market " << fc::variant(berdych_wins_market.id, 1).as(1)); - BOOST_TEST_MESSAGE("federer_wins_market " << fc::variant(federer_wins_market.id, 1).as(1)); - BOOST_TEST_MESSAGE("cilic_wins_market " << fc::variant(cilic_wins_market.id, 1).as(1)); - BOOST_TEST_MESSAGE("querrey_wins_market " << fc::variant(querrey_wins_market.id, 1).as(1)); + BOOST_TEST_MESSAGE("berdych_wins_market " << fc::variant(berdych_wins_market_id, 1).as(1)); + BOOST_TEST_MESSAGE("federer_wins_market " << fc::variant(federer_wins_market_id, 1).as(1)); + BOOST_TEST_MESSAGE("cilic_wins_market " << fc::variant(cilic_wins_market_id, 1).as(1)); + BOOST_TEST_MESSAGE("querrey_wins_market " << fc::variant(querrey_wins_market_id, 1).as(1)); - place_bet(alice_id, berdych_wins_market.id, bet_type::back, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); - place_bet(bob_id, berdych_wins_market.id, bet_type::lay, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(alice_id, berdych_wins_market_id, bet_type::back, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(bob_id, berdych_wins_market_id, bet_type::lay, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); BOOST_CHECK_EQUAL(get_balance(alice_id, asset_id_type()), 10000000 - 1000000); BOOST_CHECK_EQUAL(get_balance(bob_id, asset_id_type()), 10000000 - 1000000); - place_bet(alice_id, cilic_wins_market.id, bet_type::back, asset(100000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); - place_bet(bob_id, cilic_wins_market.id, bet_type::lay, asset(100000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(alice_id, cilic_wins_market_id, bet_type::back, asset(100000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(bob_id, cilic_wins_market_id, bet_type::lay, asset(100000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); BOOST_CHECK_EQUAL(get_balance(alice_id, asset_id_type()), 10000000 - 1000000 - 100000); BOOST_CHECK_EQUAL(get_balance(bob_id, asset_id_type()), 10000000 - 1000000 - 100000); - update_betting_market_group(moneyline_berdych_vs_federer.id, _status = betting_market_group_status::closed); + update_betting_market_group(moneyline_berdych_vs_federer_id, _status = betting_market_group_status::closed); // federer wins - resolve_betting_market_group(moneyline_berdych_vs_federer.id, - {{berdych_wins_market.id, betting_market_resolution_type::not_win}, - {federer_wins_market.id, betting_market_resolution_type::win}}); + resolve_betting_market_group(moneyline_berdych_vs_federer_id, + {{berdych_wins_market_id, betting_market_resolution_type::not_win}, + {federer_wins_market_id, betting_market_resolution_type::win}}); generate_blocks(1); uint32_t bob_rake_value = (-1000000 + 2000000) * rake_fee_percentage / GRAPHENE_1_PERCENT / 100; @@ -2868,11 +2724,11 @@ BOOST_AUTO_TEST_CASE( wimbledon_2017_gentelmen_singles_sf_test ) BOOST_CHECK_EQUAL(get_balance(alice_id, asset_id_type()), 10000000 - 1000000 - 100000); BOOST_CHECK_EQUAL(get_balance(bob_id, asset_id_type()), 10000000 - 1000000 - 100000 + 2000000 - bob_rake_value); - update_betting_market_group(moneyline_cilic_vs_querrey.id, _status = betting_market_group_status::closed); + update_betting_market_group(moneyline_cilic_vs_querrey_id, _status = betting_market_group_status::closed); // cilic wins - resolve_betting_market_group(moneyline_cilic_vs_querrey.id, - {{cilic_wins_market.id, betting_market_resolution_type::win}, - {querrey_wins_market.id, betting_market_resolution_type::not_win}}); + resolve_betting_market_group(moneyline_cilic_vs_querrey_id, + {{cilic_wins_market_id, betting_market_resolution_type::win}, + {querrey_wins_market_id, betting_market_resolution_type::not_win}}); generate_blocks(1); uint32_t alice_rake_value = (-100000 + 200000) * rake_fee_percentage / GRAPHENE_1_PERCENT / 100; @@ -2896,21 +2752,17 @@ BOOST_AUTO_TEST_CASE( wimbledon_2017_gentelmen_singles_final_test ) transfer(account_id_type(), alice_id, asset(10000000)); transfer(account_id_type(), bob_id, asset(10000000)); - BOOST_TEST_MESSAGE("moneyline_cilic_vs_federer " << fc::variant(moneyline_cilic_vs_federer.id, 1).as(1)); + BOOST_TEST_MESSAGE("moneyline_cilic_vs_federer " << fc::variant(moneyline_cilic_vs_federer_id, 1).as(1)); - BOOST_TEST_MESSAGE("federer_wins_final_market " << fc::variant(federer_wins_final_market.id, 1).as(1)); - BOOST_TEST_MESSAGE("cilic_wins_final_market " << fc::variant(cilic_wins_final_market.id, 1).as(1)); + BOOST_TEST_MESSAGE("federer_wins_final_market " << fc::variant(federer_wins_final_market_id, 1).as(1)); + BOOST_TEST_MESSAGE("cilic_wins_final_market " << fc::variant(cilic_wins_final_market_id, 1).as(1)); - betting_market_group_id_type moneyline_cilic_vs_federer_id = moneyline_cilic_vs_federer.id; update_betting_market_group(moneyline_cilic_vs_federer_id, _status = betting_market_group_status::in_play); - place_bet(alice_id, cilic_wins_final_market.id, bet_type::back, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); - place_bet(bob_id, cilic_wins_final_market.id, bet_type::lay, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); - - auto cilic_wins_final_market_id = cilic_wins_final_market.id; - auto federer_wins_final_market_id = federer_wins_final_market.id; + place_bet(alice_id, cilic_wins_final_market_id, bet_type::back, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(bob_id, cilic_wins_final_market_id, bet_type::lay, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); - update_event(cilic_vs_federer.id, _name = internationalized_string_type({{"en", "R. Federer vs. M. Cilic"}})); + update_event(cilic_vs_federer_id, _name = internationalized_string_type({{"en", "R. Federer vs. M. Cilic"}})); generate_blocks(13); diff --git a/tests/common/betting_test_markets.hpp b/tests/common/betting_test_markets.hpp index f67dc0677..94c5b1c80 100644 --- a/tests/common/betting_test_markets.hpp +++ b/tests/common/betting_test_markets.hpp @@ -30,113 +30,115 @@ using namespace graphene::chain; +template object_id to_id(const O& o) { return o.id; } + #define CREATE_ICE_HOCKEY_BETTING_MARKET(never_in_play, delay_before_settling) \ create_sport({{"en", "Ice Hockey"}, {"zh_Hans", "冰球"}, {"ja", "アイスホッケー"}}); \ generate_blocks(1); \ - const sport_object& ice_hockey = *db.get_index_type().indices().get().rbegin(); \ - create_event_group({{"en", "NHL"}, {"zh_Hans", "國家冰球聯盟"}, {"ja", "ナショナルホッケーリーグ"}}, ice_hockey.id); \ + const auto ice_hockey_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_event_group({{"en", "NHL"}, {"zh_Hans", "國家冰球聯盟"}, {"ja", "ナショナルホッケーリーグ"}}, ice_hockey_id); \ generate_blocks(1); \ - const event_group_object& nhl = *db.get_index_type().indices().get().rbegin(); \ - create_event({{"en", "Washington Capitals/Chicago Blackhawks"}, {"zh_Hans", "華盛頓首都隊/芝加哥黑鷹"}, {"ja", "ワシントン・キャピタルズ/シカゴ・ブラックホークス"}}, {{"en", "2016-17"}}, nhl.id); \ + const auto nhl_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_event({{"en", "Washington Capitals/Chicago Blackhawks"}, {"zh_Hans", "華盛頓首都隊/芝加哥黑鷹"}, {"ja", "ワシントン・キャピタルズ/シカゴ・ブラックホークス"}}, {{"en", "2016-17"}}, nhl_id); \ generate_blocks(1); \ - const event_object& capitals_vs_blackhawks = *db.get_index_type().indices().get().rbegin(); \ + const auto capitals_vs_blackhawks_id = to_id(*db.get_index_type().indices().get().rbegin()); \ create_betting_market_rules({{"en", "NHL Rules v1.0"}}, {{"en", "The winner will be the team with the most points at the end of the game. The team with fewer points will not be the winner."}}); \ generate_blocks(1); \ - const betting_market_rules_object& betting_market_rules = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market_group({{"en", "Moneyline"}}, capitals_vs_blackhawks.id, betting_market_rules.id, asset_id_type(), never_in_play, delay_before_settling); \ + const auto betting_market_rules_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market_group({{"en", "Moneyline"}}, capitals_vs_blackhawks_id, betting_market_rules_id, asset_id_type(), never_in_play, delay_before_settling); \ generate_blocks(1); \ - const betting_market_group_object& moneyline_betting_markets = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(moneyline_betting_markets.id, {{"en", "Washington Capitals win"}}); \ + const auto moneyline_betting_markets_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(moneyline_betting_markets_id, {{"en", "Washington Capitals win"}}); \ generate_blocks(1); \ - const betting_market_object& capitals_win_market = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(moneyline_betting_markets.id, {{"en", "Chicago Blackhawks win"}}); \ + const auto capitals_win_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(moneyline_betting_markets_id, {{"en", "Chicago Blackhawks win"}}); \ generate_blocks(1); \ - const betting_market_object& blackhawks_win_market = *db.get_index_type().indices().get().rbegin(); \ - (void)capitals_win_market; (void)blackhawks_win_market; + const auto blackhawks_win_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + (void)capitals_win_market_id; (void)blackhawks_win_market_id; // create the basic betting market, plus groups for the first, second, and third period results #define CREATE_EXTENDED_ICE_HOCKEY_BETTING_MARKET(never_in_play, delay_before_settling) \ CREATE_ICE_HOCKEY_BETTING_MARKET(never_in_play, delay_before_settling) \ - create_betting_market_group({{"en", "First Period Result"}}, capitals_vs_blackhawks.id, betting_market_rules.id, asset_id_type(), never_in_play, delay_before_settling); \ + create_betting_market_group({{"en", "First Period Result"}}, capitals_vs_blackhawks_id, betting_market_rules_id, asset_id_type(), never_in_play, delay_before_settling); \ generate_blocks(1); \ - const betting_market_group_object& first_period_result_betting_markets = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(first_period_result_betting_markets.id, {{"en", "Washington Capitals win"}}); \ + const auto first_period_result_betting_markets_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(first_period_result_betting_markets_id, {{"en", "Washington Capitals win"}}); \ generate_blocks(1); \ - const betting_market_object& first_period_capitals_win_market = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(first_period_result_betting_markets.id, {{"en", "Chicago Blackhawks win"}}); \ + const auto first_period_capitals_win_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(first_period_result_betting_markets_id, {{"en", "Chicago Blackhawks win"}}); \ generate_blocks(1); \ - const betting_market_object& first_period_blackhawks_win_market = *db.get_index_type().indices().get().rbegin(); \ - (void)first_period_capitals_win_market; (void)first_period_blackhawks_win_market; \ + const auto first_period_blackhawks_win_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + (void)first_period_capitals_win_market_id; (void)first_period_blackhawks_win_market_id; \ \ - create_betting_market_group({{"en", "Second Period Result"}}, capitals_vs_blackhawks.id, betting_market_rules.id, asset_id_type(), never_in_play, delay_before_settling); \ + create_betting_market_group({{"en", "Second Period Result"}}, capitals_vs_blackhawks_id, betting_market_rules_id, asset_id_type(), never_in_play, delay_before_settling); \ generate_blocks(1); \ - const betting_market_group_object& second_period_result_betting_markets = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(second_period_result_betting_markets.id, {{"en", "Washington Capitals win"}}); \ + const auto second_period_result_betting_markets_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(second_period_result_betting_markets_id, {{"en", "Washington Capitals win"}}); \ generate_blocks(1); \ - const betting_market_object& second_period_capitals_win_market = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(second_period_result_betting_markets.id, {{"en", "Chicago Blackhawks win"}}); \ + const auto second_period_capitals_win_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(second_period_result_betting_markets_id, {{"en", "Chicago Blackhawks win"}}); \ generate_blocks(1); \ - const betting_market_object& second_period_blackhawks_win_market = *db.get_index_type().indices().get().rbegin(); \ - (void)second_period_capitals_win_market; (void)second_period_blackhawks_win_market; \ + const auto second_period_blackhawks_win_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + (void)second_period_capitals_win_market_id; (void)second_period_blackhawks_win_market_id; \ \ - create_betting_market_group({{"en", "Third Period Result"}}, capitals_vs_blackhawks.id, betting_market_rules.id, asset_id_type(), never_in_play, delay_before_settling); \ + create_betting_market_group({{"en", "Third Period Result"}}, capitals_vs_blackhawks_id, betting_market_rules_id, asset_id_type(), never_in_play, delay_before_settling); \ generate_blocks(1); \ - const betting_market_group_object& third_period_result_betting_markets = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(third_period_result_betting_markets.id, {{"en", "Washington Capitals win"}}); \ + const auto third_period_result_betting_markets_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(third_period_result_betting_markets_id, {{"en", "Washington Capitals win"}}); \ generate_blocks(1); \ - const betting_market_object& third_period_capitals_win_market = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(third_period_result_betting_markets.id, {{"en", "Chicago Blackhawks win"}}); \ + const auto third_period_capitals_win_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(third_period_result_betting_markets_id, {{"en", "Chicago Blackhawks win"}}); \ generate_blocks(1); \ - const betting_market_object& third_period_blackhawks_win_market = *db.get_index_type().indices().get().rbegin(); \ - (void)third_period_capitals_win_market; (void)third_period_blackhawks_win_market; + const auto third_period_blackhawks_win_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + (void)third_period_capitals_win_market_id; (void)third_period_blackhawks_win_market_id; #define CREATE_TENNIS_BETTING_MARKET() \ create_betting_market_rules({{"en", "Tennis Rules v1.0"}}, {{"en", "The winner is the player who wins the last ball in the match."}}); \ generate_blocks(1); \ - const betting_market_rules_object& tennis_rules = *db.get_index_type().indices().get().rbegin(); \ + const auto tennis_rules_id = to_id(*db.get_index_type().indices().get().rbegin()); \ create_sport({{"en", "Tennis"}}); \ generate_blocks(1); \ - const sport_object& tennis = *db.get_index_type().indices().get().rbegin(); \ - create_event_group({{"en", "Wimbledon"}}, tennis.id); \ + const auto tennis_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_event_group({{"en", "Wimbledon"}}, tennis_id); \ generate_blocks(1); \ - const event_group_object& wimbledon = *db.get_index_type().indices().get().rbegin(); \ - create_event({{"en", "R. Federer/T. Berdych"}}, {{"en", "2017"}}, wimbledon.id); \ + const auto wimbledon_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_event({{"en", "R. Federer/T. Berdych"}}, {{"en", "2017"}}, wimbledon_id); \ generate_blocks(1); \ - const event_object& berdych_vs_federer = *db.get_index_type().indices().get().rbegin(); \ - create_event({{"en", "M. Cilic/S. Querrye"}}, {{"en", "2017"}}, wimbledon.id); \ + const auto berdych_vs_federer_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_event({{"en", "M. Cilic/S. Querrye"}}, {{"en", "2017"}}, wimbledon_id); \ generate_blocks(1); \ - const event_object& cilic_vs_querrey = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market_group({{"en", "Moneyline 1st sf"}}, berdych_vs_federer.id, tennis_rules.id, asset_id_type(), false, 0); \ + const auto cilic_vs_querrey_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market_group({{"en", "Moneyline 1st sf"}}, berdych_vs_federer_id, tennis_rules_id, asset_id_type(), false, 0); \ generate_blocks(1); \ - const betting_market_group_object& moneyline_berdych_vs_federer = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market_group({{"en", "Moneyline 2nd sf"}}, cilic_vs_querrey.id, tennis_rules.id, asset_id_type(), false, 0); \ + const auto moneyline_berdych_vs_federer_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market_group({{"en", "Moneyline 2nd sf"}}, cilic_vs_querrey_id, tennis_rules_id, asset_id_type(), false, 0); \ generate_blocks(1); \ - const betting_market_group_object& moneyline_cilic_vs_querrey = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(moneyline_berdych_vs_federer.id, {{"en", "T. Berdych defeats R. Federer"}}); \ + const auto moneyline_cilic_vs_querrey_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(moneyline_berdych_vs_federer_id, {{"en", "T. Berdych defeats R. Federer"}}); \ generate_blocks(1); \ - const betting_market_object& berdych_wins_market = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(moneyline_berdych_vs_federer.id, {{"en", "R. Federer defeats T. Berdych"}}); \ + const auto berdych_wins_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(moneyline_berdych_vs_federer_id, {{"en", "R. Federer defeats T. Berdych"}}); \ generate_blocks(1); \ - const betting_market_object& federer_wins_market = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(moneyline_cilic_vs_querrey.id, {{"en", "M. Cilic defeats S. Querrey"}}); \ + const auto federer_wins_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(moneyline_cilic_vs_querrey_id, {{"en", "M. Cilic defeats S. Querrey"}}); \ generate_blocks(1); \ - const betting_market_object& cilic_wins_market = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(moneyline_cilic_vs_querrey.id, {{"en", "S. Querrey defeats M. Cilic"}});\ + const auto cilic_wins_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(moneyline_cilic_vs_querrey_id, {{"en", "S. Querrey defeats M. Cilic"}});\ generate_blocks(1); \ - const betting_market_object& querrey_wins_market = *db.get_index_type().indices().get().rbegin(); \ - create_event({{"en", "R. Federer/M. Cilic"}}, {{"en", "2017"}}, wimbledon.id); \ + const auto querrey_wins_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_event({{"en", "R. Federer/M. Cilic"}}, {{"en", "2017"}}, wimbledon_id); \ generate_blocks(1); \ - const event_object& cilic_vs_federer = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market_group({{"en", "Moneyline final"}}, cilic_vs_federer.id, tennis_rules.id, asset_id_type(), false, 0); \ + const auto cilic_vs_federer_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market_group({{"en", "Moneyline final"}}, cilic_vs_federer_id, tennis_rules_id, asset_id_type(), false, 0); \ generate_blocks(1); \ - const betting_market_group_object& moneyline_cilic_vs_federer = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(moneyline_cilic_vs_federer.id, {{"en", "R. Federer defeats M. Cilic"}}); \ + const auto moneyline_cilic_vs_federer_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(moneyline_cilic_vs_federer_id, {{"en", "R. Federer defeats M. Cilic"}}); \ generate_blocks(1); \ - const betting_market_object& federer_wins_final_market = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(moneyline_cilic_vs_federer.id, {{"en", "M. Cilic defeats R. Federer"}}); \ + const auto federer_wins_final_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(moneyline_cilic_vs_federer_id, {{"en", "M. Cilic defeats R. Federer"}}); \ generate_blocks(1); \ - const betting_market_object& cilic_wins_final_market = *db.get_index_type().indices().get().rbegin(); \ - (void)federer_wins_market;(void)cilic_wins_market;(void)federer_wins_final_market; (void)cilic_wins_final_market; (void)berdych_wins_market; (void)querrey_wins_market; + const auto cilic_wins_final_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + (void)federer_wins_market_id;(void)cilic_wins_market_id;(void)federer_wins_final_market_id; (void)cilic_wins_final_market_id; (void)berdych_wins_market_id; (void)querrey_wins_market_id; // set up a fixture that places a series of two matched bets, we'll use this fixture to verify // the result in all three possible outcomes @@ -149,25 +151,23 @@ struct simple_bet_test_fixture : database_fixture { { ACTORS( (alice)(bob) ); CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0); + capitals_win_betting_market_id = capitals_win_market_id; + blackhawks_win_betting_market_id = blackhawks_win_market_id; // give alice and bob 10k each transfer(account_id_type(), alice_id, asset(10000)); transfer(account_id_type(), bob_id, asset(10000)); // place bets at 10:1 - place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(100, asset_id_type()), 11 * GRAPHENE_BETTING_ODDS_PRECISION); - place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(1000, asset_id_type()), 11 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(100, asset_id_type()), 11 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(bob_id, capitals_win_market_id, bet_type::lay, asset(1000, asset_id_type()), 11 * GRAPHENE_BETTING_ODDS_PRECISION); // reverse positions at 1:1 - place_bet(alice_id, capitals_win_market.id, bet_type::lay, asset(1100, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); - place_bet(bob_id, capitals_win_market.id, bet_type::back, asset(1100, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); - - capitals_win_betting_market_id = capitals_win_market.id; - blackhawks_win_betting_market_id = blackhawks_win_market.id; - moneyline_betting_markets_id = moneyline_betting_markets.id; + place_bet(alice_id, capitals_win_market_id, bet_type::lay, asset(1100, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(bob_id, capitals_win_market_id, bet_type::back, asset(1100, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); // close betting to prepare for the next operation which will be grading or cancel - update_betting_market_group(moneyline_betting_markets.id, graphene::chain::keywords::_status = betting_market_group_status::closed); + update_betting_market_group(moneyline_betting_markets_id, graphene::chain::keywords::_status = betting_market_group_status::closed); generate_blocks(1); } }; diff --git a/tests/common/database_fixture.cpp b/tests/common/database_fixture.cpp index d1c8a2b62..fd009b1d9 100644 --- a/tests/common/database_fixture.cpp +++ b/tests/common/database_fixture.cpp @@ -689,7 +689,7 @@ void database_fixture::issue_uia( account_id_type recipient_id, asset amount ) } void database_fixture::change_fees( - const flat_set< fee_parameters >& new_params, + const fee_parameters::flat_set_type& new_params, uint32_t new_scale /* = 0 */ ) { @@ -1612,6 +1612,7 @@ void database_fixture::resolve_betting_market_group(betting_market_group_id_type betting_market_group_resolve_operation betting_market_group_resolve_op; betting_market_group_resolve_op.betting_market_group_id = betting_market_group_id; betting_market_group_resolve_op.resolutions = resolutions; + wdump((resolutions)(betting_market_group_resolve_op)); process_operation_by_witnesses(betting_market_group_resolve_op); } FC_CAPTURE_AND_RETHROW( (betting_market_group_id)(resolutions) ) } diff --git a/tests/common/database_fixture.hpp b/tests/common/database_fixture.hpp index 366e707ec..cab5a954e 100644 --- a/tests/common/database_fixture.hpp +++ b/tests/common/database_fixture.hpp @@ -23,11 +23,21 @@ */ #pragma once -#include -#include #include +#include +#include + +#include +#include #include +#include +#include +#include + +#include +#include +#include #include @@ -287,7 +297,7 @@ struct database_fixture { void transfer( const account_object& from, const account_object& to, const asset& amount, const asset& fee = asset() ); void fund_fee_pool( const account_object& from, const asset_object& asset_to_fund, const share_type amount ); void enable_fees(); - void change_fees( const flat_set< fee_parameters >& new_params, uint32_t new_scale = 0 ); + void change_fees( const fee_parameters::flat_set_type& new_params, uint32_t new_scale = 0 ); void upgrade_to_lifetime_member( account_id_type account ); void upgrade_to_lifetime_member( const account_object& account ); void upgrade_to_annual_member( account_id_type account ); diff --git a/tests/generate_empty_blocks/main.cpp b/tests/generate_empty_blocks/main.cpp index 298b03cd6..b3da426db 100644 --- a/tests/generate_empty_blocks/main.cpp +++ b/tests/generate_empty_blocks/main.cpp @@ -32,7 +32,7 @@ #include #include -#include +#include #include #include @@ -132,14 +132,14 @@ int main( int argc, char** argv ) signed_block b = db.generate_block(db.get_slot_time(slot), db.get_scheduled_witness(slot), nathan_priv_key, database::skip_nothing); FC_ASSERT( db.head_block_id() == b.id() ); fc::sha256 h = b.digest(); - uint64_t rand = h._hash[0]; + uint64_t rand = h._hash[0].value(); slot = 1; while(true) { if( (rand % 100) < miss_rate ) { slot++; - rand = (rand/100) ^ h._hash[slot&3]; + rand = (rand/100) ^ h._hash[slot&3].value(); missed++; } else diff --git a/tests/intense/block_tests.cpp b/tests/intense/block_tests.cpp index 7004f13f0..25134fce0 100644 --- a/tests/intense/block_tests.cpp +++ b/tests/intense/block_tests.cpp @@ -28,7 +28,7 @@ #include #include -#include +#include #include #include #include diff --git a/tests/peerplays_sidechain/bitcoin_sign_tests.cpp b/tests/peerplays_sidechain/bitcoin_sign_tests.cpp index 82a121c90..87244fd53 100644 --- a/tests/peerplays_sidechain/bitcoin_sign_tests.cpp +++ b/tests/peerplays_sidechain/bitcoin_sign_tests.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -192,7 +193,8 @@ BOOST_AUTO_TEST_CASE(weighted_multisig_spend_test) { int32_t hash_type = 1; // implement SIGHASH_ALL scheme for (auto &key : priv_keys) { - bytes key_data(key.get_secret().data(), key.get_secret().data() + key.get_secret().data_size()); + auto secret = key.get_secret(); + bytes key_data(secret.data(), secret.data() + secret.data_size()); std::vector sigs = sign_witness_transaction_part(tx, {redeem_script}, {amount}, key_data, btc_context(), hash_type); // insert signatures in reverse order tx.vin[0].scriptWitness.insert(tx.vin[0].scriptWitness.begin(), sigs[0]); @@ -334,7 +336,8 @@ BOOST_AUTO_TEST_CASE(user_sig_one_or_weighted_multisig_spend_test) { uint64_t amount = 10000; int32_t hash_type = 1; // implement SIGHASH_ALL scheme - bytes key_data(user_key.get_secret().data(), user_key.get_secret().data() + user_key.get_secret().data_size()); + auto secret = user_key.get_secret(); + bytes key_data(secret.data(), secret.data() + secret.data_size()); std::vector sigs = sign_witness_transaction_part(tx, {redeem_script}, {amount}, key_data, btc_context(), hash_type); tx.vin[0].scriptWitness.push_back(sigs[0]); sign_witness_transaction_finalize(tx, {redeem_script}, false); @@ -368,7 +371,8 @@ BOOST_AUTO_TEST_CASE(user_sig_one_or_weighted_multisig_spend_test) { int32_t hash_type = 1; // implement SIGHASH_ALL scheme for (auto &key : priv_keys) { - bytes key_data(key.get_secret().data(), key.get_secret().data() + key.get_secret().data_size()); + auto secret = key.get_secret(); + bytes key_data(secret.data(), secret.data() + secret.data_size()); std::vector sigs = sign_witness_transaction_part(tx, {redeem_script}, {amount}, key_data, btc_context(), hash_type); // insert signatures in reverse order tx.vin[0].scriptWitness.insert(tx.vin[0].scriptWitness.begin(), sigs[0]); @@ -434,7 +438,8 @@ BOOST_AUTO_TEST_CASE(user_sig_timelocked_one_or_weighted_multisig_spend_test) { uint64_t amount = 10000; int32_t hash_type = 1; // implement SIGHASH_ALL scheme - bytes key_data(user_key.get_secret().data(), user_key.get_secret().data() + user_key.get_secret().data_size()); + auto secret = user_key.get_secret(); + bytes key_data(secret.data(), secret.data() + secret.data_size()); std::vector sigs = sign_witness_transaction_part(tx, {redeem_script}, {amount}, key_data, btc_context(), hash_type); tx.vin[0].scriptWitness.push_back(sigs[0]); sign_witness_transaction_finalize(tx, {redeem_script}, false); diff --git a/tests/performance/performance_tests.cpp b/tests/performance/performance_tests.cpp index e7d0c98b1..708248183 100644 --- a/tests/performance/performance_tests.cpp +++ b/tests/performance/performance_tests.cpp @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include diff --git a/tests/tests/account_role_tests.cpp b/tests/tests/account_role_tests.cpp index 73824678a..5688f1c4f 100644 --- a/tests/tests/account_role_tests.cpp +++ b/tests/tests/account_role_tests.cpp @@ -1,9 +1,7 @@ #include #include -#include #include #include -#include #include #include @@ -16,6 +14,9 @@ #include #include +#include +#include + #include #include @@ -376,4 +377,4 @@ BOOST_AUTO_TEST_CASE(nft_offer_bid_account_role_test) FC_LOG_AND_RETHROW() } -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END() diff --git a/tests/tests/affiliate_tests.cpp b/tests/tests/affiliate_tests.cpp index 804d9e8a8..ad34b3842 100644 --- a/tests/tests/affiliate_tests.cpp +++ b/tests/tests/affiliate_tests.cpp @@ -524,17 +524,17 @@ BOOST_AUTO_TEST_CASE( bookie_payout_test ) CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0); // place bets at 10:1 - place_bet(ath.paula_id, capitals_win_market.id, bet_type::back, asset(10000, asset_id_type()), 11 * GRAPHENE_BETTING_ODDS_PRECISION); - place_bet(ath.penny_id, capitals_win_market.id, bet_type::lay, asset(100000, asset_id_type()), 11 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(ath.paula_id, capitals_win_market_id, bet_type::back, asset(10000, asset_id_type()), 11 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(ath.penny_id, capitals_win_market_id, bet_type::lay, asset(100000, asset_id_type()), 11 * GRAPHENE_BETTING_ODDS_PRECISION); // reverse positions at 1:1 - place_bet(ath.paula_id, capitals_win_market.id, bet_type::lay, asset(110000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); - place_bet(ath.penny_id, capitals_win_market.id, bet_type::back, asset(110000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(ath.paula_id, capitals_win_market_id, bet_type::lay, asset(110000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(ath.penny_id, capitals_win_market_id, bet_type::back, asset(110000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); - update_betting_market_group(moneyline_betting_markets.id, graphene::chain::keywords::_status = betting_market_group_status::closed); - resolve_betting_market_group(moneyline_betting_markets.id, - {{capitals_win_market.id, betting_market_resolution_type::win}, - {blackhawks_win_market.id, betting_market_resolution_type::not_win}}); + update_betting_market_group(moneyline_betting_markets_id, graphene::chain::keywords::_status = betting_market_group_status::closed); + resolve_betting_market_group(moneyline_betting_markets_id, + {{capitals_win_market_id, betting_market_resolution_type::win}, + {blackhawks_win_market_id, betting_market_resolution_type::not_win}}); generate_block(); uint16_t rake_fee_percentage = db.get_global_properties().parameters.betting_rake_fee_percentage(); @@ -559,10 +559,10 @@ BOOST_AUTO_TEST_CASE( bookie_payout_test ) issue_uia( ath.paula_id, asset( 1000000, btc_id ) ); issue_uia( ath.petra_id, asset( 1000000, btc_id ) ); - create_event({{"en", "Washington Capitals/Chicago Blackhawks"}, {"zh_Hans", "華盛頓首都隊/芝加哥黑鷹"}, {"ja", "ワシントン・キャピタルズ/シカゴ・ブラックホークス"}}, {{"en", "2016-17"}}, nhl.id); \ + create_event({{"en", "Washington Capitals/Chicago Blackhawks"}, {"zh_Hans", "華盛頓首都隊/芝加哥黑鷹"}, {"ja", "ワシントン・キャピタルズ/シカゴ・ブラックホークス"}}, {{"en", "2016-17"}}, nhl_id); \ generate_blocks(1); \ const event_object& capitals_vs_blackhawks2 = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market_group({{"en", "Moneyline"}}, capitals_vs_blackhawks2.id, betting_market_rules.id, btc_id, false, 0); + create_betting_market_group({{"en", "Moneyline"}}, capitals_vs_blackhawks2.id, betting_market_rules_id, btc_id, false, 0); generate_blocks(1); const betting_market_group_object& moneyline_betting_markets2 = *db.get_index_type().indices().get().rbegin(); create_betting_market(moneyline_betting_markets2.id, {{"en", "Washington Capitals win"}}); diff --git a/tests/tests/authority_tests.cpp b/tests/tests/authority_tests.cpp index 387036df2..f298d7589 100644 --- a/tests/tests/authority_tests.cpp +++ b/tests/tests/authority_tests.cpp @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include diff --git a/tests/tests/basic_tests.cpp b/tests/tests/basic_tests.cpp index da6085415..cb214ed84 100644 --- a/tests/tests/basic_tests.cpp +++ b/tests/tests/basic_tests.cpp @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include diff --git a/tests/tests/block_tests.cpp b/tests/tests/block_tests.cpp index 9885b5483..1ad92ee5b 100644 --- a/tests/tests/block_tests.cpp +++ b/tests/tests/block_tests.cpp @@ -1031,9 +1031,9 @@ BOOST_FIXTURE_TEST_CASE( rsf_missed_blocks, database_fixture ) { generate_block(); - auto rsf = [&]() -> string + auto rsf = [this]() -> string { - fc::uint128 rsf; + fc::uint128_t rsf; if (db.get_global_properties().parameters.witness_schedule_algorithm == GRAPHENE_WITNESS_SCHEDULED_ALGORITHM) rsf = db.get(witness_schedule_id_type()).recent_slots_filled; else @@ -1042,7 +1042,7 @@ BOOST_FIXTURE_TEST_CASE( rsf_missed_blocks, database_fixture ) result.reserve(128); for( int i=0; i<128; i++ ) { - result += ((rsf.lo & 1) == 0) ? '0' : '1'; + result += rsf & 1 ? '1' : '0'; rsf >>= 1; } return result; diff --git a/tests/tests/confidential_tests.cpp b/tests/tests/confidential_tests.cpp index a6a19f060..b57f2625f 100644 --- a/tests/tests/confidential_tests.cpp +++ b/tests/tests/confidential_tests.cpp @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include diff --git a/tests/tests/custom_permission_tests.cpp b/tests/tests/custom_permission_tests.cpp index 4aad18979..030ad97f2 100644 --- a/tests/tests/custom_permission_tests.cpp +++ b/tests/tests/custom_permission_tests.cpp @@ -1,7 +1,5 @@ -#include #include #include -#include #include #include @@ -13,7 +11,12 @@ #include +#include + #include + +#include + #include "../common/database_fixture.hpp" using namespace graphene::chain; diff --git a/tests/tests/database_tests.cpp b/tests/tests/database_tests.cpp index 9585d4a1f..443d2dae3 100644 --- a/tests/tests/database_tests.cpp +++ b/tests/tests/database_tests.cpp @@ -89,7 +89,7 @@ BOOST_AUTO_TEST_CASE( flat_index_test ) price_feed current_feed; current_feed.settlement_price = bitusd.amount(100) / asset(100); publish_feed(bitusd, sam, current_feed); - FC_ASSERT( bitusd.bitasset_data_id->instance == 0 ); + FC_ASSERT( bitusd.bitasset_data_id->instance.value == 0 ); FC_ASSERT( !(*bitusd.bitasset_data_id)(db).current_feed.settlement_price.is_null() ); try { auto ses = db._undo_db.start_undo_session(); diff --git a/tests/tests/fee_tests.cpp b/tests/tests/fee_tests.cpp index 74ae896cb..17607f6fc 100644 --- a/tests/tests/fee_tests.cpp +++ b/tests/tests/fee_tests.cpp @@ -34,6 +34,8 @@ #include #include +#include + #include #include "../common/database_fixture.hpp" @@ -244,7 +246,7 @@ uint64_t pct( uint64_t percentage, uint64_t val ) fc::uint128_t x = percentage; x *= val; x /= GRAPHENE_100_PERCENT; - return x.to_uint64(); + return static_cast(x); } uint64_t pct( uint64_t percentage0, uint64_t percentage1, uint64_t val ) @@ -1005,7 +1007,7 @@ BOOST_AUTO_TEST_CASE( issue_429_test ) const auto& fees = *db.get_global_properties().parameters.current_fees; auto fees_to_pay = fees.get(); - + { signed_transaction tx; asset_create_operation op; diff --git a/tests/tests/network_broadcast_api_tests.cpp b/tests/tests/network_broadcast_api_tests.cpp index 4c3e7ed49..1b235c950 100644 --- a/tests/tests/network_broadcast_api_tests.cpp +++ b/tests/tests/network_broadcast_api_tests.cpp @@ -5,10 +5,11 @@ #include #include #include -#include +#include #include #include -#include +#include +#include #include #include diff --git a/tests/tests/serialization_tests.cpp b/tests/tests/serialization_tests.cpp index 59e16f01e..91085af45 100644 --- a/tests/tests/serialization_tests.cpp +++ b/tests/tests/serialization_tests.cpp @@ -86,42 +86,6 @@ BOOST_AUTO_TEST_CASE( json_tests ) } } -BOOST_AUTO_TEST_CASE( extended_private_key_type_test ) -{ - try - { - fc::ecc::extended_private_key key = fc::ecc::extended_private_key( fc::ecc::private_key::generate(), - fc::sha256(), - 0, 0, 0 ); - extended_private_key_type type = extended_private_key_type( key ); - std::string packed = std::string( type ); - extended_private_key_type unpacked = extended_private_key_type( packed ); - BOOST_CHECK( type == unpacked ); - } catch ( const fc::exception& e ) - { - edump((e.to_detail_string())); - throw; - } -} - -BOOST_AUTO_TEST_CASE( extended_public_key_type_test ) -{ - try - { - fc::ecc::extended_public_key key = fc::ecc::extended_public_key( fc::ecc::private_key::generate().get_public_key(), - fc::sha256(), - 0, 0, 0 ); - extended_public_key_type type = extended_public_key_type( key ); - std::string packed = std::string( type ); - extended_public_key_type unpacked = extended_public_key_type( packed ); - BOOST_CHECK( type == unpacked ); - } catch ( const fc::exception& e ) - { - edump((e.to_detail_string())); - throw; - } -} - BOOST_AUTO_TEST_CASE( extension_serialization_test ) { try diff --git a/tests/tests/sidechain_addresses_test.cpp b/tests/tests/sidechain_addresses_test.cpp index 755ad37f9..99d28d4ba 100644 --- a/tests/tests/sidechain_addresses_test.cpp +++ b/tests/tests/sidechain_addresses_test.cpp @@ -5,7 +5,8 @@ #include #include #include -#include + +#include using namespace graphene::chain; using namespace graphene::chain::test; diff --git a/tests/tests/son_wallet_tests.cpp b/tests/tests/son_wallet_tests.cpp index cef29b546..dcde84c84 100644 --- a/tests/tests/son_wallet_tests.cpp +++ b/tests/tests/son_wallet_tests.cpp @@ -4,7 +4,8 @@ #include #include -#include + +#include using namespace graphene; using namespace graphene::chain; diff --git a/tests/tournament/tournament_tests.cpp b/tests/tournament/tournament_tests.cpp index 8aa884791..1c5f51f7c 100644 --- a/tests/tournament/tournament_tests.cpp +++ b/tests/tournament/tournament_tests.cpp @@ -273,7 +273,6 @@ BOOST_FIXTURE_TEST_CASE( whitelist_must_not_be_longer_than, database_fixture ) BOOST_CHECK(nathan.is_lifetime_member()); asset buy_in = asset(10000); - db.get_global_properties().parameters.maximum_tournament_whitelist_length; flat_set whitelist; for(uint16_t i = 0; i < db.get_global_properties().parameters.maximum_tournament_whitelist_length+1; ++i) { @@ -1611,7 +1610,7 @@ BOOST_FIXTURE_TEST_CASE( simple, database_fixture ) const account_object winner = winner_id(db); BOOST_TEST_MESSAGE( "The winner is " + winner.name ); - share_type rake_amount = (fc::uint128_t(tournament.prize_pool.value) * rake_fee_percentage / GRAPHENE_1_PERCENT / 100).to_uint64(); + share_type rake_amount = (fc::uint128_t(tournament.prize_pool.value) * rake_fee_percentage / GRAPHENE_1_PERCENT / 100); optional dividend_account = tournament_helper.get_asset_dividend_account(tournament.options.buy_in.asset_id); if (dividend_account.valid()) players_balances[*dividend_account][tournament.options.buy_in.asset_id] += rake_amount; @@ -1728,7 +1727,7 @@ BOOST_FIXTURE_TEST_CASE( ties, database_fixture ) assert(final_match.match_winners.size() == 1); const account_id_type& winner_id = *final_match.match_winners.begin(); BOOST_TEST_MESSAGE( "The winner of " + std::string(object_id_type(tournament_id)) + " is " + winner_id(db).name + " " + std::string(object_id_type(winner_id))); - share_type rake_amount = (fc::uint128_t(tournament.prize_pool.value) * rake_fee_percentage / GRAPHENE_1_PERCENT / 100).to_uint64(); + share_type rake_amount = (fc::uint128_t(tournament.prize_pool.value) * rake_fee_percentage / GRAPHENE_1_PERCENT / 100); optional dividend_account = tournament_helper.get_asset_dividend_account(tournament.options.buy_in.asset_id); if (dividend_account.valid()) players_balances[*dividend_account][tournament.options.buy_in.asset_id] += rake_amount; players_balances[winner_id][tournament.options.buy_in.asset_id] += tournament.prize_pool - rake_amount; @@ -1940,7 +1939,7 @@ BOOST_FIXTURE_TEST_CASE( assets, database_fixture ) assert(final_match.match_winners.size() == 1); const account_id_type& winner_id = *final_match.match_winners.begin(); BOOST_TEST_MESSAGE( "The winner of " + std::string(object_id_type(tournament_id)) + " is " + winner_id(db).name + " " + std::string(object_id_type(winner_id))); - share_type rake_amount = (fc::uint128_t(tournament.prize_pool.value) * rake_fee_percentage / GRAPHENE_1_PERCENT / 100).to_uint64(); + share_type rake_amount = (fc::uint128_t(tournament.prize_pool.value) * rake_fee_percentage / GRAPHENE_1_PERCENT / 100); optional dividend_account = tournament_helper.get_asset_dividend_account(tournament.options.buy_in.asset_id); if (dividend_account.valid()) players_balances[*dividend_account][tournament.options.buy_in.asset_id] += rake_amount; players_balances[winner_id][tournament.options.buy_in.asset_id] += tournament.prize_pool - rake_amount; @@ -2076,7 +2075,7 @@ BOOST_FIXTURE_TEST_CASE( basic, database_fixture ) assert(final_match.match_winners.size() == 1); const account_id_type& winner_id = *final_match.match_winners.begin(); BOOST_TEST_MESSAGE( "The winner of " + std::string(object_id_type(tournament_id)) + " is " + winner_id(db).name + " " + std::string(object_id_type(winner_id))); - share_type rake_amount = (fc::uint128_t(tournament.prize_pool.value) * rake_fee_percentage / GRAPHENE_1_PERCENT / 100).to_uint64(); + share_type rake_amount = (fc::uint128_t(tournament.prize_pool.value) * rake_fee_percentage / GRAPHENE_1_PERCENT / 100); optional dividend_account = tournament_helper.get_asset_dividend_account(tournament.options.buy_in.asset_id); if (dividend_account.valid()) players_initial_balances[*dividend_account][tournament.options.buy_in.asset_id] += rake_amount; @@ -2214,7 +2213,7 @@ BOOST_FIXTURE_TEST_CASE( massive, database_fixture ) assert(final_match.match_winners.size() == 1); const account_id_type& winner_id = *final_match.match_winners.begin(); BOOST_TEST_MESSAGE( "The winner of " + std::string(object_id_type(tournament_id)) + " is " + winner_id(db).name + " " + std::string(object_id_type(winner_id))); - share_type rake_amount = (fc::uint128_t(tournament.prize_pool.value) * rake_fee_percentage / GRAPHENE_1_PERCENT / 100).to_uint64(); + share_type rake_amount = (fc::uint128_t(tournament.prize_pool.value) * rake_fee_percentage / GRAPHENE_1_PERCENT / 100); optional dividend_account = tournament_helper.get_asset_dividend_account(tournament.options.buy_in.asset_id); if (dividend_account.valid()) players_balances[*dividend_account][tournament.options.buy_in.asset_id] += rake_amount;