From 47805938d33e1ec71c5c0825ac0e261fc9c3b8c0 Mon Sep 17 00:00:00 2001 From: manikey123 Date: Sun, 24 Mar 2019 01:22:00 -0700 Subject: [PATCH 001/133] Added the fix to make top 4 apis configurable --- libraries/app/application.cpp | 31 +++++++-- libraries/app/database_api.cpp | 15 +++-- .../app/include/graphene/app/application.hpp | 4 ++ tests/common/database_fixture.cpp | 25 ++++++- tests/tests/database_api_tests.cpp | 65 +++++++++++++++++++ 5 files changed, 129 insertions(+), 11 deletions(-) diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index cc3941b50a..ff027c3931 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -337,9 +337,22 @@ void application_impl::set_api_limit() { if(_options->count("api-limit-get-asset-holders")){ _app_options.api_limit_get_asset_holders = _options->at("api-limit-get-asset-holders").as(); } - if(_options->count("api-limit-get-key-references")){ - _app_options.api_limit_get_key_references = _options->at("api-limit-get-key-references").as(); - } + if(_options->count("api-limit-get-key-references")){ + _app_options.api_limit_get_key_references = _options->at("api-limit-get-key-references").as(); + } + if(_options->count("api-limit-get-limit-orders")){ + _app_options.api_limit_get_limit_orders = _options->at("api-limit-get-limit-orders").as(); + } + if(_options->count("api-limit-get-call-orders")){ + _app_options.api_limit_get_call_orders = _options->at("api-limit-get-call-orders").as(); + } + if(_options->count("api-limit-get-settle-orders")){ + _app_options.api_limit_get_settle_orders = _options->at("api-limit-get-settle-orders").as(); + } + if(_options->count("api-limit-get-order-book")){ + _app_options.api_limit_get_order_book = _options->at("api-limit-get-order-book").as(); + } + } void application_impl::startup() @@ -1015,8 +1028,16 @@ void application::set_program_options(boost::program_options::options_descriptio "For history_api::get_account_history_by_operations to set its default limit value as 100") ("api-limit-get-asset-holders",boost::program_options::value()->default_value(100), "For asset_api::get_asset_holders to set its default limit value as 100") - ("api-limit-get-key-references",boost::program_options::value()->default_value(100), - "For database_api_impl::get_key_references to set its default limit value as 100") + ("api-limit-get-key-references",boost::program_options::value()->default_value(100), + "For database_api_impl::get_key_references to set its default limit value as 100") + ("api-limit-get-limit-orders",boost::program_options::value()->default_value(300), + "For database_api_impl::get_limit_orders to set its default limit value as 300") + ("api-limit-get-call-orders",boost::program_options::value()->default_value(300), + "For database_api_impl::get_call_orders to set its default limit value as 300") + ("api-limit-get-settle-orders",boost::program_options::value()->default_value(300), + "For database_api_impl::get_settle_orders to set its default limit value as 300") + ("api-limit-get-order-book",boost::program_options::value()->default_value(50), + "For database_api_impl::get_order_book to set its default limit value as 50") ; command_line_options.add(configuration_file_options); command_line_options.add_options() diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 7ced33d48b..3d151bda43 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -260,7 +260,8 @@ class database_api_impl : public std::enable_shared_from_this } vector get_limit_orders(const asset_id_type a, const asset_id_type b, const uint32_t limit)const { - FC_ASSERT( limit <= 300 ); + uint64_t api_limit_get_limit_orders=_app_options->api_limit_get_limit_orders; + FC_ASSERT( limit <= api_limit_get_limit_orders ); const auto& limit_order_idx = _db.get_index_type(); const auto& limit_price_idx = limit_order_idx.indices().get(); @@ -1274,7 +1275,8 @@ vector database_api::get_limit_orders(std::string a, std::st */ vector database_api_impl::get_limit_orders(const std::string& a, const std::string& b, uint32_t limit)const { - FC_ASSERT( limit <= 300 ); + uint64_t api_limit_get_limit_orders=_app_options->api_limit_get_limit_orders; + FC_ASSERT( limit <= api_limit_get_limit_orders ); const asset_id_type asset_a_id = get_asset_from_string(a)->id; const asset_id_type asset_b_id = get_asset_from_string(b)->id; @@ -1289,7 +1291,8 @@ vector database_api::get_call_orders(const std::string& a, ui vector database_api_impl::get_call_orders(const std::string& a, uint32_t limit)const { - FC_ASSERT( limit <= 300 ); + uint64_t api_limit_get_call_orders=_app_options->api_limit_get_call_orders; + FC_ASSERT( limit <= api_limit_get_call_orders ); const asset_id_type asset_a_id = get_asset_from_string(a)->id; const auto& call_index = _db.get_index_type().indices().get(); @@ -1314,7 +1317,8 @@ vector database_api::get_settle_orders(const std::strin vector database_api_impl::get_settle_orders(const std::string& a, uint32_t limit)const { - FC_ASSERT( limit <= 300 ); + uint64_t api_limit_get_settle_orders=_app_options->api_limit_get_settle_orders; + FC_ASSERT( limit <= api_limit_get_settle_orders ); const asset_id_type asset_a_id = get_asset_from_string(a)->id; const auto& settle_index = _db.get_index_type().indices().get(); @@ -1483,7 +1487,8 @@ order_book database_api::get_order_book( const string& base, const string& quote order_book database_api_impl::get_order_book( const string& base, const string& quote, unsigned limit )const { using boost::multiprecision::uint128_t; - FC_ASSERT( limit <= 50 ); + uint64_t api_limit_get_order_book=_app_options->api_limit_get_order_book; + FC_ASSERT( limit <= api_limit_get_order_book ); order_book result; result.base = base; diff --git a/libraries/app/include/graphene/app/application.hpp b/libraries/app/include/graphene/app/application.hpp index 6f1a0d6e90..717666fc90 100644 --- a/libraries/app/include/graphene/app/application.hpp +++ b/libraries/app/include/graphene/app/application.hpp @@ -47,6 +47,10 @@ namespace graphene { namespace app { uint64_t api_limit_get_account_history_by_operations = 100; uint64_t api_limit_get_asset_holders = 100; uint64_t api_limit_get_key_references = 100; + uint64_t api_limit_get_limit_orders = 300; + uint64_t api_limit_get_call_orders = 300; + uint64_t api_limit_get_settle_orders = 300; + uint64_t api_limit_get_order_book = 50; }; class application diff --git a/tests/common/database_fixture.cpp b/tests/common/database_fixture.cpp index 65f7981330..33f4a133ca 100644 --- a/tests/common/database_fixture.cpp +++ b/tests/common/database_fixture.cpp @@ -158,6 +158,27 @@ database_fixture::database_fixture() options.insert(std::make_pair("api-limit-get-key-references", boost::program_options::variable_value((uint64_t)200, false))); options.insert(std::make_pair("plugins", boost::program_options::variable_value(string("account_history"), false))); } + if(current_test_name =="api_limit_get_limit_orders") + { + options.insert(std::make_pair("api-limit-get-limit-orders", boost::program_options::variable_value((uint64_t)350, false))); + options.insert(std::make_pair("plugins", boost::program_options::variable_value(string("account_history"), false))); + } + if(current_test_name =="api_limit_get_call_orders") + { + options.insert(std::make_pair("api-limit-get-call-orders", boost::program_options::variable_value((uint64_t)350, false))); + options.insert(std::make_pair("plugins", boost::program_options::variable_value(string("account_history"), false))); + } + if(current_test_name =="api_limit_get_settle_orders") + { + options.insert(std::make_pair("api-limit-get-settle-orders", boost::program_options::variable_value((uint64_t)350, false))); + options.insert(std::make_pair("plugins", boost::program_options::variable_value(string("account_history"), false))); + } + if(current_test_name =="api_limit_get_order_book") + { + options.insert(std::make_pair("api-limit-get-order-book", boost::program_options::variable_value((uint64_t)80, false))); + options.insert(std::make_pair("plugins", boost::program_options::variable_value(string("account_history"), false))); + } + // add account tracking for ahplugin for special test case with track-account enabled if( !options.count("track-account") && current_test_name == "track_account") { std::vector track_account; @@ -202,7 +223,9 @@ database_fixture::database_fixture() if (current_test_name == "api_limit_get_account_history_operations" || current_test_name == "api_limit_get_account_history" || current_test_name == "api_limit_get_grouped_limit_orders" || current_test_name == "api_limit_get_relative_account_history" || current_test_name == "api_limit_get_account_history_by_operations" || current_test_name =="api_limit_get_asset_holders" - || current_test_name =="api_limit_get_key_references") + || current_test_name =="api_limit_get_key_references" || current_test_name =="api_limit_get_limit_orders" + || current_test_name =="api_limit_get_call_orders" || current_test_name =="api_limit_get_settle_orders" + || current_test_name =="api_limit_get_order_book") { app.initialize(graphene::utilities::temp_directory_path(), options); app.set_api_limit(); diff --git a/tests/tests/database_api_tests.cpp b/tests/tests/database_api_tests.cpp index 1a547b6b67..8fb926fe71 100644 --- a/tests/tests/database_api_tests.cpp +++ b/tests/tests/database_api_tests.cpp @@ -971,4 +971,69 @@ BOOST_AUTO_TEST_CASE( api_limit_get_key_references ){ throw; } } +BOOST_AUTO_TEST_CASE( api_limit_get_limit_orders ){ + try{ + graphene::app::database_api db_api( db, &( app.get_options() )); + //account_id_type() do 3 ops + create_bitasset("USD", account_id_type()); + create_account("dan"); + create_account("bob"); + asset_id_type bit_jmj_id = create_bitasset("JMJBIT").id; + generate_block(); + fc::usleep(fc::milliseconds(2000)); + GRAPHENE_CHECK_THROW(db_api.get_limit_orders(std::string(static_cast(asset_id_type())), std::string(static_cast(bit_jmj_id)), 370), fc::exception); + vector limit_orders =db_api.get_limit_orders(std::string(static_cast(asset_id_type())), std::string(static_cast(bit_jmj_id)), 340); + BOOST_REQUIRE_EQUAL( limit_orders.size(), 0u); + + }catch (fc::exception& e) { + edump((e.to_detail_string())); + throw; + } +} +BOOST_AUTO_TEST_CASE( api_limit_get_call_orders ){ + try{ + graphene::app::database_api db_api( db, &( app.get_options() )); + //account_id_type() do 3 ops + create_bitasset("USD", account_id_type()); + create_account("dan"); + create_account("bob"); + generate_block(); + fc::usleep(fc::milliseconds(2000)); + GRAPHENE_CHECK_THROW(db_api.get_call_orders(std::string(static_cast(asset_id_type())), 370), fc::exception); + }catch (fc::exception& e) { + edump((e.to_detail_string())); + throw; + } +} +BOOST_AUTO_TEST_CASE( api_limit_get_settle_orders ){ + try{ + graphene::app::database_api db_api( db, &( app.get_options() )); + //account_id_type() do 3 ops + create_bitasset("USD", account_id_type()); + create_account("dan"); + create_account("bob"); + generate_block(); + fc::usleep(fc::milliseconds(2000)); + GRAPHENE_CHECK_THROW(db_api.get_settle_orders(std::string(static_cast(asset_id_type())), 370), fc::exception); + }catch (fc::exception& e) { + edump((e.to_detail_string())); + throw; + } +} +BOOST_AUTO_TEST_CASE( api_limit_get_order_book ){ + try{ + graphene::app::database_api db_api( db, &( app.get_options() )); + //account_id_type() do 3 ops + create_bitasset("USD", account_id_type()); + create_account("dan"); + create_account("bob"); + asset_id_type bit_jmj_id = create_bitasset("JMJBIT").id; + generate_block(); + fc::usleep(fc::milliseconds(2000)); + GRAPHENE_CHECK_THROW(db_api.get_order_book(std::string(static_cast(asset_id_type())), std::string(static_cast(bit_jmj_id)),89), fc::exception); + }catch (fc::exception& e) { + edump((e.to_detail_string())); + throw; + } +} BOOST_AUTO_TEST_SUITE_END() From eec1da5bf6eef7215dd477e91578100c8b7f2252 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Sat, 13 Apr 2019 23:38:56 -0500 Subject: [PATCH 002/133] Ref #1506: Isolate chain/protocol to its own library --- .gitignore | 2 + libraries/CMakeLists.txt | 1 + libraries/app/api.cpp | 2 +- libraries/app/application.cpp | 4 +- libraries/app/application_impl.hxx | 2 +- libraries/app/include/graphene/app/api.hpp | 4 +- .../app/include/graphene/app/database_api.hpp | 2 +- .../app/include/graphene/app/full_account.hpp | 2 + libraries/app/include/graphene/app/util.hpp | 4 +- libraries/app/plugin.cpp | 2 +- libraries/chain/CMakeLists.txt | 31 +- libraries/chain/block_database.cpp | 2 +- libraries/chain/buyback.cpp | 2 +- .../chain/committee_member_evaluator.cpp | 6 +- libraries/chain/confidential_evaluator.cpp | 2 +- libraries/chain/db_block.cpp | 3 +- libraries/chain/db_init.cpp | 2 - libraries/chain/db_maint.cpp | 2 + libraries/chain/db_management.cpp | 3 +- libraries/chain/db_notify.cpp | 7 +- libraries/chain/db_update.cpp | 2 +- libraries/chain/evaluator.cpp | 4 +- libraries/chain/genesis_state.cpp | 3 + libraries/chain/get_config.cpp | 2 +- .../include/graphene/chain/account_object.hpp | 9 +- .../graphene/chain/assert_evaluator.hpp | 2 +- .../graphene/chain/asset_evaluator.hpp | 2 +- .../include/graphene/chain/asset_object.hpp | 12 +- .../graphene/chain/balance_evaluator.hpp | 2 +- .../include/graphene/chain/balance_object.hpp | 2 + .../include/graphene/chain/block_database.hpp | 3 +- .../graphene/chain/block_summary_object.hpp | 2 + .../graphene/chain/budget_record_object.hpp | 4 +- .../chain/include/graphene/chain/buyback.hpp | 2 +- .../include/graphene/chain/buyback_object.hpp | 4 +- .../graphene/chain/chain_property_object.hpp | 2 + .../chain/committee_member_object.hpp | 5 +- .../graphene/chain/confidential_evaluator.hpp | 5 +- .../graphene/chain/confidential_object.hpp | 6 +- .../chain/include/graphene/chain/config.hpp | 112 +---- .../graphene/chain/custom_evaluator.hpp | 2 +- .../chain/include/graphene/chain/database.hpp | 12 + .../include/graphene/chain/evaluator.hpp | 7 +- .../include/graphene/chain/exceptions.hpp | 22 +- .../graphene/chain/fba_accumulator_id.hpp | 2 +- .../include/graphene/chain/fba_object.hpp | 4 +- .../include/graphene/chain/fork_database.hpp | 4 +- .../include/graphene/chain/genesis_state.hpp | 4 +- .../graphene/chain/global_property_object.hpp | 7 +- .../include/graphene/chain/htlc_evaluator.hpp | 1 + .../include/graphene/chain/htlc_object.hpp | 9 +- .../chain/include/graphene/chain/impacted.hpp | 6 +- .../graphene/chain/market_evaluator.hpp | 8 +- .../include/graphene/chain/market_object.hpp | 10 +- .../chain/operation_history_object.hpp | 7 +- .../graphene/chain/proposal_evaluator.hpp | 2 +- .../graphene/chain/proposal_object.hpp | 4 +- .../include/graphene/chain/protocol/types.hpp | 458 ------------------ .../graphene/chain/special_authority.hpp | 3 +- .../chain/special_authority_object.hpp | 4 +- .../chain/transaction_evaluation_state.hpp | 8 +- .../graphene/chain/transaction_object.hpp | 5 +- .../graphene/chain/transfer_evaluator.hpp | 2 +- .../chain/include/graphene/chain/types.hpp | 106 ++++ .../graphene/chain/vesting_balance_object.hpp | 5 +- .../include/graphene/chain/vote_count.hpp | 2 +- .../chain/withdraw_permission_object.hpp | 4 +- .../include/graphene/chain/witness_object.hpp | 4 +- .../chain/witness_schedule_object.hpp | 4 +- .../include/graphene/chain/worker_object.hpp | 5 + libraries/chain/market_evaluator.cpp | 2 +- libraries/chain/special_authority.cpp | 22 +- libraries/chain/witness_evaluator.cpp | 4 +- libraries/chain/worker_evaluator.cpp | 6 +- .../db/include/graphene/db/generic_index.hpp | 2 +- .../include/graphene/db/object_database.hpp | 12 +- .../db/include/graphene/db/object_id.hpp | 43 +- libraries/egenesis/egenesis_brief.cpp.tmpl | 2 +- libraries/egenesis/egenesis_full.cpp.tmpl | 2 +- libraries/egenesis/embed_genesis.cpp | 4 +- .../include/graphene/egenesis/egenesis.hpp | 2 +- libraries/fc | 2 +- libraries/net/CMakeLists.txt | 2 +- .../include/graphene/net/core_messages.hpp | 14 +- libraries/net/include/graphene/net/node.hpp | 8 +- libraries/net/node.cpp | 2 +- libraries/net/node_impl.hxx | 4 +- libraries/net/peer_connection.cpp | 2 +- .../account_history_plugin.hpp | 2 +- .../graphene/debug_witness/debug_witness.hpp | 2 +- .../delayed_node/delayed_node_plugin.cpp | 2 +- .../market_history/market_history_plugin.cpp | 2 +- libraries/protocol/CMakeLists.txt | 42 ++ libraries/{chain => }/protocol/account.cpp | 6 +- libraries/{chain => }/protocol/address.cpp | 17 +- libraries/{chain => }/protocol/assert.cpp | 6 +- libraries/{chain => }/protocol/asset.cpp | 6 +- libraries/{chain => }/protocol/asset_ops.cpp | 6 +- libraries/{chain => }/protocol/authority.cpp | 6 +- libraries/{chain => }/protocol/block.cpp | 4 +- .../{chain => }/protocol/chain_parameters.cpp | 6 +- .../{chain => }/protocol/committee_member.cpp | 6 +- .../{chain => }/protocol/confidential.cpp | 9 +- libraries/{chain => }/protocol/custom.cpp | 4 +- .../{chain => }/protocol/fee_schedule.cpp | 6 +- libraries/{chain => }/protocol/htlc.cpp | 4 +- .../include/graphene}/protocol/README.md | 0 .../include/graphene}/protocol/account.hpp | 48 +- .../include/graphene}/protocol/address.hpp | 18 +- .../include/graphene}/protocol/assert.hpp | 18 +- .../include/graphene}/protocol/asset.hpp | 12 +- .../include/graphene}/protocol/asset_ops.hpp | 74 +-- .../include/graphene}/protocol/authority.hpp | 10 +- .../include/graphene}/protocol/balance.hpp | 12 +- .../include/graphene}/protocol/base.hpp | 16 +- .../include/graphene}/protocol/block.hpp | 12 +- .../include/graphene}/protocol/buyback.hpp | 6 +- .../graphene}/protocol/chain_parameters.hpp | 16 +- .../graphene}/protocol/committee_member.hpp | 20 +- .../graphene}/protocol/confidential.hpp | 28 +- .../include/graphene/protocol/config.hpp | 134 +++++ .../include/graphene}/protocol/custom.hpp | 10 +- .../include/graphene/protocol/exceptions.hpp | 48 ++ .../include/graphene}/protocol/ext.hpp | 27 +- .../include/graphene}/protocol/fba.hpp | 10 +- .../graphene}/protocol/fee_schedule.hpp | 10 +- .../include/graphene}/protocol/htlc.hpp | 30 +- .../include/graphene}/protocol/market.hpp | 43 +- .../include/graphene}/protocol/memo.hpp | 10 +- .../include/graphene}/protocol/operations.hpp | 42 +- .../include/graphene}/protocol/proposal.hpp | 18 +- .../graphene/protocol}/pts_address.hpp | 14 +- .../graphene}/protocol/special_authority.hpp | 12 +- .../graphene}/protocol/transaction.hpp | 16 +- .../include/graphene}/protocol/transfer.hpp | 16 +- .../include/graphene/protocol/types.hpp | 324 +++++++++++++ .../include/graphene}/protocol/vesting.hpp | 22 +- .../include/graphene}/protocol/vote.hpp | 18 +- .../protocol/withdraw_permission.hpp | 24 +- .../include/graphene}/protocol/witness.hpp | 14 +- .../include/graphene}/protocol/worker.hpp | 16 +- libraries/{chain => }/protocol/market.cpp | 6 +- libraries/{chain => }/protocol/memo.cpp | 6 +- libraries/{chain => }/protocol/operations.cpp | 6 +- libraries/{chain => }/protocol/proposal.cpp | 8 +- libraries/{chain => protocol}/pts_address.cpp | 16 +- .../special_authority.cpp} | 32 +- .../{chain => }/protocol/transaction.cpp | 26 +- libraries/{chain => }/protocol/transfer.cpp | 6 +- libraries/{chain => }/protocol/types.cpp | 37 +- .../protocol/config.hpp => protocol/vote.cpp} | 21 +- .../protocol/withdraw_permission.cpp | 6 +- libraries/{chain => }/protocol/witness.cpp | 6 +- libraries/{chain => }/protocol/worker.cpp | 4 +- libraries/wallet/wallet.cpp | 23 +- programs/build_helpers/member_enumerator.cpp | 4 +- programs/genesis_util/convert_address.cpp | 6 +- programs/genesis_util/genesis_update.cpp | 2 +- programs/genesis_util/get_dev_key.cpp | 8 +- programs/js_operation_serializer/main.cpp | 15 +- programs/size_checker/main.cpp | 8 +- tests/common/database_fixture.hpp | 10 +- tests/tests/call_order_tests.cpp | 1 + tests/tests/htlc_tests.cpp | 2 +- tests/tests/market_rounding_tests.cpp | 1 + tests/tests/market_tests.cpp | 1 + tests/tests/settle_tests.cpp | 1 + 167 files changed, 1407 insertions(+), 1265 deletions(-) delete mode 100644 libraries/chain/include/graphene/chain/protocol/types.hpp create mode 100644 libraries/chain/include/graphene/chain/types.hpp create mode 100644 libraries/protocol/CMakeLists.txt rename libraries/{chain => }/protocol/account.cpp (98%) rename libraries/{chain => }/protocol/address.cpp (87%) rename libraries/{chain => }/protocol/assert.cpp (93%) rename libraries/{chain => }/protocol/asset.cpp (99%) rename libraries/{chain => }/protocol/asset_ops.cpp (98%) rename libraries/{chain => }/protocol/authority.cpp (92%) rename libraries/{chain => }/protocol/block.cpp (97%) rename libraries/{chain => }/protocol/chain_parameters.cpp (95%) rename libraries/{chain => }/protocol/committee_member.cpp (93%) rename libraries/{chain => }/protocol/confidential.cpp (96%) rename libraries/{chain => }/protocol/custom.cpp (94%) rename libraries/{chain => }/protocol/fee_schedule.cpp (98%) rename libraries/{chain => }/protocol/htlc.cpp (97%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/README.md (100%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/account.hpp (86%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/address.hpp (85%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/assert.hpp (84%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/asset.hpp (96%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/asset_ops.hpp (89%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/authority.hpp (93%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/balance.hpp (88%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/base.hpp (93%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/block.hpp (84%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/buyback.hpp (89%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/chain_parameters.hpp (96%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/committee_member.hpp (85%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/confidential.hpp (92%) create mode 100644 libraries/protocol/include/graphene/protocol/config.hpp rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/custom.hpp (87%) create mode 100644 libraries/protocol/include/graphene/protocol/exceptions.hpp rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/ext.hpp (84%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/fba.hpp (84%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/fee_schedule.hpp (97%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/htlc.hpp (85%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/market.hpp (84%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/memo.hpp (93%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/operations.hpp (82%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/proposal.hpp (92%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene/protocol}/pts_address.hpp (83%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/special_authority.hpp (82%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/transaction.hpp (95%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/transfer.hpp (86%) create mode 100644 libraries/protocol/include/graphene/protocol/types.hpp rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/vesting.hpp (82%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/vote.hpp (88%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/withdraw_permission.hpp (88%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/witness.hpp (84%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/worker.hpp (88%) rename libraries/{chain => }/protocol/market.cpp (95%) rename libraries/{chain => }/protocol/memo.cpp (97%) rename libraries/{chain => }/protocol/operations.cpp (96%) rename libraries/{chain => }/protocol/proposal.cpp (96%) rename libraries/{chain => protocol}/pts_address.cpp (84%) rename libraries/{chain/protocol/vote.cpp => protocol/special_authority.cpp} (65%) rename libraries/{chain => }/protocol/transaction.cpp (94%) rename libraries/{chain => }/protocol/transfer.cpp (94%) rename libraries/{chain => }/protocol/types.cpp (84%) rename libraries/{chain/include/graphene/chain/protocol/config.hpp => protocol/vote.cpp} (74%) rename libraries/{chain => }/protocol/withdraw_permission.cpp (95%) rename libraries/{chain => }/protocol/witness.cpp (93%) rename libraries/{chain => }/protocol/worker.cpp (94%) diff --git a/.gitignore b/.gitignore index 7b1936ffd0..d8f84ca0a8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +build*/ + *.a *.sw* diff --git a/libraries/CMakeLists.txt b/libraries/CMakeLists.txt index 35b768460f..0069bca13e 100644 --- a/libraries/CMakeLists.txt +++ b/libraries/CMakeLists.txt @@ -7,3 +7,4 @@ add_subdirectory( utilities ) add_subdirectory( app ) add_subdirectory( plugins ) add_subdirectory( wallet ) +add_subdirectory( protocol ) diff --git a/libraries/app/api.cpp b/libraries/app/api.cpp index c2631b1293..94701fdeca 100644 --- a/libraries/app/api.cpp +++ b/libraries/app/api.cpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index 8f089c0b0b..0b5175d216 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -28,8 +28,8 @@ #include #include -#include -#include +#include +#include #include diff --git a/libraries/app/application_impl.hxx b/libraries/app/application_impl.hxx index 2c33a46654..175648e10f 100644 --- a/libraries/app/application_impl.hxx +++ b/libraries/app/application_impl.hxx @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include namespace graphene { namespace app { namespace detail { diff --git a/libraries/app/include/graphene/app/api.hpp b/libraries/app/include/graphene/app/api.hpp index 484cde78c5..f477c9dbc8 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 diff --git a/libraries/app/include/graphene/app/database_api.hpp b/libraries/app/include/graphene/app/database_api.hpp index b5ecbf4625..e5a5638e5e 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 139eb5cc1e..990abafc87 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 { diff --git a/libraries/app/include/graphene/app/util.hpp b/libraries/app/include/graphene/app/util.hpp index 520ce6c502..038771015c 100644 --- a/libraries/app/include/graphene/app/util.hpp +++ b/libraries/app/include/graphene/app/util.hpp @@ -27,10 +27,10 @@ #include -#include +#include namespace graphene { namespace app { - using namespace graphene::chain; + using namespace graphene::protocol; typedef boost::multiprecision::uint256_t u256; diff --git a/libraries/app/plugin.cpp b/libraries/app/plugin.cpp index cae488a666..02d1fdb828 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 411f92661f..fb7f586c60 100644 --- a/libraries/chain/CMakeLists.txt +++ b/libraries/chain/CMakeLists.txt @@ -6,7 +6,6 @@ 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") if( GRAPHENE_DISABLE_UNITY_BUILD ) set( GRAPHENE_DB_FILES @@ -36,35 +35,9 @@ add_library( graphene_chain ${GRAPHENE_DB_FILES} fork_database.cpp - protocol/types.cpp - protocol/address.cpp - protocol/authority.cpp - protocol/asset.cpp - protocol/assert.cpp - protocol/account.cpp - protocol/transfer.cpp - protocol/chain_parameters.cpp - protocol/committee_member.cpp - protocol/witness.cpp - protocol/market.cpp - protocol/proposal.cpp - protocol/withdraw_permission.cpp - protocol/asset_ops.cpp - protocol/memo.cpp - protocol/worker.cpp - protocol/custom.cpp - protocol/operations.cpp - protocol/transaction.cpp - protocol/block.cpp - protocol/fee_schedule.cpp - protocol/confidential.cpp - protocol/vote.cpp - protocol/htlc.cpp genesis_state.cpp get_config.cpp - pts_address.cpp - evaluator.cpp balance_evaluator.cpp account_evaluator.cpp @@ -95,12 +68,11 @@ add_library( graphene_chain is_authorized_asset.cpp ${HEADERS} - ${PROTOCOL_HEADERS} "${CMAKE_CURRENT_BINARY_DIR}/include/graphene/chain/hardfork.hpp" ) add_dependencies( graphene_chain build_hardfork_hpp ) -target_link_libraries( graphene_chain fc 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" ) @@ -116,4 +88,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/block_database.cpp b/libraries/chain/block_database.cpp index c5fa6636a8..17c37f2b83 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 7a717544ed..dfe5f09027 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 e81737e161..90620fc010 100644 --- a/libraries/chain/committee_member_evaluator.cpp +++ b/libraries/chain/committee_member_evaluator.cpp @@ -26,8 +26,8 @@ #include #include #include -#include -#include +#include +#include #include namespace graphene { namespace chain { @@ -42,7 +42,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 9946b492d0..4be4d0e14e 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_block.cpp b/libraries/chain/db_block.cpp index 857d8c86d4..b840c2d217 100644 --- a/libraries/chain/db_block.cpp +++ b/libraries/chain/db_block.cpp @@ -33,10 +33,11 @@ #include #include #include -#include #include #include +#include + #include namespace graphene { namespace chain { diff --git a/libraries/chain/db_init.cpp b/libraries/chain/db_init.cpp index 1029947e0c..52741fb9f3 100644 --- a/libraries/chain/db_init.cpp +++ b/libraries/chain/db_init.cpp @@ -64,8 +64,6 @@ #include #include -#include - #include #include diff --git a/libraries/chain/db_maint.cpp b/libraries/chain/db_maint.cpp index 26498826d4..a452a91c88 100644 --- a/libraries/chain/db_maint.cpp +++ b/libraries/chain/db_maint.cpp @@ -26,6 +26,8 @@ #include +#include + #include #include #include diff --git a/libraries/chain/db_management.cpp b/libraries/chain/db_management.cpp index 2f213489f3..3a8f038f52 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_notify.cpp b/libraries/chain/db_notify.cpp index bcf8c6a674..eef3a3fcbe 100644 --- a/libraries/chain/db_notify.cpp +++ b/libraries/chain/db_notify.cpp @@ -1,8 +1,9 @@ #include -#include -#include -#include +#include +#include +#include + #include #include #include diff --git a/libraries/chain/db_update.cpp b/libraries/chain/db_update.cpp index 48dea9fb49..d0d98337c5 100644 --- a/libraries/chain/db_update.cpp +++ b/libraries/chain/db_update.cpp @@ -35,7 +35,7 @@ #include #include -#include +#include #include diff --git a/libraries/chain/evaluator.cpp b/libraries/chain/evaluator.cpp index c70ba5f122..97d2767dc9 100644 --- a/libraries/chain/evaluator.cpp +++ b/libraries/chain/evaluator.cpp @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include @@ -58,7 +58,7 @@ database& generic_evaluator::db()const { return trx_state->db(); } fee_paying_account = &account_id(d); fee_paying_account_statistics = &fee_paying_account->statistics(d); - fee_asset = &fee.asset_id(d); + fee_asset = &asset_id_type(fee.asset_id)(d); fee_asset_dyn_data = &fee_asset->dynamic_asset_data_id(d); FC_ASSERT( is_authorized_asset( d, *fee_paying_account, *fee_asset ), diff --git a/libraries/chain/genesis_state.cpp b/libraries/chain/genesis_state.cpp index aed80c4831..9d067a62c5 100644 --- a/libraries/chain/genesis_state.cpp +++ b/libraries/chain/genesis_state.cpp @@ -24,6 +24,9 @@ #include +// this is required to serialize a genesis_state +#include + namespace graphene { namespace chain { chain_id_type genesis_state_type::compute_chain_id() const diff --git a/libraries/chain/get_config.cpp b/libraries/chain/get_config.cpp index b8fc7a93c7..d1e791fcf0 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 { diff --git a/libraries/chain/include/graphene/chain/account_object.hpp b/libraries/chain/include/graphene/chain/account_object.hpp index cb52552eae..2f3aa611d1 100644 --- a/libraries/chain/include/graphene/chain/account_object.hpp +++ b/libraries/chain/include/graphene/chain/account_object.hpp @@ -22,12 +22,15 @@ * THE SOFTWARE. */ #pragma once -#include +#include #include +#include #include namespace graphene { namespace chain { class database; + class account_object; + class vesting_balance_object; /** * @class account_statistics_object @@ -438,6 +441,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/assert_evaluator.hpp b/libraries/chain/include/graphene/chain/assert_evaluator.hpp index b985a8498c..e4bfdd00ad 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 e2573356b0..544b4b8b21 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 38081dc40f..345cca188b 100644 --- a/libraries/chain/include/graphene/chain/asset_object.hpp +++ b/libraries/chain/include/graphene/chain/asset_object.hpp @@ -22,9 +22,10 @@ * THE SOFTWARE. */ #pragma once -#include +#include #include #include +#include /** * @defgroup prediction_market Prediction Market @@ -38,6 +39,7 @@ namespace graphene { namespace chain { class account_object; + class asset_bitasset_data_object; class database; using namespace graphene::db; @@ -106,13 +108,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); } /// Ticker symbol for this asset, i.e. "USD" string symbol; @@ -312,6 +314,10 @@ 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) + FC_REFLECT_DERIVED( graphene::chain::asset_dynamic_data_object, (graphene::db::object), (current_supply)(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 9458b1734b..ef1491b982 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 8d531d0c5a..ebff56bc56 100644 --- a/libraries/chain/include/graphene/chain/balance_object.hpp +++ b/libraries/chain/include/graphene/chain/balance_object.hpp @@ -71,5 +71,7 @@ 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/block_database.hpp b/libraries/chain/include/graphene/chain/block_database.hpp index ccae46cf04..b5f1146ca5 100644 --- a/libraries/chain/include/graphene/chain/block_database.hpp +++ b/libraries/chain/include/graphene/chain/block_database.hpp @@ -23,10 +23,11 @@ */ #pragma once #include -#include +#include namespace graphene { namespace chain { 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 f002c030bb..04ac7d88ba 100644 --- a/libraries/chain/include/graphene/chain/block_summary_object.hpp +++ b/libraries/chain/include/graphene/chain/block_summary_object.hpp @@ -47,4 +47,6 @@ 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 49544793a6..540abe4d31 100644 --- a/libraries/chain/include/graphene/chain/budget_record_object.hpp +++ b/libraries/chain/include/graphene/chain/budget_record_object.hpp @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #pragma once -#include +#include #include #include @@ -68,6 +68,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 79b4886b76..32bd75340d 100644 --- a/libraries/chain/include/graphene/chain/buyback_object.hpp +++ b/libraries/chain/include/graphene/chain/buyback_object.hpp @@ -23,7 +23,7 @@ */ #pragma once -#include +#include #include #include @@ -64,4 +64,6 @@ 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) ) diff --git a/libraries/chain/include/graphene/chain/chain_property_object.hpp b/libraries/chain/include/graphene/chain/chain_property_object.hpp index 3d2c82a68c..8b4df9389e 100644 --- a/libraries/chain/include/graphene/chain/chain_property_object.hpp +++ b/libraries/chain/include/graphene/chain/chain_property_object.hpp @@ -44,6 +44,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_object.hpp b/libraries/chain/include/graphene/chain/committee_member_object.hpp index 7b0d8e7547..b3fee66178 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; @@ -73,5 +74,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 bc877faf3d..136519c739 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 f98e20a9a7..ac21875a54 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 #include @@ -68,4 +68,6 @@ 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_BLOCKCHAIN_PRECISION uint64_t( 100000 ) - -#define GRAPHENE_BLOCKCHAIN_PRECISION_DIGITS 5 -/** 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_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_MAX_WITNESSES (1001) // SHOULD BE ODD -#define GRAPHENE_DEFAULT_MAX_COMMITTEE (1001) // SHOULD BE ODD -#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_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_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_MAX_NESTED_OBJECTS (200) +#define GRAPHENE_CURRENT_DB_VERSION "20190423" /** * every second, the fraction of burned core asset which cycles is @@ -112,39 +39,6 @@ #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_RECENTLY_MISSED_COUNT_INCREMENT 4 #define GRAPHENE_RECENTLY_MISSED_COUNT_DECREMENT 3 -#define GRAPHENE_CURRENT_DB_VERSION "20190423" - -#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)) -/// 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_MAX_NESTED_OBJECTS (200) diff --git a/libraries/chain/include/graphene/chain/custom_evaluator.hpp b/libraries/chain/include/graphene/chain/custom_evaluator.hpp index 968f6e4857..f9efe76edb 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/database.hpp b/libraries/chain/include/graphene/chain/database.hpp index a470b8a422..395818389b 100644 --- a/libraries/chain/include/graphene/chain/database.hpp +++ b/libraries/chain/include/graphene/chain/database.hpp @@ -22,6 +22,9 @@ * THE SOFTWARE. */ #pragma once + +#include + #include #include #include @@ -45,6 +48,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 collateral_bid_object; + class call_order_object; struct budget_record; enum class vesting_balance_type; diff --git a/libraries/chain/include/graphene/chain/evaluator.hpp b/libraries/chain/include/graphene/chain/evaluator.hpp index 1ae582bd68..8fb356916d 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; - class 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/exceptions.hpp b/libraries/chain/include/graphene/chain/exceptions.hpp index 14931bc196..028d312e56 100644 --- a/libraries/chain/include/graphene/chain/exceptions.hpp +++ b/libraries/chain/include/graphene/chain/exceptions.hpp @@ -24,14 +24,10 @@ #pragma once #include -#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 - +#include +#include +#include +#include #define GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( op_name ) \ FC_DECLARE_DERIVED_EXCEPTION( \ @@ -85,7 +81,6 @@ 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" ) @@ -94,15 +89,6 @@ namespace graphene { namespace chain { 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_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( 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( pop_empty_chain, graphene::chain::undo_database_exception, 3070001, "there are no blocks to pop" ) diff --git a/libraries/chain/include/graphene/chain/fba_accumulator_id.hpp b/libraries/chain/include/graphene/chain/fba_accumulator_id.hpp index 9bc0cf230e..f0eefdbe66 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 aec9e9cd86..9796b4a0dc 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,4 +49,6 @@ 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 363a21f2ce..f5214a8859 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/genesis_state.hpp b/libraries/chain/include/graphene/chain/genesis_state.hpp index df87d1797e..48f2690224 100644 --- a/libraries/chain/include/graphene/chain/genesis_state.hpp +++ b/libraries/chain/include/graphene/chain/genesis_state.hpp @@ -23,8 +23,8 @@ */ #pragma once -#include -#include +#include +#include #include #include diff --git a/libraries/chain/include/graphene/chain/global_property_object.hpp b/libraries/chain/include/graphene/chain/global_property_object.hpp index 2c5a1f1272..9acb406096 100644 --- a/libraries/chain/include/graphene/chain/global_property_object.hpp +++ b/libraries/chain/include/graphene/chain/global_property_object.hpp @@ -24,8 +24,8 @@ #pragma once #include -#include -#include +#include +#include #include #include @@ -124,6 +124,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/htlc_evaluator.hpp b/libraries/chain/include/graphene/chain/htlc_evaluator.hpp index 08a24b2bdc..dfd3c39fad 100644 --- a/libraries/chain/include/graphene/chain/htlc_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/htlc_evaluator.hpp @@ -23,6 +23,7 @@ */ #pragma once #include +#include namespace graphene { namespace chain { diff --git a/libraries/chain/include/graphene/chain/htlc_object.hpp b/libraries/chain/include/graphene/chain/htlc_object.hpp index da853877d3..404dfcfc6d 100644 --- a/libraries/chain/include/graphene/chain/htlc_object.hpp +++ b/libraries/chain/include/graphene/chain/htlc_object.hpp @@ -25,13 +25,14 @@ #include #include -#include -#include -#include +#include +#include +#include #include #include namespace graphene { namespace chain { + using namespace protocol; /** * @brief database object to store HTLCs @@ -119,6 +120,8 @@ namespace graphene { namespace chain { } } // namespace graphene::chain +MAP_OBJECT_ID_TO_TYPE(graphene::chain::htlc_object) + FC_REFLECT( graphene::chain::htlc_object::transfer_info, (from) (to) (amount) (asset_id) ) FC_REFLECT( graphene::chain::htlc_object::condition_info::hash_lock_info, diff --git a/libraries/chain/include/graphene/chain/impacted.hpp b/libraries/chain/include/graphene/chain/impacted.hpp index 2a22cbd123..9d986cb8ab 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/market_evaluator.hpp b/libraries/chain/include/graphene/chain/market_evaluator.hpp index af66323578..60a37e5bd3 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,10 +31,8 @@ namespace graphene { namespace chain { class asset_object; class asset_bitasset_data_object; class call_order_object; - struct bid_collateral_operation; - struct call_order_update_operation; - struct limit_order_cancel_operation; - struct limit_order_create_operation; + class limit_order_object; + class collateral_bid_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 168e2b6439..37cbdc1fd6 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 @@ -68,7 +68,6 @@ class limit_order_object : public abstract_object asset_id_type receive_asset_id()const { return sell_price.quote.asset_id; } }; -struct by_id; struct by_price; struct by_expiration; struct by_account; @@ -272,6 +271,11 @@ typedef generic_index +#include #include #include @@ -99,8 +99,6 @@ namespace graphene { namespace chain { //std::pair account_seq()const { return std::tie( account, sequence ); } }; - struct by_id; - typedef multi_index_container< operation_history_object, indexed_by< @@ -141,6 +139,9 @@ namespace graphene { namespace chain { } } // 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) ) diff --git a/libraries/chain/include/graphene/chain/proposal_evaluator.hpp b/libraries/chain/include/graphene/chain/proposal_evaluator.hpp index 04b5c62d22..e18ddd4226 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 namespace graphene { namespace chain { diff --git a/libraries/chain/include/graphene/chain/proposal_object.hpp b/libraries/chain/include/graphene/chain/proposal_object.hpp index 0d6b5d666d..8908c06b81 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 @@ -104,6 +104,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 35b1c88a14..0000000000 --- a/libraries/chain/include/graphene/chain/protocol/types.hpp +++ /dev/null @@ -1,458 +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 - -// TODO: move this to fc -#include -namespace fc { namespace raw { - template - inline void pack( T& ds, const fc::sha1& ep, uint32_t _max_depth = 1 ) { - ds << ep; - } - - template - inline void unpack( T& ds, sha1& ep, uint32_t _max_depth = 1 ) { - ds >> ep; - } - -} } -// /TODO: move to fc - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - -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::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{}; - - typedef fc::ecc::private_key private_key_type; - typedef fc::sha256 chain_id_type; - - typedef boost::rational< int32_t > ratio_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, - htlc_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_collateral_bid_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 htlc_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, htlc_object_type, htlc_object> htlc_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 collateral_bid_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_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_collateral_bid_object_type, collateral_bid_object > collateral_bid_id_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 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); - }; - - 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 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); - }; - - // Forward-declare fee_schedule to allow typename reflection below - struct fee_schedule; -} } // 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 ); - - // Define typename reflectors for shared_ptr here, so they're available everywhere that needs them - // (Cannot be done in fee_schedule.hpp because chain_parameters.hpp forward declares fee_schedule to make a shared_ptr to one) - 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 ); -} -namespace fc { -} - - -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) - (htlc_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_collateral_bid_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::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::collateral_bid_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::htlc_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/special_authority.hpp b/libraries/chain/include/graphene/chain/special_authority.hpp index f091f73617..931b35a704 100644 --- a/libraries/chain/include/graphene/chain/special_authority.hpp +++ b/libraries/chain/include/graphene/chain/special_authority.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 da9ecc5e0c..b901d657d9 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/transaction_evaluation_state.hpp b/libraries/chain/include/graphene/chain/transaction_evaluation_state.hpp index 1b8fa95780..53c6f3eb87 100644 --- a/libraries/chain/include/graphene/chain/transaction_evaluation_state.hpp +++ b/libraries/chain/include/graphene/chain/transaction_evaluation_state.hpp @@ -22,11 +22,13 @@ * THE SOFTWARE. */ #pragma once -#include +#include -namespace graphene { namespace chain { +namespace graphene { +namespace protocol { class signed_transaction; } +namespace chain { class database; - class 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_object.hpp index 4f76d6bef6..89faa451bd 100644 --- a/libraries/chain/include/graphene/chain/transaction_object.hpp +++ b/libraries/chain/include/graphene/chain/transaction_object.hpp @@ -24,7 +24,7 @@ #pragma once #include -#include +#include #include #include #include @@ -57,7 +57,6 @@ namespace graphene { namespace chain { }; struct by_expiration; - struct by_id; struct by_trx_id; typedef multi_index_container< transaction_object, @@ -71,4 +70,6 @@ namespace graphene { namespace chain { typedef generic_index transaction_index; } } +MAP_OBJECT_ID_TO_TYPE(graphene::chain::transaction_object) + FC_REFLECT_DERIVED( graphene::chain::transaction_object, (graphene::db::object), (trx)(trx_id) ) diff --git a/libraries/chain/include/graphene/chain/transfer_evaluator.hpp b/libraries/chain/include/graphene/chain/transfer_evaluator.hpp index 900ab0741f..6c2bc7ee99 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 0000000000..c84608a282 --- /dev/null +++ b/libraries/chain/include/graphene/chain/types.hpp @@ -0,0 +1,106 @@ +/* + * 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 graphene::protocol; + +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_collateral_bid_object_type +}; + +using global_property_id_type = object_id; +using dynamic_global_property_id_type = object_id; +using asset_dynamic_data_id_type = object_id; +using asset_bitasset_data_id_type = object_id; +using account_balance_id_type = object_id; +using account_statistics_id_type = object_id; +using transaction_obj_id_type = object_id; +using block_summary_id_type = object_id; +using account_transaction_history_id_type = object_id; +using chain_property_id_type = object_id; +using witness_schedule_id_type = object_id; +using budget_record_id_type = object_id; +using blinded_balance_id_type = object_id; +using special_authority_id_type = object_id; +using buyback_id_type = object_id; +using fba_accumulator_id_type = object_id; +using collateral_bid_id_type = object_id; + +} } + +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_collateral_bid_object_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::collateral_bid_id_type) diff --git a/libraries/chain/include/graphene/chain/vesting_balance_object.hpp b/libraries/chain/include/graphene/chain/vesting_balance_object.hpp index ec3ab0c850..6365aca85f 100644 --- a/libraries/chain/include/graphene/chain/vesting_balance_object.hpp +++ b/libraries/chain/include/graphene/chain/vesting_balance_object.hpp @@ -23,7 +23,7 @@ */ #pragma once -#include +#include #include #include #include @@ -39,6 +39,7 @@ namespace graphene { namespace chain { using namespace graphene::db; + using namespace graphene::protocol; class vesting_balance_object; @@ -278,6 +279,8 @@ namespace detail { } } // 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 f76a784d4b..ed8ed130fe 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 f202ee1b66..2fe5a6c967 100644 --- a/libraries/chain/include/graphene/chain/withdraw_permission_object.hpp +++ b/libraries/chain/include/graphene/chain/withdraw_permission_object.hpp @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #pragma once -#include +#include #include #include @@ -113,6 +113,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 4d41a014c9..e0f73338ed 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 b5f1ea8ad7..0de263d1fd 100644 --- a/libraries/chain/include/graphene/chain/witness_schedule_object.hpp +++ b/libraries/chain/include/graphene/chain/witness_schedule_object.hpp @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #pragma once -#include +#include #include #include @@ -41,6 +41,8 @@ class witness_schedule_object : public graphene::db::abstract_object #include +#include +#include namespace graphene { namespace chain { +class database; /** * @defgroup worker_types Implementations of the various worker types in the system @@ -157,6 +160,8 @@ using worker_index = generic_index #include -#include +#include #include diff --git a/libraries/chain/special_authority.cpp b/libraries/chain/special_authority.cpp index ca974f3083..7936af3098 100644 --- a/libraries/chain/special_authority.cpp +++ b/libraries/chain/special_authority.cpp @@ -22,29 +22,11 @@ * THE SOFTWARE. */ -#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; @@ -55,7 +37,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/witness_evaluator.cpp b/libraries/chain/witness_evaluator.cpp index e5853eb8c4..fea334824c 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 { @@ -41,7 +41,7 @@ object_id_type witness_create_evaluator::do_apply( const witness_create_operatio database& _db = db(); 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( [&op,&vote_id]( witness_object& obj ){ diff --git a/libraries/chain/worker_evaluator.cpp b/libraries/chain/worker_evaluator.cpp index 240f9723fa..a0463a738a 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 { @@ -85,8 +85,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/include/graphene/db/generic_index.hpp b/libraries/db/include/graphene/db/generic_index.hpp index fb11d44a37..b19fdf0aa7 100644 --- a/libraries/db/include/graphene/db/generic_index.hpp +++ b/libraries/db/include/graphene/db/generic_index.hpp @@ -28,7 +28,7 @@ #include #include -namespace graphene { namespace chain { +namespace graphene { namespace db { using boost::multi_index_container; using namespace boost::multi_index; diff --git a/libraries/db/include/graphene/db/object_database.hpp b/libraries/db/include/graphene/db/object_database.hpp index b5e85d76a3..73807eebb8 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 typename object_downcast::type* { + return find::type>(id); + } - template - const T& get( object_id id )const { return get(id); } + template + auto get( object_id id )const -> const typename object_downcast::type& { + return get::type>(id); + } template IndexType* add_index() diff --git a/libraries/db/include/graphene/db/object_id.hpp b/libraries/db/include/graphene/db/object_id.hpp index acada38d14..68de0bd2ac 100644 --- a/libraries/db/include/graphene/db/object_id.hpp +++ b/libraries/db/include/graphene/db/object_id.hpp @@ -91,14 +91,23 @@ 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 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) { @@ -115,14 +124,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; } @@ -138,8 +151,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(); @@ -148,10 +161,10 @@ struct get_typename> } }; -template -struct reflector > +template +struct reflector > { - typedef graphene::db::object_id type; + typedef graphene::db::object_id type; typedef fc::true_type is_defined; typedef fc::false_type is_enum; enum member_count_enum { @@ -188,13 +201,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/egenesis/egenesis_brief.cpp.tmpl b/libraries/egenesis/egenesis_brief.cpp.tmpl index d026c599ad..be2ceab386 100644 --- a/libraries/egenesis/egenesis_brief.cpp.tmpl +++ b/libraries/egenesis/egenesis_brief.cpp.tmpl @@ -23,7 +23,7 @@ ${generated_file_banner} * THE SOFTWARE. */ -#include +#include #include namespace graphene { namespace egenesis { diff --git a/libraries/egenesis/egenesis_full.cpp.tmpl b/libraries/egenesis/egenesis_full.cpp.tmpl index d89a694bc5..0aead4c823 100644 --- a/libraries/egenesis/egenesis_full.cpp.tmpl +++ b/libraries/egenesis/egenesis_full.cpp.tmpl @@ -23,7 +23,7 @@ ${generated_file_banner} * THE SOFTWARE. */ -#include +#include #include namespace graphene { namespace egenesis { diff --git a/libraries/egenesis/embed_genesis.cpp b/libraries/egenesis/embed_genesis.cpp index 25af734566..a23a32b80c 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 848a4d29c4..8d5753017d 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 af572ba7d0..6b1fdd513d 160000 --- a/libraries/fc +++ b/libraries/fc @@ -1 +1 @@ -Subproject commit af572ba7d016136883c31daaf054e03e5f3695a1 +Subproject commit 6b1fdd513d6bfa130caea5e9101885fe36ca98c8 diff --git a/libraries/net/CMakeLists.txt b/libraries/net/CMakeLists.txt index 4110098a1f..9778040e32 100644 --- a/libraries/net/CMakeLists.txt +++ b/libraries/net/CMakeLists.txt @@ -10,7 +10,7 @@ set(SOURCES node.cpp add_library( graphene_net ${SOURCES} ${HEADERS} ) target_link_libraries( graphene_net - PUBLIC fc graphene_db ) + PUBLIC fc graphene_db graphene_protocol ) target_include_directories( graphene_net PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" PRIVATE "${CMAKE_SOURCE_DIR}/libraries/chain/include" diff --git a/libraries/net/include/graphene/net/core_messages.hpp b/libraries/net/include/graphene/net/core_messages.hpp index 76f74bd253..1ca737583b 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; @@ -95,9 +95,9 @@ namespace graphene { namespace net { { static const core_message_type_enum type; - graphene::chain::precomputable_transaction trx; + graphene::protocol::precomputable_transaction trx; trx_message() {} - trx_message(graphene::chain::signed_transaction transaction) : + trx_message(graphene::protocol::signed_transaction transaction) : trx(std::move(transaction)) {} }; diff --git a/libraries/net/include/graphene/net/node.hpp b/libraries/net/include/graphene/net/node.hpp index fd111ce879..fe03ac0cb6 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 { @@ -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/node.cpp b/libraries/net/node.cpp index 234cbb1374..a0b58b10f5 100644 --- a/libraries/net/node.cpp +++ b/libraries/net/node.cpp @@ -81,7 +81,7 @@ // Nasty hack: A circular dependency around fee_schedule is resolved by fwd-declaring it and using a shared_ptr // to it in chain_parameters, which is used in an operation and thus must be serialized by the net library. // Resolving that forward declaration doesn't happen until now: -#include +#include #include diff --git a/libraries/net/node_impl.hxx b/libraries/net/node_impl.hxx index d755e250b7..7d31d16eea 100644 --- a/libraries/net/node_impl.hxx +++ b/libraries/net/node_impl.hxx @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include #include @@ -150,7 +150,7 @@ private: uint32_t& remaining_item_count, uint32_t limit = 2000) override; message get_item( const item_id& id ) override; - graphene::chain::chain_id_type get_chain_id() const override; + graphene::protocol::chain_id_type get_chain_id() const override; std::vector get_blockchain_synopsis(const item_hash_t& reference_point, uint32_t number_of_blocks_after_reference_point) override; void sync_status( uint32_t item_type, uint32_t item_count ) override; diff --git a/libraries/net/peer_connection.cpp b/libraries/net/peer_connection.cpp index 23ac403ab0..1b35432af0 100644 --- a/libraries/net/peer_connection.cpp +++ b/libraries/net/peer_connection.cpp @@ -25,7 +25,7 @@ #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 7bec37ddfe..70fbe43697 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 @@ -82,7 +82,7 @@ class account_history_plugin : public graphene::app::plugin } } //graphene::account_history -/*struct by_id; +/* struct by_seq; struct by_op; typedef boost::multi_index_container< 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 22c71236b5..4b5369211a 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 c56f8bb6b3..bd778b68ea 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/market_history/market_history_plugin.cpp b/libraries/plugins/market_history/market_history_plugin.cpp index f6948dc59e..9c01ea2149 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/protocol/CMakeLists.txt b/libraries/protocol/CMakeLists.txt new file mode 100644 index 0000000000..eb91de4b06 --- /dev/null +++ b/libraries/protocol/CMakeLists.txt @@ -0,0 +1,42 @@ +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 + transaction.cpp + types.cpp + withdraw_permission.cpp + worker.cpp + htlc.cpp) + + +add_library( graphene_protocol ${SOURCES} ${HEADERS} ) +target_link_libraries( graphene_protocol graphene_db 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 98% rename from libraries/chain/protocol/account.cpp rename to libraries/protocol/account.cpp index 9d281e4caf..881b5de1e2 100644 --- a/libraries/chain/protocol/account.cpp +++ b/libraries/protocol/account.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 { /** * Names must comply with the following grammar (RFC 1035): @@ -275,4 +275,4 @@ void account_transfer_operation::validate()const } -} } // graphene::chain +} } // graphene::protocol diff --git a/libraries/chain/protocol/address.cpp b/libraries/protocol/address.cpp similarity index 87% rename from libraries/chain/protocol/address.cpp rename to libraries/protocol/address.cpp index 19bb4df569..1662d50ec2 100644 --- a/libraries/chain/protocol/address.cpp +++ b/libraries/protocol/address.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 #include -namespace graphene { - namespace chain { +namespace graphene { namespace protocol { address::address(){} address::address( const std::string& base58str ) @@ -83,7 +82,7 @@ namespace graphene { addr = fc::ripemd160::hash( fc::sha512::hash( pub.data, sizeof( pub ) ) ); } - 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 ) ) ); } @@ -97,16 +96,16 @@ namespace graphene { return GRAPHENE_ADDRESS_PREFIX + fc::to_base58( bin_addr.data, sizeof( bin_addr ) ); } -} } // 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() ); } } diff --git a/libraries/chain/protocol/assert.cpp b/libraries/protocol/assert.cpp similarity index 93% rename from libraries/chain/protocol/assert.cpp rename to libraries/protocol/assert.cpp index 2c15a44563..f652b20a7f 100644 --- a/libraries/chain/protocol/assert.cpp +++ b/libraries/protocol/assert.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 { bool account_name_eq_lit_predicate::validate()const { @@ -63,4 +63,4 @@ share_type assert_operation::calculate_fee(const fee_parameters_type& k)const } -} } // namespace graphene::chain +} } // namespace graphene::protocol diff --git a/libraries/chain/protocol/asset.cpp b/libraries/protocol/asset.cpp similarity index 99% rename from libraries/chain/protocol/asset.cpp rename to libraries/protocol/asset.cpp index a9c1daf502..2800cd2a1e 100644 --- a/libraries/chain/protocol/asset.cpp +++ b/libraries/protocol/asset.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 #include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { typedef boost::multiprecision::uint128_t uint128_t; typedef boost::multiprecision::int128_t int128_t; @@ -314,4 +314,4 @@ const int64_t scaled_precision_lut[19] = p10< 16 >::v, p10< 17 >::v, p10< 18 >::v }; -} } // graphene::chain +} } // graphene::protocol diff --git a/libraries/chain/protocol/asset_ops.cpp b/libraries/protocol/asset_ops.cpp similarity index 98% rename from libraries/chain/protocol/asset_ops.cpp rename to libraries/protocol/asset_ops.cpp index c88eb9bd8a..6a26453b5f 100644 --- a/libraries/chain/protocol/asset_ops.cpp +++ b/libraries/protocol/asset_ops.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 { /** * Valid symbols can contain [A-Z0-9], and '.' @@ -250,4 +250,4 @@ void asset_claim_pool_operation::validate()const { FC_ASSERT( amount_to_claim.asset_id == asset_id_type()); } -} } // namespace graphene::chain +} } // namespace graphene::protocol diff --git a/libraries/chain/protocol/authority.cpp b/libraries/protocol/authority.cpp similarity index 92% rename from libraries/chain/protocol/authority.cpp rename to libraries/protocol/authority.cpp index 97470d3328..a5a3541791 100644 --- a/libraries/chain/protocol/authority.cpp +++ b/libraries/protocol/authority.cpp @@ -22,9 +22,9 @@ * THE SOFTWARE. */ -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { void add_authority_accounts( flat_set& result, @@ -35,4 +35,4 @@ void add_authority_accounts( result.insert( item.first ); } -} } // graphene::chain +} } // graphene::protocol diff --git a/libraries/chain/protocol/block.cpp b/libraries/protocol/block.cpp similarity index 97% rename from libraries/chain/protocol/block.cpp rename to libraries/protocol/block.cpp index 9fdf4707eb..acd1576d6d 100644 --- a/libraries/chain/protocol/block.cpp +++ b/libraries/protocol/block.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 { digest_type block_header::digest()const { return digest_type::hash(*this); diff --git a/libraries/chain/protocol/chain_parameters.cpp b/libraries/protocol/chain_parameters.cpp similarity index 95% rename from libraries/chain/protocol/chain_parameters.cpp rename to libraries/protocol/chain_parameters.cpp index 8e70d624e0..e53d1d9ef5 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 93% rename from libraries/chain/protocol/committee_member.cpp rename to libraries/protocol/committee_member.cpp index 4c8c5d2591..ea1fc98d36 100644 --- a/libraries/chain/protocol/committee_member.cpp +++ b/libraries/protocol/committee_member.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 committee_member_create_operation::validate()const { @@ -44,4 +44,4 @@ void committee_member_update_global_parameters_operation::validate() const new_parameters.validate(); } -} } // graphene::chain +} } // graphene::protocol diff --git a/libraries/chain/protocol/confidential.cpp b/libraries/protocol/confidential.cpp similarity index 96% rename from libraries/chain/protocol/confidential.cpp rename to libraries/protocol/confidential.cpp index 603befa122..0689a3ca14 100644 --- a/libraries/chain/protocol/confidential.cpp +++ b/libraries/protocol/confidential.cpp @@ -21,15 +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 -namespace graphene { namespace chain { +namespace graphene { namespace protocol { void transfer_to_blind_operation::validate()const { @@ -161,4 +160,4 @@ stealth_confirmation::stealth_confirmation( const std::string& base58 ) -} } // graphene::chain +} } // graphene::protocol diff --git a/libraries/chain/protocol/custom.cpp b/libraries/protocol/custom.cpp similarity index 94% rename from libraries/chain/protocol/custom.cpp rename to libraries/protocol/custom.cpp index b69243bee3..c199552c36 100644 --- a/libraries/chain/protocol/custom.cpp +++ b/libraries/protocol/custom.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 custom_operation::validate()const { diff --git a/libraries/chain/protocol/fee_schedule.cpp b/libraries/protocol/fee_schedule.cpp similarity index 98% rename from libraries/chain/protocol/fee_schedule.cpp rename to libraries/protocol/fee_schedule.cpp index 2be3952585..f0acea9782 100644 --- a/libraries/chain/protocol/fee_schedule.cpp +++ b/libraries/protocol/fee_schedule.cpp @@ -22,11 +22,11 @@ * THE SOFTWARE. */ #include -#include +#include #define MAX_FEE_STABILIZATION_ITERATION 4 -namespace graphene { namespace chain { +namespace graphene { namespace protocol { fee_schedule::fee_schedule() { @@ -181,4 +181,4 @@ namespace graphene { namespace chain { "Committee proposal review period must be less than the maximum proposal lifetime" ); } -} } // graphene::chain +} } // graphene::protocol diff --git a/libraries/chain/protocol/htlc.cpp b/libraries/protocol/htlc.cpp similarity index 97% rename from libraries/chain/protocol/htlc.cpp rename to libraries/protocol/htlc.cpp index 645feb6dbf..a8d5eeed8c 100644 --- a/libraries/chain/protocol/htlc.cpp +++ b/libraries/protocol/htlc.cpp @@ -21,11 +21,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include +#include #define SECONDS_PER_DAY (60 * 60 * 24) -namespace graphene { namespace chain { +namespace graphene { namespace protocol { void htlc_create_operation::validate()const { FC_ASSERT( fee.amount >= 0, "Fee amount should not be negative" ); 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 86% rename from libraries/chain/include/graphene/chain/protocol/account.hpp rename to libraries/protocol/include/graphene/protocol/account.hpp index f2be53837b..158a997a57 100644 --- a/libraries/chain/include/graphene/chain/protocol/account.hpp +++ b/libraries/protocol/include/graphene/protocol/account.hpp @@ -22,14 +22,14 @@ * THE SOFTWARE. */ #pragma once -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { bool is_valid_name( const string& s ); bool is_cheap_name( const string& n ); @@ -267,35 +267,35 @@ 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_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(graphene::chain::account_create_operation::ext, (null_ext)(owner_special_authority)(active_special_authority)(buyback_options) ) -FC_REFLECT_TYPENAME(graphene::chain::extension) -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) ) +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) ) -FC_REFLECT_TYPENAME(graphene::chain::extension) -FC_REFLECT( graphene::chain::account_update_operation, +FC_REFLECT(graphene::protocol::account_update_operation::ext, (null_ext)(owner_special_authority)(active_special_authority) ) +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::protocol::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::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::chain::account_transfer_operation, (fee)(account_id)(new_owner)(extensions) ) +FC_REFLECT( graphene::protocol::account_transfer_operation, (fee)(account_id)(new_owner)(extensions) ) diff --git a/libraries/chain/include/graphene/chain/protocol/address.hpp b/libraries/protocol/include/graphene/protocol/address.hpp similarity index 85% rename from libraries/chain/include/graphene/chain/protocol/address.hpp rename to libraries/protocol/include/graphene/protocol/address.hpp index b225b42caf..eb1cd385a9 100644 --- a/libraries/chain/include/graphene/chain/protocol/address.hpp +++ b/libraries/protocol/include/graphene/protocol/address.hpp @@ -23,8 +23,8 @@ */ #pragma once -#include -#include +#include +#include #include #include @@ -34,7 +34,7 @@ namespace fc { namespace ecc { typedef fc::array public_key_data; } } // fc::ecc -namespace graphene { namespace chain { +namespace graphene { namespace protocol { struct public_key_type; @@ -74,21 +74,21 @@ 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 ); + 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 ); } namespace std { template<> - struct hash + struct hash { public: - size_t operator()(const graphene::chain::address &a) const + size_t operator()(const graphene::protocol::address &a) const { return (uint64_t(a.addr._hash[0])<<32) | uint64_t( a.addr._hash[0] ); } @@ -96,4 +96,4 @@ namespace std } #include -FC_REFLECT( graphene::chain::address, (addr) ) +FC_REFLECT( graphene::protocol::address, (addr) ) diff --git a/libraries/chain/include/graphene/chain/protocol/assert.hpp b/libraries/protocol/include/graphene/protocol/assert.hpp similarity index 84% rename from libraries/chain/include/graphene/chain/protocol/assert.hpp rename to libraries/protocol/include/graphene/protocol/assert.hpp index c9f3b2774a..9b2362aac3 100644 --- a/libraries/chain/include/graphene/chain/protocol/assert.hpp +++ b/libraries/protocol/include/graphene/protocol/assert.hpp @@ -22,9 +22,9 @@ * THE SOFTWARE. */ #pragma once -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * Used to verify that account_id->name is equal to the given string literal. @@ -103,12 +103,12 @@ 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) ) diff --git a/libraries/chain/include/graphene/chain/protocol/asset.hpp b/libraries/protocol/include/graphene/protocol/asset.hpp similarity index 96% rename from libraries/chain/include/graphene/chain/protocol/asset.hpp rename to libraries/protocol/include/graphene/protocol/asset.hpp index b354d5ccac..8278692280 100644 --- a/libraries/chain/include/graphene/chain/protocol/asset.hpp +++ b/libraries/protocol/include/graphene/protocol/asset.hpp @@ -22,10 +22,10 @@ * THE SOFTWARE. */ #pragma once -#include -#include +#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { extern const int64_t scaled_precision_lut[]; @@ -221,10 +221,10 @@ 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 ) diff --git a/libraries/chain/include/graphene/chain/protocol/asset_ops.hpp b/libraries/protocol/include/graphene/protocol/asset_ops.hpp similarity index 89% rename from libraries/chain/include/graphene/chain/protocol/asset_ops.hpp rename to libraries/protocol/include/graphene/protocol/asset_ops.hpp index 9c6fca3c9c..9687ffb1a4 100644 --- a/libraries/chain/include/graphene/chain/protocol/asset_ops.hpp +++ b/libraries/protocol/include/graphene/protocol/asset_ops.hpp @@ -22,10 +22,10 @@ * THE SOFTWARE. */ #pragma once -#include -#include +#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { struct additional_asset_options { @@ -511,14 +511,14 @@ namespace graphene { namespace chain { void validate()const; }; -} } // graphene::chain +} } // graphene::protocol -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::chain::asset_claim_pool_operation, (fee)(issuer)(asset_id)(amount_to_claim)(extensions) ) -FC_REFLECT( graphene::chain::asset_claim_pool_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::protocol::asset_claim_pool_operation, (fee)(issuer)(asset_id)(amount_to_claim)(extensions) ) +FC_REFLECT( graphene::protocol::asset_claim_pool_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) @@ -532,7 +532,7 @@ FC_REFLECT( graphene::chain::asset_options, (description) (extensions) ) -FC_REFLECT( graphene::chain::bitasset_options, +FC_REFLECT( graphene::protocol::bitasset_options, (feed_lifetime_sec) (minimum_feeds) (force_settlement_delay_sec) @@ -542,22 +542,22 @@ FC_REFLECT( graphene::chain::bitasset_options, (extensions) ) -FC_REFLECT( graphene::chain::additional_asset_options, (reward_percent)(whitelist_market_fee_sharing) ) -FC_REFLECT( graphene::chain::asset_create_operation::fee_parameters_type, (symbol3)(symbol4)(long_symbol)(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_issuer_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::asset_update_bitasset_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_create_operation, +FC_REFLECT( graphene::protocol::additional_asset_options, (reward_percent)(whitelist_market_fee_sharing) ) +FC_REFLECT( graphene::protocol::asset_create_operation::fee_parameters_type, (symbol3)(symbol4)(long_symbol)(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_issuer_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::asset_update_bitasset_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_create_operation, (fee) (issuer) (symbol) @@ -567,7 +567,7 @@ FC_REFLECT( graphene::chain::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) @@ -575,31 +575,31 @@ FC_REFLECT( graphene::chain::asset_update_operation, (new_options) (extensions) ) -FC_REFLECT( graphene::chain::asset_update_issuer_operation, +FC_REFLECT( graphene::protocol::asset_update_issuer_operation, (fee) (issuer) (asset_to_update) (new_issuer) (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_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::protocol::asset_fund_fee_pool_operation, (fee)(from_account)(asset_id)(amount)(extensions) ); diff --git a/libraries/chain/include/graphene/chain/protocol/authority.hpp b/libraries/protocol/include/graphene/protocol/authority.hpp similarity index 93% rename from libraries/chain/include/graphene/chain/protocol/authority.hpp rename to libraries/protocol/include/graphene/protocol/authority.hpp index 145c24b5c5..fa150b1606 100644 --- a/libraries/chain/include/graphene/chain/protocol/authority.hpp +++ b/libraries/protocol/include/graphene/protocol/authority.hpp @@ -22,9 +22,9 @@ * THE SOFTWARE. */ #pragma once -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * @class authority @@ -129,7 +129,7 @@ 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_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) ) diff --git a/libraries/chain/include/graphene/chain/protocol/balance.hpp b/libraries/protocol/include/graphene/protocol/balance.hpp similarity index 88% rename from libraries/chain/include/graphene/chain/protocol/balance.hpp rename to libraries/protocol/include/graphene/protocol/balance.hpp index f60087a71e..495c5a8d0e 100644 --- a/libraries/chain/include/graphene/chain/protocol/balance.hpp +++ b/libraries/protocol/include/graphene/protocol/balance.hpp @@ -22,12 +22,12 @@ * THE SOFTWARE. */ #pragma once -#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 @@ -52,8 +52,8 @@ 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) ) diff --git a/libraries/chain/include/graphene/chain/protocol/base.hpp b/libraries/protocol/include/graphene/protocol/base.hpp similarity index 93% rename from libraries/chain/include/graphene/chain/protocol/base.hpp rename to libraries/protocol/include/graphene/protocol/base.hpp index 73209a1861..2b55685dee 100644 --- a/libraries/chain/include/graphene/chain/protocol/base.hpp +++ b/libraries/protocol/include/graphene/protocol/base.hpp @@ -23,13 +23,13 @@ */ #pragma once -#include -#include -#include +#include +#include +#include #include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * @defgroup operations Operations @@ -120,8 +120,8 @@ namespace graphene { namespace chain { ///@} -} } // 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/block.hpp b/libraries/protocol/include/graphene/protocol/block.hpp similarity index 84% rename from libraries/chain/include/graphene/chain/protocol/block.hpp rename to libraries/protocol/include/graphene/protocol/block.hpp index aa8c46052f..a178928fd5 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 { class block_header { @@ -65,8 +65,8 @@ namespace graphene { namespace chain { mutable checksum_type _calculated_merkle_root; }; -} } // graphene::chain +} } // graphene::protocol -FC_REFLECT( graphene::chain::block_header, (previous)(timestamp)(witness)(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( graphene::protocol::block_header, (previous)(timestamp)(witness)(transaction_merkle_root)(extensions) ) +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) ) diff --git a/libraries/chain/include/graphene/chain/protocol/buyback.hpp b/libraries/protocol/include/graphene/protocol/buyback.hpp similarity index 89% rename from libraries/chain/include/graphene/chain/protocol/buyback.hpp rename to libraries/protocol/include/graphene/protocol/buyback.hpp index 6adad52d1f..3661cbd41c 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,4 +49,4 @@ 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) ); 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 f0eb522fe5..d19431715f 100644 --- a/libraries/chain/include/graphene/chain/protocol/chain_parameters.hpp +++ b/libraries/protocol/include/graphene/protocol/chain_parameters.hpp @@ -22,11 +22,13 @@ * THE SOFTWARE. */ #pragma once + #include -#include -#include +#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { + struct fee_schedule; struct htlc_options { @@ -90,18 +92,18 @@ namespace graphene { namespace chain { static void safe_copy(chain_parameters& to, const chain_parameters& from); }; -} } // graphene::chain +} } // graphene::protocol -FC_REFLECT( graphene::chain::htlc_options, +FC_REFLECT( graphene::protocol::htlc_options, (max_timeout_secs) (max_preimage_size) ) -FC_REFLECT( graphene::chain::chain_parameters::ext, +FC_REFLECT( graphene::protocol::chain_parameters::ext, (updatable_htlc_options) ) -FC_REFLECT( graphene::chain::chain_parameters, +FC_REFLECT( graphene::protocol::chain_parameters, (current_fees) (block_interval) (maintenance_interval) diff --git a/libraries/chain/include/graphene/chain/protocol/committee_member.hpp b/libraries/protocol/include/graphene/protocol/committee_member.hpp similarity index 85% rename from libraries/chain/include/graphene/chain/protocol/committee_member.hpp rename to libraries/protocol/include/graphene/protocol/committee_member.hpp index 7718836723..71bcf2ff80 100644 --- a/libraries/chain/include/graphene/chain/protocol/committee_member.hpp +++ b/libraries/protocol/include/graphene/protocol/committee_member.hpp @@ -22,10 +22,10 @@ * THE SOFTWARE. */ #pragma once -#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,14 +93,14 @@ 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) ); diff --git a/libraries/chain/include/graphene/chain/protocol/confidential.hpp b/libraries/protocol/include/graphene/protocol/confidential.hpp similarity index 92% rename from libraries/chain/include/graphene/chain/protocol/confidential.hpp rename to libraries/protocol/include/graphene/protocol/confidential.hpp index 763006ae68..ba3f4077ca 100644 --- a/libraries/chain/include/graphene/chain/protocol/confidential.hpp +++ b/libraries/protocol/include/graphene/protocol/confidential.hpp @@ -23,9 +23,9 @@ */ #pragma once -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { using fc::ecc::blind_factor_type; @@ -258,26 +258,26 @@ 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) ) diff --git a/libraries/protocol/include/graphene/protocol/config.hpp b/libraries/protocol/include/graphene/protocol/config.hpp new file mode 100644 index 0000000000..6f1f6da431 --- /dev/null +++ b/libraries/protocol/include/graphene/protocol/config.hpp @@ -0,0 +1,134 @@ +/* + * 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 "BTS" +#define GRAPHENE_ADDRESS_PREFIX "BTS" + +#define GRAPHENE_BLOCKCHAIN_PRECISION uint64_t( 100000 ) +#define GRAPHENE_BLOCKCHAIN_PRECISION_DIGITS 5 + +#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_WORKER_NAME_LENGTH 63 +#define GRAPHENE_MAX_URL_LENGTH 127 + +#define GRAPHENE_MAX_SIG_CHECK_DEPTH 2 + +#define GRAPHENE_IRREVERSIBLE_THRESHOLD (70 * GRAPHENE_1_PERCENT) + +/** + * 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 5 /* seconds */ +#define GRAPHENE_DEFAULT_MAX_TRANSACTION_SIZE 2048 +#define GRAPHENE_DEFAULT_MAX_BLOCK_SIZE (2*1000*1000) /* < 2 MiB (less than MAX_MESSAGE_SIZE in graphene/net/config.hpp) */ +#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_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_DEFAULT_MAX_AUTHORITY_MEMBERSHIP 10 +#define GRAPHENE_DEFAULT_MAX_ASSET_WHITELIST_AUTHORITIES 10 +#define GRAPHENE_DEFAULT_MAX_ASSET_FEED_PUBLISHERS 10 + +#define GRAPHENE_DEFAULT_MIN_WITNESS_COUNT (11) +#define GRAPHENE_DEFAULT_MIN_COMMITTEE_MEMBER_COUNT (11) +#define GRAPHENE_DEFAULT_MAX_WITNESSES (1001) // SHOULD BE ODD +#define GRAPHENE_DEFAULT_MAX_COMMITTEE (1001) // SHOULD BE ODD +#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_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_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_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_MIN_BLOCK_SIZE_LIMIT (GRAPHENE_MIN_TRANSACTION_SIZE_LIMIT*5) // 5 transactions per block + +/** 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 +/** + * 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) + +/** + * 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)) +/// 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)) diff --git a/libraries/chain/include/graphene/chain/protocol/custom.hpp b/libraries/protocol/include/graphene/protocol/custom.hpp similarity index 87% rename from libraries/chain/include/graphene/chain/protocol/custom.hpp rename to libraries/protocol/include/graphene/protocol/custom.hpp index e5701a4b2a..d3d25f6a36 100644 --- a/libraries/chain/include/graphene/chain/protocol/custom.hpp +++ b/libraries/protocol/include/graphene/protocol/custom.hpp @@ -23,9 +23,9 @@ */ #pragma once -#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 @@ -52,7 +52,7 @@ namespace graphene { namespace chain { share_type calculate_fee(const fee_parameters_type& k)const; }; -} } // 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) ) diff --git a/libraries/protocol/include/graphene/protocol/exceptions.hpp b/libraries/protocol/include/graphene/protocol/exceptions.hpp new file mode 100644 index 0000000000..5141151d21 --- /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, "protocol exception" ) + + FC_DECLARE_DERIVED_EXCEPTION( transaction_exception, graphene::protocol::protocol_exception, 4010000, "transaction validation exception" ) + + FC_DECLARE_DERIVED_EXCEPTION( tx_missing_active_auth, graphene::protocol::transaction_exception, 4010001, "missing required active authority" ) + FC_DECLARE_DERIVED_EXCEPTION( tx_missing_owner_auth, graphene::protocol::transaction_exception, 4010002, "missing required owner authority" ) + FC_DECLARE_DERIVED_EXCEPTION( tx_missing_other_auth, graphene::protocol::transaction_exception, 4010003, "missing required other authority" ) + FC_DECLARE_DERIVED_EXCEPTION( tx_irrelevant_sig, graphene::protocol::transaction_exception, 4010004, "irrelevant signature included" ) + FC_DECLARE_DERIVED_EXCEPTION( tx_duplicate_sig, graphene::protocol::transaction_exception, 4010005, "duplicate signature included" ) + FC_DECLARE_DERIVED_EXCEPTION( invalid_committee_approval, graphene::protocol::transaction_exception, 4010006, "committee account cannot directly approve transaction" ) + FC_DECLARE_DERIVED_EXCEPTION( insufficient_fee, graphene::protocol::transaction_exception, 4010007, "insufficient fee" ) + +} } // graphene::protocol diff --git a/libraries/chain/include/graphene/chain/protocol/ext.hpp b/libraries/protocol/include/graphene/protocol/ext.hpp similarity index 84% rename from libraries/chain/include/graphene/chain/protocol/ext.hpp rename to libraries/protocol/include/graphene/protocol/ext.hpp index f868fa0b23..b5b187d145 100644 --- a/libraries/chain/include/graphene/chain/protocol/ext.hpp +++ b/libraries/protocol/include/graphene/protocol/ext.hpp @@ -25,8 +25,9 @@ #include #include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { using fc::unsigned_int; @@ -128,7 +129,7 @@ struct graphene_extension_unpack_visitor const uint32_t max_depth; }; -} } // graphene::chain +} } // graphene::protocol namespace fc { @@ -161,9 +162,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() ) @@ -194,7 +195,7 @@ 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 ); @@ -204,36 +205,36 @@ void to_variant( const graphene::chain::extension& value, fc::variant& var, u namespace raw { template< typename Stream, typename T > -void pack( Stream& stream, const graphene::chain::extension& value, uint32_t _max_depth=FC_PACK_MAX_DEPTH ) +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::chain::graphene_extension_pack_count_visitor count_vtor( value.value ); + 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::chain::graphene_extension_pack_read_visitor read_vtor( stream, value.value, _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::chain::extension& value, uint32_t _max_depth=FC_PACK_MAX_DEPTH ) +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::chain::extension(); - graphene::chain::graphene_extension_unpack_visitor vtor( s, value.value, _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::chain::extension > +template struct get_typename< graphene::protocol::extension > { static const char* name() { - static std::string n = std::string("graphene::chain::extension<") + static std::string n = std::string("graphene::protocol::extension<") + fc::get_typename::name() + std::string(">"); return n.c_str(); } diff --git a/libraries/chain/include/graphene/chain/protocol/fba.hpp b/libraries/protocol/include/graphene/protocol/fba.hpp similarity index 84% rename from libraries/chain/include/graphene/chain/protocol/fba.hpp rename to libraries/protocol/include/graphene/protocol/fba.hpp index 7460ca8df6..944b1c188b 100644 --- a/libraries/chain/include/graphene/chain/protocol/fba.hpp +++ b/libraries/protocol/include/graphene/protocol/fba.hpp @@ -22,9 +22,9 @@ * THE SOFTWARE. */ #pragma once -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { struct fba_distribute_operation : public base_operation { @@ -32,7 +32,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; } @@ -42,6 +42,6 @@ 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::chain::fba_distribute_operation, (fee)(account_id)(fba_id)(amount) ) +FC_REFLECT( graphene::protocol::fba_distribute_operation, (fee)(account_id)(fba_id)(amount) ) diff --git a/libraries/chain/include/graphene/chain/protocol/fee_schedule.hpp b/libraries/protocol/include/graphene/protocol/fee_schedule.hpp similarity index 97% rename from libraries/chain/include/graphene/chain/protocol/fee_schedule.hpp rename to libraries/protocol/include/graphene/protocol/fee_schedule.hpp index 0b22c53c7c..2a39bdf471 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 @@ -207,7 +207,7 @@ namespace graphene { namespace chain { typedef fee_schedule fee_schedule_type; -} } // graphene::chain +} } // graphene::protocol -FC_REFLECT_TYPENAME( graphene::chain::fee_parameters ) -FC_REFLECT( graphene::chain::fee_schedule, (parameters)(scale) ) +FC_REFLECT_TYPENAME( graphene::protocol::fee_parameters ) +FC_REFLECT( graphene::protocol::fee_schedule, (parameters)(scale) ) diff --git a/libraries/chain/include/graphene/chain/protocol/htlc.hpp b/libraries/protocol/include/graphene/protocol/htlc.hpp similarity index 85% rename from libraries/chain/include/graphene/chain/protocol/htlc.hpp rename to libraries/protocol/include/graphene/protocol/htlc.hpp index 7e4e713368..c7b8d282ff 100644 --- a/libraries/chain/include/graphene/chain/protocol/htlc.hpp +++ b/libraries/protocol/include/graphene/protocol/htlc.hpp @@ -28,13 +28,11 @@ #include #include #include -#include -#include +#include +#include #include // std::max -namespace graphene { - namespace chain { - +namespace graphene { namespace protocol { typedef fc::ripemd160 htlc_algo_ripemd160; typedef fc::sha1 htlc_algo_sha1; typedef fc::sha256 htlc_algo_sha256; @@ -195,17 +193,17 @@ namespace graphene { } } -FC_REFLECT_TYPENAME( graphene::chain::htlc_hash ) +FC_REFLECT_TYPENAME( graphene::protocol::htlc_hash ) -FC_REFLECT( graphene::chain::htlc_create_operation::fee_parameters_type, (fee) (fee_per_day) ) -FC_REFLECT( graphene::chain::htlc_redeem_operation::fee_parameters_type, (fee) (fee_per_kb) ) -FC_REFLECT( graphene::chain::htlc_redeemed_operation::fee_parameters_type, ) // VIRTUAL -FC_REFLECT( graphene::chain::htlc_extend_operation::fee_parameters_type, (fee) (fee_per_day)) -FC_REFLECT( graphene::chain::htlc_refund_operation::fee_parameters_type, ) // VIRTUAL +FC_REFLECT( graphene::protocol::htlc_create_operation::fee_parameters_type, (fee) (fee_per_day) ) +FC_REFLECT( graphene::protocol::htlc_redeem_operation::fee_parameters_type, (fee) (fee_per_kb) ) +FC_REFLECT( graphene::protocol::htlc_redeemed_operation::fee_parameters_type, ) // VIRTUAL +FC_REFLECT( graphene::protocol::htlc_extend_operation::fee_parameters_type, (fee) (fee_per_day)) +FC_REFLECT( graphene::protocol::htlc_refund_operation::fee_parameters_type, ) // VIRTUAL -FC_REFLECT( graphene::chain::htlc_create_operation, +FC_REFLECT( graphene::protocol::htlc_create_operation, (fee)(from)(to)(amount)(preimage_hash)(preimage_size)(claim_period_seconds)(extensions)) -FC_REFLECT( graphene::chain::htlc_redeem_operation, (fee)(htlc_id)(redeemer)(preimage)(extensions)) -FC_REFLECT( graphene::chain::htlc_redeemed_operation, (fee)(htlc_id)(from)(to)(redeemer)(amount) ) -FC_REFLECT( graphene::chain::htlc_extend_operation, (fee)(htlc_id)(update_issuer)(seconds_to_add)(extensions)) -FC_REFLECT( graphene::chain::htlc_refund_operation, (fee)(htlc_id)(to)) +FC_REFLECT( graphene::protocol::htlc_redeem_operation, (fee)(htlc_id)(redeemer)(preimage)(extensions)) +FC_REFLECT( graphene::protocol::htlc_redeemed_operation, (fee)(htlc_id)(from)(to)(redeemer)(amount) ) +FC_REFLECT( graphene::protocol::htlc_extend_operation, (fee)(htlc_id)(update_issuer)(seconds_to_add)(extensions)) +FC_REFLECT( graphene::protocol::htlc_refund_operation, (fee)(htlc_id)(to)) diff --git a/libraries/chain/include/graphene/chain/protocol/market.hpp b/libraries/protocol/include/graphene/protocol/market.hpp similarity index 84% rename from libraries/chain/include/graphene/chain/protocol/market.hpp rename to libraries/protocol/include/graphene/protocol/market.hpp index 55438d7cc5..2a887498e7 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 @@ -216,22 +215,20 @@ namespace graphene { namespace chain { /// This is a virtual operation; there is no fee 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) ) -FC_REFLECT( graphene::chain::bid_collateral_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::fill_order_operation::fee_parameters_type, ) // VIRTUAL -FC_REFLECT( graphene::chain::execute_bid_operation::fee_parameters_type, ) // VIRTUAL - -FC_REFLECT( graphene::chain::call_order_update_operation::options_type, (target_collateral_ratio) ) - -FC_REFLECT_TYPENAME( graphene::chain::call_order_update_operation::extensions_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)(fill_price)(is_maker) ) -FC_REFLECT( graphene::chain::bid_collateral_operation, (fee)(bidder)(additional_collateral)(debt_covered)(extensions) ) -FC_REFLECT( graphene::chain::execute_bid_operation, (fee)(bidder)(debt)(collateral) ) +} } // 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::bid_collateral_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::fill_order_operation::fee_parameters_type, ) // VIRTUAL +FC_REFLECT( graphene::protocol::execute_bid_operation::fee_parameters_type, ) // VIRTUAL + +FC_REFLECT( graphene::protocol::call_order_update_operation::options_type, (target_collateral_ratio) ) + +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)(fill_price)(is_maker) ) +FC_REFLECT( graphene::protocol::bid_collateral_operation, (fee)(bidder)(additional_collateral)(debt_covered)(extensions) ) +FC_REFLECT( graphene::protocol::execute_bid_operation, (fee)(bidder)(debt)(collateral) ) diff --git a/libraries/chain/include/graphene/chain/protocol/memo.hpp b/libraries/protocol/include/graphene/protocol/memo.hpp similarity index 93% rename from libraries/chain/include/graphene/chain/protocol/memo.hpp rename to libraries/protocol/include/graphene/protocol/memo.hpp index b126d3a7d5..544b7447fd 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,7 +85,7 @@ 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) ) diff --git a/libraries/chain/include/graphene/chain/protocol/operations.hpp b/libraries/protocol/include/graphene/protocol/operations.hpp similarity index 82% rename from libraries/chain/include/graphene/chain/protocol/operations.hpp rename to libraries/protocol/include/graphene/protocol/operations.hpp index 9b5ffabb37..7d4f9d0f5f 100644 --- a/libraries/chain/include/graphene/chain/protocol/operations.hpp +++ b/libraries/protocol/include/graphene/protocol/operations.hpp @@ -22,25 +22,25 @@ * 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 -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * @ingroup operations @@ -129,7 +129,7 @@ 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) ) diff --git a/libraries/chain/include/graphene/chain/protocol/proposal.hpp b/libraries/protocol/include/graphene/protocol/proposal.hpp similarity index 92% rename from libraries/chain/include/graphene/chain/protocol/proposal.hpp rename to libraries/protocol/include/graphene/protocol/proposal.hpp index 3383b6cfd6..41be9afc30 100644 --- a/libraries/chain/include/graphene/chain/protocol/proposal.hpp +++ b/libraries/protocol/include/graphene/protocol/proposal.hpp @@ -22,9 +22,9 @@ * THE SOFTWARE. */ #pragma once -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * @defgroup proposed_transactions The Graphene Transaction Proposal Protocol * @ingroup operations @@ -167,15 +167,15 @@ 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) ) diff --git a/libraries/chain/include/graphene/chain/pts_address.hpp b/libraries/protocol/include/graphene/protocol/pts_address.hpp similarity index 83% rename from libraries/chain/include/graphene/chain/pts_address.hpp rename to libraries/protocol/include/graphene/protocol/pts_address.hpp index 636e2f114e..c9ea9febcc 100644 --- a/libraries/chain/include/graphene/chain/pts_address.hpp +++ b/libraries/protocol/include/graphene/protocol/pts_address.hpp @@ -28,7 +28,7 @@ namespace fc { namespace ecc { class public_key; } } -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * Implements address stringification and validation from PTS @@ -51,15 +51,15 @@ namespace graphene { namespace chain { 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) ); @@ -69,10 +69,10 @@ namespace std } #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 ); } diff --git a/libraries/chain/include/graphene/chain/protocol/special_authority.hpp b/libraries/protocol/include/graphene/protocol/special_authority.hpp similarity index 82% rename from libraries/chain/include/graphene/chain/protocol/special_authority.hpp rename to libraries/protocol/include/graphene/protocol/special_authority.hpp index 3ee6f15fd2..de97257e5d 100644 --- a/libraries/chain/include/graphene/chain/protocol/special_authority.hpp +++ b/libraries/protocol/include/graphene/protocol/special_authority.hpp @@ -23,10 +23,10 @@ */ #pragma once -#include +#include #include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { struct no_special_authority {}; @@ -43,8 +43,8 @@ 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 ) diff --git a/libraries/chain/include/graphene/chain/protocol/transaction.hpp b/libraries/protocol/include/graphene/protocol/transaction.hpp similarity index 95% rename from libraries/chain/include/graphene/chain/protocol/transaction.hpp rename to libraries/protocol/include/graphene/protocol/transaction.hpp index 6361d006ec..3ba121c8d6 100644 --- a/libraries/chain/include/graphene/chain/protocol/transaction.hpp +++ b/libraries/protocol/include/graphene/protocol/transaction.hpp @@ -22,12 +22,12 @@ * THE SOFTWARE. */ #pragma once -#include -#include +#include +#include #include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * @defgroup transactions Transactions @@ -287,10 +287,10 @@ 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::precomputable_transaction, (graphene::chain::signed_transaction), ) -FC_REFLECT_DERIVED( graphene::chain::processed_transaction, (graphene::chain::precomputable_transaction), (operation_results) ) +FC_REFLECT_DERIVED( graphene::protocol::signed_transaction, (graphene::protocol::transaction), (signatures) ) +FC_REFLECT_DERIVED( graphene::protocol::precomputable_transaction, (graphene::protocol::signed_transaction), ) +FC_REFLECT_DERIVED( graphene::protocol::processed_transaction, (graphene::protocol::precomputable_transaction), (operation_results) ) diff --git a/libraries/chain/include/graphene/chain/protocol/transfer.hpp b/libraries/protocol/include/graphene/protocol/transfer.hpp similarity index 86% rename from libraries/chain/include/graphene/chain/protocol/transfer.hpp rename to libraries/protocol/include/graphene/protocol/transfer.hpp index f4417bb747..1262be2acb 100644 --- a/libraries/chain/include/graphene/chain/protocol/transfer.hpp +++ b/libraries/protocol/include/graphene/protocol/transfer.hpp @@ -22,10 +22,10 @@ * THE SOFTWARE. */ #pragma once -#include -#include +#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * @ingroup operations @@ -98,10 +98,10 @@ 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) ) diff --git a/libraries/protocol/include/graphene/protocol/types.hpp b/libraries/protocol/include/graphene/protocol/types.hpp new file mode 100644 index 0000000000..9dd290c7b2 --- /dev/null +++ b/libraries/protocol/include/graphene/protocol/types.hpp @@ -0,0 +1,324 @@ +/* + * 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 + +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; } + +/** + * 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, + htlc_object_type, + OBJECT_TYPE_COUNT ///< Sentry value which contains the number of different object types +}; + +using account_id_type = object_id; +using asset_id_type = object_id; +using force_settlement_id_type = object_id; +using committee_member_id_type = object_id; +using witness_id_type = object_id; +using limit_order_id_type = object_id; +using call_order_id_type = object_id; +using custom_id_type = object_id; +using proposal_id_type = object_id; +using operation_history_id_type = object_id; +using withdraw_permission_id_type = object_id; +using vesting_balance_id_type = object_id; +using worker_id_type = object_id; +using balance_id_type = object_id; +using htlc_id_type = object_id; + +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; + +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); +}; + +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 extended_public_key_type { + struct binary_key { + binary_key() = default; + 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() = default; + 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& p); + friend bool operator == (const extended_private_key_type& p1, const extended_private_key_type& p); + friend bool operator != (const extended_private_key_type& p1, const extended_private_key_type& p); +}; + +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); +void to_variant(const graphene::protocol::extended_public_key_type& var, fc::variant& vo, uint32_t max_depth = 2); +void from_variant(const fc::variant& var, graphene::protocol::extended_public_key_type& vo, uint32_t max_depth = 2); +void to_variant(const graphene::protocol::extended_private_key_type& var, fc::variant& vo, uint32_t max_depth = 2); +void from_variant(const fc::variant& var, graphene::protocol::extended_private_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_REFLECT_ENUM(graphene::protocol::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) + (htlc_object_type) + (OBJECT_TYPE_COUNT)) + +FC_REFLECT_TYPENAME(graphene::protocol::account_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::asset_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::force_settlement_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::committee_member_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::witness_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::limit_order_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::call_order_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::custom_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::proposal_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::operation_history_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::withdraw_permission_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::vesting_balance_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::worker_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::balance_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::htlc_id_type) + +FC_REFLECT(graphene::protocol::public_key_type, (key_data)) +FC_REFLECT(graphene::protocol::public_key_type::binary_key, (data)(check)) +FC_REFLECT(graphene::protocol::extended_public_key_type, (key_data)) +FC_REFLECT(graphene::protocol::extended_public_key_type::binary_key, (check)(data)) +FC_REFLECT(graphene::protocol::extended_private_key_type, (key_data)) +FC_REFLECT(graphene::protocol::extended_private_key_type::binary_key, (check)(data)) + +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)) diff --git a/libraries/chain/include/graphene/chain/protocol/vesting.hpp b/libraries/protocol/include/graphene/protocol/vesting.hpp similarity index 82% rename from libraries/chain/include/graphene/chain/protocol/vesting.hpp rename to libraries/protocol/include/graphene/protocol/vesting.hpp index b5d03585de..2e2ff218fe 100644 --- a/libraries/chain/include/graphene/chain/protocol/vesting.hpp +++ b/libraries/protocol/include/graphene/protocol/vesting.hpp @@ -22,9 +22,9 @@ * THE SOFTWARE. */ #pragma once -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { struct linear_vesting_policy_initializer { @@ -114,15 +114,15 @@ 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) ) -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) ) +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_EMPTY( graphene::chain::instant_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_EMPTY( graphene::protocol::instant_vesting_policy_initializer ) +FC_REFLECT_TYPENAME( graphene::protocol::vesting_policy_initializer ) diff --git a/libraries/chain/include/graphene/chain/protocol/vote.hpp b/libraries/protocol/include/graphene/protocol/vote.hpp similarity index 88% rename from libraries/chain/include/graphene/chain/protocol/vote.hpp rename to libraries/protocol/include/graphene/protocol/vote.hpp index ec2ebd1640..8d19abe084 100644 --- a/libraries/chain/include/graphene/chain/protocol/vote.hpp +++ b/libraries/protocol/include/graphene/protocol/vote.hpp @@ -31,7 +31,7 @@ #include #include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * @brief An ID for some votable object @@ -130,23 +130,19 @@ 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)(VOTE_TYPE_COUNT) ) -FC_REFLECT( graphene::chain::vote_id_type, (content) ) +FC_REFLECT_ENUM( graphene::protocol::vote_id_type::vote_type, (witness)(committee)(worker)(VOTE_TYPE_COUNT) ) +FC_REFLECT( graphene::protocol::vote_id_type, (content) ) diff --git a/libraries/chain/include/graphene/chain/protocol/withdraw_permission.hpp b/libraries/protocol/include/graphene/protocol/withdraw_permission.hpp similarity index 88% rename from libraries/chain/include/graphene/chain/protocol/withdraw_permission.hpp rename to libraries/protocol/include/graphene/protocol/withdraw_permission.hpp index 7bc905acc7..03952e1e31 100644 --- a/libraries/chain/include/graphene/chain/protocol/withdraw_permission.hpp +++ b/libraries/protocol/include/graphene/protocol/withdraw_permission.hpp @@ -22,10 +22,10 @@ * THE SOFTWARE. */ #pragma once -#include -#include +#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * @brief Create a new withdrawal permission @@ -165,17 +165,17 @@ 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) ) diff --git a/libraries/chain/include/graphene/chain/protocol/witness.hpp b/libraries/protocol/include/graphene/protocol/witness.hpp similarity index 84% rename from libraries/chain/include/graphene/chain/protocol/witness.hpp rename to libraries/protocol/include/graphene/protocol/witness.hpp index 5eb75f9be3..7eac795abb 100644 --- a/libraries/chain/include/graphene/chain/protocol/witness.hpp +++ b/libraries/protocol/include/graphene/protocol/witness.hpp @@ -22,9 +22,9 @@ * THE SOFTWARE. */ #pragma once -#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. @@ -74,10 +74,10 @@ 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) ) +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) ) -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) ) +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) ) diff --git a/libraries/chain/include/graphene/chain/protocol/worker.hpp b/libraries/protocol/include/graphene/protocol/worker.hpp similarity index 88% rename from libraries/chain/include/graphene/chain/protocol/worker.hpp rename to libraries/protocol/include/graphene/protocol/worker.hpp index 9e6eef3592..7bd7825923 100644 --- a/libraries/chain/include/graphene/chain/protocol/worker.hpp +++ b/libraries/protocol/include/graphene/protocol/worker.hpp @@ -22,9 +22,9 @@ * THE SOFTWARE. */ #pragma once -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * @defgroup workers The Blockchain Worker System @@ -95,12 +95,12 @@ 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) ) diff --git a/libraries/chain/protocol/market.cpp b/libraries/protocol/market.cpp similarity index 95% rename from libraries/chain/protocol/market.cpp rename to libraries/protocol/market.cpp index fd12fa4e7d..19e37bbb7d 100644 --- a/libraries/chain/protocol/market.cpp +++ b/libraries/protocol/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 limit_order_create_operation::validate()const { @@ -54,4 +54,4 @@ void bid_collateral_operation::validate()const FC_ASSERT( debt_covered.amount == 0 || (debt_covered.amount > 0 && additional_collateral.amount > 0) ); } FC_CAPTURE_AND_RETHROW((*this)) } -} } // graphene::chain +} } // graphene::protocol diff --git a/libraries/chain/protocol/memo.cpp b/libraries/protocol/memo.cpp similarity index 97% rename from libraries/chain/protocol/memo.cpp rename to libraries/protocol/memo.cpp index e04b5e4302..75e77cbc7b 100644 --- a/libraries/chain/protocol/memo.cpp +++ b/libraries/protocol/memo.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 memo_data::set_message(const fc::ecc::private_key& priv, const fc::ecc::public_key& pub, const string& msg, uint64_t custom_nonce) @@ -87,4 +87,4 @@ memo_message memo_message::deserialize(const string& serial) return result; } -} } // graphene::chain +} } // graphene::protocol diff --git a/libraries/chain/protocol/operations.cpp b/libraries/protocol/operations.cpp similarity index 96% rename from libraries/chain/protocol/operations.cpp rename to libraries/protocol/operations.cpp index 48a65f6fed..5092921261 100644 --- a/libraries/chain/protocol/operations.cpp +++ b/libraries/protocol/operations.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 { uint64_t base_operation::calculate_data_fee( uint64_t bytes, uint64_t price_per_kbyte ) { @@ -90,4 +90,4 @@ void operation_get_required_authorities( const operation& op, op.visit( operation_get_required_auth( active, owner, other ) ); } -} } // namespace graphene::chain +} } // namespace graphene::protocol diff --git a/libraries/chain/protocol/proposal.cpp b/libraries/protocol/proposal.cpp similarity index 96% rename from libraries/chain/protocol/proposal.cpp rename to libraries/protocol/proposal.cpp index 7d072e4a90..86f1158e76 100644 --- a/libraries/chain/protocol/proposal.cpp +++ b/libraries/protocol/proposal.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 +#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 ) { @@ -104,4 +104,4 @@ void proposal_update_operation::get_required_owner_authorities( flat_set -#include +#include #include #include #include #include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { pts_address::pts_address() { @@ -42,10 +41,7 @@ namespace graphene { namespace chain { if( v.size() ) memcpy( addr.data, v.data(), std::min( v.size(), sizeof(addr) ) ); - 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 ) @@ -89,12 +85,12 @@ namespace graphene { namespace chain { 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() ); } } diff --git a/libraries/chain/protocol/vote.cpp b/libraries/protocol/special_authority.cpp similarity index 65% rename from libraries/chain/protocol/vote.cpp rename to libraries/protocol/special_authority.cpp index f78f2b4f11..2f7b4f919c 100644 --- a/libraries/chain/protocol/vote.cpp +++ b/libraries/protocol/special_authority.cpp @@ -22,30 +22,26 @@ * THE SOFTWARE. */ -#include -#include -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { -vote_id_type get_next_vote_id( global_property_object& gpo, vote_id_type::vote_type type ) +struct special_authority_validate_visitor { - return vote_id_type( type, gpo.next_available_vote_id++ ); -} - -} } // graphene::chain + typedef void result_type; -namespace fc -{ + void operator()( const no_special_authority& a ) {} -void to_variant( const graphene::chain::vote_id_type& var, variant& vo, uint32_t max_depth ) -{ - vo = string(var); -} + 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 diff --git a/libraries/chain/protocol/transaction.cpp b/libraries/protocol/transaction.cpp similarity index 94% rename from libraries/chain/protocol/transaction.cpp rename to libraries/protocol/transaction.cpp index 6b4d7f3235..3964769d0e 100644 --- a/libraries/chain/protocol/transaction.cpp +++ b/libraries/protocol/transaction.cpp @@ -21,14 +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 #include #include #include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { digest_type processed_transaction::merkle_digest()const { @@ -71,14 +72,14 @@ const transaction_id_type& transaction::id() const return _tx_id_buffer; } -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)); 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 ); @@ -385,7 +386,8 @@ set signed_transaction::minimize_required_signatures( result.erase( k ); try { - graphene::chain::verify_authority( operations, result, get_active, get_owner, allow_non_immediate_owner, max_recursion ); + graphene::protocol::verify_authority( operations, result, get_active, get_owner, + allow_non_immediate_owner, max_recursion ); continue; // element stays erased if verify_authority is ok } catch( const tx_missing_owner_auth& e ) {} @@ -433,12 +435,8 @@ void signed_transaction::verify_authority( bool allow_non_immediate_owner, uint32_t max_recursion )const { try { - graphene::chain::verify_authority( operations, - get_signature_keys( chain_id ), - get_active, - get_owner, - allow_non_immediate_owner, - max_recursion ); + graphene::protocol::verify_authority( operations, get_signature_keys( chain_id ), get_active, get_owner, + allow_non_immediate_owner, max_recursion ); } FC_CAPTURE_AND_RETHROW( (*this) ) } -} } // graphene::chain +} } // graphene::protocol diff --git a/libraries/chain/protocol/transfer.cpp b/libraries/protocol/transfer.cpp similarity index 94% rename from libraries/chain/protocol/transfer.cpp rename to libraries/protocol/transfer.cpp index 3dfe4eb727..8d97f894f0 100644 --- a/libraries/chain/protocol/transfer.cpp +++ b/libraries/protocol/transfer.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 { share_type transfer_operation::calculate_fee( const fee_parameters_type& schedule )const { @@ -60,4 +60,4 @@ void override_transfer_operation::validate()const FC_ASSERT( issuer != from ); } -} } // graphene::chain +} } // graphene::protocol diff --git a/libraries/chain/protocol/types.cpp b/libraries/protocol/types.cpp similarity index 84% rename from libraries/chain/protocol/types.cpp rename to libraries/protocol/types.cpp index 4ca33e6f64..d3d6fd27d7 100644 --- a/libraries/chain/protocol/types.cpp +++ b/libraries/protocol/types.cpp @@ -21,16 +21,16 @@ * 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 -namespace graphene { namespace chain { +namespace graphene { namespace protocol { public_key_type::public_key_type():key_data(){}; @@ -144,7 +144,7 @@ namespace graphene { namespace chain { // extended_private_key_type - extended_private_key_type::extended_private_key_type():key_data(){}; + extended_private_key_type::extended_private_key_type() = default; extended_private_key_type::extended_private_key_type( const fc::ecc::extended_key_data& data ) :key_data( data ){}; @@ -196,47 +196,48 @@ namespace graphene { namespace chain { return p1.key_data != p2.key_data; } -} } // graphene::chain +} } // graphene::protocol namespace fc { using namespace std; - void to_variant( const graphene::chain::public_key_type& var, fc::variant& vo, uint32_t max_depth ) + 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::chain::public_key_type& vo, uint32_t max_depth ) + void from_variant( const fc::variant& var, graphene::protocol::public_key_type& vo, uint32_t max_depth ) { - vo = graphene::chain::public_key_type( var.as_string() ); + vo = graphene::protocol::public_key_type( var.as_string() ); } - void to_variant( const graphene::chain::extended_public_key_type& var, fc::variant& vo, uint32_t max_depth ) + void to_variant( const graphene::protocol::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 ) + void from_variant( const fc::variant& var, graphene::protocol::extended_public_key_type& vo, uint32_t max_depth ) { - vo = graphene::chain::extended_public_key_type( var.as_string() ); + vo = graphene::protocol::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 ) + void to_variant( const graphene::protocol::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 ) + void from_variant( const fc::variant& var, graphene::protocol::extended_private_key_type& vo, uint32_t max_depth ) { - vo = graphene::chain::extended_private_key_type( var.as_string() ); + vo = graphene::protocol::extended_private_key_type( var.as_string() ); } - void from_variant( const fc::variant& var, std::shared_ptr& vo, + 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(); + 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); + from_variant(var, const_cast(*vo), max_depth); } + } // fc diff --git a/libraries/chain/include/graphene/chain/protocol/config.hpp b/libraries/protocol/vote.cpp similarity index 74% rename from libraries/chain/include/graphene/chain/protocol/config.hpp rename to libraries/protocol/vote.cpp index 870b08fe3e..ae1755c14b 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 +#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 diff --git a/libraries/chain/protocol/withdraw_permission.cpp b/libraries/protocol/withdraw_permission.cpp similarity index 95% rename from libraries/chain/protocol/withdraw_permission.cpp rename to libraries/protocol/withdraw_permission.cpp index 33b40c8561..fdbe74a739 100644 --- a/libraries/chain/protocol/withdraw_permission.cpp +++ b/libraries/protocol/withdraw_permission.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 withdraw_permission_update_operation::validate()const { @@ -66,5 +66,5 @@ void withdraw_permission_delete_operation::validate() const } -} } // graphene::chain +} } // graphene::protocol diff --git a/libraries/chain/protocol/witness.cpp b/libraries/protocol/witness.cpp similarity index 93% rename from libraries/chain/protocol/witness.cpp rename to libraries/protocol/witness.cpp index 82fa462af1..6ec418a9e7 100644 --- a/libraries/chain/protocol/witness.cpp +++ b/libraries/protocol/witness.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 witness_create_operation::validate() const { @@ -38,4 +38,4 @@ void witness_update_operation::validate() const FC_ASSERT(new_url->size() < GRAPHENE_MAX_URL_LENGTH ); } -} } // graphene::chain +} } // graphene::protocol diff --git a/libraries/chain/protocol/worker.cpp b/libraries/protocol/worker.cpp similarity index 94% rename from libraries/chain/protocol/worker.cpp rename to libraries/protocol/worker.cpp index eb133da077..2344edb83f 100644 --- a/libraries/chain/protocol/worker.cpp +++ b/libraries/protocol/worker.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 worker_create_operation::validate() const { diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 11eb4fe023..9bcbf8a7b8 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -65,8 +65,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include @@ -532,11 +532,11 @@ class wallet_api_impl return _checksum == fc::sha512(); } - template - T get_object(object_id id)const + template + typename graphene::db::object_downcast::type 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::type>( GRAPHENE_MAX_NESTED_OBJECTS ); } void set_operation_fees( signed_transaction& tx, const fee_schedule& s ) @@ -1007,7 +1007,7 @@ class wallet_api_impl total_fee += gprops.get_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 { @@ -1951,7 +1951,7 @@ class wallet_api_impl if( vbid ) { - result.emplace_back( get_object(*vbid), now ); + result.emplace_back( get_object(*vbid), now ); return result; } /* @@ -1988,7 +1988,7 @@ class wallet_api_impl vbid = wit.pay_vb; } - vesting_balance_object vbo = get_object< vesting_balance_object >( *vbid ); + vesting_balance_object vbo = get_object( *vbid ); vesting_balance_withdraw_operation vesting_balance_withdraw_op; vesting_balance_withdraw_op.vesting_balance = *vbid; @@ -2333,14 +2333,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.get_current_fees()); @@ -3645,7 +3644,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 diff --git a/programs/build_helpers/member_enumerator.cpp b/programs/build_helpers/member_enumerator.cpp index 9eda6e3ab5..cce25a5f4a 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 diff --git a/programs/genesis_util/convert_address.cpp b/programs/genesis_util/convert_address.cpp index 7f73acdb1c..f8224cc8e8 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 7e251de8a7..d35547bfde 100644 --- a/programs/genesis_util/genesis_update.cpp +++ b/programs/genesis_util/genesis_update.cpp @@ -32,7 +32,7 @@ #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 ea7cdf9f0e..4fc6a42f2c 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 b7dab82825..d677bb8e86 100644 --- a/programs/js_operation_serializer/main.cpp +++ b/programs/js_operation_serializer/main.cpp @@ -21,8 +21,8 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include -#include +#include +#include #include #include @@ -125,11 +125,12 @@ template<> struct js_name { static std::string name(){ retu 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()) + "\")"; }; }; @@ -272,8 +273,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() {} diff --git a/programs/size_checker/main.cpp b/programs/size_checker/main.cpp index 72d7d85f85..f4fb956341 100644 --- a/programs/size_checker/main.cpp +++ b/programs/size_checker/main.cpp @@ -26,8 +26,8 @@ #include #include -#include -#include +#include +#include #include #include @@ -35,7 +35,7 @@ #include #include -using namespace graphene::chain; +using namespace graphene::protocol; vector< fc::variant_object > g_op_types; @@ -68,7 +68,7 @@ int main( int argc, char** argv ) { try { - graphene::chain::operation op; + graphene::protocol::operation op; vector witnesses; witnesses.resize(50); diff --git a/tests/common/database_fixture.hpp b/tests/common/database_fixture.hpp index e10f679de4..bf764f45f6 100644 --- a/tests/common/database_fixture.hpp +++ b/tests/common/database_fixture.hpp @@ -23,12 +23,16 @@ */ #pragma once -#include -#include -#include #include +#include +#include + +#include +#include #include +#include +#include #include #include diff --git a/tests/tests/call_order_tests.cpp b/tests/tests/call_order_tests.cpp index 2095de0ac1..4f700cda87 100644 --- a/tests/tests/call_order_tests.cpp +++ b/tests/tests/call_order_tests.cpp @@ -26,6 +26,7 @@ #include #include +#include #include #include "../common/database_fixture.hpp" diff --git a/tests/tests/htlc_tests.cpp b/tests/tests/htlc_tests.cpp index 88b9bf73f9..81ce1ed700 100644 --- a/tests/tests/htlc_tests.cpp +++ b/tests/tests/htlc_tests.cpp @@ -38,7 +38,7 @@ #include -#include +#include #include #include diff --git a/tests/tests/market_rounding_tests.cpp b/tests/tests/market_rounding_tests.cpp index b71e1cd0ff..66698bee45 100644 --- a/tests/tests/market_rounding_tests.cpp +++ b/tests/tests/market_rounding_tests.cpp @@ -26,6 +26,7 @@ #include +#include #include #include "../common/database_fixture.hpp" diff --git a/tests/tests/market_tests.cpp b/tests/tests/market_tests.cpp index 1b14123a88..f71c56a1fb 100644 --- a/tests/tests/market_tests.cpp +++ b/tests/tests/market_tests.cpp @@ -26,6 +26,7 @@ #include +#include #include #include "../common/database_fixture.hpp" diff --git a/tests/tests/settle_tests.cpp b/tests/tests/settle_tests.cpp index 07244cd225..f64719e613 100644 --- a/tests/tests/settle_tests.cpp +++ b/tests/tests/settle_tests.cpp @@ -26,6 +26,7 @@ #include +#include #include #include "../common/database_fixture.hpp" From dae82b1efc72d823ab5b8357ccd3be047f4f4daa Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Sun, 14 Apr 2019 15:41:42 -0500 Subject: [PATCH 003/133] Ref #1506: Add object_downcast_t Allows the more concise expression `object_downcast_t` instead of the old `typename object_downcast::type` --- libraries/db/include/graphene/db/object_database.hpp | 8 ++++---- libraries/db/include/graphene/db/object_id.hpp | 2 ++ libraries/wallet/wallet.cpp | 4 ++-- programs/js_operation_serializer/main.cpp | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/libraries/db/include/graphene/db/object_database.hpp b/libraries/db/include/graphene/db/object_database.hpp index 73807eebb8..c7825572fb 100644 --- a/libraries/db/include/graphene/db/object_database.hpp +++ b/libraries/db/include/graphene/db/object_database.hpp @@ -122,13 +122,13 @@ namespace graphene { namespace db { } template - auto find( object_id id )const -> const typename object_downcast::type* { - return find::type>(id); + auto find( object_id id )const -> const object_downcast_t* { + return find>(id); } template - auto get( object_id id )const -> const typename object_downcast::type& { - return get::type>(id); + auto get( object_id id )const -> const object_downcast_t& { + return get>(id); } template diff --git a/libraries/db/include/graphene/db/object_id.hpp b/libraries/db/include/graphene/db/object_id.hpp index 68de0bd2ac..9bdfe550ea 100644 --- a/libraries/db/include/graphene/db/object_id.hpp +++ b/libraries/db/include/graphene/db/object_id.hpp @@ -100,6 +100,8 @@ namespace graphene { namespace db { template<> \ struct object_downcast> { using type = OBJECT; }; \ } } + template + using object_downcast_t = typename object_downcast::type; template struct object_id diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 9bcbf8a7b8..a7359c6410 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -533,10 +533,10 @@ class wallet_api_impl } template - typename graphene::db::object_downcast::type get_object(ID id)const + typename graphene::db::object_downcast_tget_object(ID id)const { auto ob = _remote_db->get_objects({id}).front(); - return ob.template as::type>( GRAPHENE_MAX_NESTED_OBJECTS ); + return ob.template as>( GRAPHENE_MAX_NESTED_OBJECTS ); } void set_operation_fees( signed_transaction& tx, const fee_schedule& s ) diff --git a/programs/js_operation_serializer/main.cpp b/programs/js_operation_serializer/main.cpp index d677bb8e86..94e5057d7c 100644 --- a/programs/js_operation_serializer/main.cpp +++ b/programs/js_operation_serializer/main.cpp @@ -126,7 +126,7 @@ template<> struct js_name< vote_id_type > { static std::string name(){ retu template<> struct js_name< time_point_sec > { static std::string name(){ return "time_point_sec"; } }; template -struct js_name > +struct js_name > { static std::string name(){ return "protocol_id_type(\"" + From 074f0005f67b60d42fc707db82c093ece146a335 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Fri, 19 Apr 2019 17:11:28 -0500 Subject: [PATCH 004/133] Ref #1506: Move ID types from db to protocol The ID types, object_id and object_id_type, were defined in the db library, and the protocol library depends on db to get these types. Technically, the ID types are defined by the protocol and used by the database, and not vice versa. Therefore these types should be in the protocol library, and db should depend on protocol to get them. This commit makes it so. --- libraries/db/CMakeLists.txt | 2 +- libraries/db/include/graphene/db/object.hpp | 2 +- libraries/protocol/CMakeLists.txt | 2 +- .../db => protocol/include/graphene/protocol}/object_id.hpp | 0 libraries/protocol/include/graphene/protocol/types.hpp | 2 +- 5 files changed, 4 insertions(+), 4 deletions(-) rename libraries/{db/include/graphene/db => protocol/include/graphene/protocol}/object_id.hpp (100%) diff --git a/libraries/db/CMakeLists.txt b/libraries/db/CMakeLists.txt index 6feb985c6f..b0899d8683 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/object.hpp b/libraries/db/include/graphene/db/object.hpp index c410e273ee..6da932b029 100644 --- a/libraries/db/include/graphene/db/object.hpp +++ b/libraries/db/include/graphene/db/object.hpp @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #pragma once -#include +#include #include #include #include diff --git a/libraries/protocol/CMakeLists.txt b/libraries/protocol/CMakeLists.txt index eb91de4b06..e1be1fb6d8 100644 --- a/libraries/protocol/CMakeLists.txt +++ b/libraries/protocol/CMakeLists.txt @@ -29,7 +29,7 @@ list(APPEND SOURCES account.cpp add_library( graphene_protocol ${SOURCES} ${HEADERS} ) -target_link_libraries( graphene_protocol graphene_db fc ) +target_link_libraries( graphene_protocol fc ) target_include_directories( graphene_protocol PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) install( TARGETS diff --git a/libraries/db/include/graphene/db/object_id.hpp b/libraries/protocol/include/graphene/protocol/object_id.hpp similarity index 100% rename from libraries/db/include/graphene/db/object_id.hpp rename to libraries/protocol/include/graphene/protocol/object_id.hpp diff --git a/libraries/protocol/include/graphene/protocol/types.hpp b/libraries/protocol/include/graphene/protocol/types.hpp index 9dd290c7b2..429a5ed671 100644 --- a/libraries/protocol/include/graphene/protocol/types.hpp +++ b/libraries/protocol/include/graphene/protocol/types.hpp @@ -46,7 +46,7 @@ #include #include #include -#include +#include #include #include From 90f33c1be45cd053b44f2af1f6363b7fbd6ad1ea Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Sat, 13 Apr 2019 23:38:56 -0500 Subject: [PATCH 005/133] Ref #1506: Isolate chain/protocol to its own library --- libraries/wallet/wallet.cpp | 2 +- tests/benchmarks/main.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index a7359c6410..8a8b58d875 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -533,7 +533,7 @@ class wallet_api_impl } template - typename graphene::db::object_downcast_tget_object(ID id)const + 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 ); diff --git a/tests/benchmarks/main.cpp b/tests/benchmarks/main.cpp index 706318d62e..479fb3371d 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 + From 38b4acdd0b09eda16f7c0aaf59f8b8d8ba5ff820 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Fri, 26 Apr 2019 14:49:05 -0500 Subject: [PATCH 006/133] Bump FC --- libraries/fc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/fc b/libraries/fc index 6b1fdd513d..e003fec4cd 160000 --- a/libraries/fc +++ b/libraries/fc @@ -1 +1 @@ -Subproject commit 6b1fdd513d6bfa130caea5e9101885fe36ca98c8 +Subproject commit e003fec4cd9c2d2ee4a663a631dcea6041a770ed From c15b5072cb22330dd981a1e7490a7d2ba833ddde Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Wed, 1 May 2019 12:45:22 -0500 Subject: [PATCH 007/133] Remove commented-out index code --- .../account_history_plugin.hpp | 25 ------------------- 1 file changed, 25 deletions(-) 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 70fbe43697..99492768ce 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 @@ -81,28 +81,3 @@ class account_history_plugin : public graphene::app::plugin }; } } //graphene::account_history - -/* -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; -*/ From ea4d28bc7066125f60865a077aecb4955dfc27cc Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Wed, 1 May 2019 12:47:49 -0500 Subject: [PATCH 008/133] Wrap overlength line --- libraries/protocol/include/graphene/protocol/object_id.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/protocol/include/graphene/protocol/object_id.hpp b/libraries/protocol/include/graphene/protocol/object_id.hpp index 9bdfe550ea..4175a8ea75 100644 --- a/libraries/protocol/include/graphene/protocol/object_id.hpp +++ b/libraries/protocol/include/graphene/protocol/object_id.hpp @@ -98,7 +98,8 @@ namespace graphene { namespace db { #define MAP_OBJECT_ID_TO_TYPE(OBJECT) \ namespace graphene { namespace db { \ template<> \ - struct object_downcast> { using type = OBJECT; }; \ + struct object_downcast> { using type = OBJECT; }; \ } } template using object_downcast_t = typename object_downcast::type; From 683f5d58a96313a8f9703014709977fcabf1cbba Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Wed, 1 May 2019 12:50:00 -0500 Subject: [PATCH 009/133] Remove unused key types --- .../include/graphene/protocol/types.hpp | 48 ------- libraries/protocol/types.cpp | 128 ------------------ tests/tests/serialization_tests.cpp | 36 ----- 3 files changed, 212 deletions(-) diff --git a/libraries/protocol/include/graphene/protocol/types.hpp b/libraries/protocol/include/graphene/protocol/types.hpp index 429a5ed671..773d5dc75c 100644 --- a/libraries/protocol/include/graphene/protocol/types.hpp +++ b/libraries/protocol/include/graphene/protocol/types.hpp @@ -202,56 +202,12 @@ class pubkey_comparator { } }; -struct extended_public_key_type { - struct binary_key { - binary_key() = default; - 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() = default; - 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& p); - friend bool operator == (const extended_private_key_type& p1, const extended_private_key_type& p); - friend bool operator != (const extended_private_key_type& p1, const extended_private_key_type& p); -}; - 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); -void to_variant(const graphene::protocol::extended_public_key_type& var, fc::variant& vo, uint32_t max_depth = 2); -void from_variant(const fc::variant& var, graphene::protocol::extended_public_key_type& vo, uint32_t max_depth = 2); -void to_variant(const graphene::protocol::extended_private_key_type& var, fc::variant& vo, uint32_t max_depth = 2); -void from_variant(const fc::variant& var, graphene::protocol::extended_private_key_type& vo, uint32_t max_depth = 2); template<> @@ -304,10 +260,6 @@ FC_REFLECT_TYPENAME(graphene::protocol::htlc_id_type) FC_REFLECT(graphene::protocol::public_key_type, (key_data)) FC_REFLECT(graphene::protocol::public_key_type::binary_key, (data)(check)) -FC_REFLECT(graphene::protocol::extended_public_key_type, (key_data)) -FC_REFLECT(graphene::protocol::extended_public_key_type::binary_key, (check)(data)) -FC_REFLECT(graphene::protocol::extended_private_key_type, (key_data)) -FC_REFLECT(graphene::protocol::extended_private_key_type::binary_key, (check)(data)) FC_REFLECT_TYPENAME(graphene::protocol::share_type) FC_REFLECT(graphene::protocol::void_t,) diff --git a/libraries/protocol/types.cpp b/libraries/protocol/types.cpp index d3d6fd27d7..22a5ab33d7 100644 --- a/libraries/protocol/types.cpp +++ b/libraries/protocol/types.cpp @@ -88,114 +88,6 @@ namespace graphene { namespace protocol { 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() = default; - - 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::protocol namespace fc @@ -211,26 +103,6 @@ namespace fc vo = graphene::protocol::public_key_type( var.as_string() ); } - void to_variant( const graphene::protocol::extended_public_key_type& var, fc::variant& vo, uint32_t max_depth ) - { - vo = std::string( var ); - } - - void from_variant( const fc::variant& var, graphene::protocol::extended_public_key_type& vo, uint32_t max_depth ) - { - vo = graphene::protocol::extended_public_key_type( var.as_string() ); - } - - void to_variant( const graphene::protocol::extended_private_key_type& var, fc::variant& vo, uint32_t max_depth ) - { - vo = std::string( var ); - } - - void from_variant( const fc::variant& var, graphene::protocol::extended_private_key_type& vo, uint32_t max_depth ) - { - vo = graphene::protocol::extended_private_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 diff --git a/tests/tests/serialization_tests.cpp b/tests/tests/serialization_tests.cpp index 59e16f01e3..91085af454 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 From 1405345090a1e91adfb84d21fc34dd309fb3cd7b Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Wed, 1 May 2019 13:56:54 -0500 Subject: [PATCH 010/133] Probably fix Docker build --- .../chain/include/graphene/chain/withdraw_permission_object.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/chain/include/graphene/chain/withdraw_permission_object.hpp b/libraries/chain/include/graphene/chain/withdraw_permission_object.hpp index 2fe5a6c967..e035d99723 100644 --- a/libraries/chain/include/graphene/chain/withdraw_permission_object.hpp +++ b/libraries/chain/include/graphene/chain/withdraw_permission_object.hpp @@ -24,6 +24,7 @@ #pragma once #include #include +#include #include namespace graphene { namespace chain { From c2acd65b2a3186312ce16f58c2205cff81b4483b Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Wed, 1 May 2019 17:00:37 -0500 Subject: [PATCH 011/133] Fix unused variable warning This code hasn't been touched in a year... why am I only seeing this warning now?... :confused: --- tests/tests/fee_tests.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/tests/fee_tests.cpp b/tests/tests/fee_tests.cpp index ec783737a7..d266ccd7be 100644 --- a/tests/tests/fee_tests.cpp +++ b/tests/tests/fee_tests.cpp @@ -274,8 +274,6 @@ BOOST_AUTO_TEST_CASE(asset_claim_pool_test) }; - const asset_object& core_asset = asset_id_type()(db); - // deposit 100 BTS to the fee pool of ALICEUSD asset fund_fee_pool( alice_id(db), aliceusd_id(db), _core(100).amount ); From 1997b5ca05db5c229bf1f0690aa796badd261750 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Wed, 1 May 2019 17:04:29 -0500 Subject: [PATCH 012/133] Fix build after rebase --- libraries/app/include/graphene/app/full_account.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/app/include/graphene/app/full_account.hpp b/libraries/app/include/graphene/app/full_account.hpp index 990abafc87..6490acc773 100644 --- a/libraries/app/include/graphene/app/full_account.hpp +++ b/libraries/app/include/graphene/app/full_account.hpp @@ -29,6 +29,7 @@ #include #include #include +#include namespace graphene { namespace app { using namespace graphene::chain; From 967b5ddc5a781bdfc5983ef870134c9db0eccc9e Mon Sep 17 00:00:00 2001 From: Eric Frias Date: Thu, 2 May 2019 14:36:56 -0400 Subject: [PATCH 013/133] Support compiling with C++17/C++2a Bitshares used 'using namespace std' in several places, and this caused conflicts between fc::variant and the new std::variant. Fixed by just importing the specific identifiers we use from namespace std. --- CMakeLists.txt | 8 ++++++-- libraries/app/api.cpp | 2 +- libraries/app/include/graphene/app/api.hpp | 4 +++- libraries/app/include/graphene/app/database_api.hpp | 4 +++- libraries/wallet/include/graphene/wallet/wallet.hpp | 3 ++- libraries/wallet/wallet.cpp | 10 ++++++++++ tests/cli/main.cpp | 3 +++ 7 files changed, 28 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 339381b9ea..fe87e980a2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,6 +68,10 @@ IF(NOT "${Boost_VERSION}" MATCHES "1.53(.*)") SET(Boost_LIBRARIES ${BOOST_LIBRARIES_TEMP} ${Boost_LIBRARIES}) ENDIF() +if( NOT CPP_STANDARD ) + set( CPP_STANDARD "-std=c++11" ) +endif() + if( WIN32 ) message( STATUS "Configuring BitShares on WIN32") @@ -109,11 +113,11 @@ else( WIN32 ) # Apple AND Linux if( APPLE ) # Apple Specific Options Here message( STATUS "Configuring BitShares on OS X" ) - set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -std=c++11 -stdlib=libc++ -Wall" ) + set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${CPP_STANDARD} -stdlib=libc++ -Wall" ) else( APPLE ) # Linux Specific Options Here message( STATUS "Configuring BitShares on Linux" ) - set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -std=c++11 -Wall" ) + set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${CPP_STANDARD} -Wall" ) if(USE_PROFILER) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg" ) endif( USE_PROFILER ) diff --git a/libraries/app/api.cpp b/libraries/app/api.cpp index c2631b1293..7dce83bf1c 100644 --- a/libraries/app/api.cpp +++ b/libraries/app/api.cpp @@ -405,7 +405,7 @@ namespace graphene { namespace app { if( start == 0 ) start = stats.total_ops; else - start = min( stats.total_ops, start ); + start = std::min( stats.total_ops, start ); if( start >= stop && start > stats.removed_ops && limit > 0 ) { diff --git a/libraries/app/include/graphene/app/api.hpp b/libraries/app/include/graphene/app/api.hpp index 484cde78c5..836aba728a 100644 --- a/libraries/app/include/graphene/app/api.hpp +++ b/libraries/app/include/graphene/app/api.hpp @@ -53,7 +53,9 @@ namespace graphene { namespace app { using namespace graphene::market_history; using namespace graphene::grouped_orders; using namespace fc::ecc; - using namespace std; + using std::string; + using std::vector; + using std::map; class application; diff --git a/libraries/app/include/graphene/app/database_api.hpp b/libraries/app/include/graphene/app/database_api.hpp index b5ecbf4625..3efd91fc63 100644 --- a/libraries/app/include/graphene/app/database_api.hpp +++ b/libraries/app/include/graphene/app/database_api.hpp @@ -61,7 +61,9 @@ namespace graphene { namespace app { using namespace graphene::chain; using namespace graphene::market_history; -using namespace std; +using std::string; +using std::vector; +using std::map; class database_api_impl; diff --git a/libraries/wallet/include/graphene/wallet/wallet.hpp b/libraries/wallet/include/graphene/wallet/wallet.hpp index c3690a91be..f67f5caef5 100644 --- a/libraries/wallet/include/graphene/wallet/wallet.hpp +++ b/libraries/wallet/include/graphene/wallet/wallet.hpp @@ -31,7 +31,8 @@ using namespace graphene::app; using namespace graphene::chain; using namespace graphene::utilities; -using namespace std; +using std::string; +using std::vector; namespace fc { diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 11eb4fe023..6f47a7edf4 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -94,6 +94,16 @@ namespace fc { namespace graphene { namespace wallet { +using std::ostream; +using std::stringstream; +using std::to_string; +using std::setprecision; +using std::fixed; +using std::ios; +using std::setiosflags; +using std::setw; +using std::endl; + namespace detail { struct operation_result_printer diff --git a/tests/cli/main.cpp b/tests/cli/main.cpp index 5163703325..a31053753d 100644 --- a/tests/cli/main.cpp +++ b/tests/cli/main.cpp @@ -80,6 +80,9 @@ int sockQuit(void) #include "../common/genesis_file_util.hpp" +using std::exception; +using std::cerr; + #define INVOKE(test) ((struct test*)this)->test_method(); ////// From 59f608950d52148c40c0cb3e85d9aabe6cb05aac Mon Sep 17 00:00:00 2001 From: Alfredo Date: Fri, 3 May 2019 18:01:01 -0300 Subject: [PATCH 014/133] fix indentation in asset_api --- libraries/app/api.cpp | 96 +++++++++++++++++++++---------------------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/libraries/app/api.cpp b/libraries/app/api.cpp index c2631b1293..ed36db1ddc 100644 --- a/libraries/app/api.cpp +++ b/libraries/app/api.cpp @@ -534,79 +534,79 @@ namespace graphene { namespace app { // asset_api asset_api::asset_api(graphene::app::application& app) : - _app(app), - _db( *app.chain_database()), - database_api( std::ref(*app.chain_database()), &(app.get_options()) - ) { } + _app(app), + _db( *app.chain_database()), + database_api( std::ref(*app.chain_database()), &(app.get_options()) + ) { } asset_api::~asset_api() { } vector asset_api::get_asset_holders( std::string asset, uint32_t start, uint32_t limit ) const { - uint64_t api_limit_get_asset_holders=_app.get_options().api_limit_get_asset_holders; - FC_ASSERT(limit <= api_limit_get_asset_holders); - asset_id_type asset_id = database_api.get_asset_id_from_string( asset ); - const auto& bal_idx = _db.get_index_type< account_balance_index >().indices().get< by_asset_balance >(); - auto range = bal_idx.equal_range( boost::make_tuple( asset_id ) ); + uint64_t api_limit_get_asset_holders=_app.get_options().api_limit_get_asset_holders; + FC_ASSERT(limit <= api_limit_get_asset_holders); + asset_id_type asset_id = database_api.get_asset_id_from_string( asset ); + const auto& bal_idx = _db.get_index_type< account_balance_index >().indices().get< by_asset_balance >(); + auto range = bal_idx.equal_range( boost::make_tuple( asset_id ) ); - vector result; + vector result; - uint32_t index = 0; - for( const account_balance_object& bal : boost::make_iterator_range( range.first, range.second ) ) - { - if( result.size() >= limit ) - break; + uint32_t index = 0; + for( const account_balance_object& bal : boost::make_iterator_range( range.first, range.second ) ) + { + if( result.size() >= limit ) + break; - if( bal.balance.value == 0 ) - continue; + if( bal.balance.value == 0 ) + continue; - if( index++ < start ) - continue; + if( index++ < start ) + continue; - const auto account = _db.find(bal.owner); + const auto account = _db.find(bal.owner); - account_asset_balance aab; - aab.name = account->name; - aab.account_id = account->id; - aab.amount = bal.balance.value; + account_asset_balance aab; + aab.name = account->name; + aab.account_id = account->id; + aab.amount = bal.balance.value; - result.push_back(aab); - } + result.push_back(aab); + } - return result; + return result; } // get number of asset holders. int asset_api::get_asset_holders_count( std::string asset ) const { - const auto& bal_idx = _db.get_index_type< account_balance_index >().indices().get< by_asset_balance >(); - asset_id_type asset_id = database_api.get_asset_id_from_string( asset ); - auto range = bal_idx.equal_range( boost::make_tuple( asset_id ) ); + const auto& bal_idx = _db.get_index_type< account_balance_index >().indices().get< by_asset_balance >(); + asset_id_type asset_id = database_api.get_asset_id_from_string( asset ); + auto range = bal_idx.equal_range( boost::make_tuple( asset_id ) ); - int count = boost::distance(range) - 1; + int count = boost::distance(range) - 1; - return count; + return count; } // function to get vector of system assets with holders count. vector asset_api::get_all_asset_holders() const { - vector result; - vector total_assets; - for( const asset_object& asset_obj : _db.get_index_type().indices() ) - { - const auto& dasset_obj = asset_obj.dynamic_asset_data_id(_db); + vector result; + vector total_assets; + for( const asset_object& asset_obj : _db.get_index_type().indices() ) + { + const auto& dasset_obj = asset_obj.dynamic_asset_data_id(_db); - asset_id_type asset_id; - asset_id = dasset_obj.id; + asset_id_type asset_id; + asset_id = dasset_obj.id; - const auto& bal_idx = _db.get_index_type< account_balance_index >().indices().get< by_asset_balance >(); - auto range = bal_idx.equal_range( boost::make_tuple( asset_id ) ); + const auto& bal_idx = _db.get_index_type< account_balance_index >().indices().get< by_asset_balance >(); + auto range = bal_idx.equal_range( boost::make_tuple( asset_id ) ); - int count = boost::distance(range) - 1; + int count = boost::distance(range) - 1; - asset_holders ah; - ah.asset_id = asset_id; - ah.count = count; + asset_holders ah; + ah.asset_id = asset_id; + ah.count = count; - result.push_back(ah); - } + result.push_back(ah); + } - return result; + return result; } // orders_api From d6a4c173da9f8e96592ea4b10a441950a25d38e5 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Fri, 3 May 2019 22:07:18 -0500 Subject: [PATCH 015/133] Ref #1506: Bumb DB_VERSION --- libraries/chain/include/graphene/chain/config.hpp | 2 +- libraries/protocol/include/graphene/protocol/fba.hpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/chain/include/graphene/chain/config.hpp b/libraries/chain/include/graphene/chain/config.hpp index 0dc3f8d388..0881fc8889 100644 --- a/libraries/chain/include/graphene/chain/config.hpp +++ b/libraries/chain/include/graphene/chain/config.hpp @@ -30,7 +30,7 @@ #define GRAPHENE_MAX_NESTED_OBJECTS (200) -#define GRAPHENE_CURRENT_DB_VERSION "20190423" +#define GRAPHENE_CURRENT_DB_VERSION "20190503" /** * every second, the fraction of burned core asset which cycles is diff --git a/libraries/protocol/include/graphene/protocol/fba.hpp b/libraries/protocol/include/graphene/protocol/fba.hpp index 944b1c188b..7b95294049 100644 --- a/libraries/protocol/include/graphene/protocol/fba.hpp +++ b/libraries/protocol/include/graphene/protocol/fba.hpp @@ -32,6 +32,7 @@ struct fba_distribute_operation : public base_operation asset fee; // always zero account_id_type account_id; + // We use object_id_type because this is an implementaton object, and therefore is not known to the protocol library object_id_type fba_id; share_type amount; From 29d4dde8717a3065aff87b423ce4bbfb2bebe35e Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Sat, 4 May 2019 12:33:25 -0500 Subject: [PATCH 016/133] Ref #1506/#1737: Some requested changes --- libraries/chain/CMakeLists.txt | 2 +- libraries/chain/account_evaluator.cpp | 2 +- libraries/chain/evaluator.cpp | 2 +- libraries/chain/get_config.cpp | 1 - libraries/chain/include/graphene/chain/config.hpp | 7 ------- ...ial_authority.hpp => special_authority_evaluation.hpp} | 0 ...ial_authority.cpp => special_authority_evaluation.cpp} | 2 +- libraries/protocol/include/graphene/protocol/config.hpp | 8 +++++++- libraries/wallet/wallet.cpp | 1 - 9 files changed, 11 insertions(+), 14 deletions(-) rename libraries/chain/include/graphene/chain/{special_authority.hpp => special_authority_evaluation.hpp} (100%) rename libraries/chain/{special_authority.cpp => special_authority_evaluation.cpp} (96%) diff --git a/libraries/chain/CMakeLists.txt b/libraries/chain/CMakeLists.txt index fb7f586c60..dbe71f9ce9 100644 --- a/libraries/chain/CMakeLists.txt +++ b/libraries/chain/CMakeLists.txt @@ -53,7 +53,7 @@ add_library( graphene_chain worker_evaluator.cpp htlc_evaluator.cpp confidential_evaluator.cpp - special_authority.cpp + special_authority_evaluation.cpp buyback.cpp account_object.cpp diff --git a/libraries/chain/account_evaluator.cpp b/libraries/chain/account_evaluator.cpp index 386f6b317d..674de46c43 100644 --- a/libraries/chain/account_evaluator.cpp +++ b/libraries/chain/account_evaluator.cpp @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/libraries/chain/evaluator.cpp b/libraries/chain/evaluator.cpp index 97d2767dc9..482d9a01e0 100644 --- a/libraries/chain/evaluator.cpp +++ b/libraries/chain/evaluator.cpp @@ -58,7 +58,7 @@ database& generic_evaluator::db()const { return trx_state->db(); } fee_paying_account = &account_id(d); fee_paying_account_statistics = &fee_paying_account->statistics(d); - fee_asset = &asset_id_type(fee.asset_id)(d); + fee_asset = &fee.asset_id(d); fee_asset_dyn_data = &fee_asset->dynamic_asset_data_id(d); FC_ASSERT( is_authorized_asset( d, *fee_paying_account, *fee_asset ), diff --git a/libraries/chain/get_config.cpp b/libraries/chain/get_config.cpp index d1e791fcf0..48c781f638 100644 --- a/libraries/chain/get_config.cpp +++ b/libraries/chain/get_config.cpp @@ -69,7 +69,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/config.hpp b/libraries/chain/include/graphene/chain/config.hpp index 0881fc8889..46a8feb54e 100644 --- a/libraries/chain/include/graphene/chain/config.hpp +++ b/libraries/chain/include/graphene/chain/config.hpp @@ -32,13 +32,6 @@ #define GRAPHENE_CURRENT_DB_VERSION "20190503" -/** - * 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_RECENTLY_MISSED_COUNT_INCREMENT 4 #define GRAPHENE_RECENTLY_MISSED_COUNT_DECREMENT 3 diff --git a/libraries/chain/include/graphene/chain/special_authority.hpp b/libraries/chain/include/graphene/chain/special_authority_evaluation.hpp similarity index 100% rename from libraries/chain/include/graphene/chain/special_authority.hpp rename to libraries/chain/include/graphene/chain/special_authority_evaluation.hpp diff --git a/libraries/chain/special_authority.cpp b/libraries/chain/special_authority_evaluation.cpp similarity index 96% rename from libraries/chain/special_authority.cpp rename to libraries/chain/special_authority_evaluation.cpp index 7936af3098..2fbc32529d 100644 --- a/libraries/chain/special_authority.cpp +++ b/libraries/chain/special_authority_evaluation.cpp @@ -22,7 +22,7 @@ * THE SOFTWARE. */ -#include +#include #include namespace graphene { namespace chain { diff --git a/libraries/protocol/include/graphene/protocol/config.hpp b/libraries/protocol/include/graphene/protocol/config.hpp index 6f1f6da431..8ea4bcc56b 100644 --- a/libraries/protocol/include/graphene/protocol/config.hpp +++ b/libraries/protocol/include/graphene/protocol/config.hpp @@ -44,6 +44,13 @@ #define GRAPHENE_IRREVERSIBLE_THRESHOLD (70 * GRAPHENE_1_PERCENT) +/** + * 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 + /** * Don't allow the committee_members to publish a limit that would * make the network unable to operate. @@ -109,7 +116,6 @@ #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) /** * Reserved Account IDs with special meaning diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 8a8b58d875..e25e707f51 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -66,7 +66,6 @@ #include #include #include -#include #include #include #include From 4bd61abf5ccebdda4577934c95cd673ceab4c4ae Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Sat, 4 May 2019 16:14:01 -0500 Subject: [PATCH 017/133] Ref #1506/#1737: Macro-fy ID type definitions Define macros to fully de-boilerplate ID type definitions. Externalities: - Rename transaction_object -> transaction_history_object - Rename impl_asset_dynamic_data_type -> impl_asset_dynamic_data_object_type - Rename impl_asset_bitasset_data_type -> impl_asset_bitasset_data_object_type The first is to avoid a naming collision on transaction_id_type, and the other two are to maintain consistency with the naming of the other types. --- libraries/app/api.cpp | 2 +- libraries/chain/db_block.cpp | 4 +- libraries/chain/db_init.cpp | 6 +- libraries/chain/db_notify.cpp | 11 +- libraries/chain/db_update.cpp | 5 +- .../include/graphene/chain/asset_object.hpp | 4 +- ...ect.hpp => transaction_history_object.hpp} | 22 +-- .../chain/include/graphene/chain/types.hpp | 100 +++----------- .../include/graphene/protocol/types.hpp | 127 +++++++----------- 9 files changed, 97 insertions(+), 184 deletions(-) rename libraries/chain/include/graphene/chain/{transaction_object.hpp => transaction_history_object.hpp} (70%) diff --git a/libraries/app/api.cpp b/libraries/app/api.cpp index 94701fdeca..aa2bcf49f0 100644 --- a/libraries/app/api.cpp +++ b/libraries/app/api.cpp @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include #include diff --git a/libraries/chain/db_block.cpp b/libraries/chain/db_block.cpp index b840c2d217..f0331c85f3 100644 --- a/libraries/chain/db_block.cpp +++ b/libraries/chain/db_block.cpp @@ -31,7 +31,7 @@ #include #include -#include +#include #include #include #include @@ -678,7 +678,7 @@ processed_transaction database::_apply_transaction(const signed_transaction& trx //Insert transaction into unique transactions database. if( !(skip & skip_transaction_dupe_check) ) { - create([&trx](transaction_object& transaction) { + create([&trx](transaction_history_object& transaction) { transaction.trx_id = trx.id(); transaction.trx = trx; }); diff --git a/libraries/chain/db_init.cpp b/libraries/chain/db_init.cpp index 52741fb9f3..3d0aaf8c04 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 @@ -110,8 +110,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; diff --git a/libraries/chain/db_notify.cpp b/libraries/chain/db_notify.cpp index eef3a3fcbe..d17bec6821 100644 --- a/libraries/chain/db_notify.cpp +++ b/libraries/chain/db_notify.cpp @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include using namespace fc; @@ -303,7 +303,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 ); @@ -388,9 +387,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); @@ -402,8 +401,8 @@ void get_relevant_accounts( const object* obj, flat_set& accoun FC_ASSERT( aobj != nullptr ); accounts.insert( aobj->owner ); break; - } case impl_transaction_object_type:{ - const auto& aobj = dynamic_cast(obj); + } case impl_transaction_history_object_type:{ + const auto& aobj = dynamic_cast(obj); FC_ASSERT( aobj != nullptr ); transaction_get_impacted_accounts( aobj->trx, accounts ); break; diff --git a/libraries/chain/db_update.cpp b/libraries/chain/db_update.cpp index d0d98337c5..cf767b5d89 100644 --- a/libraries/chain/db_update.cpp +++ b/libraries/chain/db_update.cpp @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include @@ -145,7 +145,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()); diff --git a/libraries/chain/include/graphene/chain/asset_object.hpp b/libraries/chain/include/graphene/chain/asset_object.hpp index 345cca188b..3bd68a8e53 100644 --- a/libraries/chain/include/graphene/chain/asset_object.hpp +++ b/libraries/chain/include/graphene/chain/asset_object.hpp @@ -59,7 +59,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; @@ -176,7 +176,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; diff --git a/libraries/chain/include/graphene/chain/transaction_object.hpp b/libraries/chain/include/graphene/chain/transaction_history_object.hpp similarity index 70% rename from libraries/chain/include/graphene/chain/transaction_object.hpp rename to libraries/chain/include/graphene/chain/transaction_history_object.hpp index 89faa451bd..3a25f4bfc9 100644 --- a/libraries/chain/include/graphene/chain/transaction_object.hpp +++ b/libraries/chain/include/graphene/chain/transaction_history_object.hpp @@ -41,14 +41,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; @@ -59,17 +59,19 @@ namespace graphene { namespace chain { struct by_expiration; 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; } } -MAP_OBJECT_ID_TO_TYPE(graphene::chain::transaction_object) +MAP_OBJECT_ID_TO_TYPE(graphene::chain::transaction_history_object) -FC_REFLECT_DERIVED( graphene::chain::transaction_object, (graphene::db::object), (trx)(trx_id) ) +FC_REFLECT_DERIVED( graphene::chain::transaction_history_object, (graphene::db::object), (trx)(trx_id) ) diff --git a/libraries/chain/include/graphene/chain/types.hpp b/libraries/chain/include/graphene/chain/types.hpp index c84608a282..ec3e788219 100644 --- a/libraries/chain/include/graphene/chain/types.hpp +++ b/libraries/chain/include/graphene/chain/types.hpp @@ -25,82 +25,24 @@ #include -namespace graphene { namespace chain { - -using namespace graphene::protocol; - -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_collateral_bid_object_type -}; - -using global_property_id_type = object_id; -using dynamic_global_property_id_type = object_id; -using asset_dynamic_data_id_type = object_id; -using asset_bitasset_data_id_type = object_id; -using account_balance_id_type = object_id; -using account_statistics_id_type = object_id; -using transaction_obj_id_type = object_id; -using block_summary_id_type = object_id; -using account_transaction_history_id_type = object_id; -using chain_property_id_type = object_id; -using witness_schedule_id_type = object_id; -using budget_record_id_type = object_id; -using blinded_balance_id_type = object_id; -using special_authority_id_type = object_id; -using buyback_id_type = object_id; -using fba_accumulator_id_type = object_id; -using collateral_bid_id_type = object_id; - -} } - -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_collateral_bid_object_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::collateral_bid_id_type) +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) + (collateral_bid)) diff --git a/libraries/protocol/include/graphene/protocol/types.hpp b/libraries/protocol/include/graphene/protocol/types.hpp index 773d5dc75c..ca8f5d9cdc 100644 --- a/libraries/protocol/include/graphene/protocol/types.hpp +++ b/libraries/protocol/include/graphene/protocol/types.hpp @@ -22,6 +22,14 @@ * THE SOFTWARE. */ #pragma once + +#include +#include +#include +#include +#include +#include + #include #include #include @@ -51,6 +59,28 @@ #include +#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; @@ -124,50 +154,6 @@ enum reserved_spaces { 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, - htlc_object_type, - OBJECT_TYPE_COUNT ///< Sentry value which contains the number of different object types -}; - -using account_id_type = object_id; -using asset_id_type = object_id; -using force_settlement_id_type = object_id; -using committee_member_id_type = object_id; -using witness_id_type = object_id; -using limit_order_id_type = object_id; -using call_order_id_type = object_id; -using custom_id_type = object_id; -using proposal_id_type = object_id; -using operation_history_id_type = object_id; -using withdraw_permission_id_type = object_id; -using vesting_balance_id_type = object_id; -using worker_id_type = object_id; -using balance_id_type = object_id; -using htlc_id_type = object_id; - using block_id_type = fc::ripemd160; using checksum_type = fc::ripemd160; using transaction_id_type = fc::ripemd160; @@ -222,41 +208,24 @@ void from_variant( const fc::variant& var, std::shared_ptr Date: Sat, 4 May 2019 19:11:53 -0300 Subject: [PATCH 018/133] add by_authorized withdraw objects to get_full_accounts results --- libraries/app/database_api.cpp | 17 ++++++++++++----- .../chain/withdraw_permission_object.hpp | 2 ++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 8227fa9f4a..cc81c7a41b 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -968,11 +968,18 @@ std::map database_api_impl::get_full_accounts( const }); // get withdraws permissions - auto withdraw_range = _db.get_index_type().indices().get().equal_range(account->id); - std::for_each(withdraw_range.first, withdraw_range.second, - [&acnt] (const withdraw_permission_object& withdraw) { - acnt.withdraws.emplace_back(withdraw); - }); + auto withdraw_indices = _db.get_index_type().indices(); + auto withdraw_from_range = withdraw_indices.get().equal_range(account->id); + std::for_each(withdraw_from_range.first, withdraw_from_range.second, + [&acnt] (const withdraw_permission_object& withdraw) { + acnt.withdraws.emplace_back(withdraw); + }); + auto withdraw_authorized_range = withdraw_indices.get().equal_range(account->id); + std::for_each(withdraw_authorized_range.first, withdraw_authorized_range.second, + [&acnt] (const withdraw_permission_object& withdraw) { + if ( std::find(acnt.withdraws.begin(), acnt.withdraws.end(), withdraw) == acnt.withdraws.end() ) + acnt.withdraws.emplace_back(withdraw); + }); // get htlcs auto htlc_from_range = _db.get_index_type().indices().get().equal_range(account->id); diff --git a/libraries/chain/include/graphene/chain/withdraw_permission_object.hpp b/libraries/chain/include/graphene/chain/withdraw_permission_object.hpp index f202ee1b66..adc3a73a28 100644 --- a/libraries/chain/include/graphene/chain/withdraw_permission_object.hpp +++ b/libraries/chain/include/graphene/chain/withdraw_permission_object.hpp @@ -77,6 +77,8 @@ namespace graphene { namespace chain { ? withdrawal_limit.amount - claimed_this_period : 0, withdrawal_limit.asset_id ); } + + bool operator==(const withdraw_permission_object& in) { return this->id == in.id; } }; struct by_from; From 22bc1e260d97ab094b3700f0ce856e14436b2587 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Sat, 4 May 2019 18:20:13 -0500 Subject: [PATCH 019/133] Ref #1506/#1737: Fix clean_name() --- libraries/wallet/include/graphene/wallet/reflect_util.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/wallet/include/graphene/wallet/reflect_util.hpp b/libraries/wallet/include/graphene/wallet/reflect_util.hpp index 7a9e6e0812..c037f20722 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 ) From 2c6af3ff04ee3dcf183805568c356383b604e723 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Sat, 4 May 2019 19:17:46 -0500 Subject: [PATCH 020/133] Ref #1506/#1737: Oops --- libraries/protocol/include/graphene/protocol/types.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/protocol/include/graphene/protocol/types.hpp b/libraries/protocol/include/graphene/protocol/types.hpp index ca8f5d9cdc..131956a715 100644 --- a/libraries/protocol/include/graphene/protocol/types.hpp +++ b/libraries/protocol/include/graphene/protocol/types.hpp @@ -212,8 +212,8 @@ GRAPHENE_DEFINE_IDS(protocol, protocol_ids, /*protocol objects are not prefixed* (null) (base) (account) - (force_settlement) (asset) + (force_settlement) (committee_member) (witness) (limit_order) From 25e168e652879f25e7dde3d847add4fa4e32a44a Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Mon, 6 May 2019 11:34:44 -0500 Subject: [PATCH 021/133] Fix .gitignore --- .gitignore | 2 -- 1 file changed, 2 deletions(-) diff --git a/.gitignore b/.gitignore index d8f84ca0a8..7b1936ffd0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,3 @@ -build*/ - *.a *.sw* From cab48aef565104688d04a0810a4907b38473b3b3 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Mon, 6 May 2019 16:38:37 -0300 Subject: [PATCH 022/133] add api-limit-get-full-accounts to application, complete implementation of api-limit-get-htlc-by --- libraries/app/application.cpp | 7 +++++++ libraries/app/include/graphene/app/application.hpp | 1 + 2 files changed, 8 insertions(+) diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index 8f089c0b0b..85cbad4f93 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -343,6 +343,9 @@ void application_impl::set_api_limit() { if(_options->count("api-limit-get-htlc-by")) { _app_options.api_limit_get_htlc_by = _options->at("api-limit-get-htlc-by").as(); } + if(_options->count("api-limit-get-full-accounts")) { + _app_options.api_limit_get_full_accounts = _options->at("api-limit-get-full-accounts").as(); + } } void application_impl::startup() @@ -1020,6 +1023,10 @@ void application::set_program_options(boost::program_options::options_descriptio "For asset_api::get_asset_holders to set its default limit value as 100") ("api-limit-get-key-references",boost::program_options::value()->default_value(100), "For database_api_impl::get_key_references to set its default limit value as 100") + ("api-limit-get-htlc-by",boost::program_options::value()->default_value(100), + "For database_api_impl::get_htlc_by_from and get_htlc_by_to to set its default limit value as 100") + ("api-limit-get-full-accounts",boost::program_options::value()->default_value(100), + "For database_api_impl::get_full_accounts to set its lists default limit values as 100") ; command_line_options.add(configuration_file_options); command_line_options.add_options() diff --git a/libraries/app/include/graphene/app/application.hpp b/libraries/app/include/graphene/app/application.hpp index 226fc0053f..6fa094760d 100644 --- a/libraries/app/include/graphene/app/application.hpp +++ b/libraries/app/include/graphene/app/application.hpp @@ -48,6 +48,7 @@ namespace graphene { namespace app { uint64_t api_limit_get_asset_holders = 100; uint64_t api_limit_get_key_references = 100; uint64_t api_limit_get_htlc_by = 100; + uint64_t api_limit_get_full_accounts = 100; }; class application From ee0df87ec8bca801a1361990e3e3f1e456e42349 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Mon, 6 May 2019 18:37:42 -0300 Subject: [PATCH 023/133] add configurable limits to get_full_account lists --- libraries/app/database_api.cpp | 70 ++++++++++++++++++++++------------ 1 file changed, 45 insertions(+), 25 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index cc81c7a41b..0dafb0d640 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -921,78 +921,98 @@ std::map database_api_impl::get_full_accounts( const { acnt.cashback_balance = account->cashback_balance(_db); } + + uint64_t api_limit_get_full_accounts = _app_options->api_limit_get_full_accounts; + // Add the account's proposals auto required_approvals_itr = proposals_by_account._account_to_proposals.find( account->id ); if( required_approvals_itr != proposals_by_account._account_to_proposals.end() ) { - acnt.proposals.reserve( required_approvals_itr->second.size() ); + acnt.proposals.reserve( std::min(required_approvals_itr->second.size(), api_limit_get_full_accounts) ); for( auto proposal_id : required_approvals_itr->second ) + { acnt.proposals.push_back( proposal_id(_db) ); + if(acnt.proposals.size() >= api_limit_get_full_accounts) + break; + } } - // Add the account's balances const auto& balances = _db.get_index_type< primary_index< account_balance_index > >().get_secondary_index< balances_by_account_index >().get_account_balances( account->id ); for( const auto balance : balances ) + { acnt.balances.emplace_back( *balance.second ); + if(acnt.balances.size() >= api_limit_get_full_accounts) + break; + } // Add the account's vesting balances auto vesting_range = _db.get_index_type().indices().get().equal_range(account->id); std::for_each(vesting_range.first, vesting_range.second, - [&acnt](const vesting_balance_object& balance) { - acnt.vesting_balances.emplace_back(balance); - }); + [&acnt, api_limit_get_full_accounts](const vesting_balance_object& balance) { + if(acnt.vesting_balances.size() < api_limit_get_full_accounts) + acnt.vesting_balances.emplace_back(balance); + }); // Add the account's orders auto order_range = _db.get_index_type().indices().get().equal_range(account->id); std::for_each(order_range.first, order_range.second, - [&acnt] (const limit_order_object& order) { - acnt.limit_orders.emplace_back(order); - }); + [&acnt, api_limit_get_full_accounts] (const limit_order_object& order) { + if(acnt.limit_orders.size() < api_limit_get_full_accounts) + acnt.limit_orders.emplace_back(order); + }); auto call_range = _db.get_index_type().indices().get().equal_range(account->id); std::for_each(call_range.first, call_range.second, - [&acnt] (const call_order_object& call) { - acnt.call_orders.emplace_back(call); - }); + [&acnt, api_limit_get_full_accounts] (const call_order_object& call) { + if(acnt.call_orders.size() < api_limit_get_full_accounts) + acnt.call_orders.emplace_back(call); + }); auto settle_range = _db.get_index_type().indices().get().equal_range(account->id); std::for_each(settle_range.first, settle_range.second, - [&acnt] (const force_settlement_object& settle) { - acnt.settle_orders.emplace_back(settle); - }); + [&acnt, api_limit_get_full_accounts] (const force_settlement_object& settle) { + if(acnt.settle_orders.size() < api_limit_get_full_accounts) + acnt.settle_orders.emplace_back(settle); + }); // get assets issued by user auto asset_range = _db.get_index_type().indices().get().equal_range(account->id); std::for_each(asset_range.first, asset_range.second, - [&acnt] (const asset_object& asset) { - acnt.assets.emplace_back(asset.id); - }); + [&acnt, api_limit_get_full_accounts] (const asset_object& asset) { + if(acnt.assets.size() < api_limit_get_full_accounts) + acnt.assets.emplace_back(asset.id); + }); // get withdraws permissions auto withdraw_indices = _db.get_index_type().indices(); auto withdraw_from_range = withdraw_indices.get().equal_range(account->id); std::for_each(withdraw_from_range.first, withdraw_from_range.second, - [&acnt] (const withdraw_permission_object& withdraw) { - acnt.withdraws.emplace_back(withdraw); + [&acnt, api_limit_get_full_accounts] (const withdraw_permission_object& withdraw) { + if(acnt.withdraws.size() < api_limit_get_full_accounts) + acnt.withdraws.emplace_back(withdraw); }); auto withdraw_authorized_range = withdraw_indices.get().equal_range(account->id); std::for_each(withdraw_authorized_range.first, withdraw_authorized_range.second, - [&acnt] (const withdraw_permission_object& withdraw) { - if ( std::find(acnt.withdraws.begin(), acnt.withdraws.end(), withdraw) == acnt.withdraws.end() ) + [&acnt, api_limit_get_full_accounts] (const withdraw_permission_object& withdraw) { + if((std::find(acnt.withdraws.begin(), acnt.withdraws.end(), withdraw) == acnt.withdraws.end()) or + (acnt.withdraws.size() < api_limit_get_full_accounts)) acnt.withdraws.emplace_back(withdraw); }); // get htlcs auto htlc_from_range = _db.get_index_type().indices().get().equal_range(account->id); std::for_each(htlc_from_range.first, htlc_from_range.second, - [&acnt] (const htlc_object& htlc) { - acnt.htlcs.emplace_back(htlc); + [&acnt, api_limit_get_full_accounts] (const htlc_object& htlc) { + if(acnt.htlcs.size() < api_limit_get_full_accounts) + acnt.htlcs.emplace_back(htlc); }); auto htlc_to_range = _db.get_index_type().indices().get().equal_range(account->id); std::for_each(htlc_to_range.first, htlc_to_range.second, - [&acnt] (const htlc_object& htlc) { - if ( std::find(acnt.htlcs.begin(), acnt.htlcs.end(), htlc) == acnt.htlcs.end() ) + [&acnt, api_limit_get_full_accounts] (const htlc_object& htlc) { + if ((std::find(acnt.htlcs.begin(), acnt.htlcs.end(), htlc) == acnt.htlcs.end()) or + (acnt.htlcs.size() < api_limit_get_full_accounts)) acnt.htlcs.emplace_back(htlc); }); + results[account_name_or_id] = acnt; } return results; From 851a97e598a323f06995a420f511e1f355cd1cd6 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Mon, 6 May 2019 15:42:21 +0200 Subject: [PATCH 024/133] Fix sonar detection, dont let sonar fail the build, fix target branch detection --- .travis.yml | 17 +++-- programs/build_helpers/set_sonar_branch | 82 +++++++++++++++++++++++++ sonar-project.properties | 3 + 3 files changed, 92 insertions(+), 10 deletions(-) create mode 100755 programs/build_helpers/set_sonar_branch diff --git a/.travis.yml b/.travis.yml index 76424128a0..77e0407a33 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,17 +29,14 @@ script: - ccache -s - programs/build_helpers/buildstep Prepare 1 "sed -i '/tests/d' libraries/fc/CMakeLists.txt" - programs/build_helpers/buildstep cmake 5 "cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=--coverage -DCMAKE_CXX_FLAGS=--coverage -DBoost_USE_STATIC_LIBS=OFF -DCMAKE_CXX_OUTPUT_EXTENSION_REPLACE=ON ." - - programs/build_helpers/buildstep make.cli_wallet 1600 "programs/build_helpers/make_with_sonar bw-output -j 2 cli_wallet" - - programs/build_helpers/buildstep make.witness_node 300 "programs/build_helpers/make_with_sonar bw-output -j 2 witness_node" - - programs/build_helpers/buildstep make.serializer 45 "programs/build_helpers/make_with_sonar bw-output -j 2 js_operation_serializer" - - programs/build_helpers/buildstep make.get_dev_key 10 "programs/build_helpers/make_with_sonar bw-output -j 2 get_dev_key" - - programs/build_helpers/buildstep make.chain_test 900 "programs/build_helpers/make_with_sonar bw-output -j 2 chain_test" - - programs/build_helpers/buildstep make.cli_test 200 "programs/build_helpers/make_with_sonar bw-output -j 2 cli_test" - - programs/build_helpers/buildstep make.perf_test 120 "programs/build_helpers/make_with_sonar bw-output -j 2 performance_test" + - programs/build_helpers/buildstep make.cli_wallet 2200 "programs/build_helpers/make_with_sonar bw-output -j 2 cli_wallet witness_node js_operation_serializer get_dev_key network_mapper" + - programs/build_helpers/buildstep make.chain_test 1000 "make -j 2 chain_test" + - programs/build_helpers/buildstep make.cli_test 200 "make -j 2 cli_test" + - programs/build_helpers/buildstep make.perf_test 120 "make -j 2 performance_test" - set -o pipefail - programs/build_helpers/buildstep run.chain_test 240 "libraries/fc/tests/run-parallel-tests.sh tests/chain_test" - - programs/build_helpers/buildstep run.cli_test 30 "libraries/fc/tests/run-parallel-tests.sh tests/cli_test" - - programs/build_helpers/buildstep prepare.sonar 20 'find libraries/[acdenptuw]*/CMakeFiles/*.dir programs/[cdgjsw]*/CMakeFiles/*.dir -type d | while read d; do gcov -o "$d" "${d/CMakeFiles*.dir//}"/*.cpp; done >/dev/null' - - programs/build_helpers/buildstep run.sonar 400 "which sonar-scanner && sonar-scanner || true" + - programs/build_helpers/buildstep run.cli_test 60 "libraries/fc/tests/run-parallel-tests.sh tests/cli_test" + - 'programs/build_helpers/buildstep prepare.sonar 20 "find libraries/[acdenptuw]*/CMakeFiles/*.dir programs/[cdgjsw]*/CMakeFiles/*.dir -type d | while read d; do gcov -o \"\$d\" \"\${d/CMakeFiles*.dir//}\"/*.cpp; done >/dev/null; programs/build_helpers/set_sonar_branch sonar-project.properties" || true' + - 'programs/build_helpers/buildstep run.sonar 1200 "which sonar-scanner && sonar-scanner" || true' - programs/build_helpers/buildstep end 0 - ccache -s diff --git a/programs/build_helpers/set_sonar_branch b/programs/build_helpers/set_sonar_branch new file mode 100755 index 0000000000..aed0d722d5 --- /dev/null +++ b/programs/build_helpers/set_sonar_branch @@ -0,0 +1,82 @@ +#!/bin/sh + +# Relevant variables set by travis: +# TRAVIS_BRANCH: +# * for push builds, or builds not triggered by a pull request, this is the +# name of the branch. +# * for builds triggered by a pull request this is the name of the branch +# targeted by the pull request. +# * for builds triggered by a tag, this is the same as the name of the tag +# (see TRAVIS_TAG). +# TRAVIS_PULL_REQUEST: The pull request number if the current job is a pull +# request, “false” if it’s not a pull request. +# TRAVIS_TAG: If the current build is for a git tag, this variable is set to +# the tag’s name. + +if [ "$#" != 1 ]; then + echo "Usage: $0 " 1>&2 + exit 1 +fi + +clear_branch () { + sed -i '/sonar\.branch/d' "$1" +} + +TARGET= +FETCH= + +if [ -n "$TRAVIS_PULL_REQUEST" -a "$TRAVIS_PULL_REQUEST" != false ]; then + # PRs work per default + echo "Detected PR '$TRAVIS_PULL_REQUEST'" + clear_branch "$1" + FETCH="$TRAVIS_BRANCH" +elif [ -n "$TRAVIS_TAG" ]; then + # Tag build is either master or testnet + echo "Detected tag '$TRAVIS_TAG'" + clear_branch "$1" + case "$TRAVIS_TAG" in + *test*) TARGET=testnet; FETCH=testnet; ;; + *) FETCH=master; ;; + esac +else + case "$TRAVIS_BRANCH" in + master|develop|testnet|next_hardfork) + # Long-lived branches stand for themselves + echo "Detected long-lived branch '$TRAVIS_BRANCH'" + clear_branch "$1" + FETCH="$TRAVIS_BRANCH" + ;; + *test*release*) + # Testnet release branch will be merged into testnet + echo "Detected testnet release branch '$TRAVIS_BRANCH'" + clear_branch "$1" + TARGET=testnet + FETCH=testnet + ;; + *release*) + # Release branch will be merged into default (master) + echo "Detected release branch '$TRAVIS_BRANCH'" + clear_branch "$1" + FETCH=master + ;; + *) + # All other branches should have sonar.branch.target in their + # sonar.properties, leave it unchanged + echo "Detected normal branch '$TRAVIS_BRANCH'" + FETCH="$( grep 'sonar\.branch\.target' "$1" | sed 's=^.*[:=] *==' )" + esac +fi + +echo "Branch target '$TARGET', fetch target '$FETCH'" + +if [ -n "$TARGET" ]; then + echo "sonar.branch.target=$TARGET" >>"$1" +fi +#if [ -n "$FETCH" ]; then + # Unfortunately this leads to sonar failing. Apparently it needs a full + # clone, not a shallow one. Since our repo is somewhat large and this is + # only required for blame annotations, disabled for now. + #git fetch --depth=50 origin "$FETCH:$FETCH" +#fi + +exit 0 diff --git a/sonar-project.properties b/sonar-project.properties index a4487be06e..fcf8c487b4 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -12,3 +12,6 @@ sonar.sources=libraries,programs sonar.cfamily.build-wrapper-output=bw-output sonar.cfamily.gcov.reportsPath=. sonar.cfamily.threads=2 + +# should be changed in hardfork branch and removed in release branches +sonar.branch.target=develop From 31f28a26e653a275bf6101e0241a391842bda074 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Tue, 7 May 2019 18:14:39 -0300 Subject: [PATCH 025/133] remove operator== overload from htlc and withdraw objects --- libraries/chain/include/graphene/chain/htlc_object.hpp | 3 --- .../include/graphene/chain/withdraw_permission_object.hpp | 2 -- 2 files changed, 5 deletions(-) diff --git a/libraries/chain/include/graphene/chain/htlc_object.hpp b/libraries/chain/include/graphene/chain/htlc_object.hpp index da853877d3..5ba0918e9c 100644 --- a/libraries/chain/include/graphene/chain/htlc_object.hpp +++ b/libraries/chain/include/graphene/chain/htlc_object.hpp @@ -84,9 +84,6 @@ namespace graphene { namespace chain { typedef account_id_type result_type; const result_type& operator()(const htlc_object& o)const { return o.transfer.to; } }; - - bool operator==(const htlc_object& in) { return this->id == in.id; } - }; struct by_from_id; diff --git a/libraries/chain/include/graphene/chain/withdraw_permission_object.hpp b/libraries/chain/include/graphene/chain/withdraw_permission_object.hpp index adc3a73a28..f202ee1b66 100644 --- a/libraries/chain/include/graphene/chain/withdraw_permission_object.hpp +++ b/libraries/chain/include/graphene/chain/withdraw_permission_object.hpp @@ -77,8 +77,6 @@ namespace graphene { namespace chain { ? withdrawal_limit.amount - claimed_this_period : 0, withdrawal_limit.asset_id ); } - - bool operator==(const withdraw_permission_object& in) { return this->id == in.id; } }; struct by_from; From 55098b8f686b56c0ca04c604ec0716235ef317fe Mon Sep 17 00:00:00 2001 From: Alfredo Date: Tue, 7 May 2019 18:15:26 -0300 Subject: [PATCH 026/133] add more_data struct to full_account --- .../app/include/graphene/app/full_account.hpp | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/libraries/app/include/graphene/app/full_account.hpp b/libraries/app/include/graphene/app/full_account.hpp index 139eb5cc1e..58d0b26e6e 100644 --- a/libraries/app/include/graphene/app/full_account.hpp +++ b/libraries/app/include/graphene/app/full_account.hpp @@ -31,6 +31,19 @@ namespace graphene { namespace app { using namespace graphene::chain; + struct more_data + { + bool balances = false; + bool vesting_balances = false; + bool limit_orders = false; + bool call_orders = false; + bool settle_orders = false; + bool proposals = false; + bool assets = false; + bool withdraws = false; + bool htlcs = false; + }; + struct full_account { account_object account; @@ -49,10 +62,16 @@ namespace graphene { namespace app { vector assets; vector withdraws; vector htlcs; + more_data more_data_available; }; } } +FC_REFLECT( graphene::app::more_data, + (balances) (vesting_balances) (limit_orders) (call_orders) + (settle_orders) (proposals) (assets) (withdraws) (htlcs) + ) + FC_REFLECT( graphene::app::full_account, (account) (statistics) @@ -70,4 +89,5 @@ FC_REFLECT( graphene::app::full_account, (assets) (withdraws) (htlcs) + (more_data_available) ) From d10f970852039b786c32c7d4297b2301d2b5fc66 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Tue, 7 May 2019 18:16:35 -0300 Subject: [PATCH 027/133] change for_eachs to for, populate more_data flags, remove find --- libraries/app/database_api.cpp | 127 ++++++++++++++++++++------------- 1 file changed, 78 insertions(+), 49 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 0dafb0d640..ba0dc97202 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -932,8 +932,10 @@ std::map database_api_impl::get_full_accounts( const for( auto proposal_id : required_approvals_itr->second ) { acnt.proposals.push_back( proposal_id(_db) ); - if(acnt.proposals.size() >= api_limit_get_full_accounts) + if(acnt.proposals.size() >= api_limit_get_full_accounts) { + acnt.more_data_available.proposals = true; break; + } } } @@ -942,76 +944,103 @@ std::map database_api_impl::get_full_accounts( const for( const auto balance : balances ) { acnt.balances.emplace_back( *balance.second ); - if(acnt.balances.size() >= api_limit_get_full_accounts) + if(acnt.balances.size() >= api_limit_get_full_accounts) { + acnt.more_data_available.balances = true; break; + } } // Add the account's vesting balances auto vesting_range = _db.get_index_type().indices().get().equal_range(account->id); - std::for_each(vesting_range.first, vesting_range.second, - [&acnt, api_limit_get_full_accounts](const vesting_balance_object& balance) { - if(acnt.vesting_balances.size() < api_limit_get_full_accounts) - acnt.vesting_balances.emplace_back(balance); - }); + for(auto itr = vesting_range.first; itr != vesting_range.second; ++itr) + { + acnt.vesting_balances.emplace_back(*itr); + if(acnt.vesting_balances.size() >= api_limit_get_full_accounts) { + acnt.more_data_available.vesting_balances = true; + break; + } + } // Add the account's orders auto order_range = _db.get_index_type().indices().get().equal_range(account->id); - std::for_each(order_range.first, order_range.second, - [&acnt, api_limit_get_full_accounts] (const limit_order_object& order) { - if(acnt.limit_orders.size() < api_limit_get_full_accounts) - acnt.limit_orders.emplace_back(order); - }); + for(auto itr = order_range.first; itr != order_range.second; ++itr) + { + acnt.limit_orders.emplace_back(*itr); + if(acnt.limit_orders.size() >= api_limit_get_full_accounts) { + acnt.more_data_available.limit_orders = true; + break; + } + } auto call_range = _db.get_index_type().indices().get().equal_range(account->id); - std::for_each(call_range.first, call_range.second, - [&acnt, api_limit_get_full_accounts] (const call_order_object& call) { - if(acnt.call_orders.size() < api_limit_get_full_accounts) - acnt.call_orders.emplace_back(call); - }); + for(auto itr = call_range.first; itr != call_range.second; ++itr) + { + acnt.call_orders.emplace_back(*itr); + if(acnt.call_orders.size() >= api_limit_get_full_accounts) { + acnt.more_data_available.call_orders = true; + break; + } + } auto settle_range = _db.get_index_type().indices().get().equal_range(account->id); - std::for_each(settle_range.first, settle_range.second, - [&acnt, api_limit_get_full_accounts] (const force_settlement_object& settle) { - if(acnt.settle_orders.size() < api_limit_get_full_accounts) - acnt.settle_orders.emplace_back(settle); - }); + for(auto itr = settle_range.first; itr != settle_range.second; ++itr) + { + acnt.settle_orders.emplace_back(*itr); + if(acnt.settle_orders.size() >= api_limit_get_full_accounts) { + acnt.more_data_available.settle_orders = true; + break; + } + } // get assets issued by user auto asset_range = _db.get_index_type().indices().get().equal_range(account->id); - std::for_each(asset_range.first, asset_range.second, - [&acnt, api_limit_get_full_accounts] (const asset_object& asset) { - if(acnt.assets.size() < api_limit_get_full_accounts) - acnt.assets.emplace_back(asset.id); - }); + for(auto itr = asset_range.first; itr != asset_range.second; ++itr) + { + acnt.assets.emplace_back(itr->id); + if(acnt.assets.size() >= api_limit_get_full_accounts) { + acnt.more_data_available.assets = true; + break; + } + } // get withdraws permissions auto withdraw_indices = _db.get_index_type().indices(); auto withdraw_from_range = withdraw_indices.get().equal_range(account->id); - std::for_each(withdraw_from_range.first, withdraw_from_range.second, - [&acnt, api_limit_get_full_accounts] (const withdraw_permission_object& withdraw) { - if(acnt.withdraws.size() < api_limit_get_full_accounts) - acnt.withdraws.emplace_back(withdraw); - }); + for(auto itr = withdraw_from_range.first; itr != withdraw_from_range.second; ++itr) + { + acnt.withdraws.emplace_back(*itr); + if(acnt.withdraws.size() >= api_limit_get_full_accounts) { + acnt.more_data_available.withdraws = true; + break; + } + } auto withdraw_authorized_range = withdraw_indices.get().equal_range(account->id); - std::for_each(withdraw_authorized_range.first, withdraw_authorized_range.second, - [&acnt, api_limit_get_full_accounts] (const withdraw_permission_object& withdraw) { - if((std::find(acnt.withdraws.begin(), acnt.withdraws.end(), withdraw) == acnt.withdraws.end()) or - (acnt.withdraws.size() < api_limit_get_full_accounts)) - acnt.withdraws.emplace_back(withdraw); - }); + for(auto itr = withdraw_authorized_range.first; itr != withdraw_authorized_range.second; ++itr) + { + acnt.withdraws.emplace_back(*itr); + if(acnt.withdraws.size() >= api_limit_get_full_accounts) { + acnt.more_data_available.withdraws = true; + break; + } + } // get htlcs auto htlc_from_range = _db.get_index_type().indices().get().equal_range(account->id); - std::for_each(htlc_from_range.first, htlc_from_range.second, - [&acnt, api_limit_get_full_accounts] (const htlc_object& htlc) { - if(acnt.htlcs.size() < api_limit_get_full_accounts) - acnt.htlcs.emplace_back(htlc); - }); + for(auto itr = htlc_from_range.first; itr != htlc_from_range.second; ++itr) + { + acnt.htlcs.emplace_back(*itr); + if(acnt.htlcs.size() >= api_limit_get_full_accounts) { + acnt.more_data_available.htlcs = true; + break; + } + } auto htlc_to_range = _db.get_index_type().indices().get().equal_range(account->id); - std::for_each(htlc_to_range.first, htlc_to_range.second, - [&acnt, api_limit_get_full_accounts] (const htlc_object& htlc) { - if ((std::find(acnt.htlcs.begin(), acnt.htlcs.end(), htlc) == acnt.htlcs.end()) or - (acnt.htlcs.size() < api_limit_get_full_accounts)) - acnt.htlcs.emplace_back(htlc); - }); + for(auto itr = htlc_to_range.first; itr != htlc_to_range.second; ++itr) + { + acnt.htlcs.emplace_back(*itr); + if(acnt.htlcs.size() >= api_limit_get_full_accounts) { + acnt.more_data_available.htlcs = true; + break; + } + } results[account_name_or_id] = acnt; } From 3aba3f76d47e6e4b20707c69a51de43d5dc3f84b Mon Sep 17 00:00:00 2001 From: Alfredo Date: Wed, 8 May 2019 11:33:20 -0300 Subject: [PATCH 028/133] have 2 limit options for get_full_accounts for vector accounts and list limits --- libraries/app/application.cpp | 7 ++++- libraries/app/database_api.cpp | 28 ++++++++++--------- .../app/include/graphene/app/application.hpp | 3 +- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index 85cbad4f93..5dbfdfacc3 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -346,6 +346,9 @@ void application_impl::set_api_limit() { if(_options->count("api-limit-get-full-accounts")) { _app_options.api_limit_get_full_accounts = _options->at("api-limit-get-full-accounts").as(); } + if(_options->count("api-limit-get-full-accounts-lists")) { + _app_options.api_limit_get_full_accounts_lists = _options->at("api-limit-get-full-accounts-lists").as(); + } } void application_impl::startup() @@ -1025,7 +1028,9 @@ void application::set_program_options(boost::program_options::options_descriptio "For database_api_impl::get_key_references to set its default limit value as 100") ("api-limit-get-htlc-by",boost::program_options::value()->default_value(100), "For database_api_impl::get_htlc_by_from and get_htlc_by_to to set its default limit value as 100") - ("api-limit-get-full-accounts",boost::program_options::value()->default_value(100), + ("api-limit-get-full-accounts",boost::program_options::value()->default_value(10), + "For database_api_impl::get_full_accounts to set its account default limit values as 10") + ("api-limit-get-full-accounts-lists",boost::program_options::value()->default_value(100), "For database_api_impl::get_full_accounts to set its lists default limit values as 100") ; command_line_options.add(configuration_file_options); diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index ba0dc97202..4fb1c4affb 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -889,6 +889,8 @@ std::map database_api::get_full_accounts( const vector database_api_impl::get_full_accounts( const vector& names_or_ids, bool subscribe) { + FC_ASSERT( names_or_ids.size() <= _app_options->api_limit_get_full_accounts ); + const auto& proposal_idx = _db.get_index_type(); const auto& pidx = dynamic_cast(proposal_idx); const auto& proposals_by_account = pidx.get_secondary_index(); @@ -922,17 +924,17 @@ std::map database_api_impl::get_full_accounts( const acnt.cashback_balance = account->cashback_balance(_db); } - uint64_t api_limit_get_full_accounts = _app_options->api_limit_get_full_accounts; + uint64_t api_limit_get_full_accounts_lists = _app_options->api_limit_get_full_accounts_lists; // Add the account's proposals auto required_approvals_itr = proposals_by_account._account_to_proposals.find( account->id ); if( required_approvals_itr != proposals_by_account._account_to_proposals.end() ) { - acnt.proposals.reserve( std::min(required_approvals_itr->second.size(), api_limit_get_full_accounts) ); + acnt.proposals.reserve( std::min(required_approvals_itr->second.size(), api_limit_get_full_accounts_lists) ); for( auto proposal_id : required_approvals_itr->second ) { acnt.proposals.push_back( proposal_id(_db) ); - if(acnt.proposals.size() >= api_limit_get_full_accounts) { + if(acnt.proposals.size() >= api_limit_get_full_accounts_lists) { acnt.more_data_available.proposals = true; break; } @@ -944,7 +946,7 @@ std::map database_api_impl::get_full_accounts( const for( const auto balance : balances ) { acnt.balances.emplace_back( *balance.second ); - if(acnt.balances.size() >= api_limit_get_full_accounts) { + if(acnt.balances.size() >= api_limit_get_full_accounts_lists) { acnt.more_data_available.balances = true; break; } @@ -955,7 +957,7 @@ std::map database_api_impl::get_full_accounts( const for(auto itr = vesting_range.first; itr != vesting_range.second; ++itr) { acnt.vesting_balances.emplace_back(*itr); - if(acnt.vesting_balances.size() >= api_limit_get_full_accounts) { + if(acnt.vesting_balances.size() >= api_limit_get_full_accounts_lists) { acnt.more_data_available.vesting_balances = true; break; } @@ -966,7 +968,7 @@ std::map database_api_impl::get_full_accounts( const for(auto itr = order_range.first; itr != order_range.second; ++itr) { acnt.limit_orders.emplace_back(*itr); - if(acnt.limit_orders.size() >= api_limit_get_full_accounts) { + if(acnt.limit_orders.size() >= api_limit_get_full_accounts_lists) { acnt.more_data_available.limit_orders = true; break; } @@ -975,7 +977,7 @@ std::map database_api_impl::get_full_accounts( const for(auto itr = call_range.first; itr != call_range.second; ++itr) { acnt.call_orders.emplace_back(*itr); - if(acnt.call_orders.size() >= api_limit_get_full_accounts) { + if(acnt.call_orders.size() >= api_limit_get_full_accounts_lists) { acnt.more_data_available.call_orders = true; break; } @@ -984,7 +986,7 @@ std::map database_api_impl::get_full_accounts( const for(auto itr = settle_range.first; itr != settle_range.second; ++itr) { acnt.settle_orders.emplace_back(*itr); - if(acnt.settle_orders.size() >= api_limit_get_full_accounts) { + if(acnt.settle_orders.size() >= api_limit_get_full_accounts_lists) { acnt.more_data_available.settle_orders = true; break; } @@ -995,7 +997,7 @@ std::map database_api_impl::get_full_accounts( const for(auto itr = asset_range.first; itr != asset_range.second; ++itr) { acnt.assets.emplace_back(itr->id); - if(acnt.assets.size() >= api_limit_get_full_accounts) { + if(acnt.assets.size() >= api_limit_get_full_accounts_lists) { acnt.more_data_available.assets = true; break; } @@ -1007,7 +1009,7 @@ std::map database_api_impl::get_full_accounts( const for(auto itr = withdraw_from_range.first; itr != withdraw_from_range.second; ++itr) { acnt.withdraws.emplace_back(*itr); - if(acnt.withdraws.size() >= api_limit_get_full_accounts) { + if(acnt.withdraws.size() >= api_limit_get_full_accounts_lists) { acnt.more_data_available.withdraws = true; break; } @@ -1016,7 +1018,7 @@ std::map database_api_impl::get_full_accounts( const for(auto itr = withdraw_authorized_range.first; itr != withdraw_authorized_range.second; ++itr) { acnt.withdraws.emplace_back(*itr); - if(acnt.withdraws.size() >= api_limit_get_full_accounts) { + if(acnt.withdraws.size() >= api_limit_get_full_accounts_lists) { acnt.more_data_available.withdraws = true; break; } @@ -1027,7 +1029,7 @@ std::map database_api_impl::get_full_accounts( const for(auto itr = htlc_from_range.first; itr != htlc_from_range.second; ++itr) { acnt.htlcs.emplace_back(*itr); - if(acnt.htlcs.size() >= api_limit_get_full_accounts) { + if(acnt.htlcs.size() >= api_limit_get_full_accounts_lists) { acnt.more_data_available.htlcs = true; break; } @@ -1036,7 +1038,7 @@ std::map database_api_impl::get_full_accounts( const for(auto itr = htlc_to_range.first; itr != htlc_to_range.second; ++itr) { acnt.htlcs.emplace_back(*itr); - if(acnt.htlcs.size() >= api_limit_get_full_accounts) { + if(acnt.htlcs.size() >= api_limit_get_full_accounts_lists) { acnt.more_data_available.htlcs = true; break; } diff --git a/libraries/app/include/graphene/app/application.hpp b/libraries/app/include/graphene/app/application.hpp index 6fa094760d..018d34e77c 100644 --- a/libraries/app/include/graphene/app/application.hpp +++ b/libraries/app/include/graphene/app/application.hpp @@ -48,7 +48,8 @@ namespace graphene { namespace app { uint64_t api_limit_get_asset_holders = 100; uint64_t api_limit_get_key_references = 100; uint64_t api_limit_get_htlc_by = 100; - uint64_t api_limit_get_full_accounts = 100; + uint64_t api_limit_get_full_accounts = 10; + uint64_t api_limit_get_full_accounts_lists = 100; }; class application From d1c20e7f1b9b4b575422f0e9225c7fc39a9e2ce1 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Sun, 3 Mar 2019 21:07:57 +0100 Subject: [PATCH 029/133] Switched to boost endian conversion --- CMakeLists.txt | 1 + README.md | 2 +- libraries/protocol/block.cpp | 6 +++--- libraries/protocol/transaction.cpp | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fe87e980a2..2497afb17d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,6 +51,7 @@ LIST(APPEND BOOST_COMPONENTS thread chrono unit_test_framework context) +# boost::endian is also required, but FindBoost can't handle header-only libs SET( Boost_USE_STATIC_LIBS ON CACHE STRING "ON or OFF" ) IF( WIN32 ) diff --git a/README.md b/README.md index a1e64b09dd..91c3dcb024 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ We recommend building on Ubuntu 16.04 LTS (64-bit) git submodule sync --recursive git submodule update --init --recursive -**NOTE:** Versions of [Boost](http://www.boost.org/) 1.57 through 1.69 are supported. Newer versions may work, but +**NOTE:** Versions of [Boost](http://www.boost.org/) 1.58 through 1.69 are supported. Newer versions may work, but have not been tested. If your system came pre-installed with a version of Boost that you do not wish to use, you may manually build your preferred version and use it with BitShares by specifying it on the CMake command line. diff --git a/libraries/protocol/block.cpp b/libraries/protocol/block.cpp index acd1576d6d..812d1db95f 100644 --- a/libraries/protocol/block.cpp +++ b/libraries/protocol/block.cpp @@ -21,9 +21,9 @@ * 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 protocol { @@ -34,7 +34,7 @@ namespace graphene { namespace protocol { uint32_t block_header::num_from_id(const block_id_type& id) { - return fc::endian_reverse_u32(id._hash[0]); + return boost::endian::big_to_native(id._hash[0]); } const block_id_type& signed_block_header::id()const @@ -42,7 +42,7 @@ namespace graphene { namespace protocol { if( !_block_id._hash[0] ) { 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::native_to_big(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" ); memcpy(_block_id._hash, tmp._hash, std::min(sizeof(_block_id), sizeof(tmp))); } diff --git a/libraries/protocol/transaction.cpp b/libraries/protocol/transaction.cpp index 3964769d0e..4089c2d1fc 100644 --- a/libraries/protocol/transaction.cpp +++ b/libraries/protocol/transaction.cpp @@ -25,8 +25,8 @@ #include #include #include +#include #include -#include #include namespace graphene { namespace protocol { @@ -94,7 +94,7 @@ 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_num = boost::endian::big_to_native(reference_block._hash[0]); ref_block_prefix = reference_block._hash[1]; } From 737a7d0e4195afae5b48e0878460b194d366fb6a Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Sun, 3 Mar 2019 21:09:38 +0100 Subject: [PATCH 030/133] Fix include order --- .../chain/include/graphene/chain/global_property_object.hpp | 3 ++- libraries/wallet/wallet.cpp | 3 ++- tests/tests/app_util_tests.cpp | 4 ++-- tests/tests/fee_tests.cpp | 4 ++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/libraries/chain/include/graphene/chain/global_property_object.hpp b/libraries/chain/include/graphene/chain/global_property_object.hpp index 9acb406096..2f72918726 100644 --- a/libraries/chain/include/graphene/chain/global_property_object.hpp +++ b/libraries/chain/include/graphene/chain/global_property_object.hpp @@ -22,13 +22,14 @@ * THE SOFTWARE. */ #pragma once -#include #include #include #include #include +#include + namespace graphene { namespace chain { /** diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 5acf2dc63f..6fc9aa4e8b 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -55,7 +55,6 @@ #include #include #include -#include #include #include #include @@ -75,6 +74,8 @@ #include #include +#include + #ifndef WIN32 # include # include diff --git a/tests/tests/app_util_tests.cpp b/tests/tests/app_util_tests.cpp index b85c9a3e8d..7034673443 100644 --- a/tests/tests/app_util_tests.cpp +++ b/tests/tests/app_util_tests.cpp @@ -24,10 +24,10 @@ #include -#include - #include "../common/database_fixture.hpp" +#include + using namespace graphene::chain; using namespace graphene::chain::test; using namespace graphene::app; diff --git a/tests/tests/fee_tests.cpp b/tests/tests/fee_tests.cpp index d266ccd7be..04bc758eed 100644 --- a/tests/tests/fee_tests.cpp +++ b/tests/tests/fee_tests.cpp @@ -22,8 +22,6 @@ * THE SOFTWARE. */ -#include - #include #include @@ -38,6 +36,8 @@ #include "../common/database_fixture.hpp" +#include + using namespace graphene::chain; using namespace graphene::chain::test; From faf39f2324b30acc1d44a4399700019055d423c6 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Thu, 7 Mar 2019 22:23:34 +0100 Subject: [PATCH 031/133] Use proper serialization for P2P message header --- .../net/include/graphene/net/message.hpp | 9 ++++--- libraries/net/message_oriented_connection.cpp | 15 +++++------ libraries/net/node.cpp | 26 +++++++++---------- programs/network_mapper/network_mapper.cpp | 5 ++-- 4 files changed, 28 insertions(+), 27 deletions(-) diff --git a/libraries/net/include/graphene/net/message.hpp b/libraries/net/include/graphene/net/message.hpp index 9cbc0af94c..4ff142f7e7 100644 --- a/libraries/net/include/graphene/net/message.hpp +++ b/libraries/net/include/graphene/net/message.hpp @@ -22,6 +22,7 @@ * THE SOFTWARE. */ #pragma once +#include #include #include #include @@ -39,8 +40,8 @@ namespace graphene { namespace net { */ struct message_header { - uint32_t size; // number of bytes in message, capped at MAX_MESSAGE_SIZE - uint32_t msg_type; // every channel gets a 16 bit message type specifier + boost::endian::little_uint32_buf_t size; // number of bytes in message, capped at MAX_MESSAGE_SIZE + boost::endian::little_uint32_buf_t msg_type; // every channel gets a 16 bit message type specifier }; typedef fc::uint160_t message_hash_type; @@ -85,7 +86,7 @@ namespace graphene { namespace net { T as()const { try { - FC_ASSERT( msg_type == T::type ); + FC_ASSERT( msg_type.value() == T::type ); T tmp; if( data.size() ) { @@ -103,7 +104,7 @@ namespace graphene { namespace net { "error unpacking network message as a '${type}' ${x} !=? ${msg_type}", ("type", fc::get_typename::name() ) ("x", T::type) - ("msg_type", msg_type) + ("msg_type", msg_type.value()) ); } }; diff --git a/libraries/net/message_oriented_connection.cpp b/libraries/net/message_oriented_connection.cpp index 858f615d3f..de3cf0875b 100644 --- a/libraries/net/message_oriented_connection.cpp +++ b/libraries/net/message_oriented_connection.cpp @@ -153,16 +153,15 @@ namespace graphene { namespace net { try { message m; + char buffer[BUFFER_SIZE]; while( true ) { - char buffer[BUFFER_SIZE]; _sock.read(buffer, BUFFER_SIZE); _bytes_received += BUFFER_SIZE; memcpy((char*)&m, buffer, sizeof(message_header)); + FC_ASSERT( m.size.value() <= MAX_MESSAGE_SIZE, "", ("m.size",m.size.value())("MAX_MESSAGE_SIZE",MAX_MESSAGE_SIZE) ); - FC_ASSERT( m.size <= MAX_MESSAGE_SIZE, "", ("m.size",m.size)("MAX_MESSAGE_SIZE",MAX_MESSAGE_SIZE) ); - - size_t remaining_bytes_with_padding = 16 * ((m.size - LEFTOVER + 15) / 16); + size_t remaining_bytes_with_padding = 16 * ((m.size.value() - LEFTOVER + 15) / 16); m.data.resize(LEFTOVER + remaining_bytes_with_padding); //give extra 16 bytes to allow for padding added in send call std::copy(buffer + sizeof(message_header), buffer + sizeof(buffer), m.data.begin()); if (remaining_bytes_with_padding) @@ -170,7 +169,7 @@ namespace graphene { namespace net { _sock.read(&m.data[LEFTOVER], remaining_bytes_with_padding); _bytes_received += remaining_bytes_with_padding; } - m.data.resize(m.size); // truncate off the padding bytes + m.data.resize(m.size.value()); // truncate off the padding bytes _last_message_received_time = fc::time_point::now(); @@ -255,14 +254,14 @@ namespace graphene { namespace net { try { - size_t size_of_message_and_header = sizeof(message_header) + message_to_send.size; - if( message_to_send.size > MAX_MESSAGE_SIZE ) + size_t size_of_message_and_header = sizeof(message_header) + message_to_send.size.value(); + if( message_to_send.size.value() > MAX_MESSAGE_SIZE ) elog("Trying to send a message larger than MAX_MESSAGE_SIZE. This probably won't work..."); //pad the message we send to a multiple of 16 bytes size_t size_with_padding = 16 * ((size_of_message_and_header + 15) / 16); std::unique_ptr padded_message(new char[size_with_padding]); memcpy(padded_message.get(), (char*)&message_to_send, sizeof(message_header)); - memcpy(padded_message.get() + sizeof(message_header), message_to_send.data.data(), message_to_send.size ); + memcpy(padded_message.get() + sizeof(message_header), message_to_send.data.data(), message_to_send.size.value() ); _sock.write(padded_message.get(), size_with_padding); _sock.flush(); _bytes_sent += size_with_padding; diff --git a/libraries/net/node.cpp b/libraries/net/node.cpp index a0b58b10f5..cbfc1f4bc4 100644 --- a/libraries/net/node.cpp +++ b/libraries/net/node.cpp @@ -1257,10 +1257,10 @@ namespace graphene { namespace net { namespace detail { VERIFY_CORRECT_THREAD(); message_hash_type message_hash = received_message.id(); dlog("handling message ${type} ${hash} size ${size} from peer ${endpoint}", - ("type", graphene::net::core_message_type_enum(received_message.msg_type))("hash", message_hash) + ("type", graphene::net::core_message_type_enum(received_message.msg_type.value()))("hash", message_hash) ("size", received_message.size) ("endpoint", originating_peer->get_remote_endpoint())); - switch ( received_message.msg_type ) + switch ( received_message.msg_type.value() ) { case core_message_type_enum::hello_message_type: on_hello_message(originating_peer, received_message.as()); @@ -1320,8 +1320,8 @@ namespace graphene { namespace net { namespace detail { default: // ignore any message in between core_message_type_first and _last that we don't handle above // to allow us to add messages in the future - if (received_message.msg_type < core_message_type_enum::core_message_type_first || - received_message.msg_type > core_message_type_enum::core_message_type_last) + if (received_message.msg_type.value() < core_message_type_enum::core_message_type_first || + received_message.msg_type.value() > core_message_type_enum::core_message_type_last) process_ordinary_message(originating_peer, received_message, message_hash); break; } @@ -2306,7 +2306,7 @@ namespace graphene { namespace net { namespace detail { for (const message& reply : reply_messages) { - if (reply.msg_type == block_message_type) + if (reply.msg_type.value() == block_message_type) originating_peer->send_item(item_id(block_message_type, reply.as().block_id)); else originating_peer->send_message(reply); @@ -3363,7 +3363,7 @@ namespace graphene { namespace net { namespace detail { fc::time_point message_receive_time = fc::time_point::now(); // only process it if we asked for it - auto iter = originating_peer->items_requested_from_peer.find( item_id(message_to_process.msg_type, message_hash) ); + auto iter = originating_peer->items_requested_from_peer.find( item_id(message_to_process.msg_type.value(), message_hash) ); if( iter == originating_peer->items_requested_from_peer.end() ) { wlog( "received a message I didn't ask for from peer ${endpoint}, disconnecting from peer", @@ -3383,7 +3383,7 @@ namespace graphene { namespace net { namespace detail { fc::time_point message_validated_time; try { - if (message_to_process.msg_type == trx_message_type) + if (message_to_process.msg_type.value() == trx_message_type) { trx_message transaction_message_to_process = message_to_process.as(); dlog("passing message containing transaction ${trx} to client", ("trx", transaction_message_to_process.trx.id())); @@ -3401,7 +3401,7 @@ namespace graphene { namespace net { namespace detail { { wlog( "client rejected message sent by peer ${peer}, ${e}", ("peer", originating_peer->get_remote_endpoint() )("e", e) ); // record it so we don't try to fetch this item again - _recently_failed_items.insert(peer_connection::timestamped_item_id(item_id(message_to_process.msg_type, message_hash ), fc::time_point::now())); + _recently_failed_items.insert(peer_connection::timestamped_item_id(item_id(message_to_process.msg_type.value(), message_hash ), fc::time_point::now())); return; } @@ -4434,13 +4434,13 @@ namespace graphene { namespace net { namespace detail { { VERIFY_CORRECT_THREAD(); fc::uint160_t hash_of_message_contents; - if( item_to_broadcast.msg_type == graphene::net::block_message_type ) + if( item_to_broadcast.msg_type.value() == graphene::net::block_message_type ) { graphene::net::block_message block_message_to_broadcast = item_to_broadcast.as(); hash_of_message_contents = block_message_to_broadcast.block_id; // for debugging _most_recent_blocks_accepted.push_back( block_message_to_broadcast.block_id ); } - else if( item_to_broadcast.msg_type == graphene::net::trx_message_type ) + else if( item_to_broadcast.msg_type.value() == graphene::net::trx_message_type ) { graphene::net::trx_message transaction_message_to_broadcast = item_to_broadcast.as(); hash_of_message_contents = transaction_message_to_broadcast.trx.id(); // for debugging @@ -4449,7 +4449,7 @@ namespace graphene { namespace net { namespace detail { message_hash_type hash_of_item_to_broadcast = item_to_broadcast.id(); _message_cache.cache_message( item_to_broadcast, hash_of_item_to_broadcast, propagation_data, hash_of_message_contents ); - _new_inventory.insert( item_id(item_to_broadcast.msg_type, hash_of_item_to_broadcast ) ); + _new_inventory.insert( item_id(item_to_broadcast.msg_type.value(), hash_of_item_to_broadcast ) ); trigger_advertise_inventory_loop(); } @@ -4827,9 +4827,9 @@ namespace graphene { namespace net { namespace detail { try { const message& message_to_deliver = destination_node->messages_to_deliver.front(); - if (message_to_deliver.msg_type == trx_message_type) + if (message_to_deliver.msg_type.value() == trx_message_type) destination_node->delegate->handle_transaction(message_to_deliver.as()); - else if (message_to_deliver.msg_type == block_message_type) + else if (message_to_deliver.msg_type.value() == block_message_type) { std::vector contained_transaction_message_ids; destination_node->delegate->handle_block(message_to_deliver.as(), false, contained_transaction_message_ids); diff --git a/programs/network_mapper/network_mapper.cpp b/programs/network_mapper/network_mapper.cpp index 2ecc724d8c..b00439467a 100644 --- a/programs/network_mapper/network_mapper.cpp +++ b/programs/network_mapper/network_mapper.cpp @@ -74,8 +74,9 @@ class peer_probe : public graphene::net::peer_connection_delegate { graphene::net::message_hash_type message_hash = received_message.id(); dlog( "handling message ${type} ${hash} size ${size} from peer ${endpoint}", - ( "type", graphene::net::core_message_type_enum(received_message.msg_type ) )("hash", message_hash )("size", received_message.size )("endpoint", originating_peer->get_remote_endpoint() ) ); - switch ( received_message.msg_type ) + ( "type", graphene::net::core_message_type_enum(received_message.msg_type.value() ) )("hash", message_hash ) + ("size", received_message.size )("endpoint", originating_peer->get_remote_endpoint() ) ); + switch ( received_message.msg_type.value() ) { case graphene::net::core_message_type_enum::hello_message_type: on_hello_message( originating_peer, received_message.as() ); From 8afd0bc82ba1dc161855812c83e356a5e9f6f551 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Tue, 19 Mar 2019 13:57:26 +0100 Subject: [PATCH 032/133] Removed unused hash methods --- .../include/graphene/protocol/address.hpp | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/libraries/protocol/include/graphene/protocol/address.hpp b/libraries/protocol/include/graphene/protocol/address.hpp index eb1cd385a9..e6a1054892 100644 --- a/libraries/protocol/include/graphene/protocol/address.hpp +++ b/libraries/protocol/include/graphene/protocol/address.hpp @@ -62,12 +62,6 @@ namespace graphene { namespace protocol { explicit operator std::string()const; ///< converts to base58 + checksum - friend size_t hash_value( const address& v ) { - const void* tmp = static_cast(v.addr._hash+2); - - const size_t* tmp2 = reinterpret_cast(tmp); - return *tmp2; - } fc::ripemd160 addr; }; inline bool operator == ( const address& a, const address& b ) { return a.addr == b.addr; } @@ -82,18 +76,5 @@ namespace fc void from_variant( const fc::variant& var, graphene::protocol::address& vo, uint32_t max_depth = 1 ); } -namespace std -{ - template<> - struct hash - { - public: - size_t operator()(const graphene::protocol::address &a) const - { - return (uint64_t(a.addr._hash[0])<<32) | uint64_t( a.addr._hash[0] ); - } - }; -} - #include FC_REFLECT( graphene::protocol::address, (addr) ) From 2fd3db2c9d660c6ca51685f279b91989c107afa9 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Wed, 8 May 2019 13:30:42 -0300 Subject: [PATCH 033/133] refactor get_proposed_transactions --- libraries/app/database_api.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 4fb1c4affb..0a5e993774 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -2362,22 +2362,24 @@ vector database_api::get_proposed_transactions( const std::stri return my->get_proposed_transactions( account_id_or_name ); } -/** TODO: add secondary index that will accelerate this process */ vector database_api_impl::get_proposed_transactions( const std::string account_id_or_name )const { - const auto& idx = _db.get_index_type(); + const auto& proposal_idx = _db.get_index_type(); + const auto& pidx = dynamic_cast(proposal_idx); + const auto& proposals_by_account = pidx.get_secondary_index(); + vector result; const account_id_type id = get_account_from_string(account_id_or_name)->id; - idx.inspect_all_objects( [&](const object& obj){ - const proposal_object& p = static_cast(obj); - if( p.required_active_approvals.find( id ) != p.required_active_approvals.end() ) - result.push_back(p); - else if ( p.required_owner_approvals.find( id ) != p.required_owner_approvals.end() ) - result.push_back(p); - else if ( p.available_active_approvals.find( id ) != p.available_active_approvals.end() ) - result.push_back(p); - }); + auto required_approvals_itr = proposals_by_account._account_to_proposals.find( id ); + if( required_approvals_itr != proposals_by_account._account_to_proposals.end() ) + { + result.reserve( required_approvals_itr->second.size() ); + for( auto proposal_id : required_approvals_itr->second ) + { + result.push_back( proposal_id(_db) ); + } + } return result; } From c20c3254dcc243ee15f6913446bf772dd8b71f81 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Wed, 8 May 2019 15:34:12 -0300 Subject: [PATCH 034/133] separate htlc and withdraws in from and to --- libraries/app/database_api.cpp | 24 +++++++++---------- .../app/include/graphene/app/full_account.hpp | 20 ++++++++++------ tests/tests/htlc_tests.cpp | 4 ++-- 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 0a5e993774..50aad0571e 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -1008,18 +1008,18 @@ std::map database_api_impl::get_full_accounts( const auto withdraw_from_range = withdraw_indices.get().equal_range(account->id); for(auto itr = withdraw_from_range.first; itr != withdraw_from_range.second; ++itr) { - acnt.withdraws.emplace_back(*itr); - if(acnt.withdraws.size() >= api_limit_get_full_accounts_lists) { - acnt.more_data_available.withdraws = true; + acnt.withdraws_from.emplace_back(*itr); + if(acnt.withdraws_from.size() >= api_limit_get_full_accounts_lists) { + acnt.more_data_available.withdraws_from = true; break; } } auto withdraw_authorized_range = withdraw_indices.get().equal_range(account->id); for(auto itr = withdraw_authorized_range.first; itr != withdraw_authorized_range.second; ++itr) { - acnt.withdraws.emplace_back(*itr); - if(acnt.withdraws.size() >= api_limit_get_full_accounts_lists) { - acnt.more_data_available.withdraws = true; + acnt.withdraws_authorized.emplace_back(*itr); + if(acnt.withdraws_authorized.size() >= api_limit_get_full_accounts_lists) { + acnt.more_data_available.withdraws_authorized = true; break; } } @@ -1028,18 +1028,18 @@ std::map database_api_impl::get_full_accounts( const auto htlc_from_range = _db.get_index_type().indices().get().equal_range(account->id); for(auto itr = htlc_from_range.first; itr != htlc_from_range.second; ++itr) { - acnt.htlcs.emplace_back(*itr); - if(acnt.htlcs.size() >= api_limit_get_full_accounts_lists) { - acnt.more_data_available.htlcs = true; + acnt.htlcs_from.emplace_back(*itr); + if(acnt.htlcs_from.size() >= api_limit_get_full_accounts_lists) { + acnt.more_data_available.htlcs_from = true; break; } } auto htlc_to_range = _db.get_index_type().indices().get().equal_range(account->id); for(auto itr = htlc_to_range.first; itr != htlc_to_range.second; ++itr) { - acnt.htlcs.emplace_back(*itr); - if(acnt.htlcs.size() >= api_limit_get_full_accounts_lists) { - acnt.more_data_available.htlcs = true; + acnt.htlcs_to.emplace_back(*itr); + if(acnt.htlcs_to.size() >= api_limit_get_full_accounts_lists) { + acnt.more_data_available.htlcs_to = true; break; } } diff --git a/libraries/app/include/graphene/app/full_account.hpp b/libraries/app/include/graphene/app/full_account.hpp index 58d0b26e6e..ebb1144cdb 100644 --- a/libraries/app/include/graphene/app/full_account.hpp +++ b/libraries/app/include/graphene/app/full_account.hpp @@ -40,8 +40,10 @@ namespace graphene { namespace app { bool settle_orders = false; bool proposals = false; bool assets = false; - bool withdraws = false; - bool htlcs = false; + bool withdraws_from = false; + bool withdraws_authorized = false; + bool htlcs_from = false; + bool htlcs_to = false; }; struct full_account @@ -60,8 +62,10 @@ namespace graphene { namespace app { vector settle_orders; vector proposals; vector assets; - vector withdraws; - vector htlcs; + vector withdraws_from; + vector withdraws_authorized; + vector htlcs_from; + vector htlcs_to; more_data more_data_available; }; @@ -69,7 +73,7 @@ namespace graphene { namespace app { FC_REFLECT( graphene::app::more_data, (balances) (vesting_balances) (limit_orders) (call_orders) - (settle_orders) (proposals) (assets) (withdraws) (htlcs) + (settle_orders) (proposals) (assets) (withdraws_from) (withdraws_authorized) (htlcs_from) (htlcs_to) ) FC_REFLECT( graphene::app::full_account, @@ -87,7 +91,9 @@ FC_REFLECT( graphene::app::full_account, (settle_orders) (proposals) (assets) - (withdraws) - (htlcs) + (withdraws_from) + (withdraws_authorized) + (htlcs_from) + (htlcs_to) (more_data_available) ) diff --git a/tests/tests/htlc_tests.cpp b/tests/tests/htlc_tests.cpp index 88b9bf73f9..6a22b6b00c 100644 --- a/tests/tests/htlc_tests.cpp +++ b/tests/tests/htlc_tests.cpp @@ -973,10 +973,10 @@ try { BOOST_CHECK_EQUAL( htlcs_dan[0].id.instance(), 2 ); auto full = db_api.get_full_accounts({alice.name}, false); - BOOST_CHECK_EQUAL( full[alice.name].htlcs.size(), 3 ); + BOOST_CHECK_EQUAL( full[alice.name].htlcs_from.size(), 3 ); full = db_api.get_full_accounts({bob.name}, false); - BOOST_CHECK_EQUAL( full[bob.name].htlcs.size(), 1 ); + BOOST_CHECK_EQUAL( full[bob.name].htlcs_to.size(), 1 ); } catch (fc::exception &e) { edump((e.to_detail_string())); From f95d5e57fb68e173d6daebcff6aa688a851af621 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Mon, 18 Mar 2019 15:10:03 +0100 Subject: [PATCH 035/133] _hash endianness fixes --- libraries/chain/db_block.cpp | 3 ++- libraries/protocol/block.cpp | 8 ++++---- libraries/protocol/memo.cpp | 11 ++++++----- libraries/protocol/transaction.cpp | 7 +++---- libraries/protocol/types.cpp | 4 ++-- libraries/wallet/wallet.cpp | 8 ++++---- tests/generate_empty_blocks/main.cpp | 4 ++-- 7 files changed, 23 insertions(+), 22 deletions(-) diff --git a/libraries/chain/db_block.cpp b/libraries/chain/db_block.cpp index f0331c85f3..ace071ec0d 100644 --- a/libraries/chain/db_block.cpp +++ b/libraries/chain/db_block.cpp @@ -38,6 +38,7 @@ #include +#include #include namespace graphene { namespace chain { @@ -661,7 +662,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(); diff --git a/libraries/protocol/block.cpp b/libraries/protocol/block.cpp index 812d1db95f..dfc3320706 100644 --- a/libraries/protocol/block.cpp +++ b/libraries/protocol/block.cpp @@ -34,15 +34,15 @@ namespace graphene { namespace protocol { uint32_t block_header::num_from_id(const block_id_type& id) { - return boost::endian::big_to_native(id._hash[0]); + return boost::endian::endian_reverse(id._hash[0].value()); } const block_id_type& signed_block_header::id()const { - if( !_block_id._hash[0] ) + if( !_block_id._hash[0].value() ) { auto tmp = fc::sha224::hash( *this ); - tmp._hash[0] = boost::endian::native_to_big(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" ); memcpy(_block_id._hash, tmp._hash, std::min(sizeof(_block_id), sizeof(tmp))); } @@ -72,7 +72,7 @@ namespace graphene { namespace protocol { if( transactions.size() == 0 ) return empty_checksum; - if( !_calculated_merkle_root._hash[0] ) + if( !_calculated_merkle_root._hash[0].value() ) { vector ids; ids.resize( transactions.size() ); diff --git a/libraries/protocol/memo.cpp b/libraries/protocol/memo.cpp index 75e77cbc7b..3b4bda2263 100644 --- a/libraries/protocol/memo.cpp +++ b/libraries/protocol/memo.cpp @@ -22,6 +22,7 @@ * THE SOFTWARE. */ #include +#include #include namespace graphene { namespace protocol { @@ -35,7 +36,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; @@ -43,7 +44,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 @@ -62,7 +63,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 @@ -74,7 +75,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; } @@ -82,7 +83,7 @@ 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; } diff --git a/libraries/protocol/transaction.cpp b/libraries/protocol/transaction.cpp index 4089c2d1fc..d49f269555 100644 --- a/libraries/protocol/transaction.cpp +++ b/libraries/protocol/transaction.cpp @@ -25,7 +25,6 @@ #include #include #include -#include #include #include @@ -94,8 +93,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 = boost::endian::big_to_native(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, @@ -400,7 +399,7 @@ set signed_transaction::minimize_required_signatures( const transaction_id_type& precomputable_transaction::id()const { - if( !_tx_id_buffer._hash[0] ) + if( !_tx_id_buffer._hash[0].value() ) transaction::id(); return _tx_id_buffer; } diff --git a/libraries/protocol/types.cpp b/libraries/protocol/types.cpp index 22a5ab33d7..e8166fbfc1 100644 --- a/libraries/protocol/types.cpp +++ b/libraries/protocol/types.cpp @@ -51,7 +51,7 @@ namespace graphene { namespace protocol { 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 ); + FC_ASSERT( fc::ripemd160::hash( key_data.data, key_data.size() )._hash[0].value() == bin_key.check ); }; public_key_type::operator fc::ecc::public_key_data() const @@ -68,7 +68,7 @@ namespace graphene { namespace protocol { { binary_key k; k.data = key_data; - k.check = fc::ripemd160::hash( k.data.data, k.data.size() )._hash[0]; + k.check = fc::ripemd160::hash( 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() ); } diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 6fc9aa4e8b..6189b4ae7d 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -170,7 +170,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; @@ -4800,7 +4800,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 ) ); @@ -4818,7 +4818,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 ) ); @@ -4906,7 +4906,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 ) ); diff --git a/tests/generate_empty_blocks/main.cpp b/tests/generate_empty_blocks/main.cpp index 721747eef2..7b4f3077fa 100644 --- a/tests/generate_empty_blocks/main.cpp +++ b/tests/generate_empty_blocks/main.cpp @@ -131,14 +131,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 From e6c93749273236167dceae140267c1f599b7b55e Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Wed, 10 Apr 2019 20:48:49 +0200 Subject: [PATCH 036/133] Fixed endianness in block_database index file --- libraries/chain/block_database.cpp | 39 +++++++++++++++++------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/libraries/chain/block_database.cpp b/libraries/chain/block_database.cpp index 17c37f2b83..134ca833b6 100644 --- a/libraries/chain/block_database.cpp +++ b/libraries/chain/block_database.cpp @@ -24,14 +24,19 @@ #include #include #include +#include namespace graphene { namespace chain { struct index_entry { - uint64_t block_pos = 0; - uint32_t block_size = 0; - block_id_type block_id; + index_entry() { + block_pos = 0; + block_size = 0; + }; + boost::endian::little_uint64_buf_t block_pos; + boost::endian::little_uint32_buf_t block_size; + block_id_type block_id; }; }} FC_REFLECT( graphene::chain::index_entry, (block_pos)(block_size)(block_id) ); @@ -125,7 +130,7 @@ bool block_database::contains( const block_id_type& id )const _block_num_to_pos.seekg( index_pos ); _block_num_to_pos.read( (char*)&e, sizeof(e) ); - return e.block_id == id && e.block_size > 0; + return e.block_id == id && e.block_size.value() > 0; } block_id_type block_database::fetch_block_id( uint32_t block_num )const @@ -159,10 +164,10 @@ optional block_database::fetch_optional( const block_id_type& id ) if( e.block_id != id ) return optional(); - vector data( e.block_size ); - _blocks.seekg( e.block_pos ); - if (e.block_size) - _blocks.read( data.data(), e.block_size ); + vector data( e.block_size.value() ); + _blocks.seekg( e.block_pos.value() ); + if (e.block_size.value()) + _blocks.read( data.data(), e.block_size.value() ); auto result = fc::raw::unpack(data); FC_ASSERT( result.id() == e.block_id ); return result; @@ -189,9 +194,9 @@ optional block_database::fetch_by_number( uint32_t block_num )cons _block_num_to_pos.seekg( index_pos, _block_num_to_pos.beg ); _block_num_to_pos.read( (char*)&e, sizeof(e) ); - vector data( e.block_size ); - _blocks.seekg( e.block_pos ); - _blocks.read( data.data(), e.block_size ); + vector data( e.block_size.value() ); + _blocks.seekg( e.block_pos.value() ); + _blocks.read( data.data(), e.block_size.value() ); auto result = fc::raw::unpack(data); FC_ASSERT( result.id() == e.block_id ); return result; @@ -224,14 +229,14 @@ optional block_database::last_index_entry()const { pos -= sizeof(index_entry); _block_num_to_pos.seekg( pos ); _block_num_to_pos.read( (char*)&e, sizeof(e) ); - if( _block_num_to_pos.gcount() == sizeof(e) && e.block_size > 0 - && int64_t(e.block_pos + e.block_size) <= blocks_size ) + if( _block_num_to_pos.gcount() == sizeof(e) && e.block_size.value() > 0 + && int64_t(e.block_pos.value() + e.block_size.value()) <= blocks_size ) try { - vector data( e.block_size ); - _blocks.seekg( e.block_pos ); - _blocks.read( data.data(), e.block_size ); - if( _blocks.gcount() == long(e.block_size) ) + vector data( e.block_size.value() ); + _blocks.seekg( e.block_pos.value() ); + _blocks.read( data.data(), e.block_size.value() ); + if( _blocks.gcount() == long(e.block_size.value()) ) { const signed_block block = fc::raw::unpack(data); if( block.id() == e.block_id ) From 22ee874b85f4b88570f19f2240979d6f156e9889 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Wed, 8 May 2019 17:48:27 +0200 Subject: [PATCH 037/133] Bump fc --- libraries/fc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/fc b/libraries/fc index e003fec4cd..2cf1510d81 160000 --- a/libraries/fc +++ b/libraries/fc @@ -1 +1 @@ -Subproject commit e003fec4cd9c2d2ee4a663a631dcea6041a770ed +Subproject commit 2cf1510d819ecd81f1ce6e6d941c70c64f1edaa8 From 445c6d4f7da16883a7bab304e05cb116d580de6e Mon Sep 17 00:00:00 2001 From: Alfredo Date: Wed, 8 May 2019 17:18:17 -0300 Subject: [PATCH 038/133] move additional data computation outside loops --- libraries/app/database_api.cpp | 66 +++++++++++++++++----------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 50aad0571e..57e8a7fa37 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -931,117 +931,117 @@ std::map database_api_impl::get_full_accounts( const if( required_approvals_itr != proposals_by_account._account_to_proposals.end() ) { acnt.proposals.reserve( std::min(required_approvals_itr->second.size(), api_limit_get_full_accounts_lists) ); + if(required_approvals_itr->second.size() > api_limit_get_full_accounts_lists) + acnt.more_data_available.proposals = true; for( auto proposal_id : required_approvals_itr->second ) { acnt.proposals.push_back( proposal_id(_db) ); - if(acnt.proposals.size() >= api_limit_get_full_accounts_lists) { - acnt.more_data_available.proposals = true; + if(acnt.proposals.size() >= api_limit_get_full_accounts_lists) break; - } } } // Add the account's balances const auto& balances = _db.get_index_type< primary_index< account_balance_index > >().get_secondary_index< balances_by_account_index >().get_account_balances( account->id ); + if(balances.size() > api_limit_get_full_accounts_lists) + acnt.more_data_available.balances = true; for( const auto balance : balances ) { acnt.balances.emplace_back( *balance.second ); - if(acnt.balances.size() >= api_limit_get_full_accounts_lists) { - acnt.more_data_available.balances = true; + if(acnt.balances.size() >= api_limit_get_full_accounts_lists) break; - } } // Add the account's vesting balances auto vesting_range = _db.get_index_type().indices().get().equal_range(account->id); + if(abs(distance(vesting_range.first, vesting_range.second)) > api_limit_get_full_accounts_lists) + acnt.more_data_available.vesting_balances = true; for(auto itr = vesting_range.first; itr != vesting_range.second; ++itr) { acnt.vesting_balances.emplace_back(*itr); - if(acnt.vesting_balances.size() >= api_limit_get_full_accounts_lists) { - acnt.more_data_available.vesting_balances = true; + if(acnt.vesting_balances.size() >= api_limit_get_full_accounts_lists) break; - } } // Add the account's orders auto order_range = _db.get_index_type().indices().get().equal_range(account->id); + if(abs(distance(order_range.first, order_range.second)) > api_limit_get_full_accounts_lists) + acnt.more_data_available.limit_orders = true; for(auto itr = order_range.first; itr != order_range.second; ++itr) { acnt.limit_orders.emplace_back(*itr); - if(acnt.limit_orders.size() >= api_limit_get_full_accounts_lists) { - acnt.more_data_available.limit_orders = true; + if(acnt.limit_orders.size() >= api_limit_get_full_accounts_lists) break; - } } auto call_range = _db.get_index_type().indices().get().equal_range(account->id); + if(abs(distance(call_range.first, call_range.second)) > api_limit_get_full_accounts_lists) + acnt.more_data_available.call_orders = true; for(auto itr = call_range.first; itr != call_range.second; ++itr) { acnt.call_orders.emplace_back(*itr); - if(acnt.call_orders.size() >= api_limit_get_full_accounts_lists) { - acnt.more_data_available.call_orders = true; + if(acnt.call_orders.size() >= api_limit_get_full_accounts_lists) break; - } } auto settle_range = _db.get_index_type().indices().get().equal_range(account->id); + if(abs(distance(settle_range.first, settle_range.second)) > api_limit_get_full_accounts_lists) + acnt.more_data_available.settle_orders = true; for(auto itr = settle_range.first; itr != settle_range.second; ++itr) { acnt.settle_orders.emplace_back(*itr); - if(acnt.settle_orders.size() >= api_limit_get_full_accounts_lists) { - acnt.more_data_available.settle_orders = true; + if(acnt.settle_orders.size() >= api_limit_get_full_accounts_lists) break; - } } // get assets issued by user auto asset_range = _db.get_index_type().indices().get().equal_range(account->id); + if(abs(distance(asset_range.first, asset_range.second)) > api_limit_get_full_accounts_lists) + acnt.more_data_available.assets = true; for(auto itr = asset_range.first; itr != asset_range.second; ++itr) { acnt.assets.emplace_back(itr->id); - if(acnt.assets.size() >= api_limit_get_full_accounts_lists) { - acnt.more_data_available.assets = true; + if(acnt.assets.size() >= api_limit_get_full_accounts_lists) break; - } } // get withdraws permissions auto withdraw_indices = _db.get_index_type().indices(); auto withdraw_from_range = withdraw_indices.get().equal_range(account->id); + if(abs(distance(withdraw_from_range.first, withdraw_from_range.second)) > api_limit_get_full_accounts_lists) + acnt.more_data_available.withdraws_from = true; for(auto itr = withdraw_from_range.first; itr != withdraw_from_range.second; ++itr) { acnt.withdraws_from.emplace_back(*itr); - if(acnt.withdraws_from.size() >= api_limit_get_full_accounts_lists) { - acnt.more_data_available.withdraws_from = true; + if(acnt.withdraws_from.size() >= api_limit_get_full_accounts_lists) break; - } } auto withdraw_authorized_range = withdraw_indices.get().equal_range(account->id); + if(abs(distance(withdraw_authorized_range.first, withdraw_authorized_range.second)) > api_limit_get_full_accounts_lists) + acnt.more_data_available.withdraws_authorized = true; for(auto itr = withdraw_authorized_range.first; itr != withdraw_authorized_range.second; ++itr) { acnt.withdraws_authorized.emplace_back(*itr); - if(acnt.withdraws_authorized.size() >= api_limit_get_full_accounts_lists) { - acnt.more_data_available.withdraws_authorized = true; + if(acnt.withdraws_authorized.size() >= api_limit_get_full_accounts_lists) break; - } } // get htlcs auto htlc_from_range = _db.get_index_type().indices().get().equal_range(account->id); + if(abs(distance(htlc_from_range.first, htlc_from_range.second)) > api_limit_get_full_accounts_lists) + acnt.more_data_available.htlcs_from = true; for(auto itr = htlc_from_range.first; itr != htlc_from_range.second; ++itr) { acnt.htlcs_from.emplace_back(*itr); - if(acnt.htlcs_from.size() >= api_limit_get_full_accounts_lists) { - acnt.more_data_available.htlcs_from = true; + if(acnt.htlcs_from.size() >= api_limit_get_full_accounts_lists) break; - } } auto htlc_to_range = _db.get_index_type().indices().get().equal_range(account->id); + if(abs(distance(htlc_to_range.first, htlc_to_range.second)) > api_limit_get_full_accounts_lists) + acnt.more_data_available.htlcs_to = true; for(auto itr = htlc_to_range.first; itr != htlc_to_range.second; ++itr) { acnt.htlcs_to.emplace_back(*itr); - if(acnt.htlcs_to.size() >= api_limit_get_full_accounts_lists) { - acnt.more_data_available.htlcs_to = true; + if(acnt.htlcs_to.size() >= api_limit_get_full_accounts_lists) break; - } } results[account_name_or_id] = acnt; From 413b9cfe004bee5b57990bf7831f066f661f6101 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Wed, 8 May 2019 20:31:24 -0300 Subject: [PATCH 039/133] add get_call_orders_by_account api call --- libraries/app/application.cpp | 5 ++++ libraries/app/database_api.cpp | 30 +++++++++++++++++-- .../app/include/graphene/app/application.hpp | 1 + .../app/include/graphene/app/database_api.hpp | 9 ++++++ 4 files changed, 42 insertions(+), 3 deletions(-) diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index 5dbfdfacc3..7f70fa6b66 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -349,6 +349,9 @@ void application_impl::set_api_limit() { if(_options->count("api-limit-get-full-accounts-lists")) { _app_options.api_limit_get_full_accounts_lists = _options->at("api-limit-get-full-accounts-lists").as(); } + if(_options->count("api-limit-get-call-orders")) { + _app_options.api_limit_get_call_orders = _options->at("api-limit-get-call-orders").as(); + } } void application_impl::startup() @@ -1032,6 +1035,8 @@ void application::set_program_options(boost::program_options::options_descriptio "For database_api_impl::get_full_accounts to set its account default limit values as 10") ("api-limit-get-full-accounts-lists",boost::program_options::value()->default_value(100), "For database_api_impl::get_full_accounts to set its lists default limit values as 100") + ("api-limit-get-call-orders",boost::program_options::value()->default_value(300), + "For database_api_impl::get_call_orders and get_call_orders_by_account to set its default limit values as 300") ; command_line_options.add(configuration_file_options); command_line_options.add_options() diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 57e8a7fa37..b15199ba22 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -112,6 +112,7 @@ class database_api_impl : public std::enable_shared_from_this optional ostart_id, optional ostart_price ); vector get_call_orders(const std::string& a, uint32_t limit)const; + vector get_call_orders_by_account(const std::string& account_name_or_id, uint32_t limit)const; vector get_settle_orders(const std::string& a, uint32_t limit)const; vector get_margin_positions( const std::string account_id_or_name )const; vector get_collateral_bids(const std::string& asset, uint32_t limit, uint32_t start)const; @@ -1364,16 +1365,17 @@ vector database_api::get_call_orders(const std::string& a, ui vector database_api_impl::get_call_orders(const std::string& a, uint32_t limit)const { - FC_ASSERT( limit <= 300 ); + uint64_t api_limit_get_call_orders = _app_options->api_limit_get_call_orders; + FC_ASSERT( limit <= api_limit_get_call_orders ); const asset_object* mia = get_asset_from_string(a); const auto& call_index = _db.get_index_type().indices().get(); price index_price = price::min( mia->bitasset_data(_db).options.short_backing_asset, mia->get_id() ); - + vector< call_order_object> result; auto itr_min = call_index.lower_bound(index_price); auto itr_max = call_index.upper_bound(index_price.max()); - while( itr_min != itr_max && result.size() < limit ) + while( itr_min != itr_max && result.size() < limit ) { result.emplace_back(*itr_min); ++itr_min; @@ -1381,6 +1383,28 @@ vector database_api_impl::get_call_orders(const std::string& return result; } +vector database_api::get_call_orders_by_account(const std::string& account_name_or_id, uint32_t limit)const +{ + return my->get_call_orders_by_account( account_name_or_id, limit ); +} + +vector database_api_impl::get_call_orders_by_account(const std::string& account_name_or_id, uint32_t limit)const +{ + uint64_t api_limit_get_call_orders = _app_options->api_limit_get_call_orders; + FC_ASSERT( limit <= api_limit_get_call_orders ); + + vector< call_order_object> result; + const account_id_type account = get_account_from_string(account_name_or_id)->id; + auto call_range = _db.get_index_type().indices().get().equal_range(account); + for(auto itr = call_range.first; itr != call_range.second; ++itr) + { + result.emplace_back(*itr); + if(result.size() >= limit) + break; + } + return result; +} + vector database_api::get_settle_orders(const std::string& a, uint32_t limit)const { return my->get_settle_orders( a, limit ); diff --git a/libraries/app/include/graphene/app/application.hpp b/libraries/app/include/graphene/app/application.hpp index 018d34e77c..c22fba20a0 100644 --- a/libraries/app/include/graphene/app/application.hpp +++ b/libraries/app/include/graphene/app/application.hpp @@ -50,6 +50,7 @@ namespace graphene { namespace app { uint64_t api_limit_get_htlc_by = 100; uint64_t api_limit_get_full_accounts = 10; uint64_t api_limit_get_full_accounts_lists = 100; + uint64_t api_limit_get_call_orders = 300; }; class application diff --git a/libraries/app/include/graphene/app/database_api.hpp b/libraries/app/include/graphene/app/database_api.hpp index b5ecbf4625..8f9ee3fa28 100644 --- a/libraries/app/include/graphene/app/database_api.hpp +++ b/libraries/app/include/graphene/app/database_api.hpp @@ -444,6 +444,14 @@ class database_api */ vector get_call_orders(const std::string& a, uint32_t limit)const; + /** + * @brief Get call orders from a given account + * @param account_name_or_id Account name or ID to get objects from + * @param limit Maximum number of objects to retrieve + * @return The call orders of the account + */ + vector get_call_orders_by_account(const std::string& account_name_or_id, uint32_t limit)const; + /** * @brief Get forced settlement orders in a given asset * @param a Symbol or ID of asset being settled @@ -843,6 +851,7 @@ FC_API(graphene::app::database_api, (get_limit_orders) (get_account_limit_orders) (get_call_orders) + (get_call_orders_by_account) (get_settle_orders) (get_margin_positions) (get_collateral_bids) From 4eeb4d3c1a4db1de54b99cffb07be9966892556f Mon Sep 17 00:00:00 2001 From: Alfredo Date: Wed, 8 May 2019 20:36:14 -0300 Subject: [PATCH 040/133] remove unsigned warnings --- libraries/app/database_api.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index b15199ba22..c90894054a 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -955,7 +955,7 @@ std::map database_api_impl::get_full_accounts( const // Add the account's vesting balances auto vesting_range = _db.get_index_type().indices().get().equal_range(account->id); - if(abs(distance(vesting_range.first, vesting_range.second)) > api_limit_get_full_accounts_lists) + if((unsigned)abs(distance(vesting_range.first, vesting_range.second)) > api_limit_get_full_accounts_lists) acnt.more_data_available.vesting_balances = true; for(auto itr = vesting_range.first; itr != vesting_range.second; ++itr) { @@ -966,7 +966,7 @@ std::map database_api_impl::get_full_accounts( const // Add the account's orders auto order_range = _db.get_index_type().indices().get().equal_range(account->id); - if(abs(distance(order_range.first, order_range.second)) > api_limit_get_full_accounts_lists) + if((unsigned)abs(distance(order_range.first, order_range.second)) > api_limit_get_full_accounts_lists) acnt.more_data_available.limit_orders = true; for(auto itr = order_range.first; itr != order_range.second; ++itr) { @@ -975,7 +975,7 @@ std::map database_api_impl::get_full_accounts( const break; } auto call_range = _db.get_index_type().indices().get().equal_range(account->id); - if(abs(distance(call_range.first, call_range.second)) > api_limit_get_full_accounts_lists) + if((unsigned)abs(distance(call_range.first, call_range.second)) > api_limit_get_full_accounts_lists) acnt.more_data_available.call_orders = true; for(auto itr = call_range.first; itr != call_range.second; ++itr) { @@ -984,7 +984,7 @@ std::map database_api_impl::get_full_accounts( const break; } auto settle_range = _db.get_index_type().indices().get().equal_range(account->id); - if(abs(distance(settle_range.first, settle_range.second)) > api_limit_get_full_accounts_lists) + if((unsigned)abs(distance(settle_range.first, settle_range.second)) > api_limit_get_full_accounts_lists) acnt.more_data_available.settle_orders = true; for(auto itr = settle_range.first; itr != settle_range.second; ++itr) { @@ -995,7 +995,7 @@ std::map database_api_impl::get_full_accounts( const // get assets issued by user auto asset_range = _db.get_index_type().indices().get().equal_range(account->id); - if(abs(distance(asset_range.first, asset_range.second)) > api_limit_get_full_accounts_lists) + if((unsigned)abs(distance(asset_range.first, asset_range.second)) > api_limit_get_full_accounts_lists) acnt.more_data_available.assets = true; for(auto itr = asset_range.first; itr != asset_range.second; ++itr) { @@ -1007,7 +1007,7 @@ std::map database_api_impl::get_full_accounts( const // get withdraws permissions auto withdraw_indices = _db.get_index_type().indices(); auto withdraw_from_range = withdraw_indices.get().equal_range(account->id); - if(abs(distance(withdraw_from_range.first, withdraw_from_range.second)) > api_limit_get_full_accounts_lists) + if((unsigned)abs(distance(withdraw_from_range.first, withdraw_from_range.second)) > api_limit_get_full_accounts_lists) acnt.more_data_available.withdraws_from = true; for(auto itr = withdraw_from_range.first; itr != withdraw_from_range.second; ++itr) { @@ -1016,7 +1016,7 @@ std::map database_api_impl::get_full_accounts( const break; } auto withdraw_authorized_range = withdraw_indices.get().equal_range(account->id); - if(abs(distance(withdraw_authorized_range.first, withdraw_authorized_range.second)) > api_limit_get_full_accounts_lists) + if((unsigned)abs(distance(withdraw_authorized_range.first, withdraw_authorized_range.second)) > api_limit_get_full_accounts_lists) acnt.more_data_available.withdraws_authorized = true; for(auto itr = withdraw_authorized_range.first; itr != withdraw_authorized_range.second; ++itr) { @@ -1027,7 +1027,7 @@ std::map database_api_impl::get_full_accounts( const // get htlcs auto htlc_from_range = _db.get_index_type().indices().get().equal_range(account->id); - if(abs(distance(htlc_from_range.first, htlc_from_range.second)) > api_limit_get_full_accounts_lists) + if((unsigned)abs(distance(htlc_from_range.first, htlc_from_range.second)) > api_limit_get_full_accounts_lists) acnt.more_data_available.htlcs_from = true; for(auto itr = htlc_from_range.first; itr != htlc_from_range.second; ++itr) { @@ -1036,7 +1036,7 @@ std::map database_api_impl::get_full_accounts( const break; } auto htlc_to_range = _db.get_index_type().indices().get().equal_range(account->id); - if(abs(distance(htlc_to_range.first, htlc_to_range.second)) > api_limit_get_full_accounts_lists) + if((unsigned)abs(distance(htlc_to_range.first, htlc_to_range.second)) > api_limit_get_full_accounts_lists) acnt.more_data_available.htlcs_to = true; for(auto itr = htlc_to_range.first; itr != htlc_to_range.second; ++itr) { From bda09a0989d8b5c030792b1dc6ecc12217b43868 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Thu, 9 May 2019 14:59:20 -0300 Subject: [PATCH 041/133] move additional data logic back to inside loops as suggested by abit --- libraries/app/database_api.cpp | 88 +++++++++++++++++----------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index c90894054a..516298711e 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -932,117 +932,117 @@ std::map database_api_impl::get_full_accounts( const if( required_approvals_itr != proposals_by_account._account_to_proposals.end() ) { acnt.proposals.reserve( std::min(required_approvals_itr->second.size(), api_limit_get_full_accounts_lists) ); - if(required_approvals_itr->second.size() > api_limit_get_full_accounts_lists) - acnt.more_data_available.proposals = true; for( auto proposal_id : required_approvals_itr->second ) { - acnt.proposals.push_back( proposal_id(_db) ); - if(acnt.proposals.size() >= api_limit_get_full_accounts_lists) + if(acnt.proposals.size() >= api_limit_get_full_accounts_lists) { + acnt.more_data_available.proposals = true; break; + } + acnt.proposals.push_back(proposal_id(_db)); } } // Add the account's balances const auto& balances = _db.get_index_type< primary_index< account_balance_index > >().get_secondary_index< balances_by_account_index >().get_account_balances( account->id ); - if(balances.size() > api_limit_get_full_accounts_lists) - acnt.more_data_available.balances = true; for( const auto balance : balances ) { - acnt.balances.emplace_back( *balance.second ); - if(acnt.balances.size() >= api_limit_get_full_accounts_lists) + if(acnt.balances.size() >= api_limit_get_full_accounts_lists) { + acnt.more_data_available.balances = true; break; + } + acnt.balances.emplace_back(*balance.second); } // Add the account's vesting balances auto vesting_range = _db.get_index_type().indices().get().equal_range(account->id); - if((unsigned)abs(distance(vesting_range.first, vesting_range.second)) > api_limit_get_full_accounts_lists) - acnt.more_data_available.vesting_balances = true; for(auto itr = vesting_range.first; itr != vesting_range.second; ++itr) { - acnt.vesting_balances.emplace_back(*itr); - if(acnt.vesting_balances.size() >= api_limit_get_full_accounts_lists) + if(acnt.vesting_balances.size() >= api_limit_get_full_accounts_lists) { + acnt.more_data_available.vesting_balances = true; break; + } + acnt.vesting_balances.emplace_back(*itr); } // Add the account's orders auto order_range = _db.get_index_type().indices().get().equal_range(account->id); - if((unsigned)abs(distance(order_range.first, order_range.second)) > api_limit_get_full_accounts_lists) - acnt.more_data_available.limit_orders = true; for(auto itr = order_range.first; itr != order_range.second; ++itr) { - acnt.limit_orders.emplace_back(*itr); - if(acnt.limit_orders.size() >= api_limit_get_full_accounts_lists) + if(acnt.limit_orders.size() >= api_limit_get_full_accounts_lists) { + acnt.more_data_available.limit_orders = true; break; + } + acnt.limit_orders.emplace_back(*itr); } auto call_range = _db.get_index_type().indices().get().equal_range(account->id); - if((unsigned)abs(distance(call_range.first, call_range.second)) > api_limit_get_full_accounts_lists) - acnt.more_data_available.call_orders = true; for(auto itr = call_range.first; itr != call_range.second; ++itr) { - acnt.call_orders.emplace_back(*itr); - if(acnt.call_orders.size() >= api_limit_get_full_accounts_lists) + if(acnt.call_orders.size() >= api_limit_get_full_accounts_lists) { + acnt.more_data_available.call_orders = true; break; + } + acnt.call_orders.emplace_back(*itr); } auto settle_range = _db.get_index_type().indices().get().equal_range(account->id); - if((unsigned)abs(distance(settle_range.first, settle_range.second)) > api_limit_get_full_accounts_lists) - acnt.more_data_available.settle_orders = true; for(auto itr = settle_range.first; itr != settle_range.second; ++itr) { - acnt.settle_orders.emplace_back(*itr); - if(acnt.settle_orders.size() >= api_limit_get_full_accounts_lists) + if(acnt.settle_orders.size() >= api_limit_get_full_accounts_lists) { + acnt.more_data_available.settle_orders = true; break; + } + acnt.settle_orders.emplace_back(*itr); } // get assets issued by user auto asset_range = _db.get_index_type().indices().get().equal_range(account->id); - if((unsigned)abs(distance(asset_range.first, asset_range.second)) > api_limit_get_full_accounts_lists) - acnt.more_data_available.assets = true; for(auto itr = asset_range.first; itr != asset_range.second; ++itr) { - acnt.assets.emplace_back(itr->id); - if(acnt.assets.size() >= api_limit_get_full_accounts_lists) + if(acnt.assets.size() >= api_limit_get_full_accounts_lists) { + acnt.more_data_available.assets = true; break; + } + acnt.assets.emplace_back(itr->id); } // get withdraws permissions auto withdraw_indices = _db.get_index_type().indices(); auto withdraw_from_range = withdraw_indices.get().equal_range(account->id); - if((unsigned)abs(distance(withdraw_from_range.first, withdraw_from_range.second)) > api_limit_get_full_accounts_lists) - acnt.more_data_available.withdraws_from = true; for(auto itr = withdraw_from_range.first; itr != withdraw_from_range.second; ++itr) { - acnt.withdraws_from.emplace_back(*itr); - if(acnt.withdraws_from.size() >= api_limit_get_full_accounts_lists) + if(acnt.withdraws_from.size() >= api_limit_get_full_accounts_lists) { + acnt.more_data_available.withdraws_from = true; break; + } + acnt.withdraws_from.emplace_back(*itr); } auto withdraw_authorized_range = withdraw_indices.get().equal_range(account->id); - if((unsigned)abs(distance(withdraw_authorized_range.first, withdraw_authorized_range.second)) > api_limit_get_full_accounts_lists) - acnt.more_data_available.withdraws_authorized = true; for(auto itr = withdraw_authorized_range.first; itr != withdraw_authorized_range.second; ++itr) { - acnt.withdraws_authorized.emplace_back(*itr); - if(acnt.withdraws_authorized.size() >= api_limit_get_full_accounts_lists) + if(acnt.withdraws_authorized.size() >= api_limit_get_full_accounts_lists) { + acnt.more_data_available.withdraws_authorized = true; break; + } + acnt.withdraws_authorized.emplace_back(*itr); } // get htlcs auto htlc_from_range = _db.get_index_type().indices().get().equal_range(account->id); - if((unsigned)abs(distance(htlc_from_range.first, htlc_from_range.second)) > api_limit_get_full_accounts_lists) - acnt.more_data_available.htlcs_from = true; for(auto itr = htlc_from_range.first; itr != htlc_from_range.second; ++itr) { - acnt.htlcs_from.emplace_back(*itr); - if(acnt.htlcs_from.size() >= api_limit_get_full_accounts_lists) + if(acnt.htlcs_from.size() >= api_limit_get_full_accounts_lists) { + acnt.more_data_available.htlcs_from = true; break; + } + acnt.htlcs_from.emplace_back(*itr); } auto htlc_to_range = _db.get_index_type().indices().get().equal_range(account->id); - if((unsigned)abs(distance(htlc_to_range.first, htlc_to_range.second)) > api_limit_get_full_accounts_lists) - acnt.more_data_available.htlcs_to = true; for(auto itr = htlc_to_range.first; itr != htlc_to_range.second; ++itr) { - acnt.htlcs_to.emplace_back(*itr); - if(acnt.htlcs_to.size() >= api_limit_get_full_accounts_lists) + if(acnt.htlcs_to.size() >= api_limit_get_full_accounts_lists) { + acnt.more_data_available.htlcs_to = true; break; + } + acnt.htlcs_to.emplace_back(*itr); } results[account_name_or_id] = acnt; From 66c0f40ae89130ce018ffb4c92a5d588d698c3d9 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Thu, 9 May 2019 15:42:01 -0300 Subject: [PATCH 042/133] do proposal index in 1 line --- libraries/app/database_api.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 516298711e..0f6db31a87 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -892,10 +892,6 @@ std::map database_api_impl::get_full_accounts( const { FC_ASSERT( names_or_ids.size() <= _app_options->api_limit_get_full_accounts ); - const auto& proposal_idx = _db.get_index_type(); - const auto& pidx = dynamic_cast(proposal_idx); - const auto& proposals_by_account = pidx.get_secondary_index(); - std::map results; for (const std::string& account_name_or_id : names_or_ids) @@ -928,6 +924,8 @@ std::map database_api_impl::get_full_accounts( const uint64_t api_limit_get_full_accounts_lists = _app_options->api_limit_get_full_accounts_lists; // Add the account's proposals + const auto& proposal_idx = _db.get_index_type< primary_index< proposal_index > >(); + const auto& proposals_by_account = proposal_idx.get_secondary_index(); auto required_approvals_itr = proposals_by_account._account_to_proposals.find( account->id ); if( required_approvals_itr != proposals_by_account._account_to_proposals.end() ) { @@ -2388,9 +2386,8 @@ vector database_api::get_proposed_transactions( const std::stri vector database_api_impl::get_proposed_transactions( const std::string account_id_or_name )const { - const auto& proposal_idx = _db.get_index_type(); - const auto& pidx = dynamic_cast(proposal_idx); - const auto& proposals_by_account = pidx.get_secondary_index(); + const auto& proposal_idx = _db.get_index_type< primary_index< proposal_index > >(); + const auto& proposals_by_account = proposal_idx.get_secondary_index(); vector result; const account_id_type id = get_account_from_string(account_id_or_name)->id; From 65d518021bd98250dcb928e29bae3b412072ed57 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Thu, 9 May 2019 16:20:15 -0300 Subject: [PATCH 043/133] change to withdraws_to for consistency, wrap long line --- libraries/app/database_api.cpp | 9 +++++---- libraries/app/include/graphene/app/full_account.hpp | 8 ++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 0f6db31a87..568e8c9626 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -941,7 +941,8 @@ std::map database_api_impl::get_full_accounts( const } // Add the account's balances - const auto& balances = _db.get_index_type< primary_index< account_balance_index > >().get_secondary_index< balances_by_account_index >().get_account_balances( account->id ); + const auto& balances = _db.get_index_type< primary_index< account_balance_index > >(). + get_secondary_index< balances_by_account_index >().get_account_balances( account->id ); for( const auto balance : balances ) { if(acnt.balances.size() >= api_limit_get_full_accounts_lists) { @@ -1016,11 +1017,11 @@ std::map database_api_impl::get_full_accounts( const auto withdraw_authorized_range = withdraw_indices.get().equal_range(account->id); for(auto itr = withdraw_authorized_range.first; itr != withdraw_authorized_range.second; ++itr) { - if(acnt.withdraws_authorized.size() >= api_limit_get_full_accounts_lists) { - acnt.more_data_available.withdraws_authorized = true; + if(acnt.withdraws_to.size() >= api_limit_get_full_accounts_lists) { + acnt.more_data_available.withdraws_to = true; break; } - acnt.withdraws_authorized.emplace_back(*itr); + acnt.withdraws_to.emplace_back(*itr); } // get htlcs diff --git a/libraries/app/include/graphene/app/full_account.hpp b/libraries/app/include/graphene/app/full_account.hpp index ebb1144cdb..84ffbab42c 100644 --- a/libraries/app/include/graphene/app/full_account.hpp +++ b/libraries/app/include/graphene/app/full_account.hpp @@ -41,7 +41,7 @@ namespace graphene { namespace app { bool proposals = false; bool assets = false; bool withdraws_from = false; - bool withdraws_authorized = false; + bool withdraws_to = false; bool htlcs_from = false; bool htlcs_to = false; }; @@ -63,7 +63,7 @@ namespace graphene { namespace app { vector proposals; vector assets; vector withdraws_from; - vector withdraws_authorized; + vector withdraws_to; vector htlcs_from; vector htlcs_to; more_data more_data_available; @@ -73,7 +73,7 @@ namespace graphene { namespace app { FC_REFLECT( graphene::app::more_data, (balances) (vesting_balances) (limit_orders) (call_orders) - (settle_orders) (proposals) (assets) (withdraws_from) (withdraws_authorized) (htlcs_from) (htlcs_to) + (settle_orders) (proposals) (assets) (withdraws_from) (withdraws_to) (htlcs_from) (htlcs_to) ) FC_REFLECT( graphene::app::full_account, @@ -92,7 +92,7 @@ FC_REFLECT( graphene::app::full_account, (proposals) (assets) (withdraws_from) - (withdraws_authorized) + (withdraws_to) (htlcs_from) (htlcs_to) (more_data_available) From 38c3cef72d6379b50b2268fe908a84d467ca6b93 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Thu, 9 May 2019 17:50:53 -0300 Subject: [PATCH 044/133] add start argument to get_call_orders_by_account --- libraries/app/database_api.cpp | 24 +++++++++++-------- .../app/include/graphene/app/database_api.hpp | 4 +++- .../include/graphene/chain/market_object.hpp | 7 ++++++ 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 568e8c9626..f5f798f599 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -112,7 +112,8 @@ class database_api_impl : public std::enable_shared_from_this optional ostart_id, optional ostart_price ); vector get_call_orders(const std::string& a, uint32_t limit)const; - vector get_call_orders_by_account(const std::string& account_name_or_id, uint32_t limit)const; + vector get_call_orders_by_account(const std::string& account_name_or_id, + call_order_id_type start, uint32_t limit)const; vector get_settle_orders(const std::string& a, uint32_t limit)const; vector get_margin_positions( const std::string account_id_or_name )const; vector get_collateral_bids(const std::string& asset, uint32_t limit, uint32_t start)const; @@ -1382,24 +1383,27 @@ vector database_api_impl::get_call_orders(const std::string& return result; } -vector database_api::get_call_orders_by_account(const std::string& account_name_or_id, uint32_t limit)const +vector database_api::get_call_orders_by_account(const std::string& account_name_or_id, + call_order_id_type start, uint32_t limit)const { - return my->get_call_orders_by_account( account_name_or_id, limit ); + return my->get_call_orders_by_account( account_name_or_id, start, limit ); } -vector database_api_impl::get_call_orders_by_account(const std::string& account_name_or_id, uint32_t limit)const +vector database_api_impl::get_call_orders_by_account(const std::string& account_name_or_id, + call_order_id_type start, uint32_t limit)const { uint64_t api_limit_get_call_orders = _app_options->api_limit_get_call_orders; FC_ASSERT( limit <= api_limit_get_call_orders ); - vector< call_order_object> result; + vector result; const account_id_type account = get_account_from_string(account_name_or_id)->id; - auto call_range = _db.get_index_type().indices().get().equal_range(account); - for(auto itr = call_range.first; itr != call_range.second; ++itr) + const auto& call_idx = _db.get_index_type().indices().get(); + auto call_index_end = call_idx.end(); + auto call_itr = call_idx.lower_bound(boost::make_tuple(account, start)); + while(call_itr != call_index_end && call_itr->borrower == account && result.size() < limit) { - result.emplace_back(*itr); - if(result.size() >= limit) - break; + result.push_back(*call_itr); + ++call_itr; } return result; } diff --git a/libraries/app/include/graphene/app/database_api.hpp b/libraries/app/include/graphene/app/database_api.hpp index 8f9ee3fa28..3b901a1f01 100644 --- a/libraries/app/include/graphene/app/database_api.hpp +++ b/libraries/app/include/graphene/app/database_api.hpp @@ -447,10 +447,12 @@ class database_api /** * @brief Get call orders from a given account * @param account_name_or_id Account name or ID to get objects from + * @param start Withdraw permission objects(1.8.X) before this ID will be skipped in results. Pagination purposes. * @param limit Maximum number of objects to retrieve * @return The call orders of the account */ - vector get_call_orders_by_account(const std::string& account_name_or_id, uint32_t limit)const; + vector get_call_orders_by_account(const std::string& account_name_or_id, + call_order_id_type start, uint32_t limit)const; /** * @brief Get forced settlement orders in a given asset diff --git a/libraries/chain/include/graphene/chain/market_object.hpp b/libraries/chain/include/graphene/chain/market_object.hpp index 168e2b6439..337151de21 100644 --- a/libraries/chain/include/graphene/chain/market_object.hpp +++ b/libraries/chain/include/graphene/chain/market_object.hpp @@ -196,6 +196,7 @@ class collateral_bid_object : public abstract_object struct by_collateral; struct by_account; struct by_price; +struct by_account_and_id; typedef multi_index_container< call_order_object, indexed_by< @@ -214,6 +215,12 @@ typedef multi_index_container< const_mem_fun< call_order_object, asset_id_type, &call_order_object::debt_type> > >, + ordered_unique< tag, + composite_key< call_order_object, + member< call_order_object, account_id_type, &call_order_object::borrower >, + member< object, object_id_type, &object::id > + > + >, ordered_unique< tag, composite_key< call_order_object, const_mem_fun< call_order_object, price, &call_order_object::collateralization >, From cd504f59c409bd3b9740435e9a94968791cf91a7 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Thu, 9 May 2019 18:37:45 -0300 Subject: [PATCH 045/133] add get_settle_orders_by_account --- libraries/app/application.cpp | 5 +++ libraries/app/database_api.cpp | 31 ++++++++++++++++++- .../app/include/graphene/app/application.hpp | 1 + .../app/include/graphene/app/database_api.hpp | 11 +++++++ 4 files changed, 47 insertions(+), 1 deletion(-) diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index 7f70fa6b66..43498f50af 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -352,6 +352,9 @@ void application_impl::set_api_limit() { if(_options->count("api-limit-get-call-orders")) { _app_options.api_limit_get_call_orders = _options->at("api-limit-get-call-orders").as(); } + if(_options->count("api-limit-get-settle-orders")) { + _app_options.api_limit_get_settle_orders = _options->at("api-limit-get-settle-orders").as(); + } } void application_impl::startup() @@ -1037,6 +1040,8 @@ void application::set_program_options(boost::program_options::options_descriptio "For database_api_impl::get_full_accounts to set its lists default limit values as 100") ("api-limit-get-call-orders",boost::program_options::value()->default_value(300), "For database_api_impl::get_call_orders and get_call_orders_by_account to set its default limit values as 300") + ("api-limit-get-settle-orders",boost::program_options::value()->default_value(300), + "For database_api_impl::get_settle_orders and get_settle_orders_by_account to set its default limit values as 300") ; command_line_options.add(configuration_file_options); command_line_options.add_options() diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index f5f798f599..e7eb42e572 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -115,6 +115,8 @@ class database_api_impl : public std::enable_shared_from_this vector get_call_orders_by_account(const std::string& account_name_or_id, call_order_id_type start, uint32_t limit)const; vector get_settle_orders(const std::string& a, uint32_t limit)const; + vector get_settle_orders_by_account(const std::string& account_name_or_id, + force_settlement_id_type start, uint32_t limit)const; vector get_margin_positions( const std::string account_id_or_name )const; vector get_collateral_bids(const std::string& asset, uint32_t limit, uint32_t start)const; @@ -1415,7 +1417,8 @@ vector database_api::get_settle_orders(const std::strin vector database_api_impl::get_settle_orders(const std::string& a, uint32_t limit)const { - FC_ASSERT( limit <= 300 ); + uint64_t api_limit_get_settle_orders = _app_options->api_limit_get_settle_orders; + FC_ASSERT( limit <= api_limit_get_settle_orders ); const asset_id_type asset_a_id = get_asset_from_string(a)->id; const auto& settle_index = _db.get_index_type().indices().get(); @@ -1432,6 +1435,32 @@ vector database_api_impl::get_settle_orders(const std:: return result; } +vector database_api::get_settle_orders_by_account(const std::string& account_name_or_id, + force_settlement_id_type start, uint32_t limit)const +{ + return my->get_settle_orders_by_account( account_name_or_id, start, limit); +} + +vector database_api_impl::get_settle_orders_by_account(const std::string& account_name_or_id, + force_settlement_id_type start, uint32_t limit)const +{ + uint64_t api_limit_get_settle_orders = _app_options->api_limit_get_settle_orders; + FC_ASSERT( limit <= api_limit_get_settle_orders ); + + vector result; + const account_id_type account = get_account_from_string(account_name_or_id)->id; + const auto& settle_idx = _db.get_index_type().indices().get(); + auto settle_index_end = settle_idx.end(); + auto settle_itr = settle_idx.lower_bound(boost::make_tuple(account, start)); + while(settle_itr != settle_index_end && settle_itr->owner == account && result.size() < limit) + { + result.push_back(*settle_itr); + ++settle_itr; + } + return result; +} + + vector database_api::get_margin_positions( const std::string account_id_or_name )const { return my->get_margin_positions( account_id_or_name ); diff --git a/libraries/app/include/graphene/app/application.hpp b/libraries/app/include/graphene/app/application.hpp index c22fba20a0..67edcb5374 100644 --- a/libraries/app/include/graphene/app/application.hpp +++ b/libraries/app/include/graphene/app/application.hpp @@ -51,6 +51,7 @@ namespace graphene { namespace app { uint64_t api_limit_get_full_accounts = 10; uint64_t api_limit_get_full_accounts_lists = 100; uint64_t api_limit_get_call_orders = 300; + uint64_t api_limit_get_settle_orders = 300; }; class application diff --git a/libraries/app/include/graphene/app/database_api.hpp b/libraries/app/include/graphene/app/database_api.hpp index 3b901a1f01..27d7409ec7 100644 --- a/libraries/app/include/graphene/app/database_api.hpp +++ b/libraries/app/include/graphene/app/database_api.hpp @@ -462,6 +462,16 @@ class database_api */ vector get_settle_orders(const std::string& a, uint32_t limit)const; + /** + * @brief Get forced settlement orders of a given account + * @param account_name_or_id Account name or ID to get objects from + * @param start Withdraw permission objects(1.4.X) before this ID will be skipped in results. Pagination purposes. + * @param limit Maximum number of orders to retrieve + * @return The settle orders of the account + */ + vector get_settle_orders_by_account(const std::string& account_name_or_id, + force_settlement_id_type start, uint32_t limit)const; + /** * @brief Get collateral_bid_objects for a given asset * @param a Symbol or ID of asset @@ -855,6 +865,7 @@ FC_API(graphene::app::database_api, (get_call_orders) (get_call_orders_by_account) (get_settle_orders) + (get_settle_orders_by_account) (get_margin_positions) (get_collateral_bids) (subscribe_to_market) From ce709f9abc1ac31e920b6bbf85107dff9a0da3f6 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Thu, 9 May 2019 19:57:14 -0300 Subject: [PATCH 046/133] add get_assets_by_issuer api call --- libraries/app/application.cpp | 5 +++ libraries/app/database_api.cpp | 33 +++++++++++++++++-- .../app/include/graphene/app/application.hpp | 1 + .../app/include/graphene/app/database_api.hpp | 11 +++++++ .../include/graphene/chain/asset_object.hpp | 7 ++++ 5 files changed, 55 insertions(+), 2 deletions(-) diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index 43498f50af..d6acc64453 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -355,6 +355,9 @@ void application_impl::set_api_limit() { if(_options->count("api-limit-get-settle-orders")) { _app_options.api_limit_get_settle_orders = _options->at("api-limit-get-settle-orders").as(); } + if(_options->count("api-limit-get-assets")) { + _app_options.api_limit_get_assets = _options->at("api-limit-get-assets").as(); + } } void application_impl::startup() @@ -1042,6 +1045,8 @@ void application::set_program_options(boost::program_options::options_descriptio "For database_api_impl::get_call_orders and get_call_orders_by_account to set its default limit values as 300") ("api-limit-get-settle-orders",boost::program_options::value()->default_value(300), "For database_api_impl::get_settle_orders and get_settle_orders_by_account to set its default limit values as 300") + ("api-limit-get-assets",boost::program_options::value()->default_value(101), + "For database_api_impl::list_assets and get_assets_by_issuer to set its default limit values as 101") ; command_line_options.add(configuration_file_options); command_line_options.add_options() diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index e7eb42e572..44a7255976 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -103,6 +103,8 @@ class database_api_impl : public std::enable_shared_from_this vector list_assets(const string& lower_bound_symbol, uint32_t limit)const; vector> lookup_asset_symbols(const vector& symbols_or_ids)const; uint64_t get_asset_count()const; + vector get_assets_by_issuer(const std::string& issuer_name_or_id, + asset_id_type start, uint32_t limit)const; // Markets / feeds vector get_limit_orders(const std::string& a, const std::string& b, uint32_t limit)const; @@ -929,7 +931,7 @@ std::map database_api_impl::get_full_accounts( const // Add the account's proposals const auto& proposal_idx = _db.get_index_type< primary_index< proposal_index > >(); const auto& proposals_by_account = proposal_idx.get_secondary_index(); - auto required_approvals_itr = proposals_by_account._account_to_proposals.find( account->id ); + auto required_approvals_itr = proposals_by_account._account_to_proposals.find( account->id ); if( required_approvals_itr != proposals_by_account._account_to_proposals.end() ) { acnt.proposals.reserve( std::min(required_approvals_itr->second.size(), api_limit_get_full_accounts_lists) ); @@ -1287,7 +1289,9 @@ vector database_api::list_assets(const string& lower_bound_symbol, vector database_api_impl::list_assets(const string& lower_bound_symbol, uint32_t limit)const { - FC_ASSERT( limit <= 101 ); + uint64_t api_limit_get_assets = _app_options->api_limit_get_assets; + FC_ASSERT( limit <= api_limit_get_assets ); + const auto& assets_by_symbol = _db.get_index_type().indices().get(); vector result; result.reserve(limit); @@ -1313,6 +1317,31 @@ uint64_t database_api_impl::get_asset_count()const return _db.get_index_type().indices().size(); } +vector database_api::get_assets_by_issuer(const std::string& issuer_name_or_id, + asset_id_type start, uint32_t limit)const +{ + return my->get_assets_by_issuer(issuer_name_or_id, start, limit); +} + +vector database_api_impl::get_assets_by_issuer(const std::string& issuer_name_or_id, + asset_id_type start, uint32_t limit)const +{ + uint64_t api_limit_get_assets = _app_options->api_limit_get_assets; + FC_ASSERT( limit <= api_limit_get_assets ); + + vector result; + const account_id_type account = get_account_from_string(issuer_name_or_id)->id; + const auto& asset_idx = _db.get_index_type().indices().get(); + auto asset_index_end = asset_idx.end(); + auto asset_itr = asset_idx.lower_bound(boost::make_tuple(account, start)); + while(asset_itr != asset_index_end && asset_itr->issuer == account && result.size() < limit) + { + result.push_back(*asset_itr); + ++asset_itr; + } + return result; +} + vector> database_api::lookup_asset_symbols(const vector& symbols_or_ids)const { return my->lookup_asset_symbols( symbols_or_ids ); diff --git a/libraries/app/include/graphene/app/application.hpp b/libraries/app/include/graphene/app/application.hpp index 67edcb5374..aa6854a0af 100644 --- a/libraries/app/include/graphene/app/application.hpp +++ b/libraries/app/include/graphene/app/application.hpp @@ -52,6 +52,7 @@ namespace graphene { namespace app { uint64_t api_limit_get_full_accounts_lists = 100; uint64_t api_limit_get_call_orders = 300; uint64_t api_limit_get_settle_orders = 300; + uint64_t api_limit_get_assets = 101; }; class application diff --git a/libraries/app/include/graphene/app/database_api.hpp b/libraries/app/include/graphene/app/database_api.hpp index 27d7409ec7..8b33bfce6c 100644 --- a/libraries/app/include/graphene/app/database_api.hpp +++ b/libraries/app/include/graphene/app/database_api.hpp @@ -423,6 +423,16 @@ class database_api */ uint64_t get_asset_count()const; + /** + * @brief Get asset objects issued from a given account + * @param account_name_or_id Account name or ID to get objects from + * @param start Withdraw permission objects(1.3.X) before this ID will be skipped in results. Pagination purposes. + * @param limit Maximum number of orders to retrieve + * @return The assets issued by the account + */ + vector get_assets_by_issuer(const std::string& issuer_name_or_id, + asset_id_type start, uint32_t limit)const; + ///////////////////// // Markets / feeds // ///////////////////// @@ -856,6 +866,7 @@ FC_API(graphene::app::database_api, (list_assets) (lookup_asset_symbols) (get_asset_count) + (get_assets_by_issuer) (get_asset_id_from_string) // Markets / feeds diff --git a/libraries/chain/include/graphene/chain/asset_object.hpp b/libraries/chain/include/graphene/chain/asset_object.hpp index 38081dc40f..516d325bff 100644 --- a/libraries/chain/include/graphene/chain/asset_object.hpp +++ b/libraries/chain/include/graphene/chain/asset_object.hpp @@ -294,6 +294,7 @@ namespace graphene { namespace chain { struct by_symbol; struct by_type; struct by_issuer; + struct by_issuer_and_id; typedef multi_index_container< asset_object, indexed_by< @@ -305,6 +306,12 @@ namespace graphene { namespace chain { const_mem_fun, member< object, object_id_type, &object::id > > + >, + ordered_unique< tag, + composite_key< asset_object, + member< asset_object, account_id_type, &asset_object::issuer >, + member< object, object_id_type, &object::id > + > > > > asset_object_multi_index_type; From ed53cb09fd677fa95d01cd3ad10b0d2fe0acd924 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Fri, 10 May 2019 10:58:03 -0300 Subject: [PATCH 047/133] move back proposal index outside of the loop --- libraries/app/database_api.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 44a7255976..d7d3a5358d 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -897,6 +897,9 @@ std::map database_api_impl::get_full_accounts( const { FC_ASSERT( names_or_ids.size() <= _app_options->api_limit_get_full_accounts ); + const auto& proposal_idx = _db.get_index_type< primary_index< proposal_index > >(); + const auto& proposals_by_account = proposal_idx.get_secondary_index(); + std::map results; for (const std::string& account_name_or_id : names_or_ids) @@ -929,8 +932,6 @@ std::map database_api_impl::get_full_accounts( const uint64_t api_limit_get_full_accounts_lists = _app_options->api_limit_get_full_accounts_lists; // Add the account's proposals - const auto& proposal_idx = _db.get_index_type< primary_index< proposal_index > >(); - const auto& proposals_by_account = proposal_idx.get_secondary_index(); auto required_approvals_itr = proposals_by_account._account_to_proposals.find( account->id ); if( required_approvals_itr != proposals_by_account._account_to_proposals.end() ) { From 0968f95c2e8b761808bc3058ebfae44a21814dbc Mon Sep 17 00:00:00 2001 From: Alfredo Date: Fri, 10 May 2019 11:15:15 -0300 Subject: [PATCH 048/133] fix c&p errors --- libraries/app/include/graphene/app/database_api.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/app/include/graphene/app/database_api.hpp b/libraries/app/include/graphene/app/database_api.hpp index 8b33bfce6c..341d95cafa 100644 --- a/libraries/app/include/graphene/app/database_api.hpp +++ b/libraries/app/include/graphene/app/database_api.hpp @@ -426,7 +426,7 @@ class database_api /** * @brief Get asset objects issued from a given account * @param account_name_or_id Account name or ID to get objects from - * @param start Withdraw permission objects(1.3.X) before this ID will be skipped in results. Pagination purposes. + * @param start Asset objects(1.3.X) before this ID will be skipped in results. Pagination purposes. * @param limit Maximum number of orders to retrieve * @return The assets issued by the account */ @@ -457,7 +457,7 @@ class database_api /** * @brief Get call orders from a given account * @param account_name_or_id Account name or ID to get objects from - * @param start Withdraw permission objects(1.8.X) before this ID will be skipped in results. Pagination purposes. + * @param start Call order objects(1.8.X) before this ID will be skipped in results. Pagination purposes. * @param limit Maximum number of objects to retrieve * @return The call orders of the account */ @@ -475,7 +475,7 @@ class database_api /** * @brief Get forced settlement orders of a given account * @param account_name_or_id Account name or ID to get objects from - * @param start Withdraw permission objects(1.4.X) before this ID will be skipped in results. Pagination purposes. + * @param start Force settlement objects(1.4.X) before this ID will be skipped in results. Pagination purposes. * @param limit Maximum number of orders to retrieve * @return The settle orders of the account */ From f26e5606b4af0cf7dabc2d92109b6bb9187f4c9a Mon Sep 17 00:00:00 2001 From: abitmore Date: Fri, 10 May 2019 10:38:42 -0400 Subject: [PATCH 049/133] Fix a compiler warning --- libraries/chain/db_maint.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/chain/db_maint.cpp b/libraries/chain/db_maint.cpp index a452a91c88..59cb1c6041 100644 --- a/libraries/chain/db_maint.cpp +++ b/libraries/chain/db_maint.cpp @@ -308,7 +308,7 @@ void database::update_active_committee_members() /// accounts that vote for 0 or 1 witness do not get to express an opinion on /// the number of witnesses to have (they abstain and are non-voting accounts) - uint64_t stake_tally = 0; // _committee_count_histogram_buffer[0]; + share_type stake_tally = 0; size_t committee_member_count = 0; if( stake_target > 0 ) { From 89949957341c91acfa16053d90870bfb9a49dbea Mon Sep 17 00:00:00 2001 From: Alfredo Date: Fri, 10 May 2019 11:54:13 -0300 Subject: [PATCH 050/133] remove by_issuer_and_id index --- libraries/app/database_api.cpp | 2 +- libraries/chain/include/graphene/chain/asset_object.hpp | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index d7d3a5358d..c85accb83c 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -1332,7 +1332,7 @@ vector database_api_impl::get_assets_by_issuer(const std::string& vector result; const account_id_type account = get_account_from_string(issuer_name_or_id)->id; - const auto& asset_idx = _db.get_index_type().indices().get(); + const auto& asset_idx = _db.get_index_type().indices().get(); auto asset_index_end = asset_idx.end(); auto asset_itr = asset_idx.lower_bound(boost::make_tuple(account, start)); while(asset_itr != asset_index_end && asset_itr->issuer == account && result.size() < limit) diff --git a/libraries/chain/include/graphene/chain/asset_object.hpp b/libraries/chain/include/graphene/chain/asset_object.hpp index 516d325bff..1b98c5b4fd 100644 --- a/libraries/chain/include/graphene/chain/asset_object.hpp +++ b/libraries/chain/include/graphene/chain/asset_object.hpp @@ -294,20 +294,18 @@ namespace graphene { namespace chain { struct by_symbol; struct by_type; struct by_issuer; - struct by_issuer_and_id; typedef multi_index_container< asset_object, indexed_by< ordered_unique< tag, member< object, object_id_type, &object::id > >, ordered_unique< tag, member >, - ordered_non_unique< tag, member >, ordered_unique< tag, composite_key< asset_object, const_mem_fun, member< object, object_id_type, &object::id > > >, - ordered_unique< tag, + ordered_unique< tag, composite_key< asset_object, member< asset_object, account_id_type, &asset_object::issuer >, member< object, object_id_type, &object::id > From beb1e8d794626598dc1e15b79a89a9690b9056fb Mon Sep 17 00:00:00 2001 From: abitmore Date: Fri, 10 May 2019 12:08:30 -0400 Subject: [PATCH 051/133] Replace fc uint128 with boost cpp_int in db_market and fix a compiler warning --- libraries/chain/db_market.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/libraries/chain/db_market.cpp b/libraries/chain/db_market.cpp index 8e356cf96d..de725369cf 100644 --- a/libraries/chain/db_market.cpp +++ b/libraries/chain/db_market.cpp @@ -30,16 +30,17 @@ #include #include -#include +#include namespace graphene { namespace chain { namespace detail { - uint64_t calculate_percent(const share_type& value, uint16_t percent) + share_type calculate_percent(const share_type& value, uint16_t percent) { - fc::uint128 a(value.value); + boost::multiprecision::uint128_t a(value.value); a *= percent; a /= GRAPHENE_100_PERCENT; - return a.to_uint64(); + FC_ASSERT( a <= GRAPHENE_MAX_SHARE_SUPPLY, "overflow when calculating percent" ); + return a.convert_to(); } } //detail @@ -255,13 +256,13 @@ void database::cancel_limit_order( const limit_order_object& order, bool create_ } else { - fc::uint128 fee128( deferred_paid_fee.amount.value ); + boost::multiprecision::uint128_t fee128( deferred_paid_fee.amount.value ); fee128 *= core_cancel_fee.amount.value; // to round up fee128 += order.deferred_fee.value; fee128 -= 1; fee128 /= order.deferred_fee.value; - share_type cancel_fee_amount = fee128.to_uint64(); + share_type cancel_fee_amount = fee128.convert_to(); // cancel_fee should be positive, pay it to asset's accumulated_fees fee_asset_dyn_data = &deferred_paid_fee.asset_id(*this).dynamic_asset_data_id(*this); modify( *fee_asset_dyn_data, [&](asset_dynamic_data_object& addo) { From 976b56bbe3fac494490ef57277e11674c1a8e597 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Fri, 10 May 2019 14:58:54 -0300 Subject: [PATCH 052/133] paginate get_call_orders_by_account by asset_id --- libraries/app/database_api.cpp | 8 ++++---- libraries/app/include/graphene/app/database_api.hpp | 4 ++-- libraries/chain/include/graphene/chain/market_object.hpp | 7 ------- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index c85accb83c..158590f4c4 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -115,7 +115,7 @@ class database_api_impl : public std::enable_shared_from_this optional ostart_price ); vector get_call_orders(const std::string& a, uint32_t limit)const; vector get_call_orders_by_account(const std::string& account_name_or_id, - call_order_id_type start, uint32_t limit)const; + asset_id_type start, uint32_t limit)const; vector get_settle_orders(const std::string& a, uint32_t limit)const; vector get_settle_orders_by_account(const std::string& account_name_or_id, force_settlement_id_type start, uint32_t limit)const; @@ -1416,20 +1416,20 @@ vector database_api_impl::get_call_orders(const std::string& } vector database_api::get_call_orders_by_account(const std::string& account_name_or_id, - call_order_id_type start, uint32_t limit)const + asset_id_type start, uint32_t limit)const { return my->get_call_orders_by_account( account_name_or_id, start, limit ); } vector database_api_impl::get_call_orders_by_account(const std::string& account_name_or_id, - call_order_id_type start, uint32_t limit)const + asset_id_type start, uint32_t limit)const { uint64_t api_limit_get_call_orders = _app_options->api_limit_get_call_orders; FC_ASSERT( limit <= api_limit_get_call_orders ); vector result; const account_id_type account = get_account_from_string(account_name_or_id)->id; - const auto& call_idx = _db.get_index_type().indices().get(); + const auto& call_idx = _db.get_index_type().indices().get(); auto call_index_end = call_idx.end(); auto call_itr = call_idx.lower_bound(boost::make_tuple(account, start)); while(call_itr != call_index_end && call_itr->borrower == account && result.size() < limit) diff --git a/libraries/app/include/graphene/app/database_api.hpp b/libraries/app/include/graphene/app/database_api.hpp index 341d95cafa..a95e09df70 100644 --- a/libraries/app/include/graphene/app/database_api.hpp +++ b/libraries/app/include/graphene/app/database_api.hpp @@ -457,12 +457,12 @@ class database_api /** * @brief Get call orders from a given account * @param account_name_or_id Account name or ID to get objects from - * @param start Call order objects(1.8.X) before this ID will be skipped in results. Pagination purposes. + * @param start Asset objects(1.3.X) before this ID will be skipped in results. Pagination purposes. * @param limit Maximum number of objects to retrieve * @return The call orders of the account */ vector get_call_orders_by_account(const std::string& account_name_or_id, - call_order_id_type start, uint32_t limit)const; + asset_id_type start, uint32_t limit)const; /** * @brief Get forced settlement orders in a given asset diff --git a/libraries/chain/include/graphene/chain/market_object.hpp b/libraries/chain/include/graphene/chain/market_object.hpp index 337151de21..168e2b6439 100644 --- a/libraries/chain/include/graphene/chain/market_object.hpp +++ b/libraries/chain/include/graphene/chain/market_object.hpp @@ -196,7 +196,6 @@ class collateral_bid_object : public abstract_object struct by_collateral; struct by_account; struct by_price; -struct by_account_and_id; typedef multi_index_container< call_order_object, indexed_by< @@ -215,12 +214,6 @@ typedef multi_index_container< const_mem_fun< call_order_object, asset_id_type, &call_order_object::debt_type> > >, - ordered_unique< tag, - composite_key< call_order_object, - member< call_order_object, account_id_type, &call_order_object::borrower >, - member< object, object_id_type, &object::id > - > - >, ordered_unique< tag, composite_key< call_order_object, const_mem_fun< call_order_object, price, &call_order_object::collateralization >, From d07c3745a7aa2e5879f15af634e2e850c5df44a0 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Fri, 10 May 2019 15:54:44 -0300 Subject: [PATCH 053/133] make start optional in htlc api calls --- libraries/app/database_api.cpp | 15 +++++++++++---- .../app/include/graphene/app/database_api.hpp | 4 ++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 158590f4c4..f31ea5f3dd 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -2564,9 +2564,12 @@ fc::optional database_api_impl::get_htlc(htlc_id_type id) const return fc::optional(); } -vector database_api::get_htlc_by_from(const std::string account_id_or_name, htlc_id_type start, uint32_t limit)const +vector database_api::get_htlc_by_from(const std::string account_id_or_name, optional start, uint32_t limit)const { - return my->get_htlc_by_from(account_id_or_name, start, limit); + if(start.valid()) + return my->get_htlc_by_from(account_id_or_name, *start, limit); + else + return my->get_htlc_by_from(account_id_or_name, htlc_id_type(), limit); } vector database_api_impl::get_htlc_by_from(const std::string account_id_or_name, htlc_id_type start, uint32_t limit) const @@ -2587,9 +2590,13 @@ vector database_api_impl::get_htlc_by_from(const std::string accoun return result; } -vector database_api::get_htlc_by_to(const std::string account_id_or_name, htlc_id_type start, uint32_t limit)const +vector database_api::get_htlc_by_to(const std::string account_id_or_name, optional start, uint32_t limit)const { - return my->get_htlc_by_to(account_id_or_name, start, limit); + if(start.valid()) + return my->get_htlc_by_to(account_id_or_name, *start, limit); + else + return my->get_htlc_by_to(account_id_or_name, htlc_id_type(), limit); + } vector database_api_impl::get_htlc_by_to(const std::string account_id_or_name, htlc_id_type start, uint32_t limit) const diff --git a/libraries/app/include/graphene/app/database_api.hpp b/libraries/app/include/graphene/app/database_api.hpp index a95e09df70..0bc1f5bffd 100644 --- a/libraries/app/include/graphene/app/database_api.hpp +++ b/libraries/app/include/graphene/app/database_api.hpp @@ -792,7 +792,7 @@ class database_api * @param limit Maximum number of objects to retrieve * @return HTLC objects for the account */ - vector get_htlc_by_from(const std::string account_id_or_name, htlc_id_type start, uint32_t limit) const; + vector get_htlc_by_from(const std::string account_id_or_name, optional start, uint32_t limit) const; /** * @brief Get non expired HTLC objects using the receiver account @@ -801,7 +801,7 @@ class database_api * @param limit Maximum number of objects to retrieve * @return HTLC objects for the account */ - vector get_htlc_by_to(const std::string account_id_or_name, htlc_id_type start, uint32_t limit) const; + vector get_htlc_by_to(const std::string account_id_or_name, optional start, uint32_t limit) const; private: std::shared_ptr< database_api_impl > my; From dbb1fed2fae7bb1f770303f492f03609b344a26f Mon Sep 17 00:00:00 2001 From: Alfredo Date: Fri, 10 May 2019 19:54:25 -0300 Subject: [PATCH 054/133] undo d07c374 --- libraries/app/database_api.cpp | 15 ++++----------- .../app/include/graphene/app/database_api.hpp | 4 ++-- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index f31ea5f3dd..158590f4c4 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -2564,12 +2564,9 @@ fc::optional database_api_impl::get_htlc(htlc_id_type id) const return fc::optional(); } -vector database_api::get_htlc_by_from(const std::string account_id_or_name, optional start, uint32_t limit)const +vector database_api::get_htlc_by_from(const std::string account_id_or_name, htlc_id_type start, uint32_t limit)const { - if(start.valid()) - return my->get_htlc_by_from(account_id_or_name, *start, limit); - else - return my->get_htlc_by_from(account_id_or_name, htlc_id_type(), limit); + return my->get_htlc_by_from(account_id_or_name, start, limit); } vector database_api_impl::get_htlc_by_from(const std::string account_id_or_name, htlc_id_type start, uint32_t limit) const @@ -2590,13 +2587,9 @@ vector database_api_impl::get_htlc_by_from(const std::string accoun return result; } -vector database_api::get_htlc_by_to(const std::string account_id_or_name, optional start, uint32_t limit)const +vector database_api::get_htlc_by_to(const std::string account_id_or_name, htlc_id_type start, uint32_t limit)const { - if(start.valid()) - return my->get_htlc_by_to(account_id_or_name, *start, limit); - else - return my->get_htlc_by_to(account_id_or_name, htlc_id_type(), limit); - + return my->get_htlc_by_to(account_id_or_name, start, limit); } vector database_api_impl::get_htlc_by_to(const std::string account_id_or_name, htlc_id_type start, uint32_t limit) const diff --git a/libraries/app/include/graphene/app/database_api.hpp b/libraries/app/include/graphene/app/database_api.hpp index 0bc1f5bffd..a95e09df70 100644 --- a/libraries/app/include/graphene/app/database_api.hpp +++ b/libraries/app/include/graphene/app/database_api.hpp @@ -792,7 +792,7 @@ class database_api * @param limit Maximum number of objects to retrieve * @return HTLC objects for the account */ - vector get_htlc_by_from(const std::string account_id_or_name, optional start, uint32_t limit) const; + vector get_htlc_by_from(const std::string account_id_or_name, htlc_id_type start, uint32_t limit) const; /** * @brief Get non expired HTLC objects using the receiver account @@ -801,7 +801,7 @@ class database_api * @param limit Maximum number of objects to retrieve * @return HTLC objects for the account */ - vector get_htlc_by_to(const std::string account_id_or_name, optional start, uint32_t limit) const; + vector get_htlc_by_to(const std::string account_id_or_name, htlc_id_type start, uint32_t limit) const; private: std::shared_ptr< database_api_impl > my; From a57b6b180ec155fee680c318cced4be36f8f434e Mon Sep 17 00:00:00 2001 From: John Jones Date: Mon, 13 May 2019 08:44:27 -0500 Subject: [PATCH 055/133] added .gitattributes --- .gitattributes | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000000..669f353225 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +# Set the default behavior, in case core.autocrlf is set incorrectly +# Note: this is mainly to properly canonicalize the input to embed_genesis +* text eol=lf From efc818160ced4bbc968353c79caef65ea03bc0de Mon Sep 17 00:00:00 2001 From: Alfredo Date: Mon, 13 May 2019 18:21:47 -0300 Subject: [PATCH 056/133] add test cases --- tests/tests/database_api_tests.cpp | 166 +++++++++++++++++++++++++++++ 1 file changed, 166 insertions(+) diff --git a/tests/tests/database_api_tests.cpp b/tests/tests/database_api_tests.cpp index 295eac45de..c4f5433100 100644 --- a/tests/tests/database_api_tests.cpp +++ b/tests/tests/database_api_tests.cpp @@ -1121,4 +1121,170 @@ BOOST_AUTO_TEST_CASE( api_limit_get_key_references ){ throw; } } + +BOOST_AUTO_TEST_CASE( api_limit_get_full_accounts ) { + + try { + graphene::app::database_api db_api(db, &(this->app.get_options())); + + const account_object& alice = create_account("alice"); + const account_object& bob = create_account("bob"); + const account_object& carl = create_account("carl"); + const account_object& dan = create_account("dan"); + const account_object& fred = create_account("fred"); + const account_object& henry = create_account("henry"); + const account_object& kevin = create_account("kevin"); + const account_object& laura = create_account("laura"); + const account_object& lucy = create_account("lucy"); + const account_object& martin = create_account("martin"); + const account_object& patty = create_account("patty"); + + vector accounts; + accounts.push_back(alice.name); + accounts.push_back(bob.name); + accounts.push_back(carl.name); + accounts.push_back(dan.name); + accounts.push_back(fred.name); + accounts.push_back(henry.name); + accounts.push_back(kevin.name); + accounts.push_back(laura.name); + accounts.push_back(lucy.name); + accounts.push_back(martin.name); + accounts.push_back(patty.name); + + GRAPHENE_CHECK_THROW(db_api.get_full_accounts(accounts, false), fc::exception); + + accounts.erase(accounts.begin()); + auto full_accounts = db_api.get_full_accounts(accounts, false); + BOOST_CHECK(full_accounts.size() == 10); + + // not an account + accounts.erase(accounts.begin()); + accounts.push_back("nosuchaccount"); + + // request fully fails even if 9 accounts are valid + GRAPHENE_CHECK_THROW(db_api.get_full_accounts(accounts, false), fc::exception); + + } catch (fc::exception& e) { + edump((e.to_detail_string())); + throw; + } +} + +BOOST_AUTO_TEST_CASE( get_assets_by_issuer ) { + try { + graphene::app::database_api db_api(db, &(this->app.get_options())); + + create_bitasset("CNY"); + create_bitasset("EUR"); + create_bitasset("USD"); + + generate_block(); + + auto assets = db_api.get_assets_by_issuer("witness-account", asset_id_type(), 10); + + BOOST_CHECK(assets.size() == 3); + BOOST_CHECK(assets[0].symbol == "CNY"); + BOOST_CHECK(assets[1].symbol == "EUR"); + BOOST_CHECK(assets[2].symbol == "USD"); + + assets = db_api.get_assets_by_issuer("witness-account", asset_id_type(200), 100); + BOOST_CHECK(assets.size() == 0); + + GRAPHENE_CHECK_THROW(db_api.get_assets_by_issuer("nosuchaccount", asset_id_type(), 100), fc::exception); + + } catch (fc::exception& e) { + edump((e.to_detail_string())); + throw; + } +} + +BOOST_AUTO_TEST_CASE( get_call_orders_by_account ) { + + try { + ACTORS((caller)(feedproducer)); + + graphene::app::database_api db_api(db, &(this->app.get_options())); + + const auto &usd = create_bitasset("USD", feedproducer_id); + const auto &cny = create_bitasset("CNY", feedproducer_id); + const auto &core = asset_id_type()(db); + + int64_t init_balance(1000000); + transfer(committee_account, caller_id, asset(init_balance)); + + update_feed_producers(usd, {feedproducer.id}); + update_feed_producers(cny, {feedproducer.id}); + + price_feed current_feed; + current_feed.maintenance_collateral_ratio = 1750; + current_feed.maximum_short_squeeze_ratio = 1100; + current_feed.settlement_price = usd.amount(1) / core.amount(5); + publish_feed(usd, feedproducer, current_feed); + + current_feed.maintenance_collateral_ratio = 1750; + current_feed.maximum_short_squeeze_ratio = 1100; + current_feed.settlement_price = cny.amount(1) / core.amount(5); + publish_feed(cny, feedproducer, current_feed); + + auto call1 = borrow(caller, usd.amount(1000), asset(15000)); + auto call2 = borrow(caller, cny.amount(1000), asset(15000)); + + auto calls = db_api.get_call_orders_by_account("caller", asset_id_type(), 100); + + BOOST_CHECK(calls.size() == 2); + BOOST_CHECK(calls[0].id == call1->id); + BOOST_CHECK(calls[1].id == call2->id); + + GRAPHENE_CHECK_THROW(db_api.get_call_orders_by_account("nosuchaccount", asset_id_type(), 100), fc::exception); + + } catch (fc::exception& e) { + edump((e.to_detail_string())); + throw; + } +} + +BOOST_AUTO_TEST_CASE( get_settle_orders_by_account ) { + try { + ACTORS((creator)(settler)(caller)(feedproducer)); + + graphene::app::database_api db_api(db, &(this->app.get_options())); + + const auto &usd = create_bitasset("USD", creator_id); + const auto &core = asset_id_type()(db); + asset_id_type usd_id = usd.id; + + int64_t init_balance(1000000); + transfer(committee_account, settler_id, asset(init_balance)); + transfer(committee_account, caller_id, asset(init_balance)); + + update_feed_producers(usd, {feedproducer.id}); + + price_feed current_feed; + current_feed.maintenance_collateral_ratio = 1750; + current_feed.maximum_short_squeeze_ratio = 1100; + current_feed.settlement_price = usd.amount(1) / core.amount(5); + publish_feed(usd, feedproducer, current_feed); + + borrow(caller, usd.amount(1000), asset(15000)); + generate_block(); + + transfer(caller.id, settler.id, asset(200, usd_id)); + + auto result = force_settle( settler, usd_id(db).amount(4)); + generate_block(); + + auto settlements = db_api.get_settle_orders_by_account("settler", force_settlement_id_type(), 100); + + BOOST_CHECK(settlements.size() == 1); + BOOST_CHECK(settlements[0].id == result.get()); + + GRAPHENE_CHECK_THROW(db_api.get_settle_orders_by_account("nosuchaccount", force_settlement_id_type(), 100), fc::exception); + + } catch (fc::exception& e) { + edump((e.to_detail_string())); + throw; + } +} + BOOST_AUTO_TEST_SUITE_END() From 2d5a242f800156eb124895c62567990a911e2cb9 Mon Sep 17 00:00:00 2001 From: John Jones Date: Tue, 14 May 2019 07:13:22 -0500 Subject: [PATCH 057/133] only change line endings for genesis.json --- .gitattributes | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.gitattributes b/.gitattributes index 669f353225..18d8e5589b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,2 @@ -# Set the default behavior, in case core.autocrlf is set incorrectly -# Note: this is mainly to properly canonicalize the input to embed_genesis -* text eol=lf +# Set the default behavior of genesis.json, in case core.autocrlf is set incorrectly +genesis.json eol=lf From f8a96918252615d39f57a22e8a115d4905d25ee1 Mon Sep 17 00:00:00 2001 From: John Jones Date: Fri, 22 Mar 2019 15:59:40 -0500 Subject: [PATCH 058/133] Build with c++14 --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2497afb17d..69e7f7c77a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ # Defines BitShares library target. project( BitShares ) -cmake_minimum_required( VERSION 2.8.12 ) +cmake_minimum_required( VERSION 3.1 ) set( BLOCKCHAIN_NAME "BitShares" ) @@ -9,6 +9,10 @@ set( GUI_CLIENT_EXECUTABLE_NAME BitShares ) set( CUSTOM_URL_SCHEME "gcs" ) set( INSTALLER_APP_ID "68ad7005-8eee-49c9-95ce-9eed97e5b347" ) +set( CMAKE_CXX_STANDARD 14 ) +set( CMAKE_CXX_STANDARD_REQUIRED ON ) +set( CMAKE_CXX_EXTENSIONS OFF ) + # http://stackoverflow.com/a/18369825 if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8) From 84ffba0e60c766c8cf6d9d7456b1952e24fd4f01 Mon Sep 17 00:00:00 2001 From: John Jones Date: Thu, 16 May 2019 09:40:46 -0500 Subject: [PATCH 059/133] Remove cmake references to c++11 --- CMakeLists.txt | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 69e7f7c77a..6052748601 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -73,10 +73,6 @@ IF(NOT "${Boost_VERSION}" MATCHES "1.53(.*)") SET(Boost_LIBRARIES ${BOOST_LIBRARIES_TEMP} ${Boost_LIBRARIES}) ENDIF() -if( NOT CPP_STANDARD ) - set( CPP_STANDARD "-std=c++11" ) -endif() - if( WIN32 ) message( STATUS "Configuring BitShares on WIN32") @@ -118,11 +114,11 @@ else( WIN32 ) # Apple AND Linux if( APPLE ) # Apple Specific Options Here message( STATUS "Configuring BitShares on OS X" ) - set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${CPP_STANDARD} -stdlib=libc++ -Wall" ) + set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -stdlib=libc++ -Wall" ) else( APPLE ) # Linux Specific Options Here message( STATUS "Configuring BitShares on Linux" ) - set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${CPP_STANDARD} -Wall" ) + set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -Wall" ) if(USE_PROFILER) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg" ) endif( USE_PROFILER ) From 277b6ebcd2ccf4d78ebe1e22e737ca9da108b063 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Sun, 19 May 2019 15:03:40 -0300 Subject: [PATCH 060/133] get_accounts return null if account does not exist --- libraries/app/database_api.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 158590f4c4..63eb291044 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -790,14 +790,19 @@ vector> database_api_impl::get_accounts(const vector optional { - const account_object* account = get_account_from_string(id_or_name); - account_id_type id = account->id; - if(auto o = _db.find(id)) - { - subscribe_to_item( id ); - return *o; + try { + const account_object *account = get_account_from_string(id_or_name); + account_id_type id = account->id; + if(auto o = _db.find(id)) + { + subscribe_to_item( id ); + return *o; + } + return {}; + } + catch( ... ) { + return {}; } - return {}; }); return result; } From e300264fa8c51c31a145c24d44ef213613daa4ea Mon Sep 17 00:00:00 2001 From: Alfredo Date: Sun, 19 May 2019 19:05:19 -0300 Subject: [PATCH 061/133] add should_throw option to get_account_from_string --- libraries/app/database_api.cpp | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 63eb291044..d4b498f277 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -221,7 +221,7 @@ class database_api_impl : public std::enable_shared_from_this return tmp; } - const account_object* get_account_from_string( const std::string& name_or_id ) const + const account_object* get_account_from_string( const std::string& name_or_id, bool should_throw = true) const { // TODO cache the result to avoid repeatly fetching from db FC_ASSERT( name_or_id.size() > 0); @@ -235,7 +235,8 @@ class database_api_impl : public std::enable_shared_from_this if (itr != idx.end()) account = &*itr; } - FC_ASSERT( account, "no such account" ); + if(should_throw) + FC_ASSERT( account, "no such account" ); return account; } @@ -790,19 +791,12 @@ vector> database_api_impl::get_accounts(const vector optional { - try { - const account_object *account = get_account_from_string(id_or_name); - account_id_type id = account->id; - if(auto o = _db.find(id)) - { - subscribe_to_item( id ); - return *o; - } + const account_object *account = get_account_from_string(id_or_name, false); + if(account == nullptr) return {}; - } - catch( ... ) { - return {}; - } + account_id_type id = account->id; + subscribe_to_item( id ); + return *account; }); return result; } From 049043c3a7d520ad9a053a757dc55cd45110bb8e Mon Sep 17 00:00:00 2001 From: Alfredo Date: Mon, 20 May 2019 12:41:35 -0300 Subject: [PATCH 062/133] add changes to get_assets and get_full_accounts --- libraries/app/database_api.cpp | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index d4b498f277..c09d301893 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -221,7 +221,7 @@ class database_api_impl : public std::enable_shared_from_this return tmp; } - const account_object* get_account_from_string( const std::string& name_or_id, bool should_throw = true) const + const account_object* get_account_from_string( const std::string& name_or_id, bool throw_if_not_found = true ) const { // TODO cache the result to avoid repeatly fetching from db FC_ASSERT( name_or_id.size() > 0); @@ -235,12 +235,12 @@ class database_api_impl : public std::enable_shared_from_this if (itr != idx.end()) account = &*itr; } - if(should_throw) + if(throw_if_not_found) FC_ASSERT( account, "no such account" ); return account; } - const asset_object* get_asset_from_string( const std::string& symbol_or_id ) const + const asset_object* get_asset_from_string( const std::string& symbol_or_id, bool throw_if_not_found = true ) const { // TODO cache the result to avoid repeatly fetching from db FC_ASSERT( symbol_or_id.size() > 0); @@ -254,7 +254,8 @@ class database_api_impl : public std::enable_shared_from_this if (itr != idx.end()) asset = &*itr; } - FC_ASSERT( asset, "no such asset" ); + if(throw_if_not_found) + FC_ASSERT( asset, "no such asset" ); return asset; } vector> get_assets(const vector& asset_ids)const @@ -903,7 +904,7 @@ std::map database_api_impl::get_full_accounts( const for (const std::string& account_name_or_id : names_or_ids) { - const account_object* account = get_account_from_string(account_name_or_id); + const account_object* account = get_account_from_string(account_name_or_id, false); if (account == nullptr) continue; @@ -1270,14 +1271,14 @@ vector> database_api_impl::get_assets(const vector> result; result.reserve(asset_symbols_or_ids.size()); std::transform(asset_symbols_or_ids.begin(), asset_symbols_or_ids.end(), std::back_inserter(result), [this](std::string id_or_name) -> optional { - const asset_object* asset = get_asset_from_string(id_or_name); + + const asset_object* asset = get_asset_from_string(id_or_name, false); + if(asset == nullptr) + return {}; asset_id_type id = asset->id; - if(auto o = _db.find(id)) - { - subscribe_to_item( id ); - return *o; - } - return {}; + subscribe_to_item( id ); + return *asset; + }); return result; } From 084b9843cd7ff47203d66960012965899a9f71c2 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Mon, 20 May 2019 18:39:31 -0300 Subject: [PATCH 063/133] fix broken test case --- tests/tests/database_api_tests.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/tests/database_api_tests.cpp b/tests/tests/database_api_tests.cpp index c4f5433100..a76759f54f 100644 --- a/tests/tests/database_api_tests.cpp +++ b/tests/tests/database_api_tests.cpp @@ -1162,8 +1162,9 @@ BOOST_AUTO_TEST_CASE( api_limit_get_full_accounts ) { accounts.erase(accounts.begin()); accounts.push_back("nosuchaccount"); - // request fully fails even if 9 accounts are valid - GRAPHENE_CHECK_THROW(db_api.get_full_accounts(accounts, false), fc::exception); + // non existing accounts will be ignored in the results + full_accounts = db_api.get_full_accounts(accounts, false); + BOOST_CHECK(full_accounts.size() == 9); } catch (fc::exception& e) { edump((e.to_detail_string())); From 6f8a393bd94490790e0fce947eebfb2acfe90f2e Mon Sep 17 00:00:00 2001 From: abitmore Date: Wed, 3 Apr 2019 12:38:32 -0400 Subject: [PATCH 064/133] Update code to adapt FC websocket changes --- libraries/app/application.cpp | 2 +- libraries/plugins/delayed_node/delayed_node_plugin.cpp | 4 +++- programs/cli_wallet/main.cpp | 6 +++--- tests/cli/main.cpp | 3 ++- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index 8aac9c631e..59aa8956b2 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -246,7 +246,7 @@ std::vector application_impl::resolve_string_to_ip_endpoints(c void application_impl::new_connection( const fc::http::websocket_connection_ptr& c ) { - auto wsc = std::make_shared(*c, GRAPHENE_NET_MAX_NESTED_OBJECTS); + auto wsc = std::make_shared(c, GRAPHENE_NET_MAX_NESTED_OBJECTS); auto login = std::make_shared( std::ref(*_self) ); login->enable_api("database_api"); diff --git a/libraries/plugins/delayed_node/delayed_node_plugin.cpp b/libraries/plugins/delayed_node/delayed_node_plugin.cpp index bd778b68ea..01f4e48b31 100644 --- a/libraries/plugins/delayed_node/delayed_node_plugin.cpp +++ b/libraries/plugins/delayed_node/delayed_node_plugin.cpp @@ -63,7 +63,9 @@ void delayed_node_plugin::plugin_set_program_options(bpo::options_description& c void delayed_node_plugin::connect() { - my->client_connection = std::make_shared(*my->client.connect(my->remote_endpoint), GRAPHENE_NET_MAX_NESTED_OBJECTS); + my->client_connection = std::make_shared( + my->client.connect(my->remote_endpoint), + GRAPHENE_NET_MAX_NESTED_OBJECTS ); my->database_api = my->client_connection->get_remote_api(0); my->client_connection_closed = my->client_connection->closed.connect([this] { connection_failed(); diff --git a/programs/cli_wallet/main.cpp b/programs/cli_wallet/main.cpp index 2a949417ae..725921f5c5 100644 --- a/programs/cli_wallet/main.cpp +++ b/programs/cli_wallet/main.cpp @@ -193,7 +193,7 @@ int main( int argc, char** argv ) fc::http::websocket_client client; idump((wdata.ws_server)); auto con = client.connect( wdata.ws_server ); - auto apic = std::make_shared(*con, GRAPHENE_MAX_NESTED_OBJECTS); + auto apic = std::make_shared(con, GRAPHENE_MAX_NESTED_OBJECTS); auto remote_api = apic->get_remote_api< login_api >(1); edump((wdata.ws_user)(wdata.ws_password) ); @@ -230,7 +230,7 @@ int main( int argc, char** argv ) if( options.count("rpc-endpoint") ) { _websocket_server->on_connection([&wapi]( const fc::http::websocket_connection_ptr& c ){ - auto wsc = std::make_shared(*c, GRAPHENE_MAX_NESTED_OBJECTS); + auto wsc = std::make_shared(c, GRAPHENE_MAX_NESTED_OBJECTS); wsc->register_api(wapi); c->set_session_data( wsc ); }); @@ -247,7 +247,7 @@ int main( int argc, char** argv ) if( options.count("rpc-tls-endpoint") ) { _websocket_tls_server->on_connection([&wapi]( const fc::http::websocket_connection_ptr& c ){ - auto wsc = std::make_shared(*c, GRAPHENE_MAX_NESTED_OBJECTS); + auto wsc = std::make_shared(c, GRAPHENE_MAX_NESTED_OBJECTS); wsc->register_api(wapi); c->set_session_data( wsc ); }); diff --git a/tests/cli/main.cpp b/tests/cli/main.cpp index a31053753d..c53926b0b7 100644 --- a/tests/cli/main.cpp +++ b/tests/cli/main.cpp @@ -217,7 +217,8 @@ class client_connection wallet_data.ws_password = ""; websocket_connection = websocket_client.connect( wallet_data.ws_server ); - api_connection = std::make_shared(*websocket_connection, GRAPHENE_MAX_NESTED_OBJECTS); + api_connection = std::make_shared( websocket_connection, + GRAPHENE_MAX_NESTED_OBJECTS ); remote_login_api = api_connection->get_remote_api< graphene::app::login_api >(1); BOOST_CHECK(remote_login_api->login( wallet_data.ws_user, wallet_data.ws_password ) ); From 6e44ea539bb48ffa7b96745a3c46bd69817415fa Mon Sep 17 00:00:00 2001 From: abitmore Date: Tue, 7 May 2019 18:17:31 -0400 Subject: [PATCH 065/133] Fix signals handling in CLI --- programs/cli_wallet/main.cpp | 111 ++++++++++++++++++++--------------- 1 file changed, 65 insertions(+), 46 deletions(-) diff --git a/programs/cli_wallet/main.cpp b/programs/cli_wallet/main.cpp index 725921f5c5..8ad019abd8 100644 --- a/programs/cli_wallet/main.cpp +++ b/programs/cli_wallet/main.cpp @@ -205,27 +205,6 @@ int main( int argc, char** argv ) fc::api wapi(wapiptr); - auto wallet_cli = std::make_shared( GRAPHENE_MAX_NESTED_OBJECTS ); - for( auto& name_formatter : wapiptr->get_result_formatters() ) - wallet_cli->format_result( name_formatter.first, name_formatter.second ); - - boost::signals2::scoped_connection closed_connection(con->closed.connect([wallet_cli]{ - cerr << "Server has disconnected us.\n"; - wallet_cli->stop(); - })); - (void)(closed_connection); - - if( wapiptr->is_new() ) - { - std::cout << "Please use the set_password method to initialize a new wallet before continuing\n"; - wallet_cli->set_prompt( "new >>> " ); - } else - wallet_cli->set_prompt( "locked >>> " ); - - boost::signals2::scoped_connection locked_connection(wapiptr->lock_changed.connect([&](bool locked) { - wallet_cli->set_prompt( locked ? "locked >>> " : "unlocked >>> " ); - })); - auto _websocket_server = std::make_shared(); if( options.count("rpc-endpoint") ) { @@ -251,7 +230,8 @@ int main( int argc, char** argv ) 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 TLS 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(); } @@ -259,7 +239,8 @@ int main( int argc, char** argv ) auto _http_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() ) ); + 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() @@ -276,43 +257,81 @@ int main( int argc, char** argv ) if( !options.count( "daemon" ) ) { - wallet_cli->register_api( wapi ); - wallet_cli->start(); + auto wallet_cli = std::make_shared( GRAPHENE_MAX_NESTED_OBJECTS ); + for( auto& name_formatter : wapiptr->get_result_formatters() ) + wallet_cli->format_result( name_formatter.first, name_formatter.second ); - fc::set_signal_handler([](int signal) { - ilog( "Captured SIGINT not in daemon mode" ); - fclose(stdin); - }, SIGINT); - - fc::set_signal_handler([](int signal) { - ilog( "Captured SIGTERM not in daemon mode" ); - fclose(stdin); - }, SIGTERM); + if( wapiptr->is_new() ) + { + std::cout << "Please use the set_password method to initialize a new wallet before continuing\n"; + wallet_cli->set_prompt( "new >>> " ); + } + else + wallet_cli->set_prompt( "locked >>> " ); + + boost::signals2::scoped_connection locked_connection( wapiptr->lock_changed.connect( + [wallet_cli](bool locked) { + wallet_cli->set_prompt( locked ? "locked >>> " : "unlocked >>> " ); + })); + + auto sig_set = fc::set_signal_handler( [wallet_cli](int signal) { + ilog( "Captured SIGINT not in daemon mode, exiting" ); + fc::set_signal_handler( [](int sig) {}, SIGINT ); // reinstall an empty SIGINT handler + fc::usleep( fc::milliseconds(100) ); // sleep a while to cleanup things + wallet_cli->cancel(); + }, SIGINT ); + + fc::set_signal_handler( [wallet_cli,sig_set](int signal) { + ilog( "Captured SIGTERM not in daemon mode, exiting" ); + sig_set->cancel(); + fc::set_signal_handler( [](int sig) {}, SIGINT ); // reinstall an empty SIGINT handler + wallet_cli->cancel(); + }, SIGTERM ); + + boost::signals2::scoped_connection closed_connection( con->closed.connect( [wallet_cli,sig_set] { + elog( "Server has disconnected us." ); + sig_set->cancel(); + fc::set_signal_handler( [](int sig) {}, SIGINT ); // reinstall an empty SIGINT handler + wallet_cli->cancel(); + })); + wallet_cli->register_api( wapi ); + wallet_cli->start(); wallet_cli->wait(); + + locked_connection.disconnect(); + closed_connection.disconnect(); } else { - fc::promise::ptr exit_promise = new fc::promise("UNIX Signal Handler"); - fc::set_signal_handler([&exit_promise](int signal) { - exit_promise->set_value(signal); - }, SIGINT); + fc::promise::ptr exit_promise = new fc::promise("UNIX Signal Handler"); + + fc::set_signal_handler( [&exit_promise](int signal) { + ilog( "Captured SIGINT in daemon mode, exiting" ); + exit_promise->set_value(signal); + }, SIGINT ); + + fc::set_signal_handler( [&exit_promise](int signal) { + ilog( "Captured SIGTERM in daemon mode, exiting" ); + exit_promise->set_value(signal); + }, SIGTERM ); + + boost::signals2::scoped_connection closed_connection( con->closed.connect( [&exit_promise] { + elog( "Server has disconnected us." ); + exit_promise->set_value(0); + })); - fc::set_signal_handler([&exit_promise](int signal) { - exit_promise->set_value(signal); - }, SIGTERM); + ilog( "Entering Daemon Mode, ^C to exit" ); + exit_promise->wait(); - ilog( "Entering Daemon Mode, ^C to exit" ); - exit_promise->wait(); + closed_connection.disconnect(); } wapi->save_wallet_file(wallet_file.generic_string()); - locked_connection.disconnect(); - closed_connection.disconnect(); } catch ( const fc::exception& e ) { - std::cout << e.to_detail_string() << "\n"; + std::cerr << e.to_detail_string() << "\n"; return -1; } return 0; From 1ce3563f1e5b4f9ec5b1d32e51251888acaa8a4c Mon Sep 17 00:00:00 2001 From: abitmore Date: Fri, 10 May 2019 09:29:05 -0400 Subject: [PATCH 066/133] Bump FC * include CLI fixes and improvements * bring optional parameters support for API * require C++14 * fix a minor memory leak issue --- libraries/fc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/fc b/libraries/fc index 2cf1510d81..397830b8ef 160000 --- a/libraries/fc +++ b/libraries/fc @@ -1 +1 @@ -Subproject commit 2cf1510d819ecd81f1ce6e6d941c70c64f1edaa8 +Subproject commit 397830b8ef183b4cbeadf9765d5fc5666b07b30b From 57ad9d5389e3702ef9dfc4da61f4bb96586786cb Mon Sep 17 00:00:00 2001 From: abitmore Date: Sun, 12 May 2019 15:48:37 -0400 Subject: [PATCH 067/133] Handle SIGQUIT signal in CLI --- programs/cli_wallet/main.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/programs/cli_wallet/main.cpp b/programs/cli_wallet/main.cpp index 8ad019abd8..83381175ae 100644 --- a/programs/cli_wallet/main.cpp +++ b/programs/cli_wallet/main.cpp @@ -288,6 +288,13 @@ int main( int argc, char** argv ) wallet_cli->cancel(); }, SIGTERM ); + fc::set_signal_handler( [wallet_cli,sig_set](int signal) { + ilog( "Captured SIGQUIT not in daemon mode, exiting" ); + sig_set->cancel(); + fc::set_signal_handler( [](int sig) {}, SIGINT ); // reinstall an empty SIGINT handler + wallet_cli->cancel(); + }, SIGQUIT ); + boost::signals2::scoped_connection closed_connection( con->closed.connect( [wallet_cli,sig_set] { elog( "Server has disconnected us." ); sig_set->cancel(); @@ -316,6 +323,11 @@ int main( int argc, char** argv ) exit_promise->set_value(signal); }, SIGTERM ); + fc::set_signal_handler( [&exit_promise](int signal) { + ilog( "Captured SIGQUIT in daemon mode, exiting" ); + exit_promise->set_value(signal); + }, SIGQUIT ); + boost::signals2::scoped_connection closed_connection( con->closed.connect( [&exit_promise] { elog( "Server has disconnected us." ); exit_promise->set_value(0); From 9dd74ce32397a2ad2a5d153402c083898fdd683d Mon Sep 17 00:00:00 2001 From: abitmore Date: Mon, 13 May 2019 09:14:58 -0400 Subject: [PATCH 068/133] Do not sleep when CLI got SIGINT --- programs/cli_wallet/main.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/programs/cli_wallet/main.cpp b/programs/cli_wallet/main.cpp index 83381175ae..b837b6e045 100644 --- a/programs/cli_wallet/main.cpp +++ b/programs/cli_wallet/main.cpp @@ -277,7 +277,6 @@ int main( int argc, char** argv ) auto sig_set = fc::set_signal_handler( [wallet_cli](int signal) { ilog( "Captured SIGINT not in daemon mode, exiting" ); fc::set_signal_handler( [](int sig) {}, SIGINT ); // reinstall an empty SIGINT handler - fc::usleep( fc::milliseconds(100) ); // sleep a while to cleanup things wallet_cli->cancel(); }, SIGINT ); From 9bc92ec7db05e4d5d486db4184d8cc1fa434ef87 Mon Sep 17 00:00:00 2001 From: abitmore Date: Tue, 21 May 2019 14:25:51 -0400 Subject: [PATCH 069/133] Fix wallet.cpp due to API changes in FC --- libraries/wallet/wallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 6189b4ae7d..e8fce5fff0 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -83,7 +83,7 @@ // explicit instantiation for later use namespace fc { - template class api; + template class api; } #define BRAIN_KEY_WORD_COUNT 16 From a45acec93bec68333553a235e2c7a02d4f098305 Mon Sep 17 00:00:00 2001 From: abitmore Date: Sat, 25 May 2019 14:46:30 -0400 Subject: [PATCH 070/133] Test case for market fee sharing percent --- tests/tests/market_fee_sharing_tests.cpp | 36 ++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/tests/tests/market_fee_sharing_tests.cpp b/tests/tests/market_fee_sharing_tests.cpp index 17fecaf29a..2ba95b2c5b 100644 --- a/tests/tests/market_fee_sharing_tests.cpp +++ b/tests/tests/market_fee_sharing_tests.cpp @@ -147,7 +147,7 @@ BOOST_AUTO_TEST_CASE(create_asset_with_additional_options_after_hf) generate_blocks_past_hf1268(); - uint16_t reward_percent = 100; + uint16_t reward_percent = GRAPHENE_100_PERCENT + 1; // 100.01% flat_set whitelist = {issuer_id}; price price(asset(1, asset_id_type(1)), asset(1)); uint16_t market_fee_percent = 100; @@ -156,6 +156,28 @@ BOOST_AUTO_TEST_CASE(create_asset_with_additional_options_after_hf) options.value.reward_percent = reward_percent; options.value.whitelist_market_fee_sharing = whitelist; + GRAPHENE_CHECK_THROW(create_user_issued_asset("USD", + issuer, + charge_market_fee, + price, + 2, + market_fee_percent, + options), + fc::assert_exception); + + reward_percent = GRAPHENE_100_PERCENT; // 100% + options.value.reward_percent = reward_percent; + GRAPHENE_CHECK_THROW(create_user_issued_asset("USD", + issuer, + charge_market_fee, + price, + 2, + market_fee_percent, + options), + fc::assert_exception); + + reward_percent = GRAPHENE_100_PERCENT - 1; // 99.99% + options.value.reward_percent = reward_percent; asset_object usd_asset = create_user_issued_asset("USD", issuer, charge_market_fee, @@ -197,8 +219,18 @@ BOOST_AUTO_TEST_CASE(update_additional_options_after_hf) generate_blocks_past_hf1268(); - uint16_t reward_percent = 40; + uint16_t reward_percent = GRAPHENE_100_PERCENT + 1; // 100.01% flat_set whitelist = {issuer_id}; + GRAPHENE_CHECK_THROW( + update_asset(issuer_id, issuer_private_key, usd_asset.get_id(), reward_percent, whitelist), + fc::assert_exception ); + + reward_percent = GRAPHENE_100_PERCENT; // 100% + GRAPHENE_CHECK_THROW( + update_asset(issuer_id, issuer_private_key, usd_asset.get_id(), reward_percent, whitelist), + fc::assert_exception ); + + reward_percent = GRAPHENE_100_PERCENT - 1; // 99.99% update_asset(issuer_id, issuer_private_key, usd_asset.get_id(), reward_percent, whitelist); asset_object updated_asset = usd_asset.get_id()(db); From 0ffbaa70de17c698fb40b3459f9de62d0e6ce4e7 Mon Sep 17 00:00:00 2001 From: abitmore Date: Sat, 25 May 2019 14:58:03 -0400 Subject: [PATCH 071/133] Check market fee sharing percent --- libraries/chain/protocol/asset_ops.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraries/chain/protocol/asset_ops.cpp b/libraries/chain/protocol/asset_ops.cpp index c88eb9bd8a..a9bc7e9a86 100644 --- a/libraries/chain/protocol/asset_ops.cpp +++ b/libraries/chain/protocol/asset_ops.cpp @@ -236,6 +236,8 @@ void asset_options::validate()const { FC_ASSERT( whitelist_markets.find(item) == whitelist_markets.end() ); } + if( extensions.value.reward_percent.valid() ) + FC_ASSERT( *extensions.value.reward_percent < GRAPHENE_100_PERCENT ); } void asset_claim_fees_operation::validate()const { From 2389c81893074de8ff7d82ade0b8ee68f9a9889e Mon Sep 17 00:00:00 2001 From: abitmore Date: Mon, 27 May 2019 15:10:13 -0400 Subject: [PATCH 072/133] Bump FC to include websocket client fix --- libraries/fc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/fc b/libraries/fc index 397830b8ef..9ce24c2feb 160000 --- a/libraries/fc +++ b/libraries/fc @@ -1 +1 @@ -Subproject commit 397830b8ef183b4cbeadf9765d5fc5666b07b30b +Subproject commit 9ce24c2feb0ef40f722742826a1901a9273128d9 From 827068c8a6143fd3d84098fc5561f68cd0c5e61e Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Tue, 28 May 2019 21:32:33 +0200 Subject: [PATCH 073/133] Fix #1772 by decprecating cli_wallet -H --- programs/cli_wallet/main.cpp | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/programs/cli_wallet/main.cpp b/programs/cli_wallet/main.cpp index b837b6e045..4855c0f6b4 100644 --- a/programs/cli_wallet/main.cpp +++ b/programs/cli_wallet/main.cpp @@ -29,7 +29,6 @@ #include #include -#include #include #include #include @@ -80,7 +79,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") @@ -213,7 +213,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(); } @@ -230,29 +230,24 @@ int main( int argc, char** argv ) wsc->register_api(wapi); c->set_session_data( wsc ); }); - ilog( "Listening for incoming TLS RPC requests on ${p}", + 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}", + ilog( "Listening for incoming HTTP and WS 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 ); - } ); + _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" ) ) From 2d9135fe1639c03ed212c6e5a22682af0cecc109 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Fri, 10 May 2019 13:15:15 +0200 Subject: [PATCH 074/133] Externalized some API templates --- libraries/app/api.cpp | 12 ++++++++++++ libraries/app/database_api.cpp | 4 +++- libraries/app/include/graphene/app/api.hpp | 13 +++++++++++++ libraries/app/include/graphene/app/database_api.hpp | 2 ++ libraries/wallet/include/graphene/wallet/wallet.hpp | 2 ++ 5 files changed, 32 insertions(+), 1 deletion(-) diff --git a/libraries/app/api.cpp b/libraries/app/api.cpp index 7c0b7d3e42..d661bf4735 100644 --- a/libraries/app/api.cpp +++ b/libraries/app/api.cpp @@ -37,8 +37,20 @@ #include #include +#include #include +template class fc::api; +template class fc::api; +template class fc::api; +template class fc::api; +template class fc::api; +template class fc::api; +template class fc::api; +template class fc::api; +template class fc::api; + + namespace graphene { namespace app { login_api::login_api(application& a) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index c09d301893..839bb82aff 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -28,8 +28,8 @@ #include #include - #include +#include #include #include @@ -45,6 +45,8 @@ typedef std::map< std::pair, std::vector > market_queue_type; +template class fc::api; + namespace graphene { namespace app { class database_api_impl : public std::enable_shared_from_this diff --git a/libraries/app/include/graphene/app/api.hpp b/libraries/app/include/graphene/app/api.hpp index e4a3240f2b..c7e0f7f9bc 100644 --- a/libraries/app/include/graphene/app/api.hpp +++ b/libraries/app/include/graphene/app/api.hpp @@ -506,7 +506,18 @@ namespace graphene { namespace app { application& _app; graphene::app::database_api database_api; }; +} } // graphene::app +extern template class fc::api; +extern template class fc::api; +extern template class fc::api; +extern template class fc::api; +extern template class fc::api; +extern template class fc::api; +extern template class fc::api; +extern template class fc::api; + +namespace graphene { namespace app { /** * @brief The login_api class implements the bottom layer of the RPC API * @@ -565,6 +576,8 @@ namespace graphene { namespace app { }} // graphene::app +extern template class fc::api; + FC_REFLECT( graphene::app::network_broadcast_api::transaction_confirmation, (id)(block_num)(trx_num)(trx) ) FC_REFLECT( graphene::app::verify_range_result, diff --git a/libraries/app/include/graphene/app/database_api.hpp b/libraries/app/include/graphene/app/database_api.hpp index aebf628ce7..03c7acc5a7 100644 --- a/libraries/app/include/graphene/app/database_api.hpp +++ b/libraries/app/include/graphene/app/database_api.hpp @@ -811,6 +811,8 @@ class database_api } } +extern template class fc::api; + FC_REFLECT( graphene::app::order, (price)(quote)(base) ); FC_REFLECT( graphene::app::order_book, (base)(quote)(bids)(asks) ); FC_REFLECT( graphene::app::market_ticker, diff --git a/libraries/wallet/include/graphene/wallet/wallet.hpp b/libraries/wallet/include/graphene/wallet/wallet.hpp index f67f5caef5..6b69e70a41 100644 --- a/libraries/wallet/include/graphene/wallet/wallet.hpp +++ b/libraries/wallet/include/graphene/wallet/wallet.hpp @@ -1749,6 +1749,8 @@ class wallet_api } } +extern template class fc::api; + FC_REFLECT( graphene::wallet::key_label, (label)(key) ) FC_REFLECT( graphene::wallet::blind_balance, (amount)(from)(to)(one_time_key)(blinding_factor)(commitment)(used) ) FC_REFLECT( graphene::wallet::blind_confirmation::output, (label)(pub_key)(decrypted_memo)(confirmation)(auth)(confirmation_receipt) ) From 26f039bbc0bd28b95a28c256ae117cae8cd65c5e Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Sat, 11 May 2019 12:39:15 +0200 Subject: [PATCH 075/133] Externalize serialization of blocks, tx, ops --- .../include/graphene/chain/block_database.hpp | 2 + libraries/egenesis/egenesis_none.cpp | 2 + libraries/net/CMakeLists.txt | 1 + libraries/net/core_messages.cpp | 103 ++++++++++++++++ .../include/graphene/net/core_messages.hpp | 116 +++++++----------- .../net/include/graphene/net/message.hpp | 17 +-- .../include/graphene/net/peer_connection.hpp | 3 - .../include/graphene/net/peer_database.hpp | 8 +- libraries/net/message.cpp | 32 +++++ libraries/net/node.cpp | 1 + libraries/net/peer_connection.cpp | 2 +- libraries/net/peer_database.cpp | 11 ++ libraries/protocol/account.cpp | 2 + libraries/protocol/asset_ops.cpp | 2 + libraries/protocol/block.cpp | 5 + libraries/protocol/custom.cpp | 2 + .../include/graphene/protocol/block.hpp | 4 + .../include/graphene/protocol/transaction.hpp | 5 + .../include/graphene/protocol/types.hpp | 27 +++- libraries/protocol/operations.cpp | 1 + libraries/protocol/proposal.cpp | 2 + libraries/protocol/transaction.cpp | 5 + libraries/protocol/transfer.cpp | 2 + libraries/protocol/withdraw_permission.cpp | 2 + .../wallet/include/graphene/wallet/wallet.hpp | 6 +- libraries/wallet/wallet.cpp | 12 +- 26 files changed, 282 insertions(+), 93 deletions(-) create mode 100644 libraries/net/message.cpp diff --git a/libraries/chain/include/graphene/chain/block_database.hpp b/libraries/chain/include/graphene/chain/block_database.hpp index b5f1146ca5..278ea3f447 100644 --- a/libraries/chain/include/graphene/chain/block_database.hpp +++ b/libraries/chain/include/graphene/chain/block_database.hpp @@ -25,6 +25,8 @@ #include #include +#include + namespace graphene { namespace chain { struct index_entry; using namespace graphene::protocol; diff --git a/libraries/egenesis/egenesis_none.cpp b/libraries/egenesis/egenesis_none.cpp index 825f7f83fe..c7a0dcdde3 100644 --- a/libraries/egenesis/egenesis_none.cpp +++ b/libraries/egenesis/egenesis_none.cpp @@ -24,6 +24,8 @@ #include +#include + namespace graphene { namespace egenesis { using namespace graphene::chain; diff --git a/libraries/net/CMakeLists.txt b/libraries/net/CMakeLists.txt index 9778040e32..36c802a3ff 100644 --- a/libraries/net/CMakeLists.txt +++ b/libraries/net/CMakeLists.txt @@ -5,6 +5,7 @@ set(SOURCES node.cpp core_messages.cpp peer_database.cpp peer_connection.cpp + message.cpp message_oriented_connection.cpp) add_library( graphene_net ${SOURCES} ${HEADERS} ) diff --git a/libraries/net/core_messages.cpp b/libraries/net/core_messages.cpp index efff812d3f..1f7b9fce93 100644 --- a/libraries/net/core_messages.cpp +++ b/libraries/net/core_messages.cpp @@ -23,6 +23,7 @@ */ #include +#include namespace graphene { namespace net { @@ -48,3 +49,105 @@ namespace graphene { namespace net { } } // graphene::net +FC_REFLECT_DERIVED_NO_TYPENAME( graphene::net::trx_message, BOOST_PP_SEQ_NIL, (trx) ) +FC_REFLECT_DERIVED_NO_TYPENAME( graphene::net::block_message, BOOST_PP_SEQ_NIL, (block)(block_id) ) + +FC_REFLECT_DERIVED_NO_TYPENAME( graphene::net::item_id, BOOST_PP_SEQ_NIL, + (item_type) + (item_hash) ) +FC_REFLECT_DERIVED_NO_TYPENAME( graphene::net::item_ids_inventory_message, BOOST_PP_SEQ_NIL, + (item_type) + (item_hashes_available) ) +FC_REFLECT_DERIVED_NO_TYPENAME( graphene::net::blockchain_item_ids_inventory_message, BOOST_PP_SEQ_NIL, + (total_remaining_item_count) + (item_type) + (item_hashes_available) ) +FC_REFLECT_DERIVED_NO_TYPENAME( graphene::net::fetch_blockchain_item_ids_message, BOOST_PP_SEQ_NIL, + (item_type) + (blockchain_synopsis) ) +FC_REFLECT_DERIVED_NO_TYPENAME( graphene::net::fetch_items_message, BOOST_PP_SEQ_NIL, + (item_type) + (items_to_fetch) ) +FC_REFLECT_DERIVED_NO_TYPENAME( graphene::net::item_not_available_message, BOOST_PP_SEQ_NIL, (requested_item) ) +FC_REFLECT_DERIVED_NO_TYPENAME( graphene::net::hello_message, BOOST_PP_SEQ_NIL, + (user_agent) + (core_protocol_version) + (inbound_address) + (inbound_port) + (outbound_port) + (node_public_key) + (signed_shared_secret) + (chain_id) + (user_data) ) + +FC_REFLECT_DERIVED_NO_TYPENAME( graphene::net::connection_accepted_message, BOOST_PP_SEQ_NIL, BOOST_PP_SEQ_NIL ) +FC_REFLECT_DERIVED_NO_TYPENAME( graphene::net::connection_rejected_message, BOOST_PP_SEQ_NIL, + (user_agent) + (core_protocol_version) + (remote_endpoint) + (reason_code) + (reason_string)) +FC_REFLECT_DERIVED_NO_TYPENAME( graphene::net::address_request_message, BOOST_PP_SEQ_NIL, BOOST_PP_SEQ_NIL ) +FC_REFLECT_DERIVED_NO_TYPENAME( graphene::net::address_info, BOOST_PP_SEQ_NIL, + (remote_endpoint) + (last_seen_time) + (latency) + (node_id) + (direction) + (firewalled) ) +FC_REFLECT_DERIVED_NO_TYPENAME( graphene::net::address_message, BOOST_PP_SEQ_NIL, (addresses) ) +FC_REFLECT_DERIVED_NO_TYPENAME( graphene::net::closing_connection_message, BOOST_PP_SEQ_NIL, + (reason_for_closing) + (closing_due_to_error) + (error) ) + +FC_REFLECT_DERIVED_NO_TYPENAME(graphene::net::current_time_request_message, BOOST_PP_SEQ_NIL, (request_sent_time)) +FC_REFLECT_DERIVED_NO_TYPENAME(graphene::net::current_time_reply_message, BOOST_PP_SEQ_NIL, + (request_sent_time) + (request_received_time) + (reply_transmitted_time)) +FC_REFLECT_DERIVED_NO_TYPENAME(graphene::net::check_firewall_message, BOOST_PP_SEQ_NIL, (node_id)(endpoint_to_check)) +FC_REFLECT_DERIVED_NO_TYPENAME(graphene::net::check_firewall_reply_message, BOOST_PP_SEQ_NIL, + (node_id)(endpoint_checked)(result)) +FC_REFLECT_DERIVED_NO_TYPENAME(graphene::net::get_current_connections_request_message, + BOOST_PP_SEQ_NIL, BOOST_PP_SEQ_NIL) +FC_REFLECT_DERIVED_NO_TYPENAME(graphene::net::current_connection_data, BOOST_PP_SEQ_NIL, + (connection_duration) + (remote_endpoint) + (node_id) + (clock_offset) + (round_trip_delay) + (connection_direction) + (firewalled) + (user_data)) +FC_REFLECT_DERIVED_NO_TYPENAME(graphene::net::get_current_connections_reply_message, BOOST_PP_SEQ_NIL, + (upload_rate_one_minute) + (download_rate_one_minute) + (upload_rate_fifteen_minutes) + (download_rate_fifteen_minutes) + (upload_rate_one_hour) + (download_rate_one_hour) + (current_connections)) + +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::net::trx_message ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::net::block_message ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::net::item_id ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::net::item_ids_inventory_message ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::net::blockchain_item_ids_inventory_message ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::net::fetch_blockchain_item_ids_message ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::net::fetch_items_message ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::net::item_not_available_message ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::net::hello_message ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::net::connection_accepted_message ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::net::connection_rejected_message ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::net::address_request_message ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::net::address_info ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::net::address_message ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::net::closing_connection_message ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::net::current_time_request_message ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::net::current_time_reply_message ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::net::check_firewall_message ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::net::check_firewall_reply_message ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::net::get_current_connections_request_message ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::net::current_connection_data ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::net::get_current_connections_reply_message ) diff --git a/libraries/net/include/graphene/net/core_messages.hpp b/libraries/net/include/graphene/net/core_messages.hpp index 1ca737583b..c1ec69c44a 100644 --- a/libraries/net/include/graphene/net/core_messages.hpp +++ b/libraries/net/include/graphene/net/core_messages.hpp @@ -24,18 +24,17 @@ #pragma once #include -#include #include #include #include #include -#include #include #include #include #include +#include #include @@ -400,7 +399,6 @@ namespace graphene { namespace net { std::vector current_connections; }; - } } // graphene::net FC_REFLECT_ENUM( graphene::net::core_message_type_enum, @@ -425,33 +423,6 @@ FC_REFLECT_ENUM( graphene::net::core_message_type_enum, (get_current_connections_request_message_type) (get_current_connections_reply_message_type) (core_message_type_last) ) - -FC_REFLECT( graphene::net::trx_message, (trx) ) -FC_REFLECT( graphene::net::block_message, (block)(block_id) ) - -FC_REFLECT( graphene::net::item_id, (item_type) - (item_hash) ) -FC_REFLECT( graphene::net::item_ids_inventory_message, (item_type) - (item_hashes_available) ) -FC_REFLECT( graphene::net::blockchain_item_ids_inventory_message, (total_remaining_item_count) - (item_type) - (item_hashes_available) ) -FC_REFLECT( graphene::net::fetch_blockchain_item_ids_message, (item_type) - (blockchain_synopsis) ) -FC_REFLECT( graphene::net::fetch_items_message, (item_type) - (items_to_fetch) ) -FC_REFLECT( graphene::net::item_not_available_message, (requested_item) ) -FC_REFLECT( graphene::net::hello_message, (user_agent) - (core_protocol_version) - (inbound_address) - (inbound_port) - (outbound_port) - (node_public_key) - (signed_shared_secret) - (chain_id) - (user_data) ) - -FC_REFLECT_EMPTY( graphene::net::connection_accepted_message ) FC_REFLECT_ENUM(graphene::net::rejection_reason_code, (unspecified) (different_chain) (already_connected) @@ -460,54 +431,61 @@ FC_REFLECT_ENUM(graphene::net::rejection_reason_code, (unspecified) (blocked) (invalid_hello_message) (client_too_old)) -FC_REFLECT( graphene::net::connection_rejected_message, (user_agent) - (core_protocol_version) - (remote_endpoint) - (reason_code) - (reason_string)) -FC_REFLECT_EMPTY( graphene::net::address_request_message ) -FC_REFLECT( graphene::net::address_info, (remote_endpoint) - (last_seen_time) - (latency) - (node_id) - (direction) - (firewalled) ) -FC_REFLECT( graphene::net::address_message, (addresses) ) -FC_REFLECT( graphene::net::closing_connection_message, (reason_for_closing) - (closing_due_to_error) - (error) ) FC_REFLECT_ENUM(graphene::net::peer_connection_direction, (unknown) (inbound) (outbound)) FC_REFLECT_ENUM(graphene::net::firewalled_state, (unknown) (firewalled) (not_firewalled)) - -FC_REFLECT(graphene::net::current_time_request_message, (request_sent_time)) -FC_REFLECT(graphene::net::current_time_reply_message, (request_sent_time) - (request_received_time) - (reply_transmitted_time)) FC_REFLECT_ENUM(graphene::net::firewall_check_result, (unable_to_check) (unable_to_connect) (connection_successful)) -FC_REFLECT(graphene::net::check_firewall_message, (node_id)(endpoint_to_check)) -FC_REFLECT(graphene::net::check_firewall_reply_message, (node_id)(endpoint_checked)(result)) -FC_REFLECT_EMPTY(graphene::net::get_current_connections_request_message) -FC_REFLECT(graphene::net::current_connection_data, (connection_duration) - (remote_endpoint) - (node_id) - (clock_offset) - (round_trip_delay) - (connection_direction) - (firewalled) - (user_data)) -FC_REFLECT(graphene::net::get_current_connections_reply_message, (upload_rate_one_minute) - (download_rate_one_minute) - (upload_rate_fifteen_minutes) - (download_rate_fifteen_minutes) - (upload_rate_one_hour) - (download_rate_one_hour) - (current_connections)) + +FC_REFLECT_TYPENAME( graphene::net::trx_message ) +FC_REFLECT_TYPENAME( graphene::net::block_message ) +FC_REFLECT_TYPENAME( graphene::net::item_id ) +FC_REFLECT_TYPENAME( graphene::net::item_ids_inventory_message ) +FC_REFLECT_TYPENAME( graphene::net::blockchain_item_ids_inventory_message ) +FC_REFLECT_TYPENAME( graphene::net::fetch_blockchain_item_ids_message ) +FC_REFLECT_TYPENAME( graphene::net::fetch_items_message ) +FC_REFLECT_TYPENAME( graphene::net::item_not_available_message ) +FC_REFLECT_TYPENAME( graphene::net::hello_message ) +FC_REFLECT_TYPENAME( graphene::net::connection_accepted_message ) +FC_REFLECT_TYPENAME( graphene::net::connection_rejected_message ) +FC_REFLECT_TYPENAME( graphene::net::address_request_message ) +FC_REFLECT_TYPENAME( graphene::net::address_info ) +FC_REFLECT_TYPENAME( graphene::net::address_message ) +FC_REFLECT_TYPENAME( graphene::net::closing_connection_message ) +FC_REFLECT_TYPENAME( graphene::net::current_time_request_message ) +FC_REFLECT_TYPENAME( graphene::net::current_time_reply_message ) +FC_REFLECT_TYPENAME( graphene::net::check_firewall_message ) +FC_REFLECT_TYPENAME( graphene::net::check_firewall_reply_message ) +FC_REFLECT_TYPENAME( graphene::net::get_current_connections_request_message ) +FC_REFLECT_TYPENAME( graphene::net::current_connection_data ) +FC_REFLECT_TYPENAME( graphene::net::get_current_connections_reply_message ) + +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::net::trx_message ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::net::block_message ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::net::item_id ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::net::item_ids_inventory_message ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::net::blockchain_item_ids_inventory_message ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::net::fetch_blockchain_item_ids_message ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::net::fetch_items_message ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::net::item_not_available_message ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::net::hello_message ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::net::connection_accepted_message ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::net::connection_rejected_message ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::net::address_request_message ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::net::address_info ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::net::address_message ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::net::closing_connection_message ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::net::current_time_request_message ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::net::current_time_reply_message ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::net::check_firewall_message ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::net::check_firewall_reply_message ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::net::get_current_connections_request_message ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::net::current_connection_data ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::net::get_current_connections_reply_message ) #include #include diff --git a/libraries/net/include/graphene/net/message.hpp b/libraries/net/include/graphene/net/message.hpp index 4ff142f7e7..d8792da758 100644 --- a/libraries/net/include/graphene/net/message.hpp +++ b/libraries/net/include/graphene/net/message.hpp @@ -23,12 +23,15 @@ */ #pragma once #include + +#include + #include #include #include -#include +#include #include -#include +#include namespace graphene { namespace net { @@ -109,10 +112,10 @@ namespace graphene { namespace net { } }; - - - } } // graphene::net -FC_REFLECT( graphene::net::message_header, (size)(msg_type) ) -FC_REFLECT_DERIVED( graphene::net::message, (graphene::net::message_header), (data) ) +FC_REFLECT_TYPENAME( graphene::net::message_header ) +FC_REFLECT_TYPENAME( graphene::net::message ) + +GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::net::message_header) +GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::net::message) diff --git a/libraries/net/include/graphene/net/peer_connection.hpp b/libraries/net/include/graphene/net/peer_connection.hpp index 22a32dab2a..dd9d6eb774 100644 --- a/libraries/net/include/graphene/net/peer_connection.hpp +++ b/libraries/net/include/graphene/net/peer_connection.hpp @@ -26,7 +26,6 @@ #include #include #include -#include #include #include @@ -35,9 +34,7 @@ #include #include #include -#include #include -#include #include #include diff --git a/libraries/net/include/graphene/net/peer_database.hpp b/libraries/net/include/graphene/net/peer_database.hpp index d0a06dd9c6..931f6e33a7 100644 --- a/libraries/net/include/graphene/net/peer_database.hpp +++ b/libraries/net/include/graphene/net/peer_database.hpp @@ -24,13 +24,14 @@ #pragma once #include +#include + #include #include #include #include #include #include -#include namespace graphene { namespace net { @@ -118,5 +119,6 @@ namespace graphene { namespace net { } } // end namespace graphene::net -FC_REFLECT_ENUM(graphene::net::potential_peer_last_connection_disposition, (never_attempted_to_connect)(last_connection_failed)(last_connection_rejected)(last_connection_handshaking_failed)(last_connection_succeeded)) -FC_REFLECT(graphene::net::potential_peer_record, (endpoint)(last_seen_time)(last_connection_disposition)(last_connection_attempt_time)(number_of_successful_connection_attempts)(number_of_failed_connection_attempts)(last_error) ) +FC_REFLECT_TYPENAME( graphene::net::potential_peer_record ) + +GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::net::potential_peer_record) diff --git a/libraries/net/message.cpp b/libraries/net/message.cpp new file mode 100644 index 0000000000..74c04eba00 --- /dev/null +++ b/libraries/net/message.cpp @@ -0,0 +1,32 @@ +/* + * 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 + +FC_REFLECT_DERIVED_NO_TYPENAME( graphene::net::message_header, BOOST_PP_SEQ_NIL, (size)(msg_type) ) +FC_REFLECT_DERIVED_NO_TYPENAME( graphene::net::message, (graphene::net::message_header), (data) ) + +GRAPHENE_EXTERNAL_SERIALIZATION(/*not extern*/, graphene::net::message_header) +GRAPHENE_EXTERNAL_SERIALIZATION(/*not extern*/, graphene::net::message) diff --git a/libraries/net/node.cpp b/libraries/net/node.cpp index cbfc1f4bc4..f570dac5bf 100644 --- a/libraries/net/node.cpp +++ b/libraries/net/node.cpp @@ -66,6 +66,7 @@ #include #include #include +#include #include #include #include diff --git a/libraries/net/peer_connection.cpp b/libraries/net/peer_connection.cpp index 1b35432af0..12a0eccdb4 100644 --- a/libraries/net/peer_connection.cpp +++ b/libraries/net/peer_connection.cpp @@ -25,8 +25,8 @@ #include #include #include -#include +#include #include #include diff --git a/libraries/net/peer_database.cpp b/libraries/net/peer_database.cpp index 2b20364e31..76ae9c8c16 100644 --- a/libraries/net/peer_database.cpp +++ b/libraries/net/peer_database.cpp @@ -274,3 +274,14 @@ namespace graphene { namespace net { } } } // end namespace graphene::net + +FC_REFLECT_ENUM( graphene::net::potential_peer_last_connection_disposition, + (never_attempted_to_connect) + (last_connection_failed)(last_connection_rejected) + (last_connection_handshaking_failed)(last_connection_succeeded) ) +FC_REFLECT_DERIVED_NO_TYPENAME( graphene::net::potential_peer_record, BOOST_PP_SEQ_NIL, + (endpoint)(last_seen_time)(last_connection_disposition) + (last_connection_attempt_time)(number_of_successful_connection_attempts) + (number_of_failed_connection_attempts)(last_error) ) + +GRAPHENE_EXTERNAL_SERIALIZATION(/*not extern*/, graphene::net::potential_peer_record) diff --git a/libraries/protocol/account.cpp b/libraries/protocol/account.cpp index 881b5de1e2..99341da1e6 100644 --- a/libraries/protocol/account.cpp +++ b/libraries/protocol/account.cpp @@ -23,6 +23,8 @@ */ #include +#include + namespace graphene { namespace protocol { /** diff --git a/libraries/protocol/asset_ops.cpp b/libraries/protocol/asset_ops.cpp index bb77c30ddf..b4b35a03a3 100644 --- a/libraries/protocol/asset_ops.cpp +++ b/libraries/protocol/asset_ops.cpp @@ -23,6 +23,8 @@ */ #include +#include + #include namespace graphene { namespace protocol { diff --git a/libraries/protocol/block.cpp b/libraries/protocol/block.cpp index dfc3320706..37d8628cd4 100644 --- a/libraries/protocol/block.cpp +++ b/libraries/protocol/block.cpp @@ -23,6 +23,7 @@ */ #include #include +#include #include #include @@ -98,3 +99,7 @@ namespace graphene { namespace protocol { return _calculated_merkle_root; } } } + +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/protocol/custom.cpp b/libraries/protocol/custom.cpp index c199552c36..b2e34a8323 100644 --- a/libraries/protocol/custom.cpp +++ b/libraries/protocol/custom.cpp @@ -23,6 +23,8 @@ */ #include +#include + namespace graphene { namespace protocol { void custom_operation::validate()const diff --git a/libraries/protocol/include/graphene/protocol/block.hpp b/libraries/protocol/include/graphene/protocol/block.hpp index a178928fd5..8b902d8c8f 100644 --- a/libraries/protocol/include/graphene/protocol/block.hpp +++ b/libraries/protocol/include/graphene/protocol/block.hpp @@ -70,3 +70,7 @@ namespace graphene { namespace protocol { FC_REFLECT( graphene::protocol::block_header, (previous)(timestamp)(witness)(transaction_merkle_root)(extensions) ) 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::protocol::block_header) +GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::protocol::signed_block_header) +GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::protocol::signed_block) diff --git a/libraries/protocol/include/graphene/protocol/transaction.hpp b/libraries/protocol/include/graphene/protocol/transaction.hpp index 3ba121c8d6..c639772d88 100644 --- a/libraries/protocol/include/graphene/protocol/transaction.hpp +++ b/libraries/protocol/include/graphene/protocol/transaction.hpp @@ -294,3 +294,8 @@ FC_REFLECT( graphene::protocol::transaction, (ref_block_num)(ref_block_prefix)(e FC_REFLECT_DERIVED( graphene::protocol::signed_transaction, (graphene::protocol::transaction), (signatures) ) FC_REFLECT_DERIVED( graphene::protocol::precomputable_transaction, (graphene::protocol::signed_transaction), ) FC_REFLECT_DERIVED( graphene::protocol::processed_transaction, (graphene::protocol::precomputable_transaction), (operation_results) ) + +GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::protocol::transaction) +GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::protocol::signed_transaction) +GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::protocol::precomputable_transaction) +GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::protocol::processed_transaction) diff --git a/libraries/protocol/include/graphene/protocol/types.hpp b/libraries/protocol/include/graphene/protocol/types.hpp index 131956a715..444318cc5f 100644 --- a/libraries/protocol/include/graphene/protocol/types.hpp +++ b/libraries/protocol/include/graphene/protocol/types.hpp @@ -45,7 +45,8 @@ #include -#include +#include +#include #include #include @@ -59,6 +60,30 @@ #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 + #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) \ diff --git a/libraries/protocol/operations.cpp b/libraries/protocol/operations.cpp index 5092921261..943fcdb044 100644 --- a/libraries/protocol/operations.cpp +++ b/libraries/protocol/operations.cpp @@ -22,6 +22,7 @@ * THE SOFTWARE. */ #include +#include namespace graphene { namespace protocol { diff --git a/libraries/protocol/proposal.cpp b/libraries/protocol/proposal.cpp index 86f1158e76..020b5182f2 100644 --- a/libraries/protocol/proposal.cpp +++ b/libraries/protocol/proposal.cpp @@ -24,6 +24,8 @@ #include #include +#include + namespace graphene { namespace protocol { proposal_create_operation proposal_create_operation::committee_proposal(const chain_parameters& global_params, fc::time_point_sec head_block_time ) diff --git a/libraries/protocol/transaction.cpp b/libraries/protocol/transaction.cpp index d49f269555..842d48d8ce 100644 --- a/libraries/protocol/transaction.cpp +++ b/libraries/protocol/transaction.cpp @@ -439,3 +439,8 @@ void signed_transaction::verify_authority( } FC_CAPTURE_AND_RETHROW( (*this) ) } } } // graphene::protocol + +GRAPHENE_EXTERNAL_SERIALIZATION(/*not extern*/, graphene::protocol::transaction) +GRAPHENE_EXTERNAL_SERIALIZATION(/*not extern*/, graphene::protocol::signed_transaction) +GRAPHENE_EXTERNAL_SERIALIZATION(/*not extern*/, graphene::protocol::precomputable_transaction) +GRAPHENE_EXTERNAL_SERIALIZATION(/*not extern*/, graphene::protocol::processed_transaction) diff --git a/libraries/protocol/transfer.cpp b/libraries/protocol/transfer.cpp index 8d97f894f0..c4c0b15aff 100644 --- a/libraries/protocol/transfer.cpp +++ b/libraries/protocol/transfer.cpp @@ -23,6 +23,8 @@ */ #include +#include + namespace graphene { namespace protocol { share_type transfer_operation::calculate_fee( const fee_parameters_type& schedule )const diff --git a/libraries/protocol/withdraw_permission.cpp b/libraries/protocol/withdraw_permission.cpp index fdbe74a739..683121ac49 100644 --- a/libraries/protocol/withdraw_permission.cpp +++ b/libraries/protocol/withdraw_permission.cpp @@ -23,6 +23,8 @@ */ #include +#include + namespace graphene { namespace protocol { void withdraw_permission_update_operation::validate()const diff --git a/libraries/wallet/include/graphene/wallet/wallet.hpp b/libraries/wallet/include/graphene/wallet/wallet.hpp index 6b69e70a41..f0383670bb 100644 --- a/libraries/wallet/include/graphene/wallet/wallet.hpp +++ b/libraries/wallet/include/graphene/wallet/wallet.hpp @@ -229,11 +229,12 @@ struct worker_vote_delta flat_set vote_abstain; }; -struct signed_block_with_info : public signed_block +struct signed_block_with_info { signed_block_with_info( const signed_block& block ); signed_block_with_info( const signed_block_with_info& block ) = default; + signed_block block; block_id_type block_id; public_key_type signing_key; vector< transaction_id_type > transaction_ids; @@ -1799,8 +1800,7 @@ FC_REFLECT( graphene::wallet::worker_vote_delta, (vote_abstain) ) -FC_REFLECT_DERIVED( graphene::wallet::signed_block_with_info, (graphene::chain::signed_block), - (block_id)(signing_key)(transaction_ids) ) +FC_REFLECT( graphene::wallet::signed_block_with_info, (block_id)(signing_key)(transaction_ids) ) FC_REFLECT_DERIVED( graphene::wallet::vesting_balance_object_with_info, (graphene::chain::vesting_balance_object), (allowed_withdraw)(allowed_withdraw_time) ) diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index e8fce5fff0..261f7dd773 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -5038,13 +5038,13 @@ order_book wallet_api::get_order_book( const string& base, const string& quote, return( my->_remote_db->get_order_book( base, quote, limit ) ); } -signed_block_with_info::signed_block_with_info( const signed_block& block ) - : signed_block( block ) +signed_block_with_info::signed_block_with_info( const signed_block& _block ) + : block( _block ) { - block_id = id(); - signing_key = signee(); - transaction_ids.reserve( transactions.size() ); - for( const processed_transaction& tx : transactions ) + block_id = _block.id(); + signing_key = _block.signee(); + transaction_ids.reserve( _block.transactions.size() ); + for( const processed_transaction& tx : _block.transactions ) transaction_ids.push_back( tx.id() ); } From 5b3efc3005e307d8c5d5f6f4f8ce13b0bd612ce2 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Tue, 14 May 2019 00:18:12 +0200 Subject: [PATCH 076/133] Externalized db objects --- libraries/chain/CMakeLists.txt | 1 + libraries/chain/account_object.cpp | 38 +++- libraries/chain/asset_object.cpp | 35 ++- .../include/graphene/chain/account_object.hpp | 43 +--- .../include/graphene/chain/asset_object.hpp | 40 +--- .../include/graphene/chain/balance_object.hpp | 5 +- .../graphene/chain/block_summary_object.hpp | 5 +- .../graphene/chain/budget_record_object.hpp | 26 +-- .../include/graphene/chain/buyback_object.hpp | 7 +- .../graphene/chain/chain_property_object.hpp | 9 +- .../chain/committee_member_object.hpp | 10 +- .../graphene/chain/confidential_object.hpp | 7 +- .../include/graphene/chain/fba_object.hpp | 5 +- .../graphene/chain/global_property_object.hpp | 29 +-- .../include/graphene/chain/htlc_object.hpp | 23 +- .../chain/immutable_chain_parameters.hpp | 14 +- .../include/graphene/chain/market_object.hpp | 25 +-- .../chain/operation_history_object.hpp | 13 +- .../graphene/chain/proposal_object.hpp | 13 +- .../chain/special_authority_object.hpp | 9 +- .../chain/transaction_history_object.hpp | 7 +- .../graphene/chain/vesting_balance_object.hpp | 13 +- .../chain/withdraw_permission_object.hpp | 19 +- .../include/graphene/chain/witness_object.hpp | 18 +- .../chain/witness_schedule_object.hpp | 11 +- .../include/graphene/chain/worker_object.hpp | 25 +-- libraries/chain/market_object.cpp | 23 ++ libraries/chain/proposal_object.cpp | 10 +- libraries/chain/small_objects.cpp | 212 ++++++++++++++++++ libraries/chain/vesting_balance_object.cpp | 6 + 30 files changed, 440 insertions(+), 261 deletions(-) create mode 100644 libraries/chain/small_objects.cpp diff --git a/libraries/chain/CMakeLists.txt b/libraries/chain/CMakeLists.txt index dbe71f9ce9..e54f3db81a 100644 --- a/libraries/chain/CMakeLists.txt +++ b/libraries/chain/CMakeLists.txt @@ -62,6 +62,7 @@ add_library( graphene_chain market_object.cpp proposal_object.cpp vesting_balance_object.cpp + small_objects.cpp block_database.cpp diff --git a/libraries/chain/account_object.cpp b/libraries/chain/account_object.cpp index 7acaf10b21..914f99c186 100644 --- a/libraries/chain/account_object.cpp +++ b/libraries/chain/account_object.cpp @@ -22,9 +22,9 @@ * THE SOFTWARE. */ #include -#include #include -#include + +#include #include namespace graphene { namespace chain { @@ -320,3 +320,37 @@ const account_balance_object* balances_by_account_index::get_account_balance( co } } } // graphene::chain + +FC_REFLECT_DERIVED_NO_TYPENAME( graphene::chain::account_object, + (graphene::db::object), + (membership_expiration_date)(registrar)(referrer)(lifetime_referrer) + (network_fee_percentage)(lifetime_referrer_fee_percentage)(referrer_rewards_percentage) + (name)(owner)(active)(options)(statistics)(whitelisting_accounts)(blacklisting_accounts) + (whitelisted_accounts)(blacklisted_accounts) + (cashback_vb) + (owner_special_authority)(active_special_authority) + (top_n_control_flags) + (allowed_assets) + ) + +FC_REFLECT_DERIVED_NO_TYPENAME( graphene::chain::account_balance_object, + (graphene::db::object), + (owner)(asset_type)(balance)(maintenance_flag) ) + +FC_REFLECT_DERIVED_NO_TYPENAME( graphene::chain::account_statistics_object, + (graphene::chain::object), + (owner)(name) + (most_recent_op) + (total_ops)(removed_ops) + (total_core_in_orders) + (core_in_balance) + (has_cashback_vb) + (is_voting) + (last_vote_time) + (lifetime_fees_paid) + (pending_fees)(pending_vested_fees) + ) + +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::account_object ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::account_balance_object ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::account_statistics_object ) diff --git a/libraries/chain/asset_object.cpp b/libraries/chain/asset_object.cpp index c6b6ca0d82..2a2c2f4804 100644 --- a/libraries/chain/asset_object.cpp +++ b/libraries/chain/asset_object.cpp @@ -25,10 +25,9 @@ #include #include +#include #include -#include - using namespace graphene::chain; share_type asset_bitasset_data_object::max_force_settlement_volume(share_type current_supply) const @@ -176,3 +175,35 @@ string asset_object::amount_to_string(share_type amount) const } return result; } + +FC_REFLECT_DERIVED_NO_TYPENAME( graphene::chain::asset_dynamic_data_object, (graphene::db::object), + (current_supply)(confidential_supply)(accumulated_fees)(fee_pool) ) + +FC_REFLECT_DERIVED_NO_TYPENAME( graphene::chain::asset_bitasset_data_object, (graphene::db::object), + (asset_id) + (feeds) + (current_feed) + (current_feed_publication_time) + (current_maintenance_collateralization) + (options) + (force_settled_volume) + (is_prediction_market) + (settlement_price) + (settlement_fund) + (asset_cer_updated) + (feed_cer_updated) + ) + +FC_REFLECT_DERIVED_NO_TYPENAME( graphene::chain::asset_object, (graphene::db::object), + (symbol) + (precision) + (issuer) + (options) + (dynamic_asset_data_id) + (bitasset_data_id) + (buyback_account) + ) + +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_object ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_bitasset_data_object ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_dynamic_data_object ) diff --git a/libraries/chain/include/graphene/chain/account_object.hpp b/libraries/chain/include/graphene/chain/account_object.hpp index 2f3aa611d1..e1a480d6cc 100644 --- a/libraries/chain/include/graphene/chain/account_object.hpp +++ b/libraries/chain/include/graphene/chain/account_object.hpp @@ -22,9 +22,11 @@ * THE SOFTWARE. */ #pragma once -#include -#include + #include +#include +#include + #include namespace graphene { namespace chain { @@ -394,7 +396,7 @@ namespace graphene { namespace chain { */ typedef generic_index account_balance_index; - struct by_name{}; + struct by_name; /** * @ingroup object_index @@ -445,33 +447,10 @@ 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) - (network_fee_percentage)(lifetime_referrer_fee_percentage)(referrer_rewards_percentage) - (name)(owner)(active)(options)(statistics)(whitelisting_accounts)(blacklisting_accounts) - (whitelisted_accounts)(blacklisted_accounts) - (cashback_vb) - (owner_special_authority)(active_special_authority) - (top_n_control_flags) - (allowed_assets) - ) - -FC_REFLECT_DERIVED( graphene::chain::account_balance_object, - (graphene::db::object), - (owner)(asset_type)(balance)(maintenance_flag) ) - -FC_REFLECT_DERIVED( graphene::chain::account_statistics_object, - (graphene::chain::object), - (owner)(name) - (most_recent_op) - (total_ops)(removed_ops) - (total_core_in_orders) - (core_in_balance) - (has_cashback_vb) - (is_voting) - (last_vote_time) - (lifetime_fees_paid) - (pending_fees)(pending_vested_fees) - ) +FC_REFLECT_TYPENAME( graphene::chain::account_object ) +FC_REFLECT_TYPENAME( graphene::chain::account_balance_object ) +FC_REFLECT_TYPENAME( graphene::chain::account_statistics_object ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::account_object ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::account_balance_object ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::account_statistics_object ) diff --git a/libraries/chain/include/graphene/chain/asset_object.hpp b/libraries/chain/include/graphene/chain/asset_object.hpp index 625658e716..8b22073706 100644 --- a/libraries/chain/include/graphene/chain/asset_object.hpp +++ b/libraries/chain/include/graphene/chain/asset_object.hpp @@ -22,10 +22,11 @@ * THE SOFTWARE. */ #pragma once +#include +#include #include + #include -#include -#include /** * @defgroup prediction_market Prediction Market @@ -38,7 +39,6 @@ */ namespace graphene { namespace chain { - class account_object; class asset_bitasset_data_object; class database; using namespace graphene::db; @@ -323,30 +323,10 @@ 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) -FC_REFLECT_DERIVED( graphene::chain::asset_dynamic_data_object, (graphene::db::object), - (current_supply)(confidential_supply)(accumulated_fees)(fee_pool) ) - -FC_REFLECT_DERIVED( graphene::chain::asset_bitasset_data_object, (graphene::db::object), - (asset_id) - (feeds) - (current_feed) - (current_feed_publication_time) - (current_maintenance_collateralization) - (options) - (force_settled_volume) - (is_prediction_market) - (settlement_price) - (settlement_fund) - (asset_cer_updated) - (feed_cer_updated) - ) - -FC_REFLECT_DERIVED( graphene::chain::asset_object, (graphene::db::object), - (symbol) - (precision) - (issuer) - (options) - (dynamic_asset_data_id) - (bitasset_data_id) - (buyback_account) - ) +FC_REFLECT_TYPENAME( graphene::chain::asset_object ) +FC_REFLECT_TYPENAME( graphene::chain::asset_bitasset_data_object ) +FC_REFLECT_TYPENAME( graphene::chain::asset_dynamic_data_object ) + +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_object ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_bitasset_data_object ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_dynamic_data_object ) diff --git a/libraries/chain/include/graphene/chain/balance_object.hpp b/libraries/chain/include/graphene/chain/balance_object.hpp index ebff56bc56..842d99aea6 100644 --- a/libraries/chain/include/graphene/chain/balance_object.hpp +++ b/libraries/chain/include/graphene/chain/balance_object.hpp @@ -73,5 +73,6 @@ namespace graphene { namespace chain { 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) ) +FC_REFLECT_TYPENAME( graphene::chain::balance_object ) + +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::balance_object ) diff --git a/libraries/chain/include/graphene/chain/block_summary_object.hpp b/libraries/chain/include/graphene/chain/block_summary_object.hpp index 04ac7d88ba..0f2dd650f1 100644 --- a/libraries/chain/include/graphene/chain/block_summary_object.hpp +++ b/libraries/chain/include/graphene/chain/block_summary_object.hpp @@ -22,6 +22,7 @@ * THE SOFTWARE. */ #pragma once +#include #include namespace graphene { namespace chain { @@ -49,4 +50,6 @@ 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) ) +FC_REFLECT_TYPENAME( graphene::chain::block_summary_object ) + +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::block_summary_object ) diff --git a/libraries/chain/include/graphene/chain/budget_record_object.hpp b/libraries/chain/include/graphene/chain/budget_record_object.hpp index 540abe4d31..35a8b4af1b 100644 --- a/libraries/chain/include/graphene/chain/budget_record_object.hpp +++ b/libraries/chain/include/graphene/chain/budget_record_object.hpp @@ -23,7 +23,6 @@ */ #pragma once #include -#include #include namespace graphene { namespace chain { @@ -54,8 +53,6 @@ struct budget_record share_type supply_delta = 0; }; -class budget_record_object; - class budget_record_object : public graphene::db::abstract_object { public: @@ -70,23 +67,8 @@ class budget_record_object : public graphene::db::abstract_object -#include +#include #include namespace graphene { namespace chain { @@ -66,4 +65,6 @@ typedef generic_index< buyback_object, buyback_multi_index_type > buyback_index; MAP_OBJECT_ID_TO_TYPE(graphene::chain::buyback_object) -FC_REFLECT_DERIVED( graphene::chain::buyback_object, (graphene::db::object), (asset_to_buy) ) +FC_REFLECT_TYPENAME( graphene::chain::buyback_object ) + +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 8b4df9389e..0e3e8e316e 100644 --- a/libraries/chain/include/graphene/chain/chain_property_object.hpp +++ b/libraries/chain/include/graphene/chain/chain_property_object.hpp @@ -27,8 +27,6 @@ namespace graphene { namespace chain { -class chain_property_object; - /** * Contains invariants which are set at genesis and never changed. */ @@ -46,7 +44,6 @@ 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) - ) +FC_REFLECT_TYPENAME( graphene::chain::chain_property_object ) + +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::chain_property_object ) diff --git a/libraries/chain/include/graphene/chain/committee_member_object.hpp b/libraries/chain/include/graphene/chain/committee_member_object.hpp index b3fee66178..89f361c845 100644 --- a/libraries/chain/include/graphene/chain/committee_member_object.hpp +++ b/libraries/chain/include/graphene/chain/committee_member_object.hpp @@ -22,16 +22,13 @@ * THE SOFTWARE. */ #pragma once -#include +#include #include #include -#include namespace graphene { namespace chain { using namespace graphene::db; - class account_object; - /** * @brief tracks information about a committee_member account. * @ingroup object @@ -76,5 +73,6 @@ namespace graphene { namespace 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) ) +FC_REFLECT_TYPENAME( graphene::chain::committee_member_object ) + +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::committee_member_object ) diff --git a/libraries/chain/include/graphene/chain/confidential_object.hpp b/libraries/chain/include/graphene/chain/confidential_object.hpp index ac21875a54..7bbdf0575b 100644 --- a/libraries/chain/include/graphene/chain/confidential_object.hpp +++ b/libraries/chain/include/graphene/chain/confidential_object.hpp @@ -26,7 +26,6 @@ #include #include -#include #include #include @@ -50,8 +49,6 @@ class blinded_balance_object : public graphene::db::abstract_object -#include #include namespace graphene { namespace chain { @@ -51,4 +50,6 @@ class fba_accumulator_object : public graphene::db::abstract_object< fba_accumul 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) ) +FC_REFLECT_TYPENAME( graphene::chain::fba_accumulator_object ) + +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::fba_accumulator_object ) diff --git a/libraries/chain/include/graphene/chain/global_property_object.hpp b/libraries/chain/include/graphene/chain/global_property_object.hpp index 2f72918726..0ce0ca03e9 100644 --- a/libraries/chain/include/graphene/chain/global_property_object.hpp +++ b/libraries/chain/include/graphene/chain/global_property_object.hpp @@ -25,7 +25,6 @@ #include #include -#include #include #include @@ -128,26 +127,8 @@ 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) - (time) - (current_witness) - (next_maintenance_time) - (last_budget_time) - (witness_budget) - (accounts_registered_this_interval) - (recently_missed_count) - (current_aslot) - (recent_slots_filled) - (dynamic_flags) - (last_irreversible_block_num) - ) - -FC_REFLECT_DERIVED( graphene::chain::global_property_object, (graphene::db::object), - (parameters) - (pending_parameters) - (next_available_vote_id) - (active_committee_members) - (active_witnesses) - ) +FC_REFLECT_TYPENAME( graphene::chain::dynamic_global_property_object ) +FC_REFLECT_TYPENAME( graphene::chain::global_property_object ) + +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::dynamic_global_property_object ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::global_property_object ) diff --git a/libraries/chain/include/graphene/chain/htlc_object.hpp b/libraries/chain/include/graphene/chain/htlc_object.hpp index 8136a983ad..3c947aa510 100644 --- a/libraries/chain/include/graphene/chain/htlc_object.hpp +++ b/libraries/chain/include/graphene/chain/htlc_object.hpp @@ -23,14 +23,11 @@ */ #pragma once -#include -#include -#include #include -#include -#include #include +#include + namespace graphene { namespace chain { using namespace protocol; @@ -119,13 +116,9 @@ namespace graphene { namespace chain { MAP_OBJECT_ID_TO_TYPE(graphene::chain::htlc_object) -FC_REFLECT( graphene::chain::htlc_object::transfer_info, - (from) (to) (amount) (asset_id) ) -FC_REFLECT( graphene::chain::htlc_object::condition_info::hash_lock_info, - (preimage_hash) (preimage_size) ) -FC_REFLECT( graphene::chain::htlc_object::condition_info::time_lock_info, - (expiration) ) -FC_REFLECT( graphene::chain::htlc_object::condition_info, - (hash_lock)(time_lock) ) -FC_REFLECT_DERIVED( graphene::chain::htlc_object, (graphene::db::object), - (transfer) (conditions) ) +FC_REFLECT_TYPENAME( graphene::chain::htlc_object::condition_info::hash_lock_info ) +FC_REFLECT_TYPENAME( graphene::chain::htlc_object::condition_info::time_lock_info ) +FC_REFLECT_TYPENAME( graphene::chain::htlc_object::condition_info ) +FC_REFLECT_TYPENAME( graphene::chain::htlc_object ) + +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::htlc_object ) diff --git a/libraries/chain/include/graphene/chain/immutable_chain_parameters.hpp b/libraries/chain/include/graphene/chain/immutable_chain_parameters.hpp index 0082383c99..80346c122d 100644 --- a/libraries/chain/include/graphene/chain/immutable_chain_parameters.hpp +++ b/libraries/chain/include/graphene/chain/immutable_chain_parameters.hpp @@ -23,11 +23,8 @@ */ #pragma once -#include - -#include - #include +#include namespace graphene { namespace chain { @@ -41,9 +38,6 @@ struct immutable_chain_parameters } } // graphene::chain -FC_REFLECT( graphene::chain::immutable_chain_parameters, - (min_committee_member_count) - (min_witness_count) - (num_special_accounts) - (num_special_assets) -) +FC_REFLECT_TYPENAME( graphene::chain::immutable_chain_parameters ) + +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::immutable_chain_parameters ) diff --git a/libraries/chain/include/graphene/chain/market_object.hpp b/libraries/chain/include/graphene/chain/market_object.hpp index 37cbdc1fd6..d9d8cbb484 100644 --- a/libraries/chain/include/graphene/chain/market_object.hpp +++ b/libraries/chain/include/graphene/chain/market_object.hpp @@ -23,10 +23,9 @@ */ #pragma once +#include #include -#include #include -#include #include @@ -276,18 +275,12 @@ MAP_OBJECT_ID_TO_TYPE(graphene::chain::call_order_object) MAP_OBJECT_ID_TO_TYPE(graphene::chain::force_settlement_object) MAP_OBJECT_ID_TO_TYPE(graphene::chain::collateral_bid_object) -FC_REFLECT_DERIVED( graphene::chain::limit_order_object, - (graphene::db::object), - (expiration)(seller)(for_sale)(sell_price)(deferred_fee)(deferred_paid_fee) - ) - -FC_REFLECT_DERIVED( graphene::chain::call_order_object, (graphene::db::object), - (borrower)(collateral)(debt)(call_price)(target_collateral_ratio) ) - -FC_REFLECT_DERIVED( graphene::chain::force_settlement_object, - (graphene::db::object), - (owner)(balance)(settlement_date) - ) +FC_REFLECT_TYPENAME( graphene::chain::limit_order_object ) +FC_REFLECT_TYPENAME( graphene::chain::call_order_object ) +FC_REFLECT_TYPENAME( graphene::chain::force_settlement_object ) +FC_REFLECT_TYPENAME( graphene::chain::collateral_bid_object ) -FC_REFLECT_DERIVED( graphene::chain::collateral_bid_object, (graphene::db::object), - (bidder)(inv_swan_price) ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::limit_order_object ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::call_order_object ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::force_settlement_object ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::collateral_bid_object ) diff --git a/libraries/chain/include/graphene/chain/operation_history_object.hpp b/libraries/chain/include/graphene/chain/operation_history_object.hpp index 51864aef4e..e514340234 100644 --- a/libraries/chain/include/graphene/chain/operation_history_object.hpp +++ b/libraries/chain/include/graphene/chain/operation_history_object.hpp @@ -22,8 +22,10 @@ * THE SOFTWARE. */ #pragma once + #include #include + #include namespace graphene { namespace chain { @@ -94,9 +96,6 @@ namespace graphene { namespace chain { operation_history_id_type operation_id; uint64_t sequence = 0; /// the operation position within the given account account_transaction_history_id_type next; - - //std::pair account_op()const { return std::tie( account, operation_id ); } - //std::pair account_seq()const { return std::tie( account, sequence ); } }; typedef multi_index_container< @@ -142,8 +141,8 @@ namespace graphene { namespace 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_TYPENAME( graphene::chain::operation_history_object ) +FC_REFLECT_TYPENAME( graphene::chain::account_transaction_history_object ) -FC_REFLECT_DERIVED( graphene::chain::account_transaction_history_object, (graphene::chain::object), - (account)(operation_id)(sequence)(next) ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::operation_history_object ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::account_transaction_history_object ) diff --git a/libraries/chain/include/graphene/chain/proposal_object.hpp b/libraries/chain/include/graphene/chain/proposal_object.hpp index 8908c06b81..2c708ac48a 100644 --- a/libraries/chain/include/graphene/chain/proposal_object.hpp +++ b/libraries/chain/include/graphene/chain/proposal_object.hpp @@ -23,14 +23,14 @@ */ #pragma once +#include #include -#include - #include + #include namespace graphene { namespace chain { - + class database; /** * @brief tracks the approval of a partially approved transaction @@ -106,7 +106,6 @@ typedef generic_index proposal_ 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) - (available_key_approvals)(proposer)(fail_reason) ) +FC_REFLECT_TYPENAME( graphene::chain::proposal_object ) + +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::proposal_object ) diff --git a/libraries/chain/include/graphene/chain/special_authority_object.hpp b/libraries/chain/include/graphene/chain/special_authority_object.hpp index b901d657d9..2ff0cf170c 100644 --- a/libraries/chain/include/graphene/chain/special_authority_object.hpp +++ b/libraries/chain/include/graphene/chain/special_authority_object.hpp @@ -23,7 +23,6 @@ */ #pragma once #include -#include #include namespace graphene { namespace chain { @@ -65,8 +64,6 @@ typedef generic_index< special_authority_object, special_authority_multi_index_t MAP_OBJECT_ID_TO_TYPE(graphene::chain::special_authority_object) -FC_REFLECT_DERIVED( - graphene::chain::special_authority_object, - (graphene::db::object), - (account) -) +FC_REFLECT_TYPENAME( graphene::chain::special_authority_object ) + +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::special_authority_object ) diff --git a/libraries/chain/include/graphene/chain/transaction_history_object.hpp b/libraries/chain/include/graphene/chain/transaction_history_object.hpp index 3a25f4bfc9..b29b26e1dc 100644 --- a/libraries/chain/include/graphene/chain/transaction_history_object.hpp +++ b/libraries/chain/include/graphene/chain/transaction_history_object.hpp @@ -22,12 +22,9 @@ * THE SOFTWARE. */ #pragma once -#include #include -#include #include -#include #include #include @@ -74,4 +71,6 @@ namespace graphene { namespace chain { MAP_OBJECT_ID_TO_TYPE(graphene::chain::transaction_history_object) -FC_REFLECT_DERIVED( graphene::chain::transaction_history_object, (graphene::db::object), (trx)(trx_id) ) +FC_REFLECT_TYPENAME( graphene::chain::transaction_history_object ) + +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::transaction_history_object ) diff --git a/libraries/chain/include/graphene/chain/vesting_balance_object.hpp b/libraries/chain/include/graphene/chain/vesting_balance_object.hpp index 6365aca85f..2713c31bbc 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 #include @@ -33,16 +33,10 @@ #include #include -#include - - - namespace graphene { namespace chain { using namespace graphene::db; using namespace graphene::protocol; - class vesting_balance_object; - struct vesting_policy_context { vesting_policy_context( @@ -308,3 +302,6 @@ FC_REFLECT_DERIVED(graphene::chain::vesting_balance_object, (graphene::db::objec FC_REFLECT_ENUM( graphene::chain::vesting_balance_type, (unspecified)(cashback)(worker)(witness)(market_fee_sharing) ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::linear_vesting_policy ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::cdd_vesting_policy ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::vesting_balance_object ) diff --git a/libraries/chain/include/graphene/chain/withdraw_permission_object.hpp b/libraries/chain/include/graphene/chain/withdraw_permission_object.hpp index e035d99723..3763826eef 100644 --- a/libraries/chain/include/graphene/chain/withdraw_permission_object.hpp +++ b/libraries/chain/include/graphene/chain/withdraw_permission_object.hpp @@ -22,12 +22,15 @@ * THE SOFTWARE. */ #pragma once -#include + +#include #include -#include + #include namespace graphene { namespace chain { + using namespace graphene::protocol; + /** * @class withdraw_permission_object * @brief Grants another account authority to withdraw a limited amount of funds per interval @@ -116,12 +119,6 @@ namespace graphene { namespace 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) - (withdrawal_limit) - (withdrawal_period_sec) - (period_start_time) - (expiration) - (claimed_this_period) - ) +FC_REFLECT_TYPENAME( graphene::chain::withdraw_permission_object ) + +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::withdraw_permission_object ) diff --git a/libraries/chain/include/graphene/chain/witness_object.hpp b/libraries/chain/include/graphene/chain/witness_object.hpp index e0f73338ed..ee49f776e8 100644 --- a/libraries/chain/include/graphene/chain/witness_object.hpp +++ b/libraries/chain/include/graphene/chain/witness_object.hpp @@ -22,15 +22,13 @@ * THE SOFTWARE. */ #pragma once + #include -#include #include namespace graphene { namespace chain { using namespace graphene::db; - class witness_object; - class witness_object : public abstract_object { public: @@ -72,14 +70,6 @@ namespace graphene { namespace chain { MAP_OBJECT_ID_TO_TYPE(graphene::chain::witness_object) -FC_REFLECT_DERIVED( graphene::chain::witness_object, (graphene::db::object), - (witness_account) - (last_aslot) - (signing_key) - (pay_vb) - (vote_id) - (total_votes) - (url) - (total_missed) - (last_confirmed_block_num) - ) +FC_REFLECT_TYPENAME( graphene::chain::witness_object ) + +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::witness_object ) diff --git a/libraries/chain/include/graphene/chain/witness_schedule_object.hpp b/libraries/chain/include/graphene/chain/witness_schedule_object.hpp index 0de263d1fd..b7f0ec86db 100644 --- a/libraries/chain/include/graphene/chain/witness_schedule_object.hpp +++ b/libraries/chain/include/graphene/chain/witness_schedule_object.hpp @@ -23,13 +23,10 @@ */ #pragma once #include -#include #include namespace graphene { namespace chain { -class witness_schedule_object; - class witness_schedule_object : public graphene::db::abstract_object { public: @@ -43,8 +40,6 @@ class witness_schedule_object : public graphene::db::abstract_object +#include #include #include -#include namespace graphene { namespace chain { class database; @@ -162,20 +161,10 @@ using worker_index = generic_index +#include + using namespace graphene::chain; /* @@ -300,3 +302,24 @@ share_type call_order_object::get_max_debt_to_cover( price match_price, } } FC_CAPTURE_AND_RETHROW( (*this)(feed_price)(match_price)(maintenance_collateral_ratio) ) } + +FC_REFLECT_DERIVED_NO_TYPENAME( graphene::chain::limit_order_object, + (graphene::db::object), + (expiration)(seller)(for_sale)(sell_price)(deferred_fee)(deferred_paid_fee) + ) + +FC_REFLECT_DERIVED_NO_TYPENAME( graphene::chain::call_order_object, (graphene::db::object), + (borrower)(collateral)(debt)(call_price)(target_collateral_ratio) ) + +FC_REFLECT_DERIVED_NO_TYPENAME( graphene::chain::force_settlement_object, + (graphene::db::object), + (owner)(balance)(settlement_date) + ) + +FC_REFLECT_DERIVED_NO_TYPENAME( graphene::chain::collateral_bid_object, (graphene::db::object), + (bidder)(inv_swan_price) ) + +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::limit_order_object ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::call_order_object ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::force_settlement_object ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::collateral_bid_object ) diff --git a/libraries/chain/proposal_object.cpp b/libraries/chain/proposal_object.cpp index 1293452ee7..14a738cd13 100644 --- a/libraries/chain/proposal_object.cpp +++ b/libraries/chain/proposal_object.cpp @@ -23,6 +23,7 @@ */ #include #include +#include #include namespace graphene { namespace chain { @@ -39,7 +40,7 @@ bool proposal_object::is_authorized_to_execute(database& db) const [&]( account_id_type id ){ return &id(db).owner; }, allow_non_immediate_owner, db.get_global_properties().parameters.max_authority_depth, - true, /* allow committeee */ + true, /* allow committee */ available_active_approvals, available_owner_approvals ); } @@ -132,3 +133,10 @@ void required_approval_index::object_modified( const object& after ) } } } // graphene::chain + +FC_REFLECT_DERIVED_NO_TYPENAME( 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) + (available_key_approvals)(proposer)(fail_reason) ) + +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::proposal_object ) diff --git a/libraries/chain/small_objects.cpp b/libraries/chain/small_objects.cpp new file mode 100644 index 0000000000..e7a018b55d --- /dev/null +++ b/libraries/chain/small_objects.cpp @@ -0,0 +1,212 @@ +/* + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +FC_REFLECT_DERIVED_NO_TYPENAME( graphene::chain::balance_object, (graphene::db::object), + (owner)(balance)(vesting_policy)(last_claim_date) ) + +FC_REFLECT_DERIVED_NO_TYPENAME( graphene::chain::block_summary_object, (graphene::db::object), (block_id) ) + +FC_REFLECT_DERIVED_NO_TYPENAME( + graphene::chain::budget_record, BOOST_PP_SEQ_NIL, + (time_since_last_budget) + (from_initial_reserve) + (from_accumulated_fees) + (from_unused_witness_budget) + (requested_witness_budget) + (total_budget) + (witness_budget) + (worker_budget) + (leftover_worker_funds) + (supply_delta) +) + +FC_REFLECT_DERIVED_NO_TYPENAME( + graphene::chain::budget_record_object, + (graphene::db::object), + (time) + (record) +) + +FC_REFLECT_DERIVED_NO_TYPENAME( graphene::chain::buyback_object, (graphene::db::object), (asset_to_buy) ) + + +FC_REFLECT_DERIVED_NO_TYPENAME( graphene::chain::immutable_chain_parameters, BOOST_PP_SEQ_NIL, + (min_committee_member_count) + (min_witness_count) + (num_special_accounts) + (num_special_assets) +) + +FC_REFLECT_DERIVED_NO_TYPENAME( graphene::chain::chain_property_object, (graphene::db::object), + (chain_id) + (immutable_parameters) + ) + +FC_REFLECT_DERIVED_NO_TYPENAME( graphene::chain::committee_member_object, (graphene::db::object), + (committee_member_account)(vote_id)(total_votes)(url) ) + +FC_REFLECT_DERIVED_NO_TYPENAME( graphene::chain::blinded_balance_object, (graphene::db::object), + (commitment)(asset_id)(owner) ) + +FC_REFLECT_DERIVED_NO_TYPENAME( graphene::chain::fba_accumulator_object, (graphene::db::object), + (accumulated_fba_fees)(designated_asset) ) + +FC_REFLECT_DERIVED_NO_TYPENAME( graphene::chain::dynamic_global_property_object, (graphene::db::object), + (head_block_number) + (head_block_id) + (time) + (current_witness) + (next_maintenance_time) + (last_budget_time) + (witness_budget) + (accounts_registered_this_interval) + (recently_missed_count) + (current_aslot) + (recent_slots_filled) + (dynamic_flags) + (last_irreversible_block_num) + ) + +FC_REFLECT_DERIVED_NO_TYPENAME( graphene::chain::global_property_object, (graphene::db::object), + (parameters) + (pending_parameters) + (next_available_vote_id) + (active_committee_members) + (active_witnesses) + ) + +FC_REFLECT( graphene::chain::htlc_object::transfer_info, + (from) (to) (amount) (asset_id) ) +FC_REFLECT_DERIVED_NO_TYPENAME( graphene::chain::htlc_object::condition_info::hash_lock_info, BOOST_PP_SEQ_NIL, + (preimage_hash) (preimage_size) ) +FC_REFLECT_DERIVED_NO_TYPENAME( graphene::chain::htlc_object::condition_info::time_lock_info, BOOST_PP_SEQ_NIL, + (expiration) ) +FC_REFLECT_DERIVED_NO_TYPENAME( graphene::chain::htlc_object::condition_info, BOOST_PP_SEQ_NIL, + (hash_lock)(time_lock) ) +FC_REFLECT_DERIVED_NO_TYPENAME( graphene::chain::htlc_object, (graphene::db::object), + (transfer) (conditions) ) + +FC_REFLECT_DERIVED_NO_TYPENAME( graphene::chain::operation_history_object, (graphene::chain::object), + (op)(result)(block_num)(trx_in_block)(op_in_trx)(virtual_op) ) + +FC_REFLECT_DERIVED_NO_TYPENAME( graphene::chain::account_transaction_history_object, (graphene::chain::object), + (account)(operation_id)(sequence)(next) ) + +FC_REFLECT_DERIVED_NO_TYPENAME( + graphene::chain::special_authority_object, + (graphene::db::object), + (account) +) + +FC_REFLECT_DERIVED_NO_TYPENAME( graphene::chain::transaction_history_object, (graphene::db::object), (trx)(trx_id) ) + +FC_REFLECT_DERIVED_NO_TYPENAME( graphene::chain::withdraw_permission_object, (graphene::db::object), + (withdraw_from_account) + (authorized_account) + (withdrawal_limit) + (withdrawal_period_sec) + (period_start_time) + (expiration) + (claimed_this_period) + ) + +FC_REFLECT_DERIVED_NO_TYPENAME( graphene::chain::witness_object, (graphene::db::object), + (witness_account) + (last_aslot) + (signing_key) + (pay_vb) + (vote_id) + (total_votes) + (url) + (total_missed) + (last_confirmed_block_num) + ) + +FC_REFLECT_DERIVED_NO_TYPENAME( + graphene::chain::witness_schedule_object, + (graphene::db::object), + (current_shuffled_witnesses) +) + + +FC_REFLECT_DERIVED_NO_TYPENAME( graphene::chain::refund_worker_type, BOOST_PP_SEQ_NIL, (total_burned) ) +FC_REFLECT_DERIVED_NO_TYPENAME( graphene::chain::vesting_balance_worker_type, BOOST_PP_SEQ_NIL, (balance) ) +FC_REFLECT_DERIVED_NO_TYPENAME( graphene::chain::burn_worker_type, BOOST_PP_SEQ_NIL, (total_burned) ) +FC_REFLECT_DERIVED_NO_TYPENAME( graphene::chain::worker_object, (graphene::db::object), + (worker_account) + (work_begin_date) + (work_end_date) + (daily_pay) + (worker) + (vote_for) + (vote_against) + (total_votes_for) + (total_votes_against) + (name) + (url) + ) + +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 ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::budget_record_object ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::buyback_object ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::immutable_chain_parameters ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::chain_property_object ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::committee_member_object ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::blinded_balance_object ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::fba_accumulator_object ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::dynamic_global_property_object ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::global_property_object ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::htlc_object ) +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_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_schedule_object ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::worker_object ) diff --git a/libraries/chain/vesting_balance_object.cpp b/libraries/chain/vesting_balance_object.cpp index 8735a674f5..7a7acf9728 100644 --- a/libraries/chain/vesting_balance_object.cpp +++ b/libraries/chain/vesting_balance_object.cpp @@ -24,6 +24,8 @@ #include +#include + namespace graphene { namespace chain { inline bool sum_below_max_shares(const asset& a, const asset& b) @@ -268,3 +270,7 @@ asset vesting_balance_object::get_allowed_withdraw(const time_point_sec& now)con } } } // graphene::chain + +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::linear_vesting_policy ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::cdd_vesting_policy ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::vesting_balance_object ) From 1a61e43a56506a9405e424ae7c22955152e1b2e3 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Tue, 14 May 2019 11:10:21 +0200 Subject: [PATCH 077/133] Externalized genesis serialization --- libraries/chain/genesis_state.cpp | 43 +++++++++++++++++- .../include/graphene/chain/genesis_state.hpp | 45 ++++++++----------- 2 files changed, 60 insertions(+), 28 deletions(-) diff --git a/libraries/chain/genesis_state.cpp b/libraries/chain/genesis_state.cpp index 9d067a62c5..33c15cbb2c 100644 --- a/libraries/chain/genesis_state.cpp +++ b/libraries/chain/genesis_state.cpp @@ -23,8 +23,6 @@ */ #include - -// this is required to serialize a genesis_state #include namespace graphene { namespace chain { @@ -35,3 +33,44 @@ chain_id_type genesis_state_type::compute_chain_id() const } } } // graphene::chain + +FC_REFLECT_DERIVED_NO_TYPENAME(graphene::chain::genesis_state_type::initial_account_type, BOOST_PP_SEQ_NIL, + (name)(owner_key)(active_key)(is_lifetime_member) ) + +FC_REFLECT_DERIVED_NO_TYPENAME(graphene::chain::genesis_state_type::initial_asset_type, BOOST_PP_SEQ_NIL, + (symbol)(issuer_name)(description)(precision)(max_supply)(accumulated_fees)(is_bitasset) + (collateral_records)) + +FC_REFLECT_DERIVED_NO_TYPENAME(graphene::chain::genesis_state_type::initial_asset_type::initial_collateral_position, + BOOST_PP_SEQ_NIL, (owner)(collateral)(debt)) + +FC_REFLECT_DERIVED_NO_TYPENAME(graphene::chain::genesis_state_type::initial_balance_type, BOOST_PP_SEQ_NIL, + (owner)(asset_symbol)(amount)) + +FC_REFLECT_DERIVED_NO_TYPENAME(graphene::chain::genesis_state_type::initial_vesting_balance_type, BOOST_PP_SEQ_NIL, + (owner)(asset_symbol)(amount)(begin_timestamp)(vesting_duration_seconds)(begin_balance)) + +FC_REFLECT_DERIVED_NO_TYPENAME(graphene::chain::genesis_state_type::initial_witness_type, BOOST_PP_SEQ_NIL, + (owner_name)(block_signing_key)) + +FC_REFLECT_DERIVED_NO_TYPENAME(graphene::chain::genesis_state_type::initial_committee_member_type, BOOST_PP_SEQ_NIL, + (owner_name)) + +FC_REFLECT_DERIVED_NO_TYPENAME(graphene::chain::genesis_state_type::initial_worker_type, BOOST_PP_SEQ_NIL, + (owner_name)(daily_pay)) + +FC_REFLECT_DERIVED_NO_TYPENAME(graphene::chain::genesis_state_type, BOOST_PP_SEQ_NIL, + (initial_timestamp)(max_core_supply)(initial_parameters)(initial_accounts)(initial_assets) + (initial_balances)(initial_vesting_balances)(initial_active_witnesses)(initial_witness_candidates) + (initial_committee_candidates)(initial_worker_candidates) + (immutable_parameters)) + +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::genesis_state_type::initial_account_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::genesis_state_type::initial_asset_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::genesis_state_type::initial_asset_type::initial_collateral_position ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::genesis_state_type::initial_balance_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::genesis_state_type::initial_vesting_balance_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::genesis_state_type::initial_witness_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::genesis_state_type::initial_committee_member_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::genesis_state_type::initial_worker_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::genesis_state_type ) diff --git a/libraries/chain/include/graphene/chain/genesis_state.hpp b/libraries/chain/include/graphene/chain/genesis_state.hpp index 48f2690224..b50b81d908 100644 --- a/libraries/chain/include/graphene/chain/genesis_state.hpp +++ b/libraries/chain/include/graphene/chain/genesis_state.hpp @@ -127,29 +127,22 @@ struct genesis_state_type { } } // namespace graphene::chain -FC_REFLECT(graphene::chain::genesis_state_type::initial_account_type, (name)(owner_key)(active_key)(is_lifetime_member)) - -FC_REFLECT(graphene::chain::genesis_state_type::initial_asset_type, - (symbol)(issuer_name)(description)(precision)(max_supply)(accumulated_fees)(is_bitasset)(collateral_records)) - -FC_REFLECT(graphene::chain::genesis_state_type::initial_asset_type::initial_collateral_position, - (owner)(collateral)(debt)) - -FC_REFLECT(graphene::chain::genesis_state_type::initial_balance_type, - (owner)(asset_symbol)(amount)) - -FC_REFLECT(graphene::chain::genesis_state_type::initial_vesting_balance_type, - (owner)(asset_symbol)(amount)(begin_timestamp)(vesting_duration_seconds)(begin_balance)) - -FC_REFLECT(graphene::chain::genesis_state_type::initial_witness_type, (owner_name)(block_signing_key)) - -FC_REFLECT(graphene::chain::genesis_state_type::initial_committee_member_type, (owner_name)) - -FC_REFLECT(graphene::chain::genesis_state_type::initial_worker_type, (owner_name)(daily_pay)) - -FC_REFLECT(graphene::chain::genesis_state_type, - (initial_timestamp)(max_core_supply)(initial_parameters)(initial_accounts)(initial_assets)(initial_balances) - (initial_vesting_balances)(initial_active_witnesses)(initial_witness_candidates) - (initial_committee_candidates)(initial_worker_candidates) - (initial_chain_id) - (immutable_parameters)) +FC_REFLECT_TYPENAME( graphene::chain::genesis_state_type::initial_account_type ) +FC_REFLECT_TYPENAME( graphene::chain::genesis_state_type::initial_asset_type ) +FC_REFLECT_TYPENAME( graphene::chain::genesis_state_type::initial_asset_type::initial_collateral_position ) +FC_REFLECT_TYPENAME( graphene::chain::genesis_state_type::initial_balance_type ) +FC_REFLECT_TYPENAME( graphene::chain::genesis_state_type::initial_vesting_balance_type ) +FC_REFLECT_TYPENAME( graphene::chain::genesis_state_type::initial_witness_type ) +FC_REFLECT_TYPENAME( graphene::chain::genesis_state_type::initial_committee_member_type ) +FC_REFLECT_TYPENAME( graphene::chain::genesis_state_type::initial_worker_type ) +FC_REFLECT_TYPENAME( graphene::chain::genesis_state_type ) + +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::genesis_state_type::initial_account_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::genesis_state_type::initial_asset_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::genesis_state_type::initial_asset_type::initial_collateral_position ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::genesis_state_type::initial_balance_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::genesis_state_type::initial_vesting_balance_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::genesis_state_type::initial_witness_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::genesis_state_type::initial_committee_member_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::genesis_state_type::initial_worker_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::genesis_state_type ) From ccd2b3cdca922c9a408a0eb397e7df303b67f3e2 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Sun, 19 May 2019 11:38:40 +0200 Subject: [PATCH 078/133] Externalized serialization in protocol library --- libraries/app/database_api.cpp | 2 + libraries/chain/balance_evaluator.cpp | 1 + .../include/graphene/chain/genesis_state.hpp | 1 + libraries/protocol/CMakeLists.txt | 1 + libraries/protocol/account.cpp | 12 ++++++ libraries/protocol/address.cpp | 8 ++-- libraries/protocol/assert.cpp | 10 ++++- libraries/protocol/asset.cpp | 6 +++ libraries/protocol/asset_ops.cpp | 31 +++++++++++++++ libraries/protocol/authority.cpp | 4 ++ libraries/protocol/chain_parameters.cpp | 4 ++ libraries/protocol/committee_member.cpp | 10 +++++ libraries/protocol/confidential.cpp | 13 ++++--- libraries/protocol/custom.cpp | 3 ++ libraries/protocol/fee_schedule.cpp | 4 ++ libraries/protocol/htlc.cpp | 11 ++++++ .../include/graphene/protocol/account.hpp | 17 +++++++- .../include/graphene/protocol/address.hpp | 18 +++------ .../include/graphene/protocol/assert.hpp | 4 ++ .../include/graphene/protocol/asset.hpp | 5 ++- .../include/graphene/protocol/asset_ops.hpp | 32 +++++++++++++++ .../include/graphene/protocol/authority.hpp | 3 ++ .../include/graphene/protocol/balance.hpp | 4 ++ .../include/graphene/protocol/base.hpp | 5 ++- .../include/graphene/protocol/buyback.hpp | 2 + .../graphene/protocol/chain_parameters.hpp | 11 +++--- .../graphene/protocol/committee_member.hpp | 10 ++++- .../graphene/protocol/confidential.hpp | 9 +++++ .../include/graphene/protocol/custom.hpp | 4 ++ .../include/graphene/protocol/ext.hpp | 1 + .../include/graphene/protocol/fba.hpp | 3 ++ .../graphene/protocol/fee_schedule.hpp | 2 + .../include/graphene/protocol/htlc.hpp | 17 +++++--- .../include/graphene/protocol/market.hpp | 14 ++++++- .../include/graphene/protocol/memo.hpp | 3 ++ .../include/graphene/protocol/operations.hpp | 2 + .../include/graphene/protocol/proposal.hpp | 8 ++++ .../include/graphene/protocol/pts_address.hpp | 12 +++++- .../graphene/protocol/special_authority.hpp | 3 +- .../include/graphene/protocol/transaction.hpp | 3 -- .../include/graphene/protocol/transfer.hpp | 6 +++ .../include/graphene/protocol/types.hpp | 31 ++++++++++----- .../include/graphene/protocol/vesting.hpp | 6 +++ .../include/graphene/protocol/vote.hpp | 9 ++--- .../graphene/protocol/withdraw_permission.hpp | 10 +++++ .../include/graphene/protocol/witness.hpp | 6 +++ .../include/graphene/protocol/worker.hpp | 3 ++ libraries/protocol/market.cpp | 14 +++++++ libraries/protocol/memo.cpp | 4 ++ libraries/protocol/operations.cpp | 4 ++ libraries/protocol/proposal.cpp | 7 ++++ libraries/protocol/pts_address.cpp | 11 +++++- libraries/protocol/small_ops.cpp | 39 +++++++++++++++++++ libraries/protocol/special_authority.cpp | 4 ++ libraries/protocol/transaction.cpp | 6 ++- libraries/protocol/transfer.cpp | 5 +++ libraries/protocol/types.cpp | 11 +++++- libraries/protocol/vote.cpp | 4 +- libraries/protocol/withdraw_permission.cpp | 9 ++++- libraries/protocol/witness.cpp | 7 ++++ libraries/protocol/worker.cpp | 5 +++ libraries/wallet/wallet.cpp | 1 + 62 files changed, 445 insertions(+), 70 deletions(-) create mode 100644 libraries/protocol/small_ops.cpp diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 839bb82aff..113fb0453b 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -26,6 +26,8 @@ #include #include #include +#include +#include #include #include diff --git a/libraries/chain/balance_evaluator.cpp b/libraries/chain/balance_evaluator.cpp index 8c0a48c95c..7c8b8b3ff1 100644 --- a/libraries/chain/balance_evaluator.cpp +++ b/libraries/chain/balance_evaluator.cpp @@ -22,6 +22,7 @@ * THE SOFTWARE. */ #include +#include namespace graphene { namespace chain { diff --git a/libraries/chain/include/graphene/chain/genesis_state.hpp b/libraries/chain/include/graphene/chain/genesis_state.hpp index b50b81d908..98f9c0de16 100644 --- a/libraries/chain/include/graphene/chain/genesis_state.hpp +++ b/libraries/chain/include/graphene/chain/genesis_state.hpp @@ -23,6 +23,7 @@ */ #pragma once +#include #include #include #include diff --git a/libraries/protocol/CMakeLists.txt b/libraries/protocol/CMakeLists.txt index e1be1fb6d8..11a3b66016 100644 --- a/libraries/protocol/CMakeLists.txt +++ b/libraries/protocol/CMakeLists.txt @@ -21,6 +21,7 @@ list(APPEND SOURCES account.cpp market.cpp operations.cpp pts_address.cpp + small_ops.cpp transaction.cpp types.cpp withdraw_permission.cpp diff --git a/libraries/protocol/account.cpp b/libraries/protocol/account.cpp index 99341da1e6..c1e07cd194 100644 --- a/libraries/protocol/account.cpp +++ b/libraries/protocol/account.cpp @@ -278,3 +278,15 @@ void account_transfer_operation::validate()const } } // graphene::protocol + +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/protocol/address.cpp b/libraries/protocol/address.cpp index 1662d50ec2..4647416677 100644 --- a/libraries/protocol/address.cpp +++ b/libraries/protocol/address.cpp @@ -21,14 +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 + namespace graphene { namespace protocol { - address::address(){} address::address( const std::string& base58str ) { @@ -109,3 +109,5 @@ namespace fc vo = graphene::protocol::address( var.as_string() ); } } + +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::address ) diff --git a/libraries/protocol/assert.cpp b/libraries/protocol/assert.cpp index f652b20a7f..2d5454e0b9 100644 --- a/libraries/protocol/assert.cpp +++ b/libraries/protocol/assert.cpp @@ -21,7 +21,11 @@ * 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 protocol { @@ -62,5 +66,7 @@ share_type assert_operation::calculate_fee(const fee_parameters_type& k)const return k.fee * predicates.size(); } - } } // namespace graphene::protocol + +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/protocol/asset.cpp b/libraries/protocol/asset.cpp index 2800cd2a1e..898a8966f5 100644 --- a/libraries/protocol/asset.cpp +++ b/libraries/protocol/asset.cpp @@ -25,6 +25,8 @@ #include #include +#include + namespace graphene { namespace protocol { typedef boost::multiprecision::uint128_t uint128_t; typedef boost::multiprecision::int128_t int128_t; @@ -315,3 +317,7 @@ const int64_t scaled_precision_lut[19] = }; } } // graphene::protocol + +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/protocol/asset_ops.cpp b/libraries/protocol/asset_ops.cpp index b4b35a03a3..3100db2f71 100644 --- a/libraries/protocol/asset_ops.cpp +++ b/libraries/protocol/asset_ops.cpp @@ -255,3 +255,34 @@ void asset_claim_pool_operation::validate()const { } } } // 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::additional_asset_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_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_issuer_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_pool_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_claim_fees_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_update_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_update_issuer_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/protocol/authority.cpp b/libraries/protocol/authority.cpp index a5a3541791..c3fd44dd3b 100644 --- a/libraries/protocol/authority.cpp +++ b/libraries/protocol/authority.cpp @@ -24,6 +24,8 @@ #include +#include + namespace graphene { namespace protocol { void add_authority_accounts( @@ -36,3 +38,5 @@ void add_authority_accounts( } } } // graphene::protocol + +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::authority ) diff --git a/libraries/protocol/chain_parameters.cpp b/libraries/protocol/chain_parameters.cpp index e53d1d9ef5..319d00f2c5 100644 --- a/libraries/protocol/chain_parameters.cpp +++ b/libraries/protocol/chain_parameters.cpp @@ -1,6 +1,8 @@ #include #include +#include + namespace graphene { namespace protocol { chain_parameters::chain_parameters() { current_fees = std::make_shared(); @@ -77,3 +79,5 @@ namespace graphene { namespace protocol { } }} + +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::chain_parameters ) diff --git a/libraries/protocol/committee_member.cpp b/libraries/protocol/committee_member.cpp index ea1fc98d36..3972a44a1a 100644 --- a/libraries/protocol/committee_member.cpp +++ b/libraries/protocol/committee_member.cpp @@ -22,6 +22,9 @@ * THE SOFTWARE. */ #include +#include + +#include namespace graphene { namespace protocol { @@ -45,3 +48,10 @@ void committee_member_update_global_parameters_operation::validate() const } } } // graphene::protocol + +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/protocol/confidential.cpp b/libraries/protocol/confidential.cpp index 0689a3ca14..ce81b43b16 100644 --- a/libraries/protocol/confidential.cpp +++ b/libraries/protocol/confidential.cpp @@ -26,7 +26,6 @@ #include #include -#include namespace graphene { namespace protocol { @@ -140,9 +139,6 @@ share_type blind_transfer_operation::calculate_fee( const fee_parameters_type& k return k.fee + outputs.size() * k.price_per_output; } - - - /** * Packs *this then encodes as base58 encoded string. */ @@ -158,6 +154,11 @@ stealth_confirmation::stealth_confirmation( const std::string& base58 ) *this = fc::raw::unpack( fc::from_base58( base58 ) ); } - - } } // graphene::protocol + +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/protocol/custom.cpp b/libraries/protocol/custom.cpp index b2e34a8323..e3981a7fc1 100644 --- a/libraries/protocol/custom.cpp +++ b/libraries/protocol/custom.cpp @@ -37,3 +37,6 @@ share_type custom_operation::calculate_fee(const fee_parameters_type& k)const } } } + +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/protocol/fee_schedule.cpp b/libraries/protocol/fee_schedule.cpp index f0acea9782..fd7f429119 100644 --- a/libraries/protocol/fee_schedule.cpp +++ b/libraries/protocol/fee_schedule.cpp @@ -24,6 +24,8 @@ #include #include +#include + #define MAX_FEE_STABILIZATION_ITERATION 4 namespace graphene { namespace protocol { @@ -182,3 +184,5 @@ namespace graphene { namespace protocol { } } } // graphene::protocol + +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::fee_schedule ) diff --git a/libraries/protocol/htlc.cpp b/libraries/protocol/htlc.cpp index a8d5eeed8c..4f332c8593 100644 --- a/libraries/protocol/htlc.cpp +++ b/libraries/protocol/htlc.cpp @@ -23,6 +23,8 @@ */ #include +#include + #define SECONDS_PER_DAY (60 * 60 * 24) namespace graphene { namespace protocol { @@ -65,3 +67,12 @@ namespace graphene { namespace protocol { return fee_params.fee + per_day_fee; } } } + +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::htlc_create_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::htlc_redeem_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::htlc_extend_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::htlc_create_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::htlc_redeem_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::htlc_redeemed_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::htlc_extend_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::htlc_refund_operation ) diff --git a/libraries/protocol/include/graphene/protocol/account.hpp b/libraries/protocol/include/graphene/protocol/account.hpp index 158a997a57..0b6d3af114 100644 --- a/libraries/protocol/include/graphene/protocol/account.hpp +++ b/libraries/protocol/include/graphene/protocol/account.hpp @@ -22,11 +22,12 @@ * THE SOFTWARE. */ #pragma once + #include +#include +#include #include -#include #include -#include #include namespace graphene { namespace protocol { @@ -299,3 +300,15 @@ FC_REFLECT( graphene::protocol::account_upgrade_operation::fee_parameters_type, 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/protocol/include/graphene/protocol/address.hpp b/libraries/protocol/include/graphene/protocol/address.hpp index e6a1054892..5a473a0851 100644 --- a/libraries/protocol/include/graphene/protocol/address.hpp +++ b/libraries/protocol/include/graphene/protocol/address.hpp @@ -23,20 +23,13 @@ */ #pragma once -#include -#include +#include -#include #include - -namespace fc { namespace ecc { - class public_key; - typedef fc::array public_key_data; -} } // fc::ecc +#include namespace graphene { namespace protocol { - - struct public_key_type; + struct pts_address; /** * @brief a 160 bit hash of a public key @@ -51,7 +44,7 @@ namespace graphene { namespace protocol { class address { public: - address(); ///< constructs empty / null address + address(){} ///< constructs empty / null address explicit address( const std::string& base58str ); ///< converts to binary, validates checksum address( const fc::ecc::public_key& pub ); ///< converts to binary explicit address( const fc::ecc::public_key_data& pub ); ///< converts to binary @@ -76,5 +69,6 @@ namespace fc void from_variant( const fc::variant& var, graphene::protocol::address& vo, uint32_t max_depth = 1 ); } -#include FC_REFLECT( graphene::protocol::address, (addr) ) + +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::address ) diff --git a/libraries/protocol/include/graphene/protocol/assert.hpp b/libraries/protocol/include/graphene/protocol/assert.hpp index 9b2362aac3..e12de03891 100644 --- a/libraries/protocol/include/graphene/protocol/assert.hpp +++ b/libraries/protocol/include/graphene/protocol/assert.hpp @@ -22,7 +22,9 @@ * THE SOFTWARE. */ #pragma once + #include +#include namespace graphene { namespace protocol { @@ -112,3 +114,5 @@ 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::protocol::assert_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::assert_operation ) diff --git a/libraries/protocol/include/graphene/protocol/asset.hpp b/libraries/protocol/include/graphene/protocol/asset.hpp index 8278692280..ee1483a88c 100644 --- a/libraries/protocol/include/graphene/protocol/asset.hpp +++ b/libraries/protocol/include/graphene/protocol/asset.hpp @@ -22,7 +22,6 @@ * THE SOFTWARE. */ #pragma once -#include #include namespace graphene { namespace protocol { @@ -228,3 +227,7 @@ FC_REFLECT( graphene::protocol::price, (base)(quote) ) (core_exchange_rate) FC_REFLECT( graphene::protocol::price_feed, GRAPHENE_PRICE_FEED_FIELDS ) + +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/protocol/include/graphene/protocol/asset_ops.hpp b/libraries/protocol/include/graphene/protocol/asset_ops.hpp index 9687ffb1a4..8c22e82137 100644 --- a/libraries/protocol/include/graphene/protocol/asset_ops.hpp +++ b/libraries/protocol/include/graphene/protocol/asset_ops.hpp @@ -23,6 +23,7 @@ */ #pragma once #include +#include #include namespace graphene { namespace protocol { @@ -603,3 +604,34 @@ FC_REFLECT( graphene::protocol::asset_reserve_operation, (fee)(payer)(amount_to_reserve)(extensions) ) FC_REFLECT( graphene::protocol::asset_fund_fee_pool_operation, (fee)(from_account)(asset_id)(amount)(extensions) ); + +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_options ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::bitasset_options ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::additional_asset_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_claim_pool_operation::fee_parameters_type ) +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_issuer_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_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_issuer_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/protocol/include/graphene/protocol/authority.hpp b/libraries/protocol/include/graphene/protocol/authority.hpp index fa150b1606..e3fb741eb2 100644 --- a/libraries/protocol/include/graphene/protocol/authority.hpp +++ b/libraries/protocol/include/graphene/protocol/authority.hpp @@ -23,6 +23,7 @@ */ #pragma once #include +#include namespace graphene { namespace protocol { @@ -133,3 +134,5 @@ void add_authority_accounts( 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::protocol::authority ) diff --git a/libraries/protocol/include/graphene/protocol/balance.hpp b/libraries/protocol/include/graphene/protocol/balance.hpp index 495c5a8d0e..1ab1453a49 100644 --- a/libraries/protocol/include/graphene/protocol/balance.hpp +++ b/libraries/protocol/include/graphene/protocol/balance.hpp @@ -23,6 +23,8 @@ */ #pragma once #include +#include +#include namespace graphene { namespace protocol { @@ -57,3 +59,5 @@ namespace graphene { namespace protocol { 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::protocol::balance_claim_operation ) diff --git a/libraries/protocol/include/graphene/protocol/base.hpp b/libraries/protocol/include/graphene/protocol/base.hpp index 2b55685dee..fbdf39fb06 100644 --- a/libraries/protocol/include/graphene/protocol/base.hpp +++ b/libraries/protocol/include/graphene/protocol/base.hpp @@ -23,13 +23,14 @@ */ #pragma once +#include #include -#include -#include #include namespace graphene { namespace protocol { + struct asset; + struct authority; /** * @defgroup operations Operations diff --git a/libraries/protocol/include/graphene/protocol/buyback.hpp b/libraries/protocol/include/graphene/protocol/buyback.hpp index 3661cbd41c..9f58beca9b 100644 --- a/libraries/protocol/include/graphene/protocol/buyback.hpp +++ b/libraries/protocol/include/graphene/protocol/buyback.hpp @@ -50,3 +50,5 @@ struct buyback_account_options } } FC_REFLECT( graphene::protocol::buyback_account_options, (asset_to_buy)(asset_to_buy_issuer)(markets) ); + +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::buyback_account_options ) diff --git a/libraries/protocol/include/graphene/protocol/chain_parameters.hpp b/libraries/protocol/include/graphene/protocol/chain_parameters.hpp index d19431715f..4bdb871a08 100644 --- a/libraries/protocol/include/graphene/protocol/chain_parameters.hpp +++ b/libraries/protocol/include/graphene/protocol/chain_parameters.hpp @@ -25,7 +25,6 @@ #include #include -#include namespace graphene { namespace protocol { struct fee_schedule; @@ -94,12 +93,12 @@ namespace graphene { namespace protocol { } } // graphene::protocol -FC_REFLECT( graphene::protocol::htlc_options, - (max_timeout_secs) - (max_preimage_size) +FC_REFLECT( graphene::protocol::htlc_options, + (max_timeout_secs) + (max_preimage_size) ) -FC_REFLECT( graphene::protocol::chain_parameters::ext, +FC_REFLECT( graphene::protocol::chain_parameters::ext, (updatable_htlc_options) ) @@ -134,3 +133,5 @@ FC_REFLECT( graphene::protocol::chain_parameters, (max_authority_depth) (extensions) ) + +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::chain_parameters ) diff --git a/libraries/protocol/include/graphene/protocol/committee_member.hpp b/libraries/protocol/include/graphene/protocol/committee_member.hpp index 71bcf2ff80..5e63e96322 100644 --- a/libraries/protocol/include/graphene/protocol/committee_member.hpp +++ b/libraries/protocol/include/graphene/protocol/committee_member.hpp @@ -23,6 +23,7 @@ */ #pragma once #include +#include #include namespace graphene { namespace protocol { @@ -94,13 +95,20 @@ namespace graphene { namespace protocol { /// TODO: committee_member_resign_operation : public base_operation } } // 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::protocol::committee_member_create_operation, (fee)(committee_member_account)(url) ) FC_REFLECT( graphene::protocol::committee_member_update_operation, (fee)(committee_member)(committee_member_account)(new_url) ) FC_REFLECT( graphene::protocol::committee_member_update_global_parameters_operation, (fee)(new_parameters) ); + +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/protocol/include/graphene/protocol/confidential.hpp b/libraries/protocol/include/graphene/protocol/confidential.hpp index ba3f4077ca..fbb0a5b207 100644 --- a/libraries/protocol/include/graphene/protocol/confidential.hpp +++ b/libraries/protocol/include/graphene/protocol/confidential.hpp @@ -24,6 +24,8 @@ #pragma once #include +#include +#include namespace graphene { namespace protocol { @@ -281,3 +283,10 @@ FC_REFLECT( graphene::protocol::blind_transfer_operation, 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::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/custom.hpp b/libraries/protocol/include/graphene/protocol/custom.hpp index d3d25f6a36..2fc63f59f7 100644 --- a/libraries/protocol/include/graphene/protocol/custom.hpp +++ b/libraries/protocol/include/graphene/protocol/custom.hpp @@ -24,6 +24,7 @@ #pragma once #include +#include namespace graphene { namespace protocol { @@ -56,3 +57,6 @@ namespace graphene { namespace protocol { 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::protocol::custom_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::custom_operation ) diff --git a/libraries/protocol/include/graphene/protocol/ext.hpp b/libraries/protocol/include/graphene/protocol/ext.hpp index b5b187d145..5dccf9fe9b 100644 --- a/libraries/protocol/include/graphene/protocol/ext.hpp +++ b/libraries/protocol/include/graphene/protocol/ext.hpp @@ -24,6 +24,7 @@ #pragma once #include +#include #include #include diff --git a/libraries/protocol/include/graphene/protocol/fba.hpp b/libraries/protocol/include/graphene/protocol/fba.hpp index 7b95294049..22f2a7f51f 100644 --- a/libraries/protocol/include/graphene/protocol/fba.hpp +++ b/libraries/protocol/include/graphene/protocol/fba.hpp @@ -23,6 +23,7 @@ */ #pragma once #include +#include namespace graphene { namespace protocol { @@ -46,3 +47,5 @@ struct fba_distribute_operation : public base_operation FC_REFLECT( graphene::protocol::fba_distribute_operation::fee_parameters_type, ) FC_REFLECT( graphene::protocol::fba_distribute_operation, (fee)(account_id)(fba_id)(amount) ) + +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::fba_distribute_operation ) diff --git a/libraries/protocol/include/graphene/protocol/fee_schedule.hpp b/libraries/protocol/include/graphene/protocol/fee_schedule.hpp index 2a39bdf471..2502ecb477 100644 --- a/libraries/protocol/include/graphene/protocol/fee_schedule.hpp +++ b/libraries/protocol/include/graphene/protocol/fee_schedule.hpp @@ -211,3 +211,5 @@ namespace graphene { namespace protocol { FC_REFLECT_TYPENAME( graphene::protocol::fee_parameters ) FC_REFLECT( graphene::protocol::fee_schedule, (parameters)(scale) ) + +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::fee_schedule ) diff --git a/libraries/protocol/include/graphene/protocol/htlc.hpp b/libraries/protocol/include/graphene/protocol/htlc.hpp index c7b8d282ff..382912e9ab 100644 --- a/libraries/protocol/include/graphene/protocol/htlc.hpp +++ b/libraries/protocol/include/graphene/protocol/htlc.hpp @@ -23,13 +23,9 @@ */ #pragma once -#include -#include -#include #include -#include #include -#include +#include #include // std::max namespace graphene { namespace protocol { @@ -201,9 +197,18 @@ FC_REFLECT( graphene::protocol::htlc_redeemed_operation::fee_parameters_type, ) FC_REFLECT( graphene::protocol::htlc_extend_operation::fee_parameters_type, (fee) (fee_per_day)) FC_REFLECT( graphene::protocol::htlc_refund_operation::fee_parameters_type, ) // VIRTUAL -FC_REFLECT( graphene::protocol::htlc_create_operation, +FC_REFLECT( graphene::protocol::htlc_create_operation, (fee)(from)(to)(amount)(preimage_hash)(preimage_size)(claim_period_seconds)(extensions)) FC_REFLECT( graphene::protocol::htlc_redeem_operation, (fee)(htlc_id)(redeemer)(preimage)(extensions)) FC_REFLECT( graphene::protocol::htlc_redeemed_operation, (fee)(htlc_id)(from)(to)(redeemer)(amount) ) FC_REFLECT( graphene::protocol::htlc_extend_operation, (fee)(htlc_id)(update_issuer)(seconds_to_add)(extensions)) FC_REFLECT( graphene::protocol::htlc_refund_operation, (fee)(htlc_id)(to)) + +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::htlc_create_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::htlc_redeem_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::htlc_extend_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::htlc_create_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::htlc_redeem_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::htlc_redeemed_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::htlc_extend_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::htlc_refund_operation ) diff --git a/libraries/protocol/include/graphene/protocol/market.hpp b/libraries/protocol/include/graphene/protocol/market.hpp index 2a887498e7..0dc7cfad62 100644 --- a/libraries/protocol/include/graphene/protocol/market.hpp +++ b/libraries/protocol/include/graphene/protocol/market.hpp @@ -23,7 +23,7 @@ */ #pragma once #include -#include +#include namespace graphene { namespace protocol { @@ -232,3 +232,15 @@ FC_REFLECT( graphene::protocol::call_order_update_operation, (fee)(funding_accou FC_REFLECT( graphene::protocol::fill_order_operation, (fee)(order_id)(account_id)(pays)(receives)(fill_price)(is_maker) ) FC_REFLECT( graphene::protocol::bid_collateral_operation, (fee)(bidder)(additional_collateral)(debt_covered)(extensions) ) FC_REFLECT( graphene::protocol::execute_bid_operation, (fee)(bidder)(debt)(collateral) ) + +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::call_order_update_operation::options_type ) +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::bid_collateral_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::bid_collateral_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::fill_order_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::execute_bid_operation ) diff --git a/libraries/protocol/include/graphene/protocol/memo.hpp b/libraries/protocol/include/graphene/protocol/memo.hpp index 544b7447fd..d0ef211558 100644 --- a/libraries/protocol/include/graphene/protocol/memo.hpp +++ b/libraries/protocol/include/graphene/protocol/memo.hpp @@ -89,3 +89,6 @@ namespace graphene { namespace protocol { FC_REFLECT( graphene::protocol::memo_message, (checksum)(text) ) FC_REFLECT( graphene::protocol::memo_data, (from)(to)(nonce)(message) ) + +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::memo_message ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::memo_data ) diff --git a/libraries/protocol/include/graphene/protocol/operations.hpp b/libraries/protocol/include/graphene/protocol/operations.hpp index 7d4f9d0f5f..6c822399c0 100644 --- a/libraries/protocol/include/graphene/protocol/operations.hpp +++ b/libraries/protocol/include/graphene/protocol/operations.hpp @@ -133,3 +133,5 @@ namespace graphene { namespace protocol { FC_REFLECT_TYPENAME( graphene::protocol::operation ) FC_REFLECT( graphene::protocol::op_wrapper, (op) ) + +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::op_wrapper ) diff --git a/libraries/protocol/include/graphene/protocol/proposal.hpp b/libraries/protocol/include/graphene/protocol/proposal.hpp index 41be9afc30..43d3772263 100644 --- a/libraries/protocol/include/graphene/protocol/proposal.hpp +++ b/libraries/protocol/include/graphene/protocol/proposal.hpp @@ -23,6 +23,7 @@ */ #pragma once #include +#include namespace graphene { namespace protocol { /** @@ -179,3 +180,10 @@ FC_REFLECT( graphene::protocol::proposal_update_operation, (fee)(fee_paying_acco (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::protocol::proposal_delete_operation, (fee)(fee_paying_account)(using_owner_authority)(proposal)(extensions) ) + +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/protocol/include/graphene/protocol/pts_address.hpp b/libraries/protocol/include/graphene/protocol/pts_address.hpp index c9ea9febcc..7fce15c890 100644 --- a/libraries/protocol/include/graphene/protocol/pts_address.hpp +++ b/libraries/protocol/include/graphene/protocol/pts_address.hpp @@ -24,6 +24,8 @@ #pragma once #include +#include +#include #include namespace fc { namespace ecc { class public_key; } } @@ -75,4 +77,12 @@ namespace fc { 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::protocol::pts_address& tx, + uint32_t _max_depth=FC_PACK_MAX_DEPTH ); + 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::protocol::pts_address& tx, + uint32_t _max_depth=FC_PACK_MAX_DEPTH ); +} } // fc::raw diff --git a/libraries/protocol/include/graphene/protocol/special_authority.hpp b/libraries/protocol/include/graphene/protocol/special_authority.hpp index de97257e5d..4ac6e34f29 100644 --- a/libraries/protocol/include/graphene/protocol/special_authority.hpp +++ b/libraries/protocol/include/graphene/protocol/special_authority.hpp @@ -24,7 +24,6 @@ #pragma once #include -#include namespace graphene { namespace protocol { @@ -48,3 +47,5 @@ void validate_special_authority( const special_authority& auth ); 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::protocol::top_holders_special_authority ) diff --git a/libraries/protocol/include/graphene/protocol/transaction.hpp b/libraries/protocol/include/graphene/protocol/transaction.hpp index c639772d88..3e0ba2277f 100644 --- a/libraries/protocol/include/graphene/protocol/transaction.hpp +++ b/libraries/protocol/include/graphene/protocol/transaction.hpp @@ -23,9 +23,6 @@ */ #pragma once #include -#include - -#include namespace graphene { namespace protocol { diff --git a/libraries/protocol/include/graphene/protocol/transfer.hpp b/libraries/protocol/include/graphene/protocol/transfer.hpp index 1262be2acb..bd8a0353a9 100644 --- a/libraries/protocol/include/graphene/protocol/transfer.hpp +++ b/libraries/protocol/include/graphene/protocol/transfer.hpp @@ -23,6 +23,7 @@ */ #pragma once #include +#include #include namespace graphene { namespace protocol { @@ -105,3 +106,8 @@ FC_REFLECT( graphene::protocol::override_transfer_operation::fee_parameters_type 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::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 index 444318cc5f..6fbf5b3f19 100644 --- a/libraries/protocol/include/graphene/protocol/types.hpp +++ b/libraries/protocol/include/graphene/protocol/types.hpp @@ -23,6 +23,11 @@ */ #pragma once +#include +#include +#include +#include + #include #include #include @@ -30,11 +35,15 @@ #include #include +#include + #include #include #include +#include #include #include +#include #include #include #include @@ -43,29 +52,21 @@ #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 @@ -231,7 +232,8 @@ struct get_typename> { static } }; 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) @@ -268,3 +270,12 @@ FC_REFLECT_ENUM(graphene::protocol::asset_issuer_permission_flags, (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/protocol/include/graphene/protocol/vesting.hpp b/libraries/protocol/include/graphene/protocol/vesting.hpp index 2e2ff218fe..fd2dea524f 100644 --- a/libraries/protocol/include/graphene/protocol/vesting.hpp +++ b/libraries/protocol/include/graphene/protocol/vesting.hpp @@ -23,6 +23,7 @@ */ #pragma once #include +#include namespace graphene { namespace protocol { @@ -126,3 +127,8 @@ FC_REFLECT(graphene::protocol::linear_vesting_policy_initializer, (begin_timesta FC_REFLECT(graphene::protocol::cdd_vesting_policy_initializer, (start_claim)(vesting_seconds) ) FC_REFLECT_EMPTY( graphene::protocol::instant_vesting_policy_initializer ) FC_REFLECT_TYPENAME( graphene::protocol::vesting_policy_initializer ) + +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/protocol/include/graphene/protocol/vote.hpp b/libraries/protocol/include/graphene/protocol/vote.hpp index 8d19abe084..5738e483d7 100644 --- a/libraries/protocol/include/graphene/protocol/vote.hpp +++ b/libraries/protocol/include/graphene/protocol/vote.hpp @@ -24,12 +24,7 @@ #pragma once -#include -#include -#include - -#include -#include +#include namespace graphene { namespace protocol { @@ -146,3 +141,5 @@ FC_REFLECT_TYPENAME( fc::flat_set ) FC_REFLECT_ENUM( graphene::protocol::vote_id_type::vote_type, (witness)(committee)(worker)(VOTE_TYPE_COUNT) ) FC_REFLECT( graphene::protocol::vote_id_type, (content) ) + +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::vote_id_type ) diff --git a/libraries/protocol/include/graphene/protocol/withdraw_permission.hpp b/libraries/protocol/include/graphene/protocol/withdraw_permission.hpp index 03952e1e31..01b4207f72 100644 --- a/libraries/protocol/include/graphene/protocol/withdraw_permission.hpp +++ b/libraries/protocol/include/graphene/protocol/withdraw_permission.hpp @@ -23,6 +23,7 @@ */ #pragma once #include +#include #include namespace graphene { namespace protocol { @@ -179,3 +180,12 @@ FC_REFLECT( graphene::protocol::withdraw_permission_update_operation, (fee)(with 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::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/protocol/include/graphene/protocol/witness.hpp b/libraries/protocol/include/graphene/protocol/witness.hpp index 7eac795abb..93694d964c 100644 --- a/libraries/protocol/include/graphene/protocol/witness.hpp +++ b/libraries/protocol/include/graphene/protocol/witness.hpp @@ -23,6 +23,7 @@ */ #pragma once #include +#include namespace graphene { namespace protocol { @@ -81,3 +82,8 @@ FC_REFLECT( graphene::protocol::witness_create_operation, (fee)(witness_account) 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) ) + +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/protocol/include/graphene/protocol/worker.hpp b/libraries/protocol/include/graphene/protocol/worker.hpp index 7bd7825923..eb02155d78 100644 --- a/libraries/protocol/include/graphene/protocol/worker.hpp +++ b/libraries/protocol/include/graphene/protocol/worker.hpp @@ -23,6 +23,7 @@ */ #pragma once #include +#include namespace graphene { namespace protocol { @@ -104,3 +105,5 @@ FC_REFLECT( graphene::protocol::worker_create_operation::fee_parameters_type, (f 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::protocol::worker_create_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::worker_create_operation ) diff --git a/libraries/protocol/market.cpp b/libraries/protocol/market.cpp index 19e37bbb7d..299b2d0a42 100644 --- a/libraries/protocol/market.cpp +++ b/libraries/protocol/market.cpp @@ -23,6 +23,8 @@ */ #include +#include + namespace graphene { namespace protocol { void limit_order_create_operation::validate()const @@ -55,3 +57,15 @@ void bid_collateral_operation::validate()const } FC_CAPTURE_AND_RETHROW((*this)) } } } // graphene::protocol + +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::call_order_update_operation::options_type ) +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::bid_collateral_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::bid_collateral_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::fill_order_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::execute_bid_operation ) diff --git a/libraries/protocol/memo.cpp b/libraries/protocol/memo.cpp index 3b4bda2263..f28ce70656 100644 --- a/libraries/protocol/memo.cpp +++ b/libraries/protocol/memo.cpp @@ -24,6 +24,7 @@ #include #include #include +#include namespace graphene { namespace protocol { @@ -89,3 +90,6 @@ memo_message memo_message::deserialize(const string& serial) } } } // graphene::protocol + +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::memo_message ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::memo_data ) diff --git a/libraries/protocol/operations.cpp b/libraries/protocol/operations.cpp index 943fcdb044..d3063b7e93 100644 --- a/libraries/protocol/operations.cpp +++ b/libraries/protocol/operations.cpp @@ -24,6 +24,8 @@ #include #include +#include + namespace graphene { namespace protocol { uint64_t base_operation::calculate_data_fee( uint64_t bytes, uint64_t price_per_kbyte ) @@ -92,3 +94,5 @@ void operation_get_required_authorities( const operation& op, } } } // namespace graphene::protocol + +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::op_wrapper ) diff --git a/libraries/protocol/proposal.cpp b/libraries/protocol/proposal.cpp index 020b5182f2..618f9b9431 100644 --- a/libraries/protocol/proposal.cpp +++ b/libraries/protocol/proposal.cpp @@ -107,3 +107,10 @@ void proposal_update_operation::get_required_owner_authorities( flat_set #include #include +#include #include namespace graphene { namespace protocol { @@ -93,4 +94,12 @@ namespace fc { vo = graphene::protocol::pts_address( var.as_string() ); } -} + +namespace raw { + 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::protocol::pts_address& tx, + uint32_t _max_depth=FC_PACK_MAX_DEPTH ); + 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 0000000000..ea2ae2b8f0 --- /dev/null +++ b/libraries/protocol/small_ops.cpp @@ -0,0 +1,39 @@ +/* + * 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 + +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 ) diff --git a/libraries/protocol/special_authority.cpp b/libraries/protocol/special_authority.cpp index 2f7b4f919c..26d0c4fc6a 100644 --- a/libraries/protocol/special_authority.cpp +++ b/libraries/protocol/special_authority.cpp @@ -24,6 +24,8 @@ #include +#include + namespace graphene { namespace protocol { struct special_authority_validate_visitor @@ -45,3 +47,5 @@ void validate_special_authority( const special_authority& a ) } } } // graphene::protocol + +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::top_holders_special_authority ) diff --git a/libraries/protocol/transaction.cpp b/libraries/protocol/transaction.cpp index 842d48d8ce..6598e8fd5f 100644 --- a/libraries/protocol/transaction.cpp +++ b/libraries/protocol/transaction.cpp @@ -22,11 +22,13 @@ * THE SOFTWARE. */ -#include +#include #include #include +#include +#include + #include -#include namespace graphene { namespace protocol { diff --git a/libraries/protocol/transfer.cpp b/libraries/protocol/transfer.cpp index c4c0b15aff..cc63146bd8 100644 --- a/libraries/protocol/transfer.cpp +++ b/libraries/protocol/transfer.cpp @@ -63,3 +63,8 @@ void override_transfer_operation::validate()const } } } // graphene::protocol + +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 index e8166fbfc1..641e4fe328 100644 --- a/libraries/protocol/types.cpp +++ b/libraries/protocol/types.cpp @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include + #include #include @@ -112,4 +112,11 @@ namespace fc from_variant(var, const_cast(*vo), max_depth); } -} // fc +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/protocol/vote.cpp b/libraries/protocol/vote.cpp index ae1755c14b..1f94fd89d8 100644 --- a/libraries/protocol/vote.cpp +++ b/libraries/protocol/vote.cpp @@ -23,8 +23,6 @@ */ #include -#include -#include namespace fc { @@ -40,3 +38,5 @@ void from_variant( const variant& var, graphene::protocol::vote_id_type& vo, uin } } // fc + +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::vote_id_type ) diff --git a/libraries/protocol/withdraw_permission.cpp b/libraries/protocol/withdraw_permission.cpp index 683121ac49..1155e3d578 100644 --- a/libraries/protocol/withdraw_permission.cpp +++ b/libraries/protocol/withdraw_permission.cpp @@ -67,6 +67,13 @@ void withdraw_permission_delete_operation::validate() const FC_ASSERT( withdraw_from_account != authorized_account ); } - } } // graphene::protocol +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/protocol/witness.cpp b/libraries/protocol/witness.cpp index 6ec418a9e7..919153239f 100644 --- a/libraries/protocol/witness.cpp +++ b/libraries/protocol/witness.cpp @@ -23,6 +23,8 @@ */ #include +#include + namespace graphene { namespace protocol { void witness_create_operation::validate() const @@ -39,3 +41,8 @@ void witness_update_operation::validate() const } } } // graphene::protocol + +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/protocol/worker.cpp b/libraries/protocol/worker.cpp index 2344edb83f..c6606073b0 100644 --- a/libraries/protocol/worker.cpp +++ b/libraries/protocol/worker.cpp @@ -23,6 +23,8 @@ */ #include +#include + namespace graphene { namespace protocol { void worker_create_operation::validate() const @@ -36,3 +38,6 @@ void worker_create_operation::validate() const } } } + +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/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 261f7dd773..737e7f1a3b 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -65,6 +65,7 @@ #include #include #include +#include #include #include #include From edbb2458a3dc233284d0ff172c72974ceafa46a1 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Mon, 20 May 2019 21:38:21 +0200 Subject: [PATCH 079/133] Separate exception declaration and implementation --- libraries/chain/CMakeLists.txt | 1 + libraries/chain/exceptions.cpp | 138 ++++++++++++++++ .../include/graphene/chain/exceptions.hpp | 150 ++++++------------ .../graphene/chain/internal_exceptions.hpp | 10 +- libraries/net/CMakeLists.txt | 1 + libraries/net/exceptions.cpp | 41 +++++ .../net/include/graphene/net/exceptions.hpp | 14 +- .../include/graphene/protocol/exceptions.hpp | 18 +-- libraries/protocol/small_ops.cpp | 25 +++ 9 files changed, 280 insertions(+), 118 deletions(-) create mode 100644 libraries/chain/exceptions.cpp create mode 100644 libraries/net/exceptions.cpp diff --git a/libraries/chain/CMakeLists.txt b/libraries/chain/CMakeLists.txt index e54f3db81a..fbcd6ab866 100644 --- a/libraries/chain/CMakeLists.txt +++ b/libraries/chain/CMakeLists.txt @@ -37,6 +37,7 @@ add_library( graphene_chain genesis_state.cpp get_config.cpp + exceptions.cpp evaluator.cpp balance_evaluator.cpp diff --git a/libraries/chain/exceptions.cpp b/libraries/chain/exceptions.cpp new file mode 100644 index 0000000000..68606a91f6 --- /dev/null +++ b/libraries/chain/exceptions.cpp @@ -0,0 +1,138 @@ +/* + * 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 ) + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( htlc_create_operation ) + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( htlc_redeem_operation ) + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( htlc_extend_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/include/graphene/chain/exceptions.hpp b/libraries/chain/include/graphene/chain/exceptions.hpp index 028d312e56..0aa9b3db4a 100644 --- a/libraries/chain/include/graphene/chain/exceptions.hpp +++ b/libraries/chain/include/graphene/chain/exceptions.hpp @@ -31,12 +31,24 @@ #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, \ @@ -45,6 +57,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 \ @@ -54,6 +74,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 \ @@ -78,20 +106,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( 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( insufficient_feeds, graphene::chain::chain_exception, 37006, "insufficient feeds" ) + 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( pop_empty_chain, graphene::chain::undo_database_exception, 3070001, "there are no blocks to pop" ) + FC_DECLARE_DERIVED_EXCEPTION( insufficient_feeds, chain_exception, 37006 ) + + 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" ) @@ -162,93 +191,14 @@ 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 ) + //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( htlc_create_operation ) + //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( htlc_redeem_operation ) + //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( htlc_extend_operation ) #define GRAPHENE_RECODE_EXC( cause_type, effect_type ) \ catch( const cause_type& e ) \ diff --git a/libraries/chain/include/graphene/chain/internal_exceptions.hpp b/libraries/chain/include/graphene/chain/internal_exceptions.hpp index 8a57ae23ce..4381c6de68 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/net/CMakeLists.txt b/libraries/net/CMakeLists.txt index 36c802a3ff..b533e61a35 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 diff --git a/libraries/net/exceptions.cpp b/libraries/net/exceptions.cpp new file mode 100644 index 0000000000..7b6e23dc5d --- /dev/null +++ b/libraries/net/exceptions.cpp @@ -0,0 +1,41 @@ +/* + * 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 + +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" ) + +} } diff --git a/libraries/net/include/graphene/net/exceptions.hpp b/libraries/net/include/graphene/net/exceptions.hpp index 59da8ccb45..e95eea8759 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/protocol/include/graphene/protocol/exceptions.hpp b/libraries/protocol/include/graphene/protocol/exceptions.hpp index 5141151d21..f062dd7d18 100644 --- a/libraries/protocol/include/graphene/protocol/exceptions.hpp +++ b/libraries/protocol/include/graphene/protocol/exceptions.hpp @@ -33,16 +33,16 @@ namespace graphene { namespace protocol { - FC_DECLARE_EXCEPTION( protocol_exception, 4000000, "protocol exception" ) + FC_DECLARE_EXCEPTION( protocol_exception, 4000000 ) - FC_DECLARE_DERIVED_EXCEPTION( transaction_exception, graphene::protocol::protocol_exception, 4010000, "transaction validation exception" ) + FC_DECLARE_DERIVED_EXCEPTION( transaction_exception, protocol_exception, 4010000 ) - FC_DECLARE_DERIVED_EXCEPTION( tx_missing_active_auth, graphene::protocol::transaction_exception, 4010001, "missing required active authority" ) - FC_DECLARE_DERIVED_EXCEPTION( tx_missing_owner_auth, graphene::protocol::transaction_exception, 4010002, "missing required owner authority" ) - FC_DECLARE_DERIVED_EXCEPTION( tx_missing_other_auth, graphene::protocol::transaction_exception, 4010003, "missing required other authority" ) - FC_DECLARE_DERIVED_EXCEPTION( tx_irrelevant_sig, graphene::protocol::transaction_exception, 4010004, "irrelevant signature included" ) - FC_DECLARE_DERIVED_EXCEPTION( tx_duplicate_sig, graphene::protocol::transaction_exception, 4010005, "duplicate signature included" ) - FC_DECLARE_DERIVED_EXCEPTION( invalid_committee_approval, graphene::protocol::transaction_exception, 4010006, "committee account cannot directly approve transaction" ) - FC_DECLARE_DERIVED_EXCEPTION( insufficient_fee, graphene::protocol::transaction_exception, 4010007, "insufficient fee" ) + FC_DECLARE_DERIVED_EXCEPTION( tx_missing_active_auth, transaction_exception, 4010001 ) + FC_DECLARE_DERIVED_EXCEPTION( tx_missing_owner_auth, transaction_exception, 4010002 ) + FC_DECLARE_DERIVED_EXCEPTION( tx_missing_other_auth, transaction_exception, 4010003 ) + FC_DECLARE_DERIVED_EXCEPTION( tx_irrelevant_sig, transaction_exception, 4010004 ) + FC_DECLARE_DERIVED_EXCEPTION( tx_duplicate_sig, transaction_exception, 4010005 ) + FC_DECLARE_DERIVED_EXCEPTION( invalid_committee_approval, transaction_exception, 4010006 ) + FC_DECLARE_DERIVED_EXCEPTION( insufficient_fee, transaction_exception, 4010007 ) } } // graphene::protocol diff --git a/libraries/protocol/small_ops.cpp b/libraries/protocol/small_ops.cpp index ea2ae2b8f0..fcb4dd3dfc 100644 --- a/libraries/protocol/small_ops.cpp +++ b/libraries/protocol/small_ops.cpp @@ -24,11 +24,36 @@ #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 ) From 90efe68bebc8ed03e4ff6820c45df6a4aa0ad577 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Tue, 28 May 2019 21:51:30 +0200 Subject: [PATCH 080/133] Bumped fc --- libraries/fc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/fc b/libraries/fc index 9ce24c2feb..ab9b4a234e 160000 --- a/libraries/fc +++ b/libraries/fc @@ -1 +1 @@ -Subproject commit 9ce24c2feb0ef40f722742826a1901a9273128d9 +Subproject commit ab9b4a234e1cc4b1a6b4149757c646b6a9826515 From 726ce95326612ebec0858ec2fcc0e158cef22cc9 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Wed, 29 May 2019 10:30:44 +0200 Subject: [PATCH 081/133] Deprecate -r instead of -H --- programs/cli_wallet/main.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/programs/cli_wallet/main.cpp b/programs/cli_wallet/main.cpp index 4855c0f6b4..0f1bb4fa97 100644 --- a/programs/cli_wallet/main.cpp +++ b/programs/cli_wallet/main.cpp @@ -76,11 +76,12 @@ int main( int argc, char** argv ) ("server-rpc-endpoint,s", bpo::value()->implicit_value("ws://127.0.0.1:8090"), "Server websocket RPC endpoint") ("server-rpc-user,u", bpo::value(), "Server Username") ("server-rpc-password,p", bpo::value(), "Server Password") - ("rpc-endpoint,r", bpo::value()->implicit_value("127.0.0.1:8091"), "Endpoint for wallet websocket RPC to listen on") + ("rpc-endpoint,r", bpo::value()->implicit_value("127.0.0.1:8091"), + "Endpoint for wallet websocket RPC to listen on (DEPRECATED, use rpc-http-endpoint instead)") ("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 (DEPRECATED, use rpc-endpoint instead)") + "Endpoint for wallet HTTP and websocket RPC to listen on") ("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") From 6c630f6ad74c921326e245536013490241be0045 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Wed, 29 May 2019 17:37:28 +0200 Subject: [PATCH 082/133] Attempt to mitigate effects of duplicate websocket_server instances --- programs/cli_wallet/main.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/programs/cli_wallet/main.cpp b/programs/cli_wallet/main.cpp index 0f1bb4fa97..5b5b5bbdfd 100644 --- a/programs/cli_wallet/main.cpp +++ b/programs/cli_wallet/main.cpp @@ -206,9 +206,10 @@ int main( int argc, char** argv ) fc::api wapi(wapiptr); - auto _websocket_server = std::make_shared(); + std::shared_ptr _websocket_server; if( options.count("rpc-endpoint") ) { + _websocket_server = std::make_shared(); _websocket_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); @@ -223,9 +224,10 @@ int main( int argc, char** argv ) if( options.count( "rpc-tls-certificate" ) ) cert_pem = options.at("rpc-tls-certificate").as(); - auto _websocket_tls_server = std::make_shared(cert_pem); + std::shared_ptr _websocket_tls_server; if( options.count("rpc-tls-endpoint") ) { + _websocket_tls_server = std::make_shared(cert_pem); _websocket_tls_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); @@ -237,9 +239,10 @@ int main( int argc, char** argv ) _websocket_tls_server->start_accept(); } - auto _http_ws_server = std::make_shared(); + std::shared_ptr _http_ws_server; if( options.count("rpc-http-endpoint" ) ) { + _http_ws_server = std::make_shared(); 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 ){ From 5e82973b5a108e6627e4e515dd844f750119b4c3 Mon Sep 17 00:00:00 2001 From: manikey123 Date: Sat, 1 Jun 2019 23:00:39 -0700 Subject: [PATCH 083/133] updates based on review comments --- tests/common/database_fixture.cpp | 24 +++++++---- tests/tests/database_api_tests.cpp | 65 +++++++++++++++++++++--------- 2 files changed, 61 insertions(+), 28 deletions(-) diff --git a/tests/common/database_fixture.cpp b/tests/common/database_fixture.cpp index 33f4a133ca..9cf4db352d 100644 --- a/tests/common/database_fixture.cpp +++ b/tests/common/database_fixture.cpp @@ -160,23 +160,31 @@ database_fixture::database_fixture() } if(current_test_name =="api_limit_get_limit_orders") { - options.insert(std::make_pair("api-limit-get-limit-orders", boost::program_options::variable_value((uint64_t)350, false))); - options.insert(std::make_pair("plugins", boost::program_options::variable_value(string("account_history"), false))); + options.insert(std::make_pair("api-limit-get-limit-orders", boost::program_options::variable_value( + (uint64_t)350, false))); + options.insert(std::make_pair("plugins", boost::program_options::variable_value( + string("account_history"), false))); } if(current_test_name =="api_limit_get_call_orders") { - options.insert(std::make_pair("api-limit-get-call-orders", boost::program_options::variable_value((uint64_t)350, false))); - options.insert(std::make_pair("plugins", boost::program_options::variable_value(string("account_history"), false))); + options.insert(std::make_pair("api-limit-get-call-orders", boost::program_options::variable_value( + (uint64_t)350, false))); + options.insert(std::make_pair("plugins", boost::program_options::variable_value( + string("account_history"), false))); } if(current_test_name =="api_limit_get_settle_orders") { - options.insert(std::make_pair("api-limit-get-settle-orders", boost::program_options::variable_value((uint64_t)350, false))); - options.insert(std::make_pair("plugins", boost::program_options::variable_value(string("account_history"), false))); + options.insert(std::make_pair("api-limit-get-settle-orders", boost::program_options::variable_value( + (uint64_t)350, false))); + options.insert(std::make_pair("plugins", boost::program_options::variable_value( + string("account_history"), false))); } if(current_test_name =="api_limit_get_order_book") { - options.insert(std::make_pair("api-limit-get-order-book", boost::program_options::variable_value((uint64_t)80, false))); - options.insert(std::make_pair("plugins", boost::program_options::variable_value(string("account_history"), false))); + options.insert(std::make_pair("api-limit-get-order-book", boost::program_options::variable_value( + (uint64_t)80, false))); + options.insert(std::make_pair("plugins", boost::program_options::variable_value( + string("account_history"), false))); } // add account tracking for ahplugin for special test case with track-account enabled diff --git a/tests/tests/database_api_tests.cpp b/tests/tests/database_api_tests.cpp index 8fb926fe71..eb86573233 100644 --- a/tests/tests/database_api_tests.cpp +++ b/tests/tests/database_api_tests.cpp @@ -980,9 +980,12 @@ BOOST_AUTO_TEST_CASE( api_limit_get_limit_orders ){ create_account("bob"); asset_id_type bit_jmj_id = create_bitasset("JMJBIT").id; generate_block(); - fc::usleep(fc::milliseconds(2000)); - GRAPHENE_CHECK_THROW(db_api.get_limit_orders(std::string(static_cast(asset_id_type())), std::string(static_cast(bit_jmj_id)), 370), fc::exception); - vector limit_orders =db_api.get_limit_orders(std::string(static_cast(asset_id_type())), std::string(static_cast(bit_jmj_id)), 340); + fc::usleep(fc::milliseconds(100)); + GRAPHENE_CHECK_THROW(db_api.get_limit_orders(std::string(static_cast(asset_id_type())), + std::string(static_cast(bit_jmj_id)), 370), fc::exception); + vector limit_orders =db_api.get_limit_orders(std::string( + static_cast(asset_id_type())), + std::string(static_cast(bit_jmj_id)), 340); BOOST_REQUIRE_EQUAL( limit_orders.size(), 0u); }catch (fc::exception& e) { @@ -994,12 +997,19 @@ BOOST_AUTO_TEST_CASE( api_limit_get_call_orders ){ try{ graphene::app::database_api db_api( db, &( app.get_options() )); //account_id_type() do 3 ops - create_bitasset("USD", account_id_type()); - create_account("dan"); - create_account("bob"); + auto nathan_private_key = generate_private_key("nathan"); + account_id_type nathan_id = create_account("nathan", nathan_private_key.get_public_key()).id; + transfer(account_id_type(), nathan_id, asset(100)); + asset_id_type bitusd_id = create_bitasset( + "USDBIT", nathan_id, 100, disable_force_settle).id; generate_block(); - fc::usleep(fc::milliseconds(2000)); - GRAPHENE_CHECK_THROW(db_api.get_call_orders(std::string(static_cast(asset_id_type())), 370), fc::exception); + fc::usleep(fc::milliseconds(100)); + BOOST_CHECK( bitusd_id(db).is_market_issued() ); + GRAPHENE_CHECK_THROW(db_api.get_call_orders(std::string(static_cast(bitusd_id)), + 370), fc::exception); + vector< call_order_object> call_order =db_api.get_call_orders(std::string( + static_cast(bitusd_id)), 340); + BOOST_REQUIRE_EQUAL( call_order.size(), 0u); }catch (fc::exception& e) { edump((e.to_detail_string())); throw; @@ -1009,12 +1019,18 @@ BOOST_AUTO_TEST_CASE( api_limit_get_settle_orders ){ try{ graphene::app::database_api db_api( db, &( app.get_options() )); //account_id_type() do 3 ops - create_bitasset("USD", account_id_type()); - create_account("dan"); - create_account("bob"); + auto nathan_private_key = generate_private_key("nathan"); + account_id_type nathan_id = create_account("nathan", nathan_private_key.get_public_key()).id; + transfer(account_id_type(), nathan_id, asset(100)); + asset_id_type bitusd_id = create_bitasset( + "USDBIT", nathan_id, 100, disable_force_settle).id; generate_block(); - fc::usleep(fc::milliseconds(2000)); - GRAPHENE_CHECK_THROW(db_api.get_settle_orders(std::string(static_cast(asset_id_type())), 370), fc::exception); + fc::usleep(fc::milliseconds(100)); + GRAPHENE_CHECK_THROW(db_api.get_settle_orders( + std::string(static_cast(bitusd_id)), 370), fc::exception); + vector result =db_api.get_settle_orders( + std::string(static_cast(bitusd_id)), 340); + BOOST_REQUIRE_EQUAL( result.size(), 0u); }catch (fc::exception& e) { edump((e.to_detail_string())); throw; @@ -1023,14 +1039,23 @@ BOOST_AUTO_TEST_CASE( api_limit_get_settle_orders ){ BOOST_AUTO_TEST_CASE( api_limit_get_order_book ){ try{ graphene::app::database_api db_api( db, &( app.get_options() )); - //account_id_type() do 3 ops - create_bitasset("USD", account_id_type()); - create_account("dan"); - create_account("bob"); - asset_id_type bit_jmj_id = create_bitasset("JMJBIT").id; + auto nathan_private_key = generate_private_key("nathan"); + auto dan_private_key = generate_private_key("dan"); + account_id_type nathan_id = create_account("nathan", nathan_private_key.get_public_key()).id; + account_id_type dan_id = create_account("dan", dan_private_key.get_public_key()).id; + transfer(account_id_type(), nathan_id, asset(100)); + transfer(account_id_type(), dan_id, asset(100)); + asset_id_type bitusd_id = create_bitasset( + "USDBIT", nathan_id, 100, disable_force_settle).id; + asset_id_type bitdan_id = create_bitasset( + "DANBIT", dan_id, 100, disable_force_settle).id; generate_block(); - fc::usleep(fc::milliseconds(2000)); - GRAPHENE_CHECK_THROW(db_api.get_order_book(std::string(static_cast(asset_id_type())), std::string(static_cast(bit_jmj_id)),89), fc::exception); + fc::usleep(fc::milliseconds(100)); + GRAPHENE_CHECK_THROW(db_api.get_order_book(std::string(static_cast(bitusd_id)), + std::string(static_cast(bitdan_id)),89), fc::exception); + graphene::app::order_book result =db_api.get_order_book(std::string( + static_cast(bitusd_id)), std::string(static_cast(bitdan_id)),78); + BOOST_REQUIRE_EQUAL( result.bids.size(), 0u); }catch (fc::exception& e) { edump((e.to_detail_string())); throw; From 541e6be5b23ef09aca973b93ff75a1ab148920d2 Mon Sep 17 00:00:00 2001 From: manikey123 Date: Sun, 2 Jun 2019 10:23:47 -0700 Subject: [PATCH 084/133] removing same declaration issue --- libraries/app/include/graphene/app/application.hpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/libraries/app/include/graphene/app/application.hpp b/libraries/app/include/graphene/app/application.hpp index e31e8039dd..30dfc53f2a 100644 --- a/libraries/app/include/graphene/app/application.hpp +++ b/libraries/app/include/graphene/app/application.hpp @@ -54,8 +54,6 @@ namespace graphene { namespace app { uint64_t api_limit_get_settle_orders = 300; uint64_t api_limit_get_assets = 101; uint64_t api_limit_get_limit_orders = 300; - uint64_t api_limit_get_call_orders = 300; - uint64_t api_limit_get_settle_orders = 300; uint64_t api_limit_get_order_book = 50; }; From 6ba75337c50331daf895e8957a7af27fa7898e4f Mon Sep 17 00:00:00 2001 From: manikey123 Date: Mon, 3 Jun 2019 00:57:33 -0700 Subject: [PATCH 085/133] Removed duplicates in files --- libraries/app/application.cpp | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index 5f19ce0914..8c1d5701a9 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -337,9 +337,9 @@ void application_impl::set_api_limit() { if(_options->count("api-limit-get-asset-holders")){ _app_options.api_limit_get_asset_holders = _options->at("api-limit-get-asset-holders").as(); } - if(_options->count("api-limit-get-key-references")){ - _app_options.api_limit_get_key_references = _options->at("api-limit-get-key-references").as(); - } + if(_options->count("api-limit-get-key-references")){ + _app_options.api_limit_get_key_references = _options->at("api-limit-get-key-references").as(); + } if(_options->count("api-limit-get-htlc-by")) { _app_options.api_limit_get_htlc_by = _options->at("api-limit-get-htlc-by").as(); } @@ -361,12 +361,6 @@ void application_impl::set_api_limit() { if(_options->count("api-limit-get-limit-orders")){ _app_options.api_limit_get_limit_orders = _options->at("api-limit-get-limit-orders").as(); } - if(_options->count("api-limit-get-call-orders")){ - _app_options.api_limit_get_call_orders = _options->at("api-limit-get-call-orders").as(); - } - if(_options->count("api-limit-get-settle-orders")){ - _app_options.api_limit_get_settle_orders = _options->at("api-limit-get-settle-orders").as(); - } if(_options->count("api-limit-get-order-book")){ _app_options.api_limit_get_order_book = _options->at("api-limit-get-order-book").as(); } @@ -1061,10 +1055,6 @@ void application::set_program_options(boost::program_options::options_descriptio "For database_api_impl::list_assets and get_assets_by_issuer to set its default limit values as 101") ("api-limit-get-limit-orders",boost::program_options::value()->default_value(300), "For database_api_impl::get_limit_orders to set its default limit value as 300") - ("api-limit-get-call-orders",boost::program_options::value()->default_value(300), - "For database_api_impl::get_call_orders to set its default limit value as 300") - ("api-limit-get-settle-orders",boost::program_options::value()->default_value(300), - "For database_api_impl::get_settle_orders to set its default limit value as 300") ("api-limit-get-order-book",boost::program_options::value()->default_value(50), "For database_api_impl::get_order_book to set its default limit value as 50") ; From 67d4b9829467db33f7dfd78497cfaad7a96e6e9b Mon Sep 17 00:00:00 2001 From: manikey123 Date: Mon, 3 Jun 2019 01:04:36 -0700 Subject: [PATCH 086/133] updating indent --- libraries/app/application.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index 8c1d5701a9..cdb75f57fe 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -337,9 +337,9 @@ void application_impl::set_api_limit() { if(_options->count("api-limit-get-asset-holders")){ _app_options.api_limit_get_asset_holders = _options->at("api-limit-get-asset-holders").as(); } - if(_options->count("api-limit-get-key-references")){ - _app_options.api_limit_get_key_references = _options->at("api-limit-get-key-references").as(); - } + if(_options->count("api-limit-get-key-references")){ + _app_options.api_limit_get_key_references = _options->at("api-limit-get-key-references").as(); + } if(_options->count("api-limit-get-htlc-by")) { _app_options.api_limit_get_htlc_by = _options->at("api-limit-get-htlc-by").as(); } From 285d64d2a9b63152f0c3418d0dad4be41daecbda Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Tue, 4 Jun 2019 13:36:21 +0200 Subject: [PATCH 087/133] Undo superfluous change --- libraries/wallet/include/graphene/wallet/wallet.hpp | 6 +++--- libraries/wallet/wallet.cpp | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/libraries/wallet/include/graphene/wallet/wallet.hpp b/libraries/wallet/include/graphene/wallet/wallet.hpp index f0383670bb..6b69e70a41 100644 --- a/libraries/wallet/include/graphene/wallet/wallet.hpp +++ b/libraries/wallet/include/graphene/wallet/wallet.hpp @@ -229,12 +229,11 @@ struct worker_vote_delta flat_set vote_abstain; }; -struct signed_block_with_info +struct signed_block_with_info : public signed_block { signed_block_with_info( const signed_block& block ); signed_block_with_info( const signed_block_with_info& block ) = default; - signed_block block; block_id_type block_id; public_key_type signing_key; vector< transaction_id_type > transaction_ids; @@ -1800,7 +1799,8 @@ FC_REFLECT( graphene::wallet::worker_vote_delta, (vote_abstain) ) -FC_REFLECT( graphene::wallet::signed_block_with_info, (block_id)(signing_key)(transaction_ids) ) +FC_REFLECT_DERIVED( graphene::wallet::signed_block_with_info, (graphene::chain::signed_block), + (block_id)(signing_key)(transaction_ids) ) FC_REFLECT_DERIVED( graphene::wallet::vesting_balance_object_with_info, (graphene::chain::vesting_balance_object), (allowed_withdraw)(allowed_withdraw_time) ) diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 737e7f1a3b..c113db86cd 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -5039,13 +5039,13 @@ order_book wallet_api::get_order_book( const string& base, const string& quote, return( my->_remote_db->get_order_book( base, quote, limit ) ); } -signed_block_with_info::signed_block_with_info( const signed_block& _block ) - : block( _block ) +signed_block_with_info::signed_block_with_info( const signed_block& block ) + : signed_block( block ) { - block_id = _block.id(); - signing_key = _block.signee(); - transaction_ids.reserve( _block.transactions.size() ); - for( const processed_transaction& tx : _block.transactions ) + block_id = id(); + signing_key = signee(); + transaction_ids.reserve( transactions.size() ); + for( const processed_transaction& tx : transactions ) transaction_ids.push_back( tx.id() ); } From eb4e92e33ca3f5957bf7b13dd7493be83a8c1129 Mon Sep 17 00:00:00 2001 From: Alfredo Garcia Date: Fri, 7 Jun 2019 19:35:15 -0300 Subject: [PATCH 088/133] fix required-participation witness plugin option --- libraries/plugins/witness/witness.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libraries/plugins/witness/witness.cpp b/libraries/plugins/witness/witness.cpp index af2101e9ea..52c7884a05 100644 --- a/libraries/plugins/witness/witness.cpp +++ b/libraries/plugins/witness/witness.cpp @@ -64,7 +64,7 @@ void witness_plugin::plugin_set_program_options( string witness_id_example = fc::json::to_string(chain::witness_id_type(5)); command_line_options.add_options() ("enable-stale-production", bpo::bool_switch()->notifier([this](bool e){_production_enabled = e;}), "Enable block production, even if the chain is stale.") - ("required-participation", bpo::bool_switch()->notifier([this](int e){_required_witness_participation = uint32_t(e*GRAPHENE_1_PERCENT);}), "Percent of witnesses (0-99) that must be participating in order to produce blocks") + ("required-participation", bpo::value()->default_value(33), "Percent of witnesses (0-99) that must be participating in order to produce blocks") ("witness-id,w", bpo::value>()->composing()->multitoken(), ("ID of witness controlled by this node (e.g. " + witness_id_example + ", quotes are required, may specify multiple times)").c_str()) ("private-key", bpo::value>()->composing()->multitoken()-> @@ -109,6 +109,10 @@ void witness_plugin::plugin_initialize(const boost::program_options::variables_m _private_keys[key_id_to_wif_pair.first] = *private_key; } } + if(options.count("required-participation")) + { + _required_witness_participation = options["required-participation"].as()*GRAPHENE_1_PERCENT; + } ilog("witness plugin: plugin_initialize() end"); } FC_LOG_AND_RETHROW() } From 7776c1997d11baef63ddc50ecbbdb94021bd74a4 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Sat, 8 Jun 2019 10:02:44 +0200 Subject: [PATCH 089/133] Protect SIGQUIT handlers with ifdef to fix windows build --- programs/cli_wallet/main.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/programs/cli_wallet/main.cpp b/programs/cli_wallet/main.cpp index 5b5b5bbdfd..31e5b870cf 100644 --- a/programs/cli_wallet/main.cpp +++ b/programs/cli_wallet/main.cpp @@ -285,14 +285,14 @@ int main( int argc, char** argv ) fc::set_signal_handler( [](int sig) {}, SIGINT ); // reinstall an empty SIGINT handler wallet_cli->cancel(); }, SIGTERM ); - +#ifdef SIGQUIT fc::set_signal_handler( [wallet_cli,sig_set](int signal) { ilog( "Captured SIGQUIT not in daemon mode, exiting" ); sig_set->cancel(); fc::set_signal_handler( [](int sig) {}, SIGINT ); // reinstall an empty SIGINT handler wallet_cli->cancel(); }, SIGQUIT ); - +#endif boost::signals2::scoped_connection closed_connection( con->closed.connect( [wallet_cli,sig_set] { elog( "Server has disconnected us." ); sig_set->cancel(); @@ -320,12 +320,12 @@ int main( int argc, char** argv ) ilog( "Captured SIGTERM in daemon mode, exiting" ); exit_promise->set_value(signal); }, SIGTERM ); - +#ifdef SIGQUIT fc::set_signal_handler( [&exit_promise](int signal) { ilog( "Captured SIGQUIT in daemon mode, exiting" ); exit_promise->set_value(signal); }, SIGQUIT ); - +#endif boost::signals2::scoped_connection closed_connection( con->closed.connect( [&exit_promise] { elog( "Server has disconnected us." ); exit_promise->set_value(0); From f28d9bceb9e1d3d54c734b62e827136fbc7775f1 Mon Sep 17 00:00:00 2001 From: Alfredo Garcia Date: Sat, 8 Jun 2019 08:27:54 -0300 Subject: [PATCH 090/133] add checks and warnings --- libraries/plugins/witness/witness.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libraries/plugins/witness/witness.cpp b/libraries/plugins/witness/witness.cpp index 52c7884a05..c0871dddf2 100644 --- a/libraries/plugins/witness/witness.cpp +++ b/libraries/plugins/witness/witness.cpp @@ -111,7 +111,13 @@ void witness_plugin::plugin_initialize(const boost::program_options::variables_m } if(options.count("required-participation")) { + auto required_participation = options["required-participation"].as(); + FC_ASSERT(required_participation < 100); _required_witness_participation = options["required-participation"].as()*GRAPHENE_1_PERCENT; + if(required_participation < 10) + ilog("witness plugin: Warning - Low required participation"); + else if(_required_witness_participation > 90) + ilog("witness plugin: Warning - High required participation"); } ilog("witness plugin: plugin_initialize() end"); } FC_LOG_AND_RETHROW() } From 0bdf4d6d2b53305b05f11a0493162bc27a0bd49a Mon Sep 17 00:00:00 2001 From: Alfredo Garcia Date: Sat, 8 Jun 2019 17:08:05 -0300 Subject: [PATCH 091/133] do review suggestions --- libraries/plugins/witness/witness.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libraries/plugins/witness/witness.cpp b/libraries/plugins/witness/witness.cpp index c0871dddf2..b3eae7c7b3 100644 --- a/libraries/plugins/witness/witness.cpp +++ b/libraries/plugins/witness/witness.cpp @@ -64,7 +64,7 @@ void witness_plugin::plugin_set_program_options( string witness_id_example = fc::json::to_string(chain::witness_id_type(5)); command_line_options.add_options() ("enable-stale-production", bpo::bool_switch()->notifier([this](bool e){_production_enabled = e;}), "Enable block production, even if the chain is stale.") - ("required-participation", bpo::value()->default_value(33), "Percent of witnesses (0-99) that must be participating in order to produce blocks") + ("required-participation", bpo::value()->default_value(33), "Percent of witnesses (0-100) that must be participating in order to produce blocks") ("witness-id,w", bpo::value>()->composing()->multitoken(), ("ID of witness controlled by this node (e.g. " + witness_id_example + ", quotes are required, may specify multiple times)").c_str()) ("private-key", bpo::value>()->composing()->multitoken()-> @@ -112,12 +112,12 @@ void witness_plugin::plugin_initialize(const boost::program_options::variables_m if(options.count("required-participation")) { auto required_participation = options["required-participation"].as(); - FC_ASSERT(required_participation < 100); + FC_ASSERT(required_participation <= 100); _required_witness_participation = options["required-participation"].as()*GRAPHENE_1_PERCENT; if(required_participation < 10) - ilog("witness plugin: Warning - Low required participation"); - else if(_required_witness_participation > 90) - ilog("witness plugin: Warning - High required participation"); + wlog("witness plugin: Warning - Low required participation of ${rp}% found", ("rp", required_participation)); + else if(required_participation > 90) + wlog("witness plugin: Warning - High required participation of ${rp}% found", ("rp", required_participation)); } ilog("witness plugin: plugin_initialize() end"); } FC_LOG_AND_RETHROW() } From 75229b438560184646ff2a26cd7c604d878d399c Mon Sep 17 00:00:00 2001 From: Alfredo Garcia Date: Tue, 11 Jun 2019 09:21:32 -0300 Subject: [PATCH 092/133] wrap long lines in witness.cpp file --- libraries/plugins/witness/witness.cpp | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/libraries/plugins/witness/witness.cpp b/libraries/plugins/witness/witness.cpp index b3eae7c7b3..eda18b1ce8 100644 --- a/libraries/plugins/witness/witness.cpp +++ b/libraries/plugins/witness/witness.cpp @@ -63,13 +63,17 @@ void witness_plugin::plugin_set_program_options( auto default_priv_key = fc::ecc::private_key::regenerate(fc::sha256::hash(std::string("nathan"))); string witness_id_example = fc::json::to_string(chain::witness_id_type(5)); command_line_options.add_options() - ("enable-stale-production", bpo::bool_switch()->notifier([this](bool e){_production_enabled = e;}), "Enable block production, even if the chain is stale.") - ("required-participation", bpo::value()->default_value(33), "Percent of witnesses (0-100) that must be participating in order to produce blocks") + ("enable-stale-production", bpo::bool_switch()->notifier([this](bool e){_production_enabled = e;}), + "Enable block production, even if the chain is stale.") + ("required-participation", bpo::value()->default_value(33), + "Percent of witnesses (0-100) that must be participating in order to produce blocks") ("witness-id,w", bpo::value>()->composing()->multitoken(), - ("ID of witness controlled by this node (e.g. " + witness_id_example + ", quotes are required, may specify multiple times)").c_str()) + ("ID of witness controlled by this node (e.g. " + witness_id_example + + ", quotes are required, may specify multiple times)").c_str()) ("private-key", bpo::value>()->composing()->multitoken()-> - DEFAULT_VALUE_VECTOR(std::make_pair(chain::public_key_type(default_priv_key.get_public_key()), graphene::utilities::key_to_wif(default_priv_key))), - "Tuple of [PublicKey, WIF private key] (may specify multiple times)") + DEFAULT_VALUE_VECTOR(std::make_pair(chain::public_key_type(default_priv_key.get_public_key()), + graphene::utilities::key_to_wif(default_priv_key))), + "Tuple of [PublicKey, WIF private key] (may specify multiple times)") ; config_file_options.add(command_line_options); } @@ -90,7 +94,8 @@ void witness_plugin::plugin_initialize(const boost::program_options::variables_m const std::vector key_id_to_wif_pair_strings = options["private-key"].as>(); for (const std::string& key_id_to_wif_pair_string : key_id_to_wif_pair_strings) { - auto key_id_to_wif_pair = graphene::app::dejsonify >(key_id_to_wif_pair_string, 5); + auto key_id_to_wif_pair = graphene::app::dejsonify > + (key_id_to_wif_pair_string, 5); ilog("Public Key: ${public}", ("public", key_id_to_wif_pair.first)); fc::optional private_key = graphene::utilities::wif_to_key(key_id_to_wif_pair.second); if (!private_key) @@ -232,7 +237,8 @@ block_production_condition::block_production_condition_enum witness_plugin::bloc ilog("Generated block #${n} with ${x} transaction(s) and timestamp ${t} at time ${c}", (capture)); break; case block_production_condition::not_synced: - ilog("Not producing block because production is disabled until we receive a recent block (see: --enable-stale-production)"); + ilog("Not producing block because production is disabled until we receive a recent block " + "(see: --enable-stale-production)"); break; case block_production_condition::not_my_turn: break; @@ -242,7 +248,8 @@ block_production_condition::block_production_condition_enum witness_plugin::bloc ilog("Not producing block because I don't have the private key for ${scheduled_key}", (capture) ); break; case block_production_condition::low_participation: - elog("Not producing block because node appears to be on a minority fork with only ${pct}% witness participation", (capture) ); + elog("Not producing block because node appears to be on a minority fork with only ${pct}% witness participation", + (capture) ); break; case block_production_condition::lag: elog("Not producing block because node didn't wake up within 2500ms of the slot time."); @@ -262,7 +269,8 @@ block_production_condition::block_production_condition_enum witness_plugin::bloc return result; } -block_production_condition::block_production_condition_enum witness_plugin::maybe_produce_block( fc::limited_mutable_variant_object& capture ) +block_production_condition::block_production_condition_enum witness_plugin::maybe_produce_block( + fc::limited_mutable_variant_object& capture ) { chain::database& db = database(); fc::time_point now_fine = fc::time_point::now(); From a1394f60ffa1930c8de1a5f00144257bfb973c2e Mon Sep 17 00:00:00 2001 From: crypto-ape <43807588+crypto-ape@users.noreply.github.com> Date: Tue, 11 Jun 2019 17:20:21 +0200 Subject: [PATCH 093/133] extend static_variant with is_type() method --- libraries/app/database_api.cpp | 2 +- libraries/chain/db_balance.cpp | 2 +- libraries/chain/db_maint.cpp | 6 +++--- libraries/chain/fba_object.cpp | 4 ++-- libraries/chain/include/graphene/chain/account_object.hpp | 4 ++-- libraries/chain/proposal_evaluator.cpp | 2 +- libraries/chain/vesting_balance_evaluator.cpp | 2 +- .../plugins/account_history/account_history_plugin.cpp | 2 +- libraries/plugins/elasticsearch/elasticsearch_plugin.cpp | 2 +- 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 113fb0453b..0fc7755223 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -2381,7 +2381,7 @@ struct get_required_fees_helper fc::variant set_op_fees( operation& op ) { - if( op.which() == operation::tag::value ) + if( op.is_type() ) { return set_proposal_create_op_fees( op ); } diff --git a/libraries/chain/db_balance.cpp b/libraries/chain/db_balance.cpp index 96a205d6df..a75464e474 100644 --- a/libraries/chain/db_balance.cpp +++ b/libraries/chain/db_balance.cpp @@ -172,7 +172,7 @@ optional< vesting_balance_id_type > database::deposit_lazy_vesting( const vesting_balance_object& vbo = (*ovbid)(*this); if( vbo.owner != req_owner ) break; - if( vbo.policy.which() != vesting_policy::tag< cdd_vesting_policy >::value ) + if( !vbo.policy.is_type< cdd_vesting_policy >() ) break; if( vbo.policy.get< cdd_vesting_policy >().vesting_seconds != req_vesting_seconds ) break; diff --git a/libraries/chain/db_maint.cpp b/libraries/chain/db_maint.cpp index 59cb1c6041..dc9c8bdcfa 100644 --- a/libraries/chain/db_maint.cpp +++ b/libraries/chain/db_maint.cpp @@ -555,11 +555,11 @@ void visit_special_authorities( const database& db, Visitor visit ) for( const special_authority_object& sao : sa_idx ) { const account_object& acct = sao.account(db); - if( acct.owner_special_authority.which() != special_authority::tag< no_special_authority >::value ) + if( !acct.owner_special_authority.is_type< no_special_authority >() ) { visit( acct, true, acct.owner_special_authority ); } - if( acct.active_special_authority.which() != special_authority::tag< no_special_authority >::value ) + if( !acct.active_special_authority.is_type< no_special_authority >() ) { visit( acct, false, acct.active_special_authority ); } @@ -571,7 +571,7 @@ void update_top_n_authorities( database& db ) visit_special_authorities( db, [&]( const account_object& acct, bool is_owner, const special_authority& auth ) { - if( auth.which() == special_authority::tag< top_holders_special_authority >::value ) + if( auth.is_type< top_holders_special_authority >() ) { // use index to grab the top N holders of the asset and vote_counter to obtain the weights diff --git a/libraries/chain/fba_object.cpp b/libraries/chain/fba_object.cpp index 2febca45d7..0ea3ab8318 100644 --- a/libraries/chain/fba_object.cpp +++ b/libraries/chain/fba_object.cpp @@ -70,12 +70,12 @@ bool fba_accumulator_object::is_configured( const database& db )const } const account_object& issuer_acct = dasset->issuer(db); - if( issuer_acct.owner_special_authority.which() != special_authority::tag< top_holders_special_authority >::value ) + if( !issuer_acct.owner_special_authority.is_type< top_holders_special_authority >() ) { ilog( "FBA fee in block ${b} not paid because of FBA misconfiguration: designated asset issuer has not set owner top_n control", ("b", db.head_block_num()) ); return false; } - if( issuer_acct.active_special_authority.which() != special_authority::tag< top_holders_special_authority >::value ) + if( !issuer_acct.active_special_authority.is_type< top_holders_special_authority >() ) { ilog( "FBA fee in block ${b} not paid because of FBA misconfiguration: designated asset issuer has not set active top_n control", ("b", db.head_block_num()) ); return false; diff --git a/libraries/chain/include/graphene/chain/account_object.hpp b/libraries/chain/include/graphene/chain/account_object.hpp index e1a480d6cc..4178da20a2 100644 --- a/libraries/chain/include/graphene/chain/account_object.hpp +++ b/libraries/chain/include/graphene/chain/account_object.hpp @@ -257,8 +257,8 @@ namespace graphene { namespace chain { bool has_special_authority()const { - return (owner_special_authority.which() != special_authority::tag< no_special_authority >::value) - || (active_special_authority.which() != special_authority::tag< no_special_authority >::value); + return (!owner_special_authority.is_type< no_special_authority >()) + || (!active_special_authority.is_type< no_special_authority >()); } template diff --git a/libraries/chain/proposal_evaluator.cpp b/libraries/chain/proposal_evaluator.cpp index 6f90206dc8..4e9a3ea656 100644 --- a/libraries/chain/proposal_evaluator.cpp +++ b/libraries/chain/proposal_evaluator.cpp @@ -118,7 +118,7 @@ struct proposal_operation_hardfork_visitor { op.op.visit(*this); // Do not allow more than 1 proposal_update in a proposal - if ( op.op.which() == operation::tag().value ) + if ( op.op.is_type() ) { FC_ASSERT( !already_contains_proposal_update, "At most one proposal update can be nested in a proposal!" ); already_contains_proposal_update = true; diff --git a/libraries/chain/vesting_balance_evaluator.cpp b/libraries/chain/vesting_balance_evaluator.cpp index 586045e4e6..5e99c316ea 100644 --- a/libraries/chain/vesting_balance_evaluator.cpp +++ b/libraries/chain/vesting_balance_evaluator.cpp @@ -35,7 +35,7 @@ namespace detail { { if( block_time < HARDFORK_1268_TIME ) { - FC_ASSERT( policy.which() != vesting_policy_initializer::tag::value, + FC_ASSERT( !policy.is_type(), "Instant vesting policy is only available after HARDFORK_1268_TIME!"); } } diff --git a/libraries/plugins/account_history/account_history_plugin.cpp b/libraries/plugins/account_history/account_history_plugin.cpp index 4697837faa..c3d0826077 100644 --- a/libraries/plugins/account_history/account_history_plugin.cpp +++ b/libraries/plugins/account_history/account_history_plugin.cpp @@ -130,7 +130,7 @@ void account_history_plugin_impl::update_account_histories( const signed_block& vector other; operation_get_required_authorities( op.op, impacted, impacted, other ); // fee_payer is added here - if( op.op.which() == operation::tag< account_create_operation >::value ) + if( op.op.is_type< account_create_operation >() ) impacted.insert( op.result.get() ); else graphene::chain::operation_get_impacted_accounts( op.op, impacted ); diff --git a/libraries/plugins/elasticsearch/elasticsearch_plugin.cpp b/libraries/plugins/elasticsearch/elasticsearch_plugin.cpp index 0719fc06b4..d6ee6d719a 100644 --- a/libraries/plugins/elasticsearch/elasticsearch_plugin.cpp +++ b/libraries/plugins/elasticsearch/elasticsearch_plugin.cpp @@ -156,7 +156,7 @@ bool elasticsearch_plugin_impl::update_account_histories( const signed_block& b vector other; operation_get_required_authorities( op.op, impacted, impacted, other ); // fee_payer is added here - if( op.op.which() == operation::tag< account_create_operation >::value ) + if( op.op.is_type< account_create_operation >() ) impacted.insert( op.result.get() ); else graphene::chain::operation_get_impacted_accounts( op.op, impacted ); From cac547a66d918a9bf18cb8287149e4fcbc7fd504 Mon Sep 17 00:00:00 2001 From: Alfredo Garcia Date: Wed, 12 Jun 2019 13:34:53 -0300 Subject: [PATCH 094/133] update comment --- libraries/chain/db_maint.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/chain/db_maint.cpp b/libraries/chain/db_maint.cpp index 59cb1c6041..4096068a8d 100644 --- a/libraries/chain/db_maint.cpp +++ b/libraries/chain/db_maint.cpp @@ -306,8 +306,8 @@ void database::update_active_committee_members() assert( _committee_count_histogram_buffer.size() > 0 ); share_type stake_target = (_total_voting_stake-_committee_count_histogram_buffer[0]) / 2; - /// accounts that vote for 0 or 1 witness do not get to express an opinion on - /// the number of witnesses to have (they abstain and are non-voting accounts) + /// accounts that vote for 0 or 1 committee member do not get to express an opinion on + /// the number of committee members to have (they abstain and are non-voting accounts) share_type stake_tally = 0; size_t committee_member_count = 0; if( stake_target > 0 ) From fa4c3244c0d2ffba81c8758fed302a8b45cd7dea Mon Sep 17 00:00:00 2001 From: Alfredo Garcia Date: Thu, 13 Jun 2019 17:18:44 -0300 Subject: [PATCH 095/133] fix duplicate results in get_key_references --- libraries/app/database_api.cpp | 15 +++++++-------- .../app/include/graphene/app/database_api.hpp | 2 +- .../wallet/include/graphene/wallet/wallet.hpp | 2 +- libraries/wallet/wallet.cpp | 4 ++-- tests/cli/main.cpp | 7 +++++-- tests/tests/database_api_tests.cpp | 2 +- 6 files changed, 17 insertions(+), 15 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index c09d301893..1bf916cecd 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -77,7 +77,7 @@ class database_api_impl : public std::enable_shared_from_this dynamic_global_property_object get_dynamic_global_properties()const; // Keys - vector> get_key_references( vector key )const; + vector> get_key_references( vector key )const; bool is_public_key_registered(string public_key) const; // Accounts @@ -679,7 +679,7 @@ dynamic_global_property_object database_api_impl::get_dynamic_global_properties( // // ////////////////////////////////////////////////////////////////////// -vector> database_api::get_key_references( vector key )const +vector> database_api::get_key_references( vector key )const { return my->get_key_references( key ); } @@ -687,7 +687,7 @@ vector> database_api::get_key_references( vector> database_api_impl::get_key_references( vector keys )const +vector> database_api_impl::get_key_references( vector keys )const { uint64_t api_limit_get_key_references=_app_options->api_limit_get_key_references; FC_ASSERT(keys.size() <= api_limit_get_key_references); @@ -695,12 +695,11 @@ vector> database_api_impl::get_key_references( vector(idx); const auto& refs = aidx.get_secondary_index(); - vector< vector > final_result; + vector< flat_set > final_result; final_result.reserve(keys.size()); for( auto& key : keys ) { - address a1( pts_address(key, false, 56) ); address a2( pts_address(key, true, 56) ); address a3( pts_address(key, false, 0) ); @@ -714,7 +713,7 @@ vector> database_api_impl::get_key_references( vector result; + flat_set result; for( auto& a : {a1,a2,a3,a4,a5} ) { @@ -724,7 +723,7 @@ vector> database_api_impl::get_key_references( vectorsecond.size() ); for( auto item : itr->second ) { - result.push_back(item); + result.insert(item); } } } @@ -733,7 +732,7 @@ vector> database_api_impl::get_key_references( vectorsecond.size() ); - for( auto item : itr->second ) result.push_back(item); + for( auto item : itr->second ) result.insert(item); } final_result.emplace_back( std::move(result) ); } diff --git a/libraries/app/include/graphene/app/database_api.hpp b/libraries/app/include/graphene/app/database_api.hpp index aebf628ce7..a485bf1d94 100644 --- a/libraries/app/include/graphene/app/database_api.hpp +++ b/libraries/app/include/graphene/app/database_api.hpp @@ -257,7 +257,7 @@ class database_api // Keys // ////////// - vector> get_key_references( vector key )const; + vector> get_key_references( vector key )const; /** * Determine whether a textual representation of a public key diff --git a/libraries/wallet/include/graphene/wallet/wallet.hpp b/libraries/wallet/include/graphene/wallet/wallet.hpp index f67f5caef5..200f6581fc 100644 --- a/libraries/wallet/include/graphene/wallet/wallet.hpp +++ b/libraries/wallet/include/graphene/wallet/wallet.hpp @@ -1634,7 +1634,7 @@ class wallet_api * @param keys public keys to search for related accounts * @return the set of related accounts */ - vector> get_key_references(const vector &keys) const; + vector> get_key_references(const vector &keys) const; /** Returns an uninitialized object representing a given blockchain operation. * diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 6189b4ae7d..c7e966dbe0 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -2216,7 +2216,7 @@ class wallet_api_impl return tx.get_signature_keys(_chain_id); } - vector> get_key_references(const vector &keys) const + vector> get_key_references(const vector &keys) const { return _remote_db->get_key_references(keys); } @@ -4080,7 +4080,7 @@ flat_set wallet_api::get_transaction_signers(const signed_trans return my->get_transaction_signers(tx); } FC_CAPTURE_AND_RETHROW( (tx) ) } -vector> wallet_api::get_key_references(const vector &keys) const +vector> wallet_api::get_key_references(const vector &keys) const { try { return my->get_key_references(keys); } FC_CAPTURE_AND_RETHROW( (keys) ) } diff --git a/tests/cli/main.cpp b/tests/cli/main.cpp index a31053753d..247532a0de 100644 --- a/tests/cli/main.cpp +++ b/tests/cli/main.cpp @@ -473,7 +473,7 @@ BOOST_FIXTURE_TEST_CASE( cli_get_signed_transaction_signers, cli_fixture ) const auto &test_acc = con.wallet_api_ptr->get_account("test"); flat_set expected_signers = {test_bki.pub_key}; - vector > expected_key_refs{{test_acc.id, test_acc.id}}; + vector > expected_key_refs{{test_acc.id, test_acc.id}}; auto signers = con.wallet_api_ptr->get_transaction_signers(signed_trx); BOOST_CHECK(signers == expected_signers); @@ -526,7 +526,10 @@ BOOST_FIXTURE_TEST_CASE( cli_get_available_transaction_signers, cli_fixture ) // blockchain has no references to unknown accounts (privkey_1, privkey_2) // only test account available - vector > expected_key_refs{{}, {}, {test_acc.id, test_acc.id}}; + vector > expected_key_refs; + expected_key_refs.push_back(flat_set()); + expected_key_refs.push_back(flat_set()); + expected_key_refs.push_back({test_acc.id}); auto key_refs = con.wallet_api_ptr->get_key_references({expected_signers.begin(), expected_signers.end()}); std::sort(key_refs.begin(), key_refs.end()); diff --git a/tests/tests/database_api_tests.cpp b/tests/tests/database_api_tests.cpp index a76759f54f..7a20496593 100644 --- a/tests/tests/database_api_tests.cpp +++ b/tests/tests/database_api_tests.cpp @@ -1105,7 +1105,7 @@ BOOST_AUTO_TEST_CASE( api_limit_get_key_references ){ numbered_private_keys.push_back( privkey ); numbered_key_id.push_back( pubkey ); } - vector< vector > final_result=db_api.get_key_references(numbered_key_id); + vector< flat_set > final_result=db_api.get_key_references(numbered_key_id); BOOST_REQUIRE_EQUAL( final_result.size(), 2u ); numbered_private_keys.reserve( num_keys ); for( int i=num_keys1; i Date: Fri, 14 Jun 2019 12:33:45 +0200 Subject: [PATCH 096/133] bump fc --- libraries/fc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/fc b/libraries/fc index ab9b4a234e..a87a99bbeb 160000 --- a/libraries/fc +++ b/libraries/fc @@ -1 +1 @@ -Subproject commit ab9b4a234e1cc4b1a6b4149757c646b6a9826515 +Subproject commit a87a99bbeba9467aa23f1b012e79908e20e87309 From 77bd51e39f27b101d089853b604afc1ad8d23132 Mon Sep 17 00:00:00 2001 From: Abit Date: Sat, 15 Jun 2019 14:17:33 +0200 Subject: [PATCH 097/133] Use debug logging level in database_api_impl --- libraries/app/database_api.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 3445e20a3f..286e06a7ba 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -370,7 +370,7 @@ database_api::~database_api() {} database_api_impl::database_api_impl( graphene::chain::database& db, const application_options* app_options ) :_db(db), _app_options(app_options) { - wlog("creating database api ${x}", ("x",int64_t(this)) ); + dlog("creating database api ${x}", ("x",int64_t(this)) ); _new_connection = _db.new_objects.connect([this](const vector& ids, const flat_set& impacted_accounts) { on_objects_new(ids, impacted_accounts); }); @@ -389,7 +389,7 @@ database_api_impl::database_api_impl( graphene::chain::database& db, const appli database_api_impl::~database_api_impl() { - elog("freeing database api ${x}", ("x",int64_t(this)) ); + dlog("freeing database api ${x}", ("x",int64_t(this)) ); } ////////////////////////////////////////////////////////////////////// From 980ce9ec4f98cfc1b98370b2638017e493dcc12b Mon Sep 17 00:00:00 2001 From: abitmore Date: Sun, 16 Jun 2019 07:57:54 -0400 Subject: [PATCH 098/133] Slightly improve market fee sharing performance --- libraries/chain/db_market.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/libraries/chain/db_market.cpp b/libraries/chain/db_market.cpp index de725369cf..c009d0b830 100644 --- a/libraries/chain/db_market.cpp +++ b/libraries/chain/db_market.cpp @@ -1248,16 +1248,20 @@ asset database::pay_market_fees(const account_object& seller, const asset_object reward = recv_asset.amount(reward_value); FC_ASSERT( reward < issuer_fees, "Market reward should be less than issuer fees"); // cut referrer percent from reward - const auto referrer_rewards_percentage = seller.referrer_rewards_percentage; - const auto referrer_rewards_value = detail::calculate_percent(reward.amount, referrer_rewards_percentage); auto registrar_reward = reward; - - if ( referrer_rewards_value > 0 && is_authorized_asset(*this, seller.referrer(*this), recv_asset)) + if( seller.referrer != seller.registrar ) { - FC_ASSERT ( referrer_rewards_value <= reward.amount.value, "Referrer reward shouldn't be greater than total reward" ); - const asset referrer_reward = recv_asset.amount(referrer_rewards_value); - registrar_reward -= referrer_reward; - deposit_market_fee_vesting_balance(seller.referrer, referrer_reward); + const auto referrer_rewards_value = detail::calculate_percent( reward.amount, + seller.referrer_rewards_percentage ); + + if ( referrer_rewards_value > 0 && is_authorized_asset(*this, seller.referrer(*this), recv_asset) ) + { + FC_ASSERT ( referrer_rewards_value <= reward.amount.value, + "Referrer reward shouldn't be greater than total reward" ); + const asset referrer_reward = recv_asset.amount(referrer_rewards_value); + registrar_reward -= referrer_reward; + deposit_market_fee_vesting_balance(seller.referrer, referrer_reward); + } } deposit_market_fee_vesting_balance(seller.registrar, registrar_reward); } From b8f8591ec47925e9533fdbaa231ae31d2bc6d901 Mon Sep 17 00:00:00 2001 From: Valera Cogut Date: Mon, 17 Jun 2019 17:39:35 +0300 Subject: [PATCH 099/133] Safer way to handle unlock command of cli_wallet #1171 --- programs/cli_wallet/main.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/programs/cli_wallet/main.cpp b/programs/cli_wallet/main.cpp index 31e5b870cf..fbd33fb26b 100644 --- a/programs/cli_wallet/main.cpp +++ b/programs/cli_wallet/main.cpp @@ -257,6 +257,9 @@ int main( int argc, char** argv ) if( !options.count( "daemon" ) ) { auto wallet_cli = std::make_shared( GRAPHENE_MAX_NESTED_OBJECTS ); + + wallet_cli->set_regex_secret("\\s*(unlock|set_password)\\s*"); + for( auto& name_formatter : wapiptr->get_result_formatters() ) wallet_cli->format_result( name_formatter.first, name_formatter.second ); From 71fbb65f432c3c854ca01f61467eec6cbfac3c20 Mon Sep 17 00:00:00 2001 From: abitmore Date: Wed, 24 Apr 2019 05:50:23 -0400 Subject: [PATCH 100/133] Add set_auto_subscription API --- libraries/app/database_api.cpp | 58 ++++++++++++------- .../app/include/graphene/app/database_api.hpp | 18 ++++++ 2 files changed, 56 insertions(+), 20 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 286e06a7ba..19c33def45 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -63,6 +63,7 @@ class database_api_impl : public std::enable_shared_from_this // Subscriptions void set_subscribe_callback( std::function cb, bool notify_remove_create ); + void set_auto_subscription( bool enable ); void set_pending_transaction_callback( std::function cb ); void set_block_applied_callback( std::function cb ); void cancel_all_subscriptions(bool reset_callback, bool reset_market_subscriptions); @@ -189,12 +190,14 @@ class database_api_impl : public std::enable_shared_from_this template void subscribe_to_item( const T& i )const { - auto vec = fc::raw::pack(i); if( !_subscribe_callback ) return; if( !is_subscribed_to_item(i) ) + { + auto vec = fc::raw::pack(i); _subscribe_filter.insert( vec.data(), vec.size() ); + } } template @@ -269,7 +272,8 @@ class database_api_impl : public std::enable_shared_from_this [this](asset_id_type id) -> optional { if(auto o = _db.find(id)) { - subscribe_to_item( id ); + if( _enabled_auto_subscription ) + subscribe_to_item( id ); return *o; } return {}; @@ -345,6 +349,7 @@ class database_api_impl : public std::enable_shared_from_this std::function _subscribe_callback; std::function _pending_trx_callback; std::function _block_applied_callback; + bool _enabled_auto_subscription = true; boost::signals2::scoped_connection _new_connection; boost::signals2::scoped_connection _change_connection; @@ -470,12 +475,12 @@ fc::variants database_api::get_objects(const vector& ids)const fc::variants database_api_impl::get_objects(const vector& ids)const { - if( _subscribe_callback ) { + if( _subscribe_callback && _enabled_auto_subscription ) + { for( auto id : ids ) { if( id.type() == operation_history_object_type && id.space() == protocol_ids ) continue; if( id.type() == impl_account_transaction_history_object_type && id.space() == implementation_ids ) continue; - this->subscribe_to_item( id ); } } @@ -518,6 +523,16 @@ void database_api_impl::set_subscribe_callback( std::functionset_auto_subscription( enable ); +} + +void database_api_impl::set_auto_subscription( bool enable ) +{ + _enabled_auto_subscription = enable; +} + void database_api::set_pending_transaction_callback( std::function cb ) { my->set_pending_transaction_callback( cb ); @@ -711,12 +726,15 @@ vector> database_api_impl::get_key_references( vector< address a4( pts_address(key, true, 0) ); address a5( key ); - subscribe_to_item( key ); - subscribe_to_item( a1 ); - subscribe_to_item( a2 ); - subscribe_to_item( a3 ); - subscribe_to_item( a4 ); - subscribe_to_item( a5 ); + if( _enabled_auto_subscription ) + { + subscribe_to_item( key ); + subscribe_to_item( a1 ); + subscribe_to_item( a2 ); + subscribe_to_item( a3 ); + subscribe_to_item( a4 ); + subscribe_to_item( a5 ); + } flat_set result; @@ -799,8 +817,8 @@ vector> database_api_impl::get_accounts(const vectorid; - subscribe_to_item( id ); + if( _enabled_auto_subscription ) + subscribe_to_item( account->id ); return *account; }); return result; @@ -1129,7 +1147,7 @@ map database_api_impl::lookup_accounts(const string& low ++itr ) { result.insert(make_pair(itr->name, itr->get_id())); - if( limit == 1 ) + if( limit == 1 && _enabled_auto_subscription ) subscribe_to_item( itr->get_id() ); } @@ -1202,7 +1220,8 @@ vector database_api_impl::get_balance_objects( const vectorowner == owner ) { @@ -1276,13 +1295,12 @@ vector> database_api_impl::get_assets(const vector optional { - const asset_object* asset = get_asset_from_string(id_or_name, false); - if(asset == nullptr) + const asset_object* asset_obj = get_asset_from_string( id_or_name, false ); + if( asset_obj == nullptr ) return {}; - asset_id_type id = asset->id; - subscribe_to_item( id ); - return *asset; - + if( _enabled_auto_subscription ) + subscribe_to_item( asset_obj->id ); + return *asset_obj; }); return result; } diff --git a/libraries/app/include/graphene/app/database_api.hpp b/libraries/app/include/graphene/app/database_api.hpp index 14254745e9..e777faa121 100644 --- a/libraries/app/include/graphene/app/database_api.hpp +++ b/libraries/app/include/graphene/app/database_api.hpp @@ -163,8 +163,26 @@ class database_api * newly removed objects to the client, no matter whether client subscribed to the objects. * By default, API servers don't allow subscribing to universal events, which can be changed * on server startup. + * + * Note: auto-subscription is enabled by default and can be disabled with "set_auto_subscription" API. */ void set_subscribe_callback( std::function cb, bool notify_remove_create ); + /** + * @brief Set auto-subscription behavior of follow-up API queries + * @param enable whether follow-up API queries will automatically subscribe to queried objects + * + * Impacts behavior of these APIs: + * - get_accounts + * - get_assets + * - get_balance_objects + * - get_key_references + * - get_objects + * - lookup_accounts + * + * Does not impact this API: + * - get_full_accounts + */ + void set_auto_subscription( bool enable ); /** * @brief Register a callback handle which will get notified when a transaction is pushed to database * @param cb The callback handle to register From 9cbbd672283ef145375cdc26e2c77694354694c8 Mon Sep 17 00:00:00 2001 From: abitmore Date: Wed, 24 Apr 2019 05:55:12 -0400 Subject: [PATCH 101/133] Reflect set_auto_subscription API --- libraries/app/include/graphene/app/database_api.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/app/include/graphene/app/database_api.hpp b/libraries/app/include/graphene/app/database_api.hpp index e777faa121..f4edd697c5 100644 --- a/libraries/app/include/graphene/app/database_api.hpp +++ b/libraries/app/include/graphene/app/database_api.hpp @@ -844,6 +844,7 @@ FC_API(graphene::app::database_api, // Subscriptions (set_subscribe_callback) + (set_auto_subscription) (set_pending_transaction_callback) (set_block_applied_callback) (cancel_all_subscriptions) From 294f6f8f4a08f6d5666857a773da4cc2b1edefdc Mon Sep 17 00:00:00 2001 From: abitmore Date: Wed, 24 Apr 2019 07:48:24 -0400 Subject: [PATCH 102/133] Fix subscription key collision --- libraries/app/database_api.cpp | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 19c33def45..d3dbb384ce 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -187,26 +187,44 @@ class database_api_impl : public std::enable_shared_from_this //private: static string price_to_string( const price& _price, const asset_object& _base, const asset_object& _quote ); + // Note: + // Different type of object_id objects could become identical after packed. + // For example, both `account_id_type a=1.2.0` and `asset_id_type b=1.3.0` will become `0` after packed. + // In order to avoid collision, here we explicitly list a few types, rather than using a template. + vector get_subscription_key( const object_id_type& item )const + { + return fc::raw::pack(item); + } + vector get_subscription_key( const public_key_type& item )const + { + return fc::raw::pack(item); + } + vector get_subscription_key( const address& item )const + { + return fc::raw::pack(item); + } + template - void subscribe_to_item( const T& i )const + void subscribe_to_item( const T& item )const { if( !_subscribe_callback ) return; - if( !is_subscribed_to_item(i) ) + vector key = get_subscription_key( item ); + if( !_subscribe_filter.contains( key.data(), key.size() ) ) { - auto vec = fc::raw::pack(i); - _subscribe_filter.insert( vec.data(), vec.size() ); + _subscribe_filter.insert( key.data(), key.size() ); } } template - bool is_subscribed_to_item( const T& i )const + bool is_subscribed_to_item( const T& item )const { if( !_subscribe_callback ) return false; - return _subscribe_filter.contains( i ); + vector key = get_subscription_key( item ); + return _subscribe_filter.contains( key.data(), key.size() ); } bool is_impacted_account( const flat_set& accounts) From 6355a4316bf91ee8b000b63a3345a65ec0a6c41b Mon Sep 17 00:00:00 2001 From: abitmore Date: Wed, 24 Apr 2019 13:27:15 -0400 Subject: [PATCH 103/133] Fix auto-subscription issue in lookup_accounts API --- libraries/app/database_api.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index d3dbb384ce..566bb71640 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -1160,12 +1160,16 @@ map database_api_impl::lookup_accounts(const string& low const auto& accounts_by_name = _db.get_index_type().indices().get(); map result; + if( limit == 0 ) // shortcut to save a database query + return result; + + bool to_subscribe = (limit == 1 && _enabled_auto_subscription); // auto-subscribe if only look for one account for( auto itr = accounts_by_name.lower_bound(lower_bound_name); limit-- && itr != accounts_by_name.end(); ++itr ) { result.insert(make_pair(itr->name, itr->get_id())); - if( limit == 1 && _enabled_auto_subscription ) + if( to_subscribe ) subscribe_to_item( itr->get_id() ); } From 30b22e2a314c031563f51313a8b0ae1a5327a647 Mon Sep 17 00:00:00 2001 From: abitmore Date: Wed, 24 Apr 2019 17:02:57 -0400 Subject: [PATCH 104/133] Update disable_notify_all_test and add comments --- tests/tests/database_api_tests.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/tests/tests/database_api_tests.cpp b/tests/tests/database_api_tests.cpp index 8dd84270a6..7e70f51372 100644 --- a/tests/tests/database_api_tests.cpp +++ b/tests/tests/database_api_tests.cpp @@ -787,7 +787,7 @@ BOOST_AUTO_TEST_CASE( set_subscribe_callback_disable_notify_all_test ) opt.enable_subscribe_to_all = true; graphene::app::database_api db_api2( db, &opt ); - db_api2.set_subscribe_callback( callback2, true ); + db_api2.set_subscribe_callback( callback2, true ); // subscribing to all should succeed graphene::app::database_api db_api3( db, &opt ); db_api3.set_subscribe_callback( callback3, false ); @@ -796,15 +796,24 @@ BOOST_AUTO_TEST_CASE( set_subscribe_callback_disable_notify_all_test ) ids.push_back( alice_id ); db_api1.get_objects( ids ); // db_api1 subscribe to Alice - db_api2.get_objects( ids ); // db_api2 subscribe to Alice generate_block(); - ++expected_objects_changed2; // subscribed to all, notify block changes + ++expected_objects_changed1; // db_api1 subscribed to Alice, notify Alice account creation + ++expected_objects_changed2; // db_api2 subscribed to all, notify new objects + // db_api3 didn't subscribe to anything, nothing would be notified + + fc::usleep(fc::milliseconds(200)); // sleep a while to execute callback in another thread + + BOOST_CHECK_EQUAL( expected_objects_changed1, objects_changed1 ); + BOOST_CHECK_EQUAL( expected_objects_changed2, objects_changed2 ); + BOOST_CHECK_EQUAL( expected_objects_changed3, objects_changed3 ); transfer( account_id_type(), alice_id, asset(1) ); generate_block(); - ++expected_objects_changed1; // subscribed to Alice, notify Alice balance change - ++expected_objects_changed2; // subscribed to all, notify block changes + // db_api1 didn't subscribe to Alice with get_full_accounts but only subscribed to the account object, + // nothing would be notified + ++expected_objects_changed2; // db_api2 subscribed to all, notify new balance object and etc + // db_api3 didn't subscribe to anything, nothing would be notified fc::usleep(fc::milliseconds(200)); // sleep a while to execute callback in another thread From 6901250404d6886dbce1263416ac3b194f1e8d5f Mon Sep 17 00:00:00 2001 From: abitmore Date: Wed, 24 Apr 2019 19:08:40 -0400 Subject: [PATCH 105/133] Add subscription tests for get_accounts and lookup_accounts --- tests/tests/database_api_tests.cpp | 52 ++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 3 deletions(-) diff --git a/tests/tests/database_api_tests.cpp b/tests/tests/database_api_tests.cpp index 7e70f51372..82c8238e50 100644 --- a/tests/tests/database_api_tests.cpp +++ b/tests/tests/database_api_tests.cpp @@ -751,14 +751,17 @@ BOOST_AUTO_TEST_CASE( get_required_signatures_partially_signed_or_not ) } FC_LOG_AND_RETHROW() } -BOOST_AUTO_TEST_CASE( set_subscribe_callback_disable_notify_all_test ) +BOOST_AUTO_TEST_CASE( subscription_notification_test ) { try { - ACTORS( (alice) ); + ACTORS( (alice)(bob) ); uint32_t objects_changed1 = 0; uint32_t objects_changed2 = 0; uint32_t objects_changed3 = 0; + uint32_t objects_changed4 = 0; + uint32_t objects_changed5 = 0; + uint32_t objects_changed6 = 0; auto callback1 = [&]( const variant& v ) { ++objects_changed1; @@ -771,10 +774,25 @@ BOOST_AUTO_TEST_CASE( set_subscribe_callback_disable_notify_all_test ) { ++objects_changed3; }; + auto callback4 = [&]( const variant& v ) + { + ++objects_changed4; + }; + auto callback5 = [&]( const variant& v ) + { + ++objects_changed5; + }; + auto callback6 = [&]( const variant& v ) + { + ++objects_changed6; + }; uint32_t expected_objects_changed1 = 0; uint32_t expected_objects_changed2 = 0; uint32_t expected_objects_changed3 = 0; + uint32_t expected_objects_changed4 = 0; + uint32_t expected_objects_changed5 = 0; + uint32_t expected_objects_changed6 = 0; graphene::app::database_api db_api1(db); @@ -792,21 +810,43 @@ BOOST_AUTO_TEST_CASE( set_subscribe_callback_disable_notify_all_test ) graphene::app::database_api db_api3( db, &opt ); db_api3.set_subscribe_callback( callback3, false ); + graphene::app::database_api db_api4( db, &opt ); + db_api4.set_subscribe_callback( callback4, false ); + + graphene::app::database_api db_api5( db, &opt ); + db_api5.set_subscribe_callback( callback5, false ); + + graphene::app::database_api db_api6( db, &opt ); + db_api6.set_subscribe_callback( callback6, false ); + vector ids; ids.push_back( alice_id ); - db_api1.get_objects( ids ); // db_api1 subscribe to Alice + vector account_names; + account_names.push_back( "alice" ); + db_api4.get_accounts( account_names ); // db_api4 subscribe to Alice + + db_api5.lookup_accounts( "ali", 1 ); // db_api5 subscribe to Alice + + db_api6.lookup_accounts( "alice", 3 ); // db_api6 does not subscribe to Alice + generate_block(); ++expected_objects_changed1; // db_api1 subscribed to Alice, notify Alice account creation ++expected_objects_changed2; // db_api2 subscribed to all, notify new objects // db_api3 didn't subscribe to anything, nothing would be notified + ++expected_objects_changed4; // db_api4 subscribed to Alice, notify Alice account creation + ++expected_objects_changed5; // db_api4 subscribed to Alice, notify Alice account creation + // db_api6 didn't subscribe to anything, nothing would be notified fc::usleep(fc::milliseconds(200)); // sleep a while to execute callback in another thread BOOST_CHECK_EQUAL( expected_objects_changed1, objects_changed1 ); BOOST_CHECK_EQUAL( expected_objects_changed2, objects_changed2 ); BOOST_CHECK_EQUAL( expected_objects_changed3, objects_changed3 ); + BOOST_CHECK_EQUAL( expected_objects_changed4, objects_changed4 ); + BOOST_CHECK_EQUAL( expected_objects_changed5, objects_changed5 ); + BOOST_CHECK_EQUAL( expected_objects_changed6, objects_changed6 ); transfer( account_id_type(), alice_id, asset(1) ); generate_block(); @@ -814,12 +854,18 @@ BOOST_AUTO_TEST_CASE( set_subscribe_callback_disable_notify_all_test ) // nothing would be notified ++expected_objects_changed2; // db_api2 subscribed to all, notify new balance object and etc // db_api3 didn't subscribe to anything, nothing would be notified + // db_api4 only subscribed to the account object of Alice, nothing notified + // db_api5 only subscribed to the account object of Alice, nothing notified + // db_api6 didn't subscribe to anything, nothing would be notified fc::usleep(fc::milliseconds(200)); // sleep a while to execute callback in another thread BOOST_CHECK_EQUAL( expected_objects_changed1, objects_changed1 ); BOOST_CHECK_EQUAL( expected_objects_changed2, objects_changed2 ); BOOST_CHECK_EQUAL( expected_objects_changed3, objects_changed3 ); + BOOST_CHECK_EQUAL( expected_objects_changed4, objects_changed4 ); + BOOST_CHECK_EQUAL( expected_objects_changed5, objects_changed5 ); + BOOST_CHECK_EQUAL( expected_objects_changed6, objects_changed6 ); } FC_LOG_AND_RETHROW() } From b079d5abf21d5f7f24b4d7a0573b9afb8dc2e43d Mon Sep 17 00:00:00 2001 From: abitmore Date: Wed, 24 Apr 2019 19:37:17 -0400 Subject: [PATCH 106/133] Add subscription tests for get_assets --- tests/tests/database_api_tests.cpp | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/tests/tests/database_api_tests.cpp b/tests/tests/database_api_tests.cpp index 82c8238e50..05e27cad34 100644 --- a/tests/tests/database_api_tests.cpp +++ b/tests/tests/database_api_tests.cpp @@ -756,12 +756,15 @@ BOOST_AUTO_TEST_CASE( subscription_notification_test ) try { ACTORS( (alice)(bob) ); + create_user_issued_asset( "UIATEST" ); + uint32_t objects_changed1 = 0; uint32_t objects_changed2 = 0; uint32_t objects_changed3 = 0; uint32_t objects_changed4 = 0; uint32_t objects_changed5 = 0; uint32_t objects_changed6 = 0; + uint32_t objects_changed7 = 0; auto callback1 = [&]( const variant& v ) { ++objects_changed1; @@ -786,6 +789,10 @@ BOOST_AUTO_TEST_CASE( subscription_notification_test ) { ++objects_changed6; }; + auto callback7 = [&]( const variant& v ) + { + ++objects_changed7; + }; uint32_t expected_objects_changed1 = 0; uint32_t expected_objects_changed2 = 0; @@ -793,6 +800,7 @@ BOOST_AUTO_TEST_CASE( subscription_notification_test ) uint32_t expected_objects_changed4 = 0; uint32_t expected_objects_changed5 = 0; uint32_t expected_objects_changed6 = 0; + uint32_t expected_objects_changed7 = 0; graphene::app::database_api db_api1(db); @@ -819,9 +827,12 @@ BOOST_AUTO_TEST_CASE( subscription_notification_test ) graphene::app::database_api db_api6( db, &opt ); db_api6.set_subscribe_callback( callback6, false ); - vector ids; - ids.push_back( alice_id ); - db_api1.get_objects( ids ); // db_api1 subscribe to Alice + graphene::app::database_api db_api7( db, &opt ); + db_api7.set_subscribe_callback( callback7, false ); + + vector account_ids; + account_ids.push_back( alice_id ); + db_api1.get_objects( account_ids ); // db_api1 subscribe to Alice vector account_names; account_names.push_back( "alice" ); @@ -831,13 +842,18 @@ BOOST_AUTO_TEST_CASE( subscription_notification_test ) db_api6.lookup_accounts( "alice", 3 ); // db_api6 does not subscribe to Alice + vector asset_names; + asset_names.push_back( "UIATEST" ); + db_api7.get_assets( asset_names ); // db_api7 subscribe to UIA + generate_block(); ++expected_objects_changed1; // db_api1 subscribed to Alice, notify Alice account creation ++expected_objects_changed2; // db_api2 subscribed to all, notify new objects // db_api3 didn't subscribe to anything, nothing would be notified ++expected_objects_changed4; // db_api4 subscribed to Alice, notify Alice account creation - ++expected_objects_changed5; // db_api4 subscribed to Alice, notify Alice account creation + ++expected_objects_changed5; // db_api5 subscribed to Alice, notify Alice account creation // db_api6 didn't subscribe to anything, nothing would be notified + ++expected_objects_changed7; // db_api7 subscribed to UIA, notify asset creation fc::usleep(fc::milliseconds(200)); // sleep a while to execute callback in another thread @@ -847,6 +863,7 @@ BOOST_AUTO_TEST_CASE( subscription_notification_test ) BOOST_CHECK_EQUAL( expected_objects_changed4, objects_changed4 ); BOOST_CHECK_EQUAL( expected_objects_changed5, objects_changed5 ); BOOST_CHECK_EQUAL( expected_objects_changed6, objects_changed6 ); + BOOST_CHECK_EQUAL( expected_objects_changed7, objects_changed7 ); transfer( account_id_type(), alice_id, asset(1) ); generate_block(); @@ -857,6 +874,7 @@ BOOST_AUTO_TEST_CASE( subscription_notification_test ) // db_api4 only subscribed to the account object of Alice, nothing notified // db_api5 only subscribed to the account object of Alice, nothing notified // db_api6 didn't subscribe to anything, nothing would be notified + // db_api7: no change on UIA, nothing would be notified fc::usleep(fc::milliseconds(200)); // sleep a while to execute callback in another thread @@ -866,6 +884,7 @@ BOOST_AUTO_TEST_CASE( subscription_notification_test ) BOOST_CHECK_EQUAL( expected_objects_changed4, objects_changed4 ); BOOST_CHECK_EQUAL( expected_objects_changed5, objects_changed5 ); BOOST_CHECK_EQUAL( expected_objects_changed6, objects_changed6 ); + BOOST_CHECK_EQUAL( expected_objects_changed7, objects_changed7 ); } FC_LOG_AND_RETHROW() } From 2310367ff461fd57cfda99c6898f0c7cc97f364a Mon Sep 17 00:00:00 2001 From: abitmore Date: Wed, 24 Apr 2019 20:35:03 -0400 Subject: [PATCH 107/133] No longer subscribe to keys or addresses --- libraries/app/database_api.cpp | 20 ------------------- .../app/include/graphene/app/database_api.hpp | 2 -- 2 files changed, 22 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 566bb71640..3d3c709227 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -195,14 +195,6 @@ class database_api_impl : public std::enable_shared_from_this { return fc::raw::pack(item); } - vector get_subscription_key( const public_key_type& item )const - { - return fc::raw::pack(item); - } - vector get_subscription_key( const address& item )const - { - return fc::raw::pack(item); - } template void subscribe_to_item( const T& item )const @@ -744,16 +736,6 @@ vector> database_api_impl::get_key_references( vector< address a4( pts_address(key, true, 0) ); address a5( key ); - if( _enabled_auto_subscription ) - { - subscribe_to_item( key ); - subscribe_to_item( a1 ); - subscribe_to_item( a2 ); - subscribe_to_item( a3 ); - subscribe_to_item( a4 ); - subscribe_to_item( a5 ); - } - flat_set result; for( auto& a : {a1,a2,a3,a4,a5} ) @@ -1242,8 +1224,6 @@ vector database_api_impl::get_balance_objects( const vectorowner == owner ) { diff --git a/libraries/app/include/graphene/app/database_api.hpp b/libraries/app/include/graphene/app/database_api.hpp index f4edd697c5..13734e751b 100644 --- a/libraries/app/include/graphene/app/database_api.hpp +++ b/libraries/app/include/graphene/app/database_api.hpp @@ -174,8 +174,6 @@ class database_api * Impacts behavior of these APIs: * - get_accounts * - get_assets - * - get_balance_objects - * - get_key_references * - get_objects * - lookup_accounts * From 247da40579f800da5b0bc3831396ced89ec35637 Mon Sep 17 00:00:00 2001 From: abitmore Date: Thu, 25 Apr 2019 06:34:47 -0400 Subject: [PATCH 108/133] Use boost preprocessor macros in subscription test --- tests/tests/database_api_tests.cpp | 93 +++++++++--------------------- 1 file changed, 27 insertions(+), 66 deletions(-) diff --git a/tests/tests/database_api_tests.cpp b/tests/tests/database_api_tests.cpp index 05e27cad34..8b89aa0842 100644 --- a/tests/tests/database_api_tests.cpp +++ b/tests/tests/database_api_tests.cpp @@ -758,49 +758,28 @@ BOOST_AUTO_TEST_CASE( subscription_notification_test ) create_user_issued_asset( "UIATEST" ); - uint32_t objects_changed1 = 0; - uint32_t objects_changed2 = 0; - uint32_t objects_changed3 = 0; - uint32_t objects_changed4 = 0; - uint32_t objects_changed5 = 0; - uint32_t objects_changed6 = 0; - uint32_t objects_changed7 = 0; - auto callback1 = [&]( const variant& v ) - { - ++objects_changed1; - }; - auto callback2 = [&]( const variant& v ) - { - ++objects_changed2; - }; - auto callback3 = [&]( const variant& v ) - { - ++objects_changed3; - }; - auto callback4 = [&]( const variant& v ) - { - ++objects_changed4; - }; - auto callback5 = [&]( const variant& v ) - { - ++objects_changed5; - }; - auto callback6 = [&]( const variant& v ) - { - ++objects_changed6; - }; - auto callback7 = [&]( const variant& v ) +#define SUB_NOTIF_TEST_NUM_CALLBACKS_PLUS_ONE 8 + +#define SUB_NOTIF_TEST_INIT_CALLBACKS(z, i, data) \ + uint32_t objects_changed ## i = 0; \ + auto callback ## i = [&]( const variant& v ) \ + { \ + ++objects_changed ## i; \ + }; \ + uint32_t expected_objects_changed ## i = 0; + +#define SUB_NOTIF_TEST_CHECK(z, i, data) \ + BOOST_CHECK_EQUAL( expected_objects_changed ## i, objects_changed ## i ); + + BOOST_PP_REPEAT_FROM_TO( 1, SUB_NOTIF_TEST_NUM_CALLBACKS_PLUS_ONE, SUB_NOTIF_TEST_INIT_CALLBACKS, unused ); + + auto check_results = [&]() { - ++objects_changed7; + BOOST_PP_REPEAT_FROM_TO( 1, SUB_NOTIF_TEST_NUM_CALLBACKS_PLUS_ONE, SUB_NOTIF_TEST_CHECK, unused ); }; - uint32_t expected_objects_changed1 = 0; - uint32_t expected_objects_changed2 = 0; - uint32_t expected_objects_changed3 = 0; - uint32_t expected_objects_changed4 = 0; - uint32_t expected_objects_changed5 = 0; - uint32_t expected_objects_changed6 = 0; - uint32_t expected_objects_changed7 = 0; +#undef SUB_NOTIF_TEST_CHECK +#undef SUB_NOTIF_TEST_INIT_CALLBACKS graphene::app::database_api db_api1(db); @@ -815,20 +794,14 @@ BOOST_AUTO_TEST_CASE( subscription_notification_test ) graphene::app::database_api db_api2( db, &opt ); db_api2.set_subscribe_callback( callback2, true ); // subscribing to all should succeed - graphene::app::database_api db_api3( db, &opt ); - db_api3.set_subscribe_callback( callback3, false ); - - graphene::app::database_api db_api4( db, &opt ); - db_api4.set_subscribe_callback( callback4, false ); - - graphene::app::database_api db_api5( db, &opt ); - db_api5.set_subscribe_callback( callback5, false ); +#define SUB_NOTIF_TEST_INIT_APIS(z, i, data) \ + graphene::app::database_api db_api ## i( db, &opt ); \ + db_api ## i.set_subscribe_callback( callback ## i, false ); - graphene::app::database_api db_api6( db, &opt ); - db_api6.set_subscribe_callback( callback6, false ); + BOOST_PP_REPEAT_FROM_TO( 3, SUB_NOTIF_TEST_NUM_CALLBACKS_PLUS_ONE, SUB_NOTIF_TEST_INIT_APIS, unused ); - graphene::app::database_api db_api7( db, &opt ); - db_api7.set_subscribe_callback( callback7, false ); +#undef SUB_NOTIF_TEST_INIT_APIS +#undef SUB_NOTIF_TEST_NUM_CALLBACKS_PLUS_ONE vector account_ids; account_ids.push_back( alice_id ); @@ -857,13 +830,7 @@ BOOST_AUTO_TEST_CASE( subscription_notification_test ) fc::usleep(fc::milliseconds(200)); // sleep a while to execute callback in another thread - BOOST_CHECK_EQUAL( expected_objects_changed1, objects_changed1 ); - BOOST_CHECK_EQUAL( expected_objects_changed2, objects_changed2 ); - BOOST_CHECK_EQUAL( expected_objects_changed3, objects_changed3 ); - BOOST_CHECK_EQUAL( expected_objects_changed4, objects_changed4 ); - BOOST_CHECK_EQUAL( expected_objects_changed5, objects_changed5 ); - BOOST_CHECK_EQUAL( expected_objects_changed6, objects_changed6 ); - BOOST_CHECK_EQUAL( expected_objects_changed7, objects_changed7 ); + check_results(); transfer( account_id_type(), alice_id, asset(1) ); generate_block(); @@ -878,13 +845,7 @@ BOOST_AUTO_TEST_CASE( subscription_notification_test ) fc::usleep(fc::milliseconds(200)); // sleep a while to execute callback in another thread - BOOST_CHECK_EQUAL( expected_objects_changed1, objects_changed1 ); - BOOST_CHECK_EQUAL( expected_objects_changed2, objects_changed2 ); - BOOST_CHECK_EQUAL( expected_objects_changed3, objects_changed3 ); - BOOST_CHECK_EQUAL( expected_objects_changed4, objects_changed4 ); - BOOST_CHECK_EQUAL( expected_objects_changed5, objects_changed5 ); - BOOST_CHECK_EQUAL( expected_objects_changed6, objects_changed6 ); - BOOST_CHECK_EQUAL( expected_objects_changed7, objects_changed7 ); + check_results(); } FC_LOG_AND_RETHROW() } From 271ee7ef645702db67a552996152920d8e8f0239 Mon Sep 17 00:00:00 2001 From: abitmore Date: Thu, 25 Apr 2019 06:37:59 -0400 Subject: [PATCH 109/133] Remove trailing white spaces --- tests/tests/database_api_tests.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/tests/database_api_tests.cpp b/tests/tests/database_api_tests.cpp index 8b89aa0842..978aefc252 100644 --- a/tests/tests/database_api_tests.cpp +++ b/tests/tests/database_api_tests.cpp @@ -1016,10 +1016,10 @@ BOOST_AUTO_TEST_CASE( get_transaction_hex ) } FC_LOG_AND_RETHROW() } -BOOST_AUTO_TEST_CASE(verify_account_authority) +BOOST_AUTO_TEST_CASE(verify_account_authority) { try { - + ACTORS( (nathan) ); graphene::app::database_api db_api(db); @@ -1049,7 +1049,7 @@ BOOST_AUTO_TEST_CASE( any_two_of_three ) try { account_update_operation op; op.account = nathan.id; - op.active = authority(2, public_key_type(nathan_key1.get_public_key()), 1, + op.active = authority(2, public_key_type(nathan_key1.get_public_key()), 1, public_key_type(nathan_key2.get_public_key()), 1, public_key_type(nathan_key3.get_public_key()), 1); op.owner = *op.active; trx.operations.push_back(op); From c2c4f721293b1378d5dbe08ffae0c94f24938426 Mon Sep 17 00:00:00 2001 From: abitmore Date: Thu, 25 Apr 2019 08:04:50 -0400 Subject: [PATCH 110/133] Add tests for set_auto_subscription API --- tests/tests/database_api_tests.cpp | 100 ++++++++++++++++++++++++++++- 1 file changed, 98 insertions(+), 2 deletions(-) diff --git a/tests/tests/database_api_tests.cpp b/tests/tests/database_api_tests.cpp index 978aefc252..0fa941ceac 100644 --- a/tests/tests/database_api_tests.cpp +++ b/tests/tests/database_api_tests.cpp @@ -764,12 +764,19 @@ BOOST_AUTO_TEST_CASE( subscription_notification_test ) uint32_t objects_changed ## i = 0; \ auto callback ## i = [&]( const variant& v ) \ { \ + idump((i)(v)); \ ++objects_changed ## i; \ }; \ uint32_t expected_objects_changed ## i = 0; #define SUB_NOTIF_TEST_CHECK(z, i, data) \ - BOOST_CHECK_EQUAL( expected_objects_changed ## i, objects_changed ## i ); + if( expected_objects_changed ## i > 0 ) { \ + BOOST_CHECK_LE( expected_objects_changed ## i, objects_changed ## i ); \ + } else { \ + BOOST_CHECK_EQUAL( expected_objects_changed ## i, objects_changed ## i ); \ + } \ + expected_objects_changed ## i = 0; \ + objects_changed ## i = 0; BOOST_PP_REPEAT_FROM_TO( 1, SUB_NOTIF_TEST_NUM_CALLBACKS_PLUS_ONE, SUB_NOTIF_TEST_INIT_CALLBACKS, unused ); @@ -829,7 +836,6 @@ BOOST_AUTO_TEST_CASE( subscription_notification_test ) ++expected_objects_changed7; // db_api7 subscribed to UIA, notify asset creation fc::usleep(fc::milliseconds(200)); // sleep a while to execute callback in another thread - check_results(); transfer( account_id_type(), alice_id, asset(1) ); @@ -844,7 +850,97 @@ BOOST_AUTO_TEST_CASE( subscription_notification_test ) // db_api7: no change on UIA, nothing would be notified fc::usleep(fc::milliseconds(200)); // sleep a while to execute callback in another thread + check_results(); + + vector obj_ids; + obj_ids.push_back( db.get_dynamic_global_properties().id ); + db_api3.get_objects( obj_ids ); // db_api3 subscribe to dynamic global properties + + db_api4.get_full_accounts( account_names, true ); // db_api4 subscribe to Alice with get_full_accounts + db_api5.get_full_accounts( account_names, false ); // db_api5 doesn't subscribe + + transfer( account_id_type(), alice_id, asset(1) ); + generate_block(); + // db_api1 didn't subscribe to Alice with get_full_accounts but only subscribed to the account object, + // nothing would be notified + ++expected_objects_changed2; // db_api2 subscribed to all, notify new history records and etc + ++expected_objects_changed3; // db_api3 subscribed to dynamic global properties, would be notified + ++expected_objects_changed4; // db_api4 subscribed to full account data of Alice, would be notified + // db_api5 only subscribed to the account object of Alice, nothing notified + // db_api6 didn't subscribe to anything, nothing would be notified + // db_api7: no change on UIA, nothing would be notified + + fc::usleep(fc::milliseconds(200)); // sleep a while to execute callback in another thread + check_results(); + + db_api6.set_auto_subscription( false ); + db_api6.get_objects( obj_ids ); // db_api6 doesn't auto-subscribe to dynamic global properties + + generate_block(); + // db_api1 only subscribed to the account object of Alice, nothing notified + // db_api2 subscribed to all, but no object is created or removed in this block, so nothing notified + ++expected_objects_changed3; // db_api3 subscribed to dynamic global properties, would be notified + // db_api4 subscribed to full account data of Alice, nothing would be notified + // db_api5 only subscribed to the account object of Alice, nothing notified + // db_api6 didn't subscribe to anything, nothing would be notified + // db_api7: no change on UIA, nothing would be notified + + fc::usleep(fc::milliseconds(200)); // sleep a while to execute callback in another thread + check_results(); + + account_names.clear(); + account_names.push_back( "bob" ); + db_api5.set_auto_subscription( false ); + db_api5.get_full_accounts( account_names, true ); // db_api5 subscribe to full account data of Bob + + db_api6.get_full_accounts( account_names, false ); // db_api6 doesn't subscribe + + transfer( account_id_type(), bob_id, asset(1) ); + + generate_block(); + // db_api1 only subscribed to the account object of Alice, nothing notified + ++expected_objects_changed2; // db_api2 subscribed to all, notify new history records and etc + ++expected_objects_changed3; // db_api3 subscribed to dynamic global properties, would be notified + // db_api4 subscribed to full account data of Alice, nothing would be notified + ++expected_objects_changed5; // db_api5 subscribed to full account data of Bob, would be notified + // db_api6 didn't subscribe to anything, nothing would be notified + // db_api7: no change on UIA, nothing would be notified + + fc::usleep(fc::milliseconds(200)); // sleep a while to execute callback in another thread + check_results(); + + db_api6.set_auto_subscription( true ); + db_api6.get_objects( obj_ids ); // db_api6 auto-subscribe to dynamic global properties + + generate_block(); + // db_api1 only subscribed to the account object of Alice, nothing notified + // db_api2 subscribed to all, but no object is created or removed in this block, so nothing notified + ++expected_objects_changed3; // db_api3 subscribed to dynamic global properties, would be notified + // db_api4 subscribed to full account data of Alice, nothing would be notified + // db_api5 subscribed to full account data of Bob, nothing notified + ++expected_objects_changed6; // db_api6 subscribed to dynamic global properties, would be notified + // db_api7: no change on UIA, nothing would be notified + + fc::usleep(fc::milliseconds(200)); // sleep a while to execute callback in another thread + check_results(); + + db_api5.set_subscribe_callback( callback5, false ); // reset subscription + db_api6.cancel_all_subscriptions(); + db_api6.get_objects( obj_ids ); // db_api6 doesn't auto-subscribe to dynamic global properties + + transfer( alice_id, bob_id, asset(1) ); + + generate_block(); + // db_api1 only subscribed to the account object of Alice, nothing notified + ++expected_objects_changed2; // db_api2 subscribed to all, notify new history records and etc + ++expected_objects_changed3; // db_api3 subscribed to dynamic global properties, would be notified + ++expected_objects_changed4; // db_api4 subscribed to full account data of Alice, would be notified + // db_api5 subscribed to anything, nothing notified + // db_api6 subscribed to anything, nothing notified + // db_api7: no change on UIA, nothing would be notified + + fc::usleep(fc::milliseconds(200)); // sleep a while to execute callback in another thread check_results(); } FC_LOG_AND_RETHROW() From 94a46c084a9018ac24b97537ab44ddb7054d4411 Mon Sep 17 00:00:00 2001 From: abitmore Date: Fri, 24 May 2019 10:53:52 -0400 Subject: [PATCH 111/133] Fix lookup_accounts subscription --- libraries/app/database_api.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 3d3c709227..dbd992be82 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -1152,7 +1152,7 @@ map database_api_impl::lookup_accounts(const string& low { result.insert(make_pair(itr->name, itr->get_id())); if( to_subscribe ) - subscribe_to_item( itr->get_id() ); + subscribe_to_item( itr->id ); } return result; From 8e2764b071ef5f04a0a34edeee933fa2af18831d Mon Sep 17 00:00:00 2001 From: abitmore Date: Thu, 20 Jun 2019 09:42:03 -0400 Subject: [PATCH 112/133] Update comments for get_subscription_key function --- libraries/app/database_api.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index dbd992be82..49e90fb769 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -190,7 +190,12 @@ class database_api_impl : public std::enable_shared_from_this // Note: // Different type of object_id objects could become identical after packed. // For example, both `account_id_type a=1.2.0` and `asset_id_type b=1.3.0` will become `0` after packed. - // In order to avoid collision, here we explicitly list a few types, rather than using a template. + // In order to avoid collision, we don't use a template function here, instead, we implicitly convert all + // object IDs to `object_id_type` when subscribing. + // + // If need to subscribe to other data types, override this function with the types as parameter. + // For example, we had a `get_subscription_key( const public_key_type& item )` function here, which was + // removed lately since we no longer subscribe to public keys. vector get_subscription_key( const object_id_type& item )const { return fc::raw::pack(item); From 02a2eea2d49e99d69f9e68d46d60bf006d33fd58 Mon Sep 17 00:00:00 2001 From: abitmore Date: Thu, 20 Jun 2019 10:54:58 -0400 Subject: [PATCH 113/133] Add test case for subscription key collision issue --- tests/tests/database_api_tests.cpp | 33 ++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/tests/database_api_tests.cpp b/tests/tests/database_api_tests.cpp index 0fa941ceac..a8ba90c63e 100644 --- a/tests/tests/database_api_tests.cpp +++ b/tests/tests/database_api_tests.cpp @@ -751,6 +751,39 @@ BOOST_AUTO_TEST_CASE( get_required_signatures_partially_signed_or_not ) } FC_LOG_AND_RETHROW() } +BOOST_AUTO_TEST_CASE( subscription_key_collision_test ) +{ + object_id_type uia_object_id = create_user_issued_asset( "UIATEST" ).get_id(); + + uint32_t objects_changed = 0; + auto callback = [&]( const variant& v ) + { + ++objects_changed; + }; + + graphene::app::database_api db_api(db); + db_api.set_subscribe_callback( callback, false ); + + // subscribe to an account which has same instance ID as UIATEST + vector collision_ids; + collision_ids.push_back( string( object_id_type( account_id_type( uia_object_id ) ) ) ); + db_api.get_accounts( collision_ids ); + + generate_block(); + fc::usleep(fc::milliseconds(200)); // sleep a while to execute callback in another thread + + BOOST_CHECK_EQUAL( objects_changed, 0 ); // did not subscribe to UIATEST, so no notification + + vector asset_names; + asset_names.push_back( "UIATEST" ); + db_api.get_assets( asset_names ); + + generate_block(); + fc::usleep(fc::milliseconds(200)); // sleep a while to execute callback in another thread + + BOOST_CHECK_EQUAL( objects_changed, 0 ); // UIATEST did not change in this block, so no notification +} + BOOST_AUTO_TEST_CASE( subscription_notification_test ) { try { From 927e68015587edf1aa4d361ee370525c55ae205d Mon Sep 17 00:00:00 2001 From: abitmore Date: Tue, 18 Jun 2019 14:35:23 -0400 Subject: [PATCH 114/133] Disallow temp-account to withdraw vested balance --- libraries/protocol/include/graphene/protocol/vesting.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/protocol/include/graphene/protocol/vesting.hpp b/libraries/protocol/include/graphene/protocol/vesting.hpp index fd2dea524f..b4d213190f 100644 --- a/libraries/protocol/include/graphene/protocol/vesting.hpp +++ b/libraries/protocol/include/graphene/protocol/vesting.hpp @@ -112,6 +112,7 @@ namespace graphene { namespace protocol { { FC_ASSERT( fee.amount >= 0 ); FC_ASSERT( amount.amount > 0 ); + FC_ASSERT( owner != GRAPHENE_TEMP_ACCOUNT ); } }; From 142f2f65681bacf72c7f7af939234a9fd3a16e74 Mon Sep 17 00:00:00 2001 From: Abit Date: Thu, 20 Jun 2019 22:14:40 +0200 Subject: [PATCH 115/133] Revert "wallet compatibility issue" --- libraries/wallet/wallet.cpp | 129 +++++++----------------------------- 1 file changed, 24 insertions(+), 105 deletions(-) diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 30119a562b..84ee5d409d 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -1610,15 +1610,7 @@ class wallet_api_impl committee_member_create_operation committee_member_create_op; committee_member_create_op.committee_member_account = get_account_id(owner_account); committee_member_create_op.url = url; - - /* - * Compatibility issue - * Current Date: 2018-09-28 More info: https://github.com/bitshares/bitshares-core/issues/1307 - * Todo: remove the next 2 lines and change always_id to name in remote call after next hardfork - */ - auto account = get_account(owner_account); - auto always_id = account_id_to_string(account.id); - if (_remote_db->get_committee_member_by_account(always_id)) + if (_remote_db->get_committee_member_by_account(owner_account)) FC_THROW("Account ${owner_account} is already a committee_member", ("owner_account", owner_account)); signed_transaction tx; @@ -1965,15 +1957,8 @@ class wallet_api_impl result.emplace_back( get_object(*vbid), now ); return result; } - /* - * Compatibility issue - * Current Date: 2018-09-28 More info: https://github.com/bitshares/bitshares-core/issues/1307 - * Todo: remove the next 2 lines and change always_id to name in remote call after next hardfork - */ - auto account = get_account(account_name); - auto always_id = account_id_to_string(account.id); - - vector< vesting_balance_object > vbos = _remote_db->get_vesting_balances( always_id ); + + vector< vesting_balance_object > vbos = _remote_db->get_vesting_balances( account_name ); if( vbos.size() == 0 ) return result; @@ -2021,15 +2006,7 @@ class wallet_api_impl bool broadcast /* = false */) { try { account_object voting_account_object = get_account(voting_account); - - /* - * Compatibility issue - * Current Date: 2018-09-28 More info: https://github.com/bitshares/bitshares-core/issues/1307 - * Todo: remove the next 2 lines and change always_id to name in remote call after next hardfork - */ - auto account = get_account(committee_member); - auto always_id = account_id_to_string(account.id); - fc::optional committee_member_obj = _remote_db->get_committee_member_by_account(always_id); + fc::optional committee_member_obj = _remote_db->get_committee_member_by_account(committee_member); if (!committee_member_obj) FC_THROW("Account ${committee_member} is not registered as a committee_member", ("committee_member", committee_member)); if (approve) @@ -2063,14 +2040,7 @@ class wallet_api_impl { try { account_object voting_account_object = get_account(voting_account); - /* - * Compatibility issue - * Current Date: 2018-09-28 More info: https://github.com/bitshares/bitshares-core/issues/1307 - * Todo: remove the next 2 lines and change always_id to name in remote call after next hardfork - */ - auto account = get_account(witness); - auto always_id = account_id_to_string(account.id); - fc::optional witness_obj = _remote_db->get_witness_by_account(always_id); + fc::optional witness_obj = _remote_db->get_witness_by_account(witness); if (!witness_obj) FC_THROW("Account ${witness} is not registered as a witness", ("witness", witness)); if (approve) @@ -3249,15 +3219,7 @@ map wallet_api::list_accounts(const string& lowerbound, vector wallet_api::list_account_balances(const string& id) { - /* - * Compatibility issue - * Current Date: 2018-09-13 More info: https://github.com/bitshares/bitshares-core/issues/1307 - * Todo: remove the next 2 lines and change always_id to id in remote call after next hardfork - */ - auto account = get_account(id); - auto always_id = my->account_id_to_string(account.id); - - return my->_remote_db->get_account_balances(always_id, flat_set()); + return my->_remote_db->get_account_balances(id, flat_set()); } vector wallet_api::list_assets(const string& lowerbound, uint32_t limit)const @@ -3347,14 +3309,6 @@ vector wallet_api::get_account_history(string name, int limit) { vector result; - /* - * Compatibility issue - * Current Date: 2018-09-14 More info: https://github.com/bitshares/bitshares-core/issues/1307 - * Todo: remove the next 2 lines and change always_id to name in remote call after next hardfork - */ - auto account = get_account(name); - auto always_id = my->account_id_to_string(account.id); - while( limit > 0 ) { bool skip_first_row = false; @@ -3374,11 +3328,8 @@ vector wallet_api::get_account_history(string name, int limit) int page_limit = skip_first_row ? std::min( 100, limit + 1 ) : std::min( 100, limit ); - vector current = my->_remote_hist->get_account_history( - always_id, - operation_history_id_type(), - page_limit, - start ); + vector current = my->_remote_hist->get_account_history( name, operation_history_id_type(), + page_limit, start ); bool first_row = true; for( auto& o : current ) { @@ -3406,11 +3357,7 @@ vector wallet_api::get_account_history(string name, int limit) return result; } -vector wallet_api::get_relative_account_history( - string name, - uint32_t stop, - int limit, - uint32_t start)const +vector wallet_api::get_relative_account_history(string name, uint32_t stop, int limit, uint32_t start)const { vector result; auto account_id = get_account(name).get_id(); @@ -3418,13 +3365,6 @@ vector wallet_api::get_relative_account_history( const account_object& account = my->get_account(account_id); const account_statistics_object& stats = my->get_object(account.statistics); - /* - * Compatibility issue - * Current Date: 2018-09-14 More info: https://github.com/bitshares/bitshares-core/issues/1307 - * Todo: remove the next line and change always_id to name in remote call after next hardfork - */ - auto always_id = my->account_id_to_string(account_id); - if(start == 0) start = stats.total_ops; else @@ -3432,11 +3372,7 @@ vector wallet_api::get_relative_account_history( while( limit > 0 ) { - vector current = my->_remote_hist->get_relative_account_history( - always_id, - stop, - std::min(100, limit), - start); + vector current = my->_remote_hist->get_relative_account_history(name, stop, std::min(100, limit), start); for (auto &o : current) { std::stringstream ss; auto memo = o.op.visit(detail::operation_printer(ss, *my, o)); @@ -3451,11 +3387,7 @@ vector wallet_api::get_relative_account_history( return result; } -account_history_operation_detail wallet_api::get_account_history_by_operations( - string name, - vector operation_types, - uint32_t start, - int limit) +account_history_operation_detail wallet_api::get_account_history_by_operations(string name, vector operation_types, uint32_t start, int limit) { account_history_operation_detail result; auto account_id = get_account(name).get_id(); @@ -3463,13 +3395,6 @@ account_history_operation_detail wallet_api::get_account_history_by_operations( const auto& account = my->get_account(account_id); const auto& stats = my->get_object(account.statistics); - /* - * Compatibility issue - * Current Date: 2018-09-14 More info: https://github.com/bitshares/bitshares-core/issues/1307 - * Todo: remove the next line and change always_id to name in remote call after next hardfork - */ - auto always_id = my->account_id_to_string(account_id); - // sequence of account_transaction_history_object start with 1 start = start == 0 ? 1 : start; @@ -3480,7 +3405,7 @@ account_history_operation_detail wallet_api::get_account_history_by_operations( while (limit > 0 && start <= stats.total_ops) { uint32_t min_limit = std::min (100, limit); - auto current = my->_remote_hist->get_account_history_by_operations(always_id, operation_types, start, min_limit); + auto current = my->_remote_hist->get_account_history_by_operations(name, operation_types, start, min_limit); for (auto& obj : current.operation_history_objs) { std::stringstream ss; auto memo = obj.op.visit(detail::operation_printer(ss, *my, obj)); @@ -3507,23 +3432,17 @@ full_account wallet_api::get_full_account( const string& name_or_id) return my->_remote_db->get_full_accounts({name_or_id}, false)[name_or_id]; } -vector wallet_api::get_market_history( - string symbol1, - string symbol2, - uint32_t bucket, - fc::time_point_sec start, - fc::time_point_sec end )const +vector wallet_api::get_market_history( string symbol1, string symbol2, uint32_t bucket , fc::time_point_sec start, fc::time_point_sec end )const { return my->_remote_hist->get_market_history( symbol1, symbol2, bucket, start, end ); } -vector wallet_api::get_account_limit_orders( - const string& name_or_id, - const string &base, - const string "e, - uint32_t limit, - optional ostart_id, - optional ostart_price) +vector wallet_api::get_account_limit_orders( const string& name_or_id, + const string &base, + const string "e, + uint32_t limit, + optional ostart_id, + optional ostart_price) { return my->_remote_db->get_account_limit_orders(name_or_id, base, quote, limit, ostart_id, ostart_price); } @@ -3625,11 +3544,11 @@ signed_transaction wallet_api::propose_builder_transaction( } signed_transaction wallet_api::propose_builder_transaction2( - transaction_handle_type handle, - string account_name_or_id, - time_point_sec expiration, - uint32_t review_period_seconds, - bool broadcast) + transaction_handle_type handle, + string account_name_or_id, + time_point_sec expiration, + uint32_t review_period_seconds, + bool broadcast) { return my->propose_builder_transaction2(handle, account_name_or_id, expiration, review_period_seconds, broadcast); } From 5e92c135789c43c6eeedc04ac440a23adc4490aa Mon Sep 17 00:00:00 2001 From: abitmore Date: Thu, 20 Jun 2019 16:30:41 -0400 Subject: [PATCH 116/133] Wrap long lines, remove trailing white spaces --- libraries/wallet/wallet.cpp | 113 +++++++++++++++++++++++------------- 1 file changed, 72 insertions(+), 41 deletions(-) diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 84ee5d409d..6af457cd01 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -913,7 +913,7 @@ class wallet_api_impl void quit() { ilog( "Quitting Cli Wallet ..." ); - + throw fc::canceled_exception(); } @@ -961,8 +961,8 @@ class wallet_api_impl fc::rename( tmp_wallet_filename, wallet_filename ); wlog( "renamed successfully tmp wallet file ${fn}", ("fn", tmp_wallet_filename) ); - } - else + } + else { FC_THROW("tmp wallet file cannot be validated ${fn}", ("fn", tmp_wallet_filename) ); } @@ -1874,7 +1874,7 @@ class wallet_api_impl string hash_algorithm, const std::string& preimage_hash, uint32_t preimage_size, const uint32_t claim_period_seconds, bool broadcast = false ) { - try + try { FC_ASSERT( !self.is_locked() ); fc::optional asset_obj = get_asset(asset_symbol); @@ -1895,12 +1895,12 @@ class wallet_api_impl return sign_transaction(tx, broadcast); } FC_CAPTURE_AND_RETHROW( (source)(destination)(amount)(asset_symbol)(hash_algorithm) - (preimage_hash)(preimage_size)(claim_period_seconds)(broadcast) ) + (preimage_hash)(preimage_size)(claim_period_seconds)(broadcast) ) } signed_transaction htlc_redeem( string htlc_id, string issuer, const std::vector& preimage, bool broadcast ) { - try + try { FC_ASSERT( !self.is_locked() ); fc::optional htlc_obj = get_htlc(htlc_id); @@ -1919,12 +1919,12 @@ class wallet_api_impl tx.validate(); return sign_transaction(tx, broadcast); - } FC_CAPTURE_AND_RETHROW( (htlc_id)(issuer)(preimage)(broadcast) ) + } FC_CAPTURE_AND_RETHROW( (htlc_id)(issuer)(preimage)(broadcast) ) } signed_transaction htlc_extend ( string htlc_id, string issuer, const uint32_t seconds_to_add, bool broadcast) { - try + try { FC_ASSERT( !self.is_locked() ); fc::optional htlc_obj = get_htlc(htlc_id); @@ -1943,7 +1943,7 @@ class wallet_api_impl tx.validate(); return sign_transaction(tx, broadcast); - } FC_CAPTURE_AND_RETHROW( (htlc_id)(issuer)(seconds_to_add)(broadcast) ) + } FC_CAPTURE_AND_RETHROW( (htlc_id)(issuer)(seconds_to_add)(broadcast) ) } vector< vesting_balance_object_with_info > get_vesting_balances( string account_name ) @@ -2006,20 +2006,24 @@ class wallet_api_impl bool broadcast /* = false */) { try { account_object voting_account_object = get_account(voting_account); - fc::optional committee_member_obj = _remote_db->get_committee_member_by_account(committee_member); + fc::optional committee_member_obj = + _remote_db->get_committee_member_by_account(committee_member); if (!committee_member_obj) - FC_THROW("Account ${committee_member} is not registered as a committee_member", ("committee_member", committee_member)); + FC_THROW("Account ${committee_member} is not registered as a committee_member", + ("committee_member", committee_member)); if (approve) { auto insert_result = voting_account_object.options.votes.insert(committee_member_obj->vote_id); if (!insert_result.second) - FC_THROW("Account ${account} was already voting for committee_member ${committee_member}", ("account", voting_account)("committee_member", committee_member)); + FC_THROW("Account ${account} was already voting for committee_member ${committee_member}", + ("account", voting_account)("committee_member", committee_member)); } else { unsigned votes_removed = voting_account_object.options.votes.erase(committee_member_obj->vote_id); if (!votes_removed) - FC_THROW("Account ${account} is already not voting for committee_member ${committee_member}", ("account", voting_account)("committee_member", committee_member)); + FC_THROW("Account ${account} is already not voting for committee_member ${committee_member}", + ("account", voting_account)("committee_member", committee_member)); } account_update_operation account_update_op; account_update_op.account = voting_account_object.id; @@ -2047,13 +2051,15 @@ class wallet_api_impl { auto insert_result = voting_account_object.options.votes.insert(witness_obj->vote_id); if (!insert_result.second) - FC_THROW("Account ${account} was already voting for witness ${witness}", ("account", voting_account)("witness", witness)); + FC_THROW("Account ${account} was already voting for witness ${witness}", + ("account", voting_account)("witness", witness)); } else { unsigned votes_removed = voting_account_object.options.votes.erase(witness_obj->vote_id); if (!votes_removed) - FC_THROW("Account ${account} is already not voting for witness ${witness}", ("account", voting_account)("witness", witness)); + FC_THROW("Account ${account} is already not voting for witness ${witness}", + ("account", voting_account)("witness", witness)); } account_update_operation account_update_op; account_update_op.account = voting_account_object.id; @@ -2076,7 +2082,8 @@ class wallet_api_impl { account_id_type new_voting_account_id = get_account_id(*voting_account); if (account_object_to_modify.options.voting_account == new_voting_account_id) - FC_THROW("Voting proxy for ${account} is already set to ${voter}", ("account", account_to_modify)("voter", *voting_account)); + FC_THROW("Voting proxy for ${account} is already set to ${voter}", + ("account", account_to_modify)("voter", *voting_account)); account_object_to_modify.options.voting_account = new_voting_account_id; } else @@ -2107,8 +2114,10 @@ class wallet_api_impl if (account_object_to_modify.options.num_witness == desired_number_of_witnesses && account_object_to_modify.options.num_committee == desired_number_of_committee_members) - FC_THROW("Account ${account} is already voting for ${witnesses} witnesses and ${committee_members} committee_members", - ("account", account_to_modify)("witnesses", desired_number_of_witnesses)("committee_members",desired_number_of_witnesses)); + FC_THROW("Account ${account} is already voting for ${witnesses} witnesses" + " and ${committee_members} committee_members", + ("account", account_to_modify)("witnesses", desired_number_of_witnesses) + ("committee_members",desired_number_of_witnesses)); account_object_to_modify.options.num_witness = desired_number_of_witnesses; account_object_to_modify.options.num_committee = desired_number_of_committee_members; @@ -2122,7 +2131,8 @@ class wallet_api_impl tx.validate(); return sign_transaction( tx, broadcast ); - } FC_CAPTURE_AND_RETHROW( (account_to_modify)(desired_number_of_witnesses)(desired_number_of_committee_members)(broadcast) ) } + } FC_CAPTURE_AND_RETHROW( (account_to_modify)(desired_number_of_witnesses) + (desired_number_of_committee_members)(broadcast) ) } signed_transaction sign_transaction(signed_transaction tx, bool broadcast = false) { @@ -3077,9 +3087,9 @@ std::string operation_printer::operator()(const asset_create_operation& op) cons std::string operation_printer::operator()(const htlc_redeem_operation& op) const { - out << "Redeem HTLC with database id " - << std::to_string(op.htlc_id.space_id) - << "." << std::to_string(op.htlc_id.type_id) + out << "Redeem HTLC with database id " + << std::to_string(op.htlc_id.space_id) + << "." << std::to_string(op.htlc_id.type_id) << "." << std::to_string((uint64_t)op.htlc_id.instance) << " with preimage \""; for (unsigned char c : op.preimage) @@ -3233,7 +3243,7 @@ uint64_t wallet_api::get_asset_count()const } signed_transaction wallet_api::htlc_create( string source, string destination, string amount, string asset_symbol, - string hash_algorithm, const std::string& preimage_hash, uint32_t preimage_size, + string hash_algorithm, const std::string& preimage_hash, uint32_t preimage_size, const uint32_t claim_period_seconds, bool broadcast) { return my->htlc_create(source, destination, amount, asset_symbol, hash_algorithm, preimage_hash, preimage_size, @@ -3260,18 +3270,18 @@ fc::optional wallet_api::get_htlc(std::string htlc_id) const public: typedef fc::mutable_variant_object result_type; - result_type operator()(const fc::ripemd160& obj)const + result_type operator()(const fc::ripemd160& obj)const { return convert("RIPEMD160", obj.str()); } - result_type operator()(const fc::sha1& obj)const + result_type operator()(const fc::sha1& obj)const { return convert("SHA1", obj.str()); } - result_type operator()(const fc::sha256& obj)const + result_type operator()(const fc::sha256& obj)const { return convert("SHA256", obj.str()); } private: result_type convert(const std::string& type, const std::string& hash)const { - fc::mutable_variant_object ret_val; - ret_val["hash_algo"] = type; - ret_val["preimage_hash"] = hash; + fc::mutable_variant_object ret_val; + ret_val["hash_algo"] = type; + ret_val["preimage_hash"] = hash; return ret_val; } }; @@ -3328,8 +3338,11 @@ vector wallet_api::get_account_history(string name, int limit) int page_limit = skip_first_row ? std::min( 100, limit + 1 ) : std::min( 100, limit ); - vector current = my->_remote_hist->get_account_history( name, operation_history_id_type(), - page_limit, start ); + vector current = my->_remote_hist->get_account_history( + name, + operation_history_id_type(), + page_limit, + start ); bool first_row = true; for( auto& o : current ) { @@ -3357,7 +3370,11 @@ vector wallet_api::get_account_history(string name, int limit) return result; } -vector wallet_api::get_relative_account_history(string name, uint32_t stop, int limit, uint32_t start)const +vector wallet_api::get_relative_account_history( + string name, + uint32_t stop, + int limit, + uint32_t start)const { vector result; auto account_id = get_account(name).get_id(); @@ -3372,7 +3389,11 @@ vector wallet_api::get_relative_account_history(string name, u while( limit > 0 ) { - vector current = my->_remote_hist->get_relative_account_history(name, stop, std::min(100, limit), start); + vector current = my->_remote_hist->get_relative_account_history( + name, + stop, + std::min(100, limit), + start); for (auto &o : current) { std::stringstream ss; auto memo = o.op.visit(detail::operation_printer(ss, *my, o)); @@ -3387,7 +3408,11 @@ vector wallet_api::get_relative_account_history(string name, u return result; } -account_history_operation_detail wallet_api::get_account_history_by_operations(string name, vector operation_types, uint32_t start, int limit) +account_history_operation_detail wallet_api::get_account_history_by_operations( + string name, + vector operation_types, + uint32_t start, + int limit) { account_history_operation_detail result; auto account_id = get_account(name).get_id(); @@ -3432,17 +3457,23 @@ full_account wallet_api::get_full_account( const string& name_or_id) return my->_remote_db->get_full_accounts({name_or_id}, false)[name_or_id]; } -vector wallet_api::get_market_history( string symbol1, string symbol2, uint32_t bucket , fc::time_point_sec start, fc::time_point_sec end )const +vector wallet_api::get_market_history( + string symbol1, + string symbol2, + uint32_t bucket, + fc::time_point_sec start, + fc::time_point_sec end )const { return my->_remote_hist->get_market_history( symbol1, symbol2, bucket, start, end ); } -vector wallet_api::get_account_limit_orders( const string& name_or_id, - const string &base, - const string "e, - uint32_t limit, - optional ostart_id, - optional ostart_price) +vector wallet_api::get_account_limit_orders( + const string& name_or_id, + const string &base, + const string "e, + uint32_t limit, + optional ostart_id, + optional ostart_price) { return my->_remote_db->get_account_limit_orders(name_or_id, base, quote, limit, ostart_id, ostart_price); } From d0e67571a1f836e63194466eda26bd7bee50f109 Mon Sep 17 00:00:00 2001 From: abitmore Date: Thu, 20 Jun 2019 17:03:14 -0400 Subject: [PATCH 117/133] Update code style --- libraries/wallet/wallet.cpp | 237 ++++++++++++++++++++++++------------ 1 file changed, 160 insertions(+), 77 deletions(-) diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 6af457cd01..a2783a8584 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -363,7 +363,8 @@ class wallet_api_impl if( !_wallet.pending_account_registrations.empty() ) { // make a vector of the account names pending registration - std::vector pending_account_names = boost::copy_range >(boost::adaptors::keys(_wallet.pending_account_registrations)); + std::vector pending_account_names = + boost::copy_range >(boost::adaptors::keys(_wallet.pending_account_registrations)); // look those up on the blockchain std::vector> @@ -378,10 +379,12 @@ class wallet_api_impl if (!_wallet.pending_witness_registrations.empty()) { // make a vector of the owner accounts for witnesses pending registration - std::vector pending_witness_names = boost::copy_range >(boost::adaptors::keys(_wallet.pending_witness_registrations)); + std::vector pending_witness_names = + boost::copy_range >(boost::adaptors::keys(_wallet.pending_witness_registrations)); // look up the owners on the blockchain - std::vector> owner_account_objects = _remote_db->lookup_account_names(pending_witness_names); + std::vector> owner_account_objects = + _remote_db->lookup_account_names(pending_witness_names); // if any of them have registered witnesses, claim them for( const fc::optional& optional_account : owner_account_objects ) @@ -434,13 +437,27 @@ class wallet_api_impl graphene::chain::transaction_id_type transaction_id; }; struct timestamp_index{}; - typedef boost::multi_index_container, - std::hash >, - boost::multi_index::ordered_non_unique, - boost::multi_index::member > > > recently_generated_transaction_set_type; + typedef boost::multi_index_container< + recently_generated_transaction_record, + boost::multi_index::indexed_by< + boost::multi_index::hashed_unique< + boost::multi_index::member< + recently_generated_transaction_record, + graphene::chain::transaction_id_type, + &recently_generated_transaction_record::transaction_id + >, + std::hash + >, + boost::multi_index::ordered_non_unique< + boost::multi_index::tag, + boost::multi_index::member< + recently_generated_transaction_record, + fc::time_point_sec, + &recently_generated_transaction_record::generation_time + > + > + > + > recently_generated_transaction_set_type; recently_generated_transaction_set_type _recently_generated_transactions; public: @@ -567,13 +584,15 @@ class wallet_api_impl result["head_block_age"] = fc::get_approximate_relative_time_string(dynamic_props.time, time_point_sec(time_point::now()), " old"); - result["next_maintenance_time"] = fc::get_approximate_relative_time_string(dynamic_props.next_maintenance_time); + result["next_maintenance_time"] = + fc::get_approximate_relative_time_string(dynamic_props.next_maintenance_time); result["chain_id"] = chain_props.chain_id; stringstream participation; participation << fixed << std::setprecision(2) << (100*dynamic_props.recent_slots_filled.popcount()) / 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_committee_members"] = + fc::variant(global_props.active_committee_members, GRAPHENE_MAX_NESTED_OBJECTS); return result; } @@ -589,9 +608,11 @@ class wallet_api_impl //result["blockchain_description"] = BTS_BLOCKCHAIN_DESCRIPTION; result["client_version"] = client_version; result["graphene_revision"] = graphene::utilities::git_revision_sha; - result["graphene_revision_age"] = fc::get_approximate_relative_time_string( fc::time_point_sec( graphene::utilities::git_revision_unix_timestamp ) ); + result["graphene_revision_age"] = fc::get_approximate_relative_time_string( fc::time_point_sec( + graphene::utilities::git_revision_unix_timestamp ) ); result["fc_revision"] = fc::git_revision_sha; - result["fc_revision_age"] = fc::get_approximate_relative_time_string( fc::time_point_sec( fc::git_revision_unix_timestamp ) ); + result["fc_revision_age"] = fc::get_approximate_relative_time_string( fc::time_point_sec( + fc::git_revision_unix_timestamp ) ); result["compile_date"] = "compiled on " __DATE__ " at " __TIME__; result["boost_version"] = boost::replace_all_copy(std::string(BOOST_LIB_VERSION), "_", "."); result["openssl_version"] = OPENSSL_VERSION_TEXT; @@ -763,8 +784,10 @@ class wallet_api_impl flat_set all_keys_for_account; std::vector active_keys = account.active.get_keys(); std::vector owner_keys = account.owner.get_keys(); - std::copy(active_keys.begin(), active_keys.end(), std::inserter(all_keys_for_account, all_keys_for_account.end())); - std::copy(owner_keys.begin(), owner_keys.end(), std::inserter(all_keys_for_account, all_keys_for_account.end())); + std::copy(active_keys.begin(), active_keys.end(), + std::inserter(all_keys_for_account, all_keys_for_account.end())); + std::copy(owner_keys.begin(), owner_keys.end(), + std::inserter(all_keys_for_account, all_keys_for_account.end())); all_keys_for_account.insert(account.options.memo_key); _keys[wif_pub_key] = wif_key; @@ -823,7 +846,8 @@ class wallet_api_impl account_object& old_acct = old_accounts[i]; if( !acct.valid() ) { - elog( "Could not find account ${id} : \"${name}\" does not exist on the chain!", ("id", old_acct.id)("name", old_acct.name) ); + elog( "Could not find account ${id} : \"${name}\" does not exist on the chain!", + ("id", old_acct.id)("name", old_acct.name) ); i++; continue; } @@ -1037,7 +1061,8 @@ class wallet_api_impl { FC_ASSERT(_builder_transactions.count(transaction_handle)); - return _builder_transactions[transaction_handle] = sign_transaction(_builder_transactions[transaction_handle], broadcast); + return _builder_transactions[transaction_handle] = + sign_transaction(_builder_transactions[transaction_handle], broadcast); } pair broadcast_transaction(signed_transaction tx) @@ -1046,7 +1071,8 @@ class wallet_api_impl _remote_net_broadcast->broadcast_transaction(tx); } catch (const fc::exception& e) { - elog("Caught exception while broadcasting tx ${id}: ${e}", ("id", tx.id().str())("e", e.to_detail_string())); + elog("Caught exception while broadcasting tx ${id}: ${e}", + ("id", tx.id().str())("e", e.to_detail_string())); throw; } return std::make_pair(tx.id(),tx); @@ -1162,7 +1188,8 @@ class wallet_api_impl if( broadcast ) _remote_net_broadcast->broadcast_transaction( tx ); return tx; - } FC_CAPTURE_AND_RETHROW( (name)(owner)(active)(registrar_account)(referrer_account)(referrer_percent)(broadcast) ) } + } FC_CAPTURE_AND_RETHROW( (name)(owner)(active)(registrar_account) + (referrer_account)(referrer_percent)(broadcast) ) } signed_transaction upgrade_account(string name, bool broadcast) { try { @@ -1302,7 +1329,8 @@ class wallet_api_impl string normalized_brain_key = normalize_brain_key( brain_key ); // TODO: scan blockchain for accounts that exist with same brain key fc::ecc::private_key owner_privkey = derive_private_key( normalized_brain_key, 0 ); - return create_account_with_private_key(owner_privkey, account_name, registrar_account, referrer_account, broadcast, save_wallet); + return create_account_with_private_key(owner_privkey, account_name, registrar_account, + referrer_account, broadcast, save_wallet); } FC_CAPTURE_AND_RETHROW( (account_name)(registrar_account)(referrer_account) ) } @@ -1338,11 +1366,11 @@ class wallet_api_impl { try { optional asset_to_update = find_asset(symbol); if (!asset_to_update) - FC_THROW("No asset with that symbol exists!"); + FC_THROW("No asset with that symbol exists!"); optional new_issuer_account_id; if (new_issuer) { - FC_ASSERT( false, "The use of 'new_issuer' is no longer supported. Please use `update_asset_issuer' instead!"); + FC_THROW( "The use of 'new_issuer' is no longer supported. Please use `update_asset_issuer' instead!" ); } asset_update_operation update_op; @@ -1570,7 +1598,8 @@ class wallet_api_impl FC_THROW("No asset with that symbol exists!"); FC_ASSERT(debt_asset->bitasset_data_id.valid(), "Not a bitasset, bidding not possible."); - const asset_object& collateral = get_asset(get_object(*debt_asset->bitasset_data_id).options.short_backing_asset); + const asset_object& collateral = + get_asset(get_object(*debt_asset->bitasset_data_id).options.short_backing_asset); bid_collateral_operation op; op.bidder = get_account_id(bidder_name); @@ -1660,12 +1689,14 @@ class wallet_api_impl { try { - fc::optional committee_member_id = maybe_id(owner_account); + fc::optional committee_member_id = + maybe_id(owner_account); if (committee_member_id) { std::vector ids_to_get; ids_to_get.push_back(*committee_member_id); - std::vector> committee_member_objects = _remote_db->get_committee_members(ids_to_get); + std::vector> committee_member_objects = + _remote_db->get_committee_members(ids_to_get); if (committee_member_objects.front()) return *committee_member_objects.front(); FC_THROW("No committee_member is registered for id ${id}", ("id", owner_account)); @@ -1675,7 +1706,8 @@ class wallet_api_impl // then maybe it's the owner account try { - fc::optional committee_member = _remote_db->get_committee_member_by_account(owner_account); + fc::optional committee_member = + _remote_db->get_committee_member_by_account(owner_account); if (committee_member) return *committee_member; else @@ -1697,7 +1729,8 @@ class wallet_api_impl account_object witness_account = get_account(owner_account); fc::ecc::private_key active_private_key = get_private_key_for_account(witness_account); int witness_key_index = find_first_unused_derived_key_index(active_private_key); - fc::ecc::private_key witness_private_key = derive_private_key(key_to_wif(active_private_key), witness_key_index); + fc::ecc::private_key witness_private_key = + derive_private_key(key_to_wif(active_private_key), witness_key_index); graphene::chain::public_key_type witness_public_key = witness_private_key.get_public_key(); witness_create_operation witness_create_op; @@ -2147,7 +2180,8 @@ class wallet_api_impl // when there are multiple transactions in the same block. choose a time period that should be at // least one block long, even in the worst case. 2 minutes ought to be plenty. fc::time_point_sec oldest_transaction_ids_to_track(dyn_props.time - fc::minutes(2)); - auto oldest_transaction_record_iter = _recently_generated_transactions.get().lower_bound(oldest_transaction_ids_to_track); + auto oldest_transaction_record_iter = + _recently_generated_transactions.get().lower_bound(oldest_transaction_ids_to_track); auto begin_iter = _recently_generated_transactions.get().begin(); _recently_generated_transactions.get().erase(begin_iter, oldest_transaction_record_iter); @@ -2184,7 +2218,8 @@ class wallet_api_impl } catch (const fc::exception& e) { - elog("Caught exception while broadcasting tx ${id}: ${e}", ("id", tx.id().str())("e", e.to_detail_string()) ); + elog("Caught exception while broadcasting tx ${id}: ${e}", + ("id", tx.id().str())("e", e.to_detail_string()) ); throw; } } @@ -2235,7 +2270,9 @@ class wallet_api_impl const memo_data *memo = &md; try { - FC_ASSERT(_keys.count(memo->to) || _keys.count(memo->from), "Memo is encrypted to a key ${to} or ${from} not in this wallet.", ("to", memo->to)("from",memo->from)); + FC_ASSERT( _keys.count(memo->to) || _keys.count(memo->from), + "Memo is encrypted to a key ${to} or ${from} not in this wallet.", + ("to", memo->to)("from",memo->from) ); if( _keys.count(memo->to) ) { auto my_key = wif_to_key(_keys.at(memo->to)); FC_ASSERT(my_key, "Unable to recover private key to decrypt memo. Wallet may be corrupted."); @@ -2513,7 +2550,8 @@ class wallet_api_impl for( const auto& out : r.outputs ) { asset_object a = get_asset( out.decrypted_memo.amount.asset_id ); - ss << a.amount_to_pretty_string( out.decrypted_memo.amount ) << " to " << out.label << "\n\t receipt: " << out.confirmation_receipt <<"\n\n"; + ss << a.amount_to_pretty_string( out.decrypted_memo.amount ) << " to " << out.label + << "\n\t receipt: " << out.confirmation_receipt << "\n\n"; } return ss.str(); }; @@ -2526,7 +2564,8 @@ class wallet_api_impl for( const auto& out : r.outputs ) { asset_object a = get_asset( out.decrypted_memo.amount.asset_id ); - ss << a.amount_to_pretty_string( out.decrypted_memo.amount ) << " to " << out.label << "\n\t receipt: " << out.confirmation_receipt <<"\n\n"; + ss << a.amount_to_pretty_string( out.decrypted_memo.amount ) << " to " << out.label + << "\n\t receipt: " << out.confirmation_receipt << "\n\n"; } return ss.str(); }; @@ -2535,7 +2574,8 @@ class wallet_api_impl auto r = result.as( GRAPHENE_MAX_NESTED_OBJECTS ); std::stringstream ss; asset_object as = get_asset( r.amount.asset_id ); - ss << as.amount_to_pretty_string( r.amount ) << " " << r.from_label << " => " << r.to_label << " " << r.memo <<"\n"; + ss << as.amount_to_pretty_string( r.amount ) << " " << r.from_label << " => " + << r.to_label << " " << r.memo <<"\n"; return ss.str(); }; m["blind_history"] = [this](variant result, const fc::variants& a) @@ -2549,7 +2589,8 @@ class wallet_api_impl { asset_object as = get_asset( r.amount.asset_id ); ss << fc::get_approximate_relative_time_string( r.date ) - << " " << as.amount_to_pretty_string( r.amount ) << " " << r.from_label << " => " << r.to_label << " " << r.memo <<"\n"; + << " " << as.amount_to_pretty_string( r.amount ) << " " << r.from_label << " => " << r.to_label + << " " << r.memo <<"\n"; } return ss.str(); }; @@ -2918,7 +2959,9 @@ class wallet_api_impl { std::ostringstream brain_key; brain_key << "brain key for account " << prefix << i; - signed_transaction trx = create_account_with_brain_key(brain_key.str(), prefix + fc::to_string(i), master.name, master.name, /* broadcast = */ true, /* save wallet = */ false); + signed_transaction trx = create_account_with_brain_key( + brain_key.str(), prefix + fc::to_string(i), master.name, master.name, + /* broadcast = */ true, /* save wallet = */ false); } fc::time_point end = fc::time_point::now(); ilog("Created ${n} accounts in ${time} milliseconds", @@ -2990,8 +3033,6 @@ std::string operation_printer::fee(const asset& a)const { template std::string operation_printer::operator()(const T& op)const { - //balance_accumulator acc; - //op.get_balance_delta( acc, result ); auto a = wallet.get_asset( op.fee.asset_id ); auto payer = wallet.get_account( op.fee_payer() ); @@ -2999,7 +3040,6 @@ std::string operation_printer::operator()(const T& op)const if( op_name.find_last_of(':') != string::npos ) op_name.erase(0, op_name.find_last_of(':')+1); out << op_name <<" "; - // out << "balance delta: " << fc::json::to_string(acc.balance) <<" "; out << payer.name << " fee: " << a.amount_to_pretty_string( op.fee ); operation_result_printer rprinter(wallet); std::string str_result = result.visit(rprinter); @@ -3015,7 +3055,7 @@ std::string operation_printer::operator()(const transfer_from_blind_operation& o auto receiver = wallet.get_account( op.to ); out << receiver.name - << " received " << a.amount_to_pretty_string( op.amount ) << " from blinded balance"; + << " received " << a.amount_to_pretty_string( op.amount ) << " from blinded balance"; return ""; } std::string operation_printer::operator()(const transfer_to_blind_operation& op)const @@ -3025,8 +3065,9 @@ std::string operation_printer::operator()(const transfer_to_blind_operation& op) auto sender = wallet.get_account( op.from ); out << sender.name - << " sent " << a.amount_to_pretty_string( op.amount ) << " to " << op.outputs.size() << " blinded balance" << (op.outputs.size()>1?"s":"") - << " fee: " << fa.amount_to_pretty_string( op.fee ); + << " sent " << a.amount_to_pretty_string( op.amount ) << " to " << op.outputs.size() + << " blinded balance" << (op.outputs.size()>1?"s":"") + << " fee: " << fa.amount_to_pretty_string( op.fee ); return ""; } string operation_printer::operator()(const transfer_operation& op) const @@ -3041,7 +3082,9 @@ string operation_printer::operator()(const transfer_operation& op) const out << " -- Unlock wallet to see memo."; } else { try { - FC_ASSERT(wallet._keys.count(op.memo->to) || wallet._keys.count(op.memo->from), "Memo is encrypted to a key ${to} or ${from} not in this wallet.", ("to", op.memo->to)("from",op.memo->from)); + FC_ASSERT( wallet._keys.count(op.memo->to) || wallet._keys.count(op.memo->from), + "Memo is encrypted to a key ${to} or ${from} not in this wallet.", + ("to", op.memo->to)("from",op.memo->from) ); if( wallet._keys.count(op.memo->to) ) { auto my_key = wif_to_key(wallet._keys.at(op.memo->to)); FC_ASSERT(my_key, "Unable to recover private key to decrypt memo. Wallet may be corrupted."); @@ -3329,7 +3372,8 @@ vector wallet_api::get_account_history(string name, int limit) if( start == operation_history_id_type() ) // no more data break; start = start + (-1); - if( start == operation_history_id_type() ) // will return most recent history if directly call remote API with this + if( start == operation_history_id_type() ) // will return most recent history if + // directly call remote API with this { start = start + 1; skip_first_row = true; @@ -3503,7 +3547,9 @@ brain_key_info wallet_api::suggest_brain_key()const return graphene::wallet::utility::suggest_brain_key(); } -vector wallet_api::derive_owner_keys_from_brain_key(string brain_key, int number_of_desired_keys) const +vector wallet_api::derive_owner_keys_from_brain_key( + string brain_key, + int number_of_desired_keys) const { return graphene::wallet::utility::derive_owner_keys_from_brain_key(brain_key, number_of_desired_keys); } @@ -3535,12 +3581,17 @@ transaction_handle_type wallet_api::begin_builder_transaction() return my->begin_builder_transaction(); } -void wallet_api::add_operation_to_builder_transaction(transaction_handle_type transaction_handle, const operation& op) +void wallet_api::add_operation_to_builder_transaction( + transaction_handle_type transaction_handle, + const operation& op) { my->add_operation_to_builder_transaction(transaction_handle, op); } -void wallet_api::replace_operation_in_builder_transaction(transaction_handle_type handle, unsigned operation_index, const operation& new_op) +void wallet_api::replace_operation_in_builder_transaction( + transaction_handle_type handle, + unsigned operation_index, + const operation& new_op) { my->replace_operation_in_builder_transaction(handle, operation_index, new_op); } @@ -3566,20 +3617,20 @@ pair wallet_api::broadcast_transaction(s } signed_transaction wallet_api::propose_builder_transaction( - transaction_handle_type handle, - time_point_sec expiration, - uint32_t review_period_seconds, - bool broadcast) + transaction_handle_type handle, + time_point_sec expiration, + uint32_t review_period_seconds, + bool broadcast) { return my->propose_builder_transaction(handle, expiration, review_period_seconds, broadcast); } signed_transaction wallet_api::propose_builder_transaction2( - transaction_handle_type handle, - string account_name_or_id, - time_point_sec expiration, - uint32_t review_period_seconds, - bool broadcast) + transaction_handle_type handle, + string account_name_or_id, + time_point_sec expiration, + uint32_t review_period_seconds, + bool broadcast) { return my->propose_builder_transaction2(handle, account_name_or_id, expiration, review_period_seconds, broadcast); } @@ -3698,16 +3749,22 @@ map wallet_api::import_accounts( string filename, string password ++import_failures; } } - ilog( "successfully imported ${n} keys for account ${name}", ("n", import_successes)("name", item.account_name) ); + ilog( "successfully imported ${n} keys for account ${name}", + ("n", import_successes)("name", item.account_name) ); if( import_failures > 0 ) - elog( "failed to import ${n} keys for account ${name}", ("n", import_failures)("name", item.account_name) ); + elog( "failed to import ${n} keys for account ${name}", + ("n", import_failures)("name", item.account_name) ); } } return result; } -bool wallet_api::import_account_keys( string filename, string password, string src_account_name, string dest_account_name ) +bool wallet_api::import_account_keys( + string filename, + string password, + string src_account_name, + string dest_account_name ) { FC_ASSERT( !is_locked() ); FC_ASSERT( fc::exists( filename ) ); @@ -3782,7 +3839,8 @@ signed_transaction wallet_api::register_account(string name, uint32_t referrer_percent, bool broadcast) { - return my->register_account( name, owner_pubkey, active_pubkey, registrar_account, referrer_account, referrer_percent, broadcast ); + return my->register_account( name, owner_pubkey, active_pubkey, + registrar_account, referrer_account, referrer_percent, broadcast ); } signed_transaction wallet_api::create_account_with_brain_key(string brain_key, string account_name, string registrar_account, string referrer_account, @@ -4174,18 +4232,25 @@ string wallet_api::gethelp(const string& method)const else if( method == "create_account_with_brain_key" ) { ss << "usage: create_account_with_brain_key BRAIN_KEY ACCOUNT_NAME REGISTRAR REFERRER BROADCAST\n\n"; - ss << "example: create_account_with_brain_key \"my really long brain key\" \"newaccount\" \"1.3.11\" \"1.3.11\" true\n"; - ss << "example: create_account_with_brain_key \"my really long brain key\" \"newaccount\" \"someaccount\" \"otheraccount\" true\n"; + ss << "example: create_account_with_brain_key " + << "\"my really long brain key\" \"newaccount\" \"1.3.11\" \"1.3.11\" true\n"; + ss << "example: create_account_with_brain_key " + << "\"my really long brain key\" \"newaccount\" \"someaccount\" \"otheraccount\" true\n"; ss << "\n"; - ss << "This method should be used if you would like the wallet to generate new keys derived from the brain key.\n"; - ss << "The BRAIN_KEY will be used as the owner key, and the active key will be derived from the BRAIN_KEY. Use\n"; - ss << "register_account if you already know the keys you know the public keys that you would like to register.\n"; + ss << "This method should be used if you would like the wallet to generate new keys derived from the " + << "brain key.\n"; + ss << "The BRAIN_KEY will be used as the owner key, and the active key will be derived from the BRAIN_KEY. " + << "Use\n"; + ss << "register_account if you already know the keys you know the public keys that you would like to " + << "register.\n"; } else if( method == "register_account" ) { - ss << "usage: register_account ACCOUNT_NAME OWNER_PUBLIC_KEY ACTIVE_PUBLIC_KEY REGISTRAR REFERRER REFERRER_PERCENT BROADCAST\n\n"; - ss << "example: register_account \"newaccount\" \"CORE6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV\" \"CORE6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV\" \"1.3.11\" \"1.3.11\" 50 true\n"; + ss << "usage: register_account ACCOUNT_NAME OWNER_PUBLIC_KEY ACTIVE_PUBLIC_KEY REGISTRAR " + << "REFERRER REFERRER_PERCENT BROADCAST\n\n"; + ss << "example: register_account \"newaccount\" \"CORE6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV\" " + << "\"CORE6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV\" \"1.3.11\" \"1.3.11\" 50 true\n"; ss << "\n"; ss << "Use this method to register an account for which you do not know the private keys."; } @@ -4277,14 +4342,20 @@ void wallet_api::set_password( string password ) lock(); } -vector< signed_transaction > wallet_api::import_balance( string name_or_id, const vector& wif_keys, bool broadcast ) +vector< signed_transaction > wallet_api::import_balance( + string name_or_id, + const vector& wif_keys, + bool broadcast ) { return my->import_balance( name_or_id, wif_keys, broadcast ); } namespace detail { -vector< signed_transaction > wallet_api_impl::import_balance( string name_or_id, const vector& wif_keys, bool broadcast ) +vector< signed_transaction > wallet_api_impl::import_balance( + string name_or_id, + const vector& wif_keys, + bool broadcast ) { try { FC_ASSERT(!is_locked()); const dynamic_global_property_object& dpo = _remote_db->get_dynamic_global_properties(); @@ -4434,7 +4505,8 @@ signed_transaction wallet_api::borrow_asset_ext( string seller_name, string amou bool broadcast) { FC_ASSERT(!is_locked()); - return my->borrow_asset_ext(seller_name, amount_to_sell, asset_symbol, amount_of_collateral, extensions, broadcast); + return my->borrow_asset_ext(seller_name, amount_to_sell, asset_symbol, + amount_of_collateral, extensions, broadcast); } signed_transaction wallet_api::cancel_order(object_id_type order_id, bool broadcast) @@ -4616,7 +4688,9 @@ blind_confirmation wallet_api::transfer_from_blind( string from_blind_account_ke conf_output.confirmation.encrypted_memo = change_output.confirmation.encrypted_memo; conf_output.confirmation_receipt = conf_output.confirmation; //try { - receive_blind_transfer( conf_output.confirmation_receipt, from_blind_account_key_or_label, "@"+to_account.name ); + receive_blind_transfer( conf_output.confirmation_receipt, + from_blind_account_key_or_label, + "@"+to_account.name ); //} catch ( ... ){} } @@ -4692,7 +4766,9 @@ blind_confirmation wallet_api::blind_transfer_help( string from_key_or_label, my->_wallet.blind_receipts.modify( itr, []( blind_receipt& r ){ r.used = true; } ); } - FC_ASSERT( total_amount >= amount+blind_tr.fee, "Insufficient Balance", ("available",total_amount)("amount",amount)("fee",blind_tr.fee) ); + FC_ASSERT( total_amount >= amount+blind_tr.fee, + "Insufficient Balance", + ("available",total_amount)("amount",amount)("fee",blind_tr.fee) ); auto one_time_key = fc::ecc::private_key::generate(); auto secret = one_time_key.get_shared_secret( to_key ); @@ -4754,7 +4830,8 @@ blind_confirmation wallet_api::blind_transfer_help( string from_key_or_label, 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 ) ); + conf_output.confirmation.encrypted_memo = + fc::aes_encrypt( from_secret, fc::raw::pack( conf_output.decrypted_memo ) ); conf_output.auth = change_out.owner; conf_output.confirmation_receipt = conf_output.confirmation; @@ -4860,7 +4937,8 @@ blind_confirmation wallet_api::transfer_to_blind( string from_account_id_or_name 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 ) ); + conf_output.confirmation.encrypted_memo = + fc::aes_encrypt( secret, fc::raw::pack( conf_output.decrypted_memo ) ); conf_output.confirmation_receipt = conf_output.confirmation; confirm.outputs.push_back( conf_output ); @@ -4883,7 +4961,9 @@ blind_confirmation wallet_api::transfer_to_blind( string from_account_id_or_name { for( const auto& out : confirm.outputs ) { - try { receive_blind_transfer( out.confirmation_receipt, "@"+from_account.name, "from @"+from_account.name ); } catch ( ... ){} + try { + receive_blind_transfer( out.confirmation_receipt, "@"+from_account.name, "from @"+from_account.name ); + } catch ( ... ){} } } @@ -4980,7 +5060,8 @@ vector wallet_api::blind_history( string key_or_account ) if( r.from_key == pub_key || r.to_key == pub_key ) result.push_back( r ); } - std::sort( result.begin(), result.end(), [&]( const blind_receipt& a, const blind_receipt& b ){ return a.date > b.date; } ); + std::sort( result.begin(), result.end(), + [&]( const blind_receipt& a, const blind_receipt& b ){ return a.date > b.date; } ); return result; } @@ -4999,7 +5080,9 @@ signed_block_with_info::signed_block_with_info( const signed_block& block ) transaction_ids.push_back( tx.id() ); } -vesting_balance_object_with_info::vesting_balance_object_with_info( const vesting_balance_object& vbo, fc::time_point_sec now ) +vesting_balance_object_with_info::vesting_balance_object_with_info( + const vesting_balance_object& vbo, + fc::time_point_sec now ) : vesting_balance_object( vbo ) { allowed_withdraw = get_allowed_withdraw( now ); From 173ff3d27a4ca076a62bffdcd22d8f315b239a68 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Fri, 21 Jun 2019 23:05:56 +0200 Subject: [PATCH 118/133] Separate declaration + instantiation macros for external serialization to fix windows build --- libraries/chain/account_object.cpp | 6 +- libraries/chain/asset_object.cpp | 6 +- libraries/chain/genesis_state.cpp | 18 +++--- .../include/graphene/chain/account_object.hpp | 6 +- .../include/graphene/chain/asset_object.hpp | 6 +- .../include/graphene/chain/balance_object.hpp | 2 +- .../graphene/chain/block_summary_object.hpp | 2 +- .../graphene/chain/budget_record_object.hpp | 4 +- .../include/graphene/chain/buyback_object.hpp | 2 +- .../graphene/chain/chain_property_object.hpp | 2 +- .../chain/committee_member_object.hpp | 2 +- .../graphene/chain/confidential_object.hpp | 2 +- .../include/graphene/chain/fba_object.hpp | 2 +- .../include/graphene/chain/genesis_state.hpp | 18 +++--- .../graphene/chain/global_property_object.hpp | 4 +- .../include/graphene/chain/htlc_object.hpp | 2 +- .../chain/immutable_chain_parameters.hpp | 2 +- .../include/graphene/chain/market_object.hpp | 8 +-- .../chain/operation_history_object.hpp | 4 +- .../graphene/chain/proposal_object.hpp | 2 +- .../chain/special_authority_object.hpp | 2 +- .../chain/transaction_history_object.hpp | 2 +- .../graphene/chain/vesting_balance_object.hpp | 6 +- .../chain/withdraw_permission_object.hpp | 2 +- .../include/graphene/chain/witness_object.hpp | 2 +- .../chain/witness_schedule_object.hpp | 2 +- .../include/graphene/chain/worker_object.hpp | 2 +- libraries/chain/market_object.cpp | 8 +-- libraries/chain/proposal_object.cpp | 2 +- libraries/chain/small_objects.cpp | 42 ++++++------- libraries/chain/vesting_balance_object.cpp | 6 +- libraries/net/core_messages.cpp | 44 +++++++------- .../include/graphene/net/core_messages.hpp | 44 +++++++------- .../net/include/graphene/net/message.hpp | 4 +- .../include/graphene/net/peer_database.hpp | 2 +- libraries/net/message.cpp | 4 +- libraries/net/peer_database.cpp | 2 +- libraries/protocol/account.cpp | 22 +++---- libraries/protocol/address.cpp | 2 +- libraries/protocol/assert.cpp | 4 +- libraries/protocol/asset.cpp | 6 +- libraries/protocol/asset_ops.cpp | 60 +++++++++---------- libraries/protocol/authority.cpp | 2 +- libraries/protocol/block.cpp | 6 +- libraries/protocol/chain_parameters.cpp | 2 +- libraries/protocol/committee_member.cpp | 12 ++-- libraries/protocol/confidential.cpp | 12 ++-- libraries/protocol/custom.cpp | 4 +- libraries/protocol/fee_schedule.cpp | 2 +- libraries/protocol/htlc.cpp | 16 ++--- .../include/graphene/protocol/account.hpp | 22 +++---- .../include/graphene/protocol/address.hpp | 2 +- .../include/graphene/protocol/assert.hpp | 4 +- .../include/graphene/protocol/asset.hpp | 6 +- .../include/graphene/protocol/asset_ops.hpp | 60 +++++++++---------- .../include/graphene/protocol/authority.hpp | 2 +- .../include/graphene/protocol/balance.hpp | 2 +- .../include/graphene/protocol/block.hpp | 6 +- .../include/graphene/protocol/buyback.hpp | 2 +- .../graphene/protocol/chain_parameters.hpp | 2 +- .../graphene/protocol/committee_member.hpp | 12 ++-- .../graphene/protocol/confidential.hpp | 12 ++-- .../include/graphene/protocol/custom.hpp | 4 +- .../include/graphene/protocol/fba.hpp | 2 +- .../graphene/protocol/fee_schedule.hpp | 2 +- .../include/graphene/protocol/htlc.hpp | 16 ++--- .../include/graphene/protocol/market.hpp | 22 +++---- .../include/graphene/protocol/memo.hpp | 4 +- .../include/graphene/protocol/operations.hpp | 2 +- .../include/graphene/protocol/proposal.hpp | 12 ++-- .../graphene/protocol/special_authority.hpp | 2 +- .../include/graphene/protocol/transaction.hpp | 8 +-- .../include/graphene/protocol/transfer.hpp | 8 +-- .../include/graphene/protocol/types.hpp | 13 ++-- .../include/graphene/protocol/vesting.hpp | 8 +-- .../include/graphene/protocol/vote.hpp | 2 +- .../graphene/protocol/withdraw_permission.hpp | 16 ++--- .../include/graphene/protocol/witness.hpp | 8 +-- .../include/graphene/protocol/worker.hpp | 4 +- libraries/protocol/market.cpp | 22 +++---- libraries/protocol/memo.cpp | 4 +- libraries/protocol/operations.cpp | 2 +- libraries/protocol/proposal.cpp | 12 ++-- libraries/protocol/small_ops.cpp | 14 ++--- libraries/protocol/special_authority.cpp | 2 +- libraries/protocol/transaction.cpp | 8 +-- libraries/protocol/transfer.cpp | 8 +-- libraries/protocol/vote.cpp | 2 +- libraries/protocol/withdraw_permission.cpp | 16 ++--- libraries/protocol/witness.cpp | 8 +-- libraries/protocol/worker.cpp | 4 +- 91 files changed, 398 insertions(+), 395 deletions(-) diff --git a/libraries/chain/account_object.cpp b/libraries/chain/account_object.cpp index 914f99c186..8ec70a6a4f 100644 --- a/libraries/chain/account_object.cpp +++ b/libraries/chain/account_object.cpp @@ -351,6 +351,6 @@ FC_REFLECT_DERIVED_NO_TYPENAME( graphene::chain::account_statistics_object, (pending_fees)(pending_vested_fees) ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::account_object ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::account_balance_object ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::account_statistics_object ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::chain::account_object ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::chain::account_balance_object ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::chain::account_statistics_object ) diff --git a/libraries/chain/asset_object.cpp b/libraries/chain/asset_object.cpp index 2a2c2f4804..549159da72 100644 --- a/libraries/chain/asset_object.cpp +++ b/libraries/chain/asset_object.cpp @@ -204,6 +204,6 @@ FC_REFLECT_DERIVED_NO_TYPENAME( graphene::chain::asset_object, (graphene::db::ob (buyback_account) ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_object ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_bitasset_data_object ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_dynamic_data_object ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::chain::asset_object ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::chain::asset_bitasset_data_object ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::chain::asset_dynamic_data_object ) diff --git a/libraries/chain/genesis_state.cpp b/libraries/chain/genesis_state.cpp index 33c15cbb2c..90df17af01 100644 --- a/libraries/chain/genesis_state.cpp +++ b/libraries/chain/genesis_state.cpp @@ -65,12 +65,12 @@ FC_REFLECT_DERIVED_NO_TYPENAME(graphene::chain::genesis_state_type, BOOST_PP_SEQ (initial_committee_candidates)(initial_worker_candidates) (immutable_parameters)) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::genesis_state_type::initial_account_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::genesis_state_type::initial_asset_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::genesis_state_type::initial_asset_type::initial_collateral_position ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::genesis_state_type::initial_balance_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::genesis_state_type::initial_vesting_balance_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::genesis_state_type::initial_witness_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::genesis_state_type::initial_committee_member_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::genesis_state_type::initial_worker_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::genesis_state_type ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::chain::genesis_state_type::initial_account_type ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::chain::genesis_state_type::initial_asset_type ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::chain::genesis_state_type::initial_asset_type::initial_collateral_position ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::chain::genesis_state_type::initial_balance_type ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::chain::genesis_state_type::initial_vesting_balance_type ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::chain::genesis_state_type::initial_witness_type ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::chain::genesis_state_type::initial_committee_member_type ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::chain::genesis_state_type::initial_worker_type ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::chain::genesis_state_type ) diff --git a/libraries/chain/include/graphene/chain/account_object.hpp b/libraries/chain/include/graphene/chain/account_object.hpp index 4178da20a2..70aa0f78e9 100644 --- a/libraries/chain/include/graphene/chain/account_object.hpp +++ b/libraries/chain/include/graphene/chain/account_object.hpp @@ -451,6 +451,6 @@ FC_REFLECT_TYPENAME( graphene::chain::account_object ) FC_REFLECT_TYPENAME( graphene::chain::account_balance_object ) FC_REFLECT_TYPENAME( graphene::chain::account_statistics_object ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::account_object ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::account_balance_object ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::account_statistics_object ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::chain::account_object ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::chain::account_balance_object ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::chain::account_statistics_object ) diff --git a/libraries/chain/include/graphene/chain/asset_object.hpp b/libraries/chain/include/graphene/chain/asset_object.hpp index 8b22073706..1a4ad3e47d 100644 --- a/libraries/chain/include/graphene/chain/asset_object.hpp +++ b/libraries/chain/include/graphene/chain/asset_object.hpp @@ -327,6 +327,6 @@ FC_REFLECT_TYPENAME( graphene::chain::asset_object ) FC_REFLECT_TYPENAME( graphene::chain::asset_bitasset_data_object ) FC_REFLECT_TYPENAME( graphene::chain::asset_dynamic_data_object ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_object ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_bitasset_data_object ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_dynamic_data_object ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::chain::asset_object ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::chain::asset_bitasset_data_object ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::chain::asset_dynamic_data_object ) diff --git a/libraries/chain/include/graphene/chain/balance_object.hpp b/libraries/chain/include/graphene/chain/balance_object.hpp index 842d99aea6..ef385a0642 100644 --- a/libraries/chain/include/graphene/chain/balance_object.hpp +++ b/libraries/chain/include/graphene/chain/balance_object.hpp @@ -75,4 +75,4 @@ MAP_OBJECT_ID_TO_TYPE(graphene::chain::balance_object) FC_REFLECT_TYPENAME( graphene::chain::balance_object ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::balance_object ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::chain::balance_object ) diff --git a/libraries/chain/include/graphene/chain/block_summary_object.hpp b/libraries/chain/include/graphene/chain/block_summary_object.hpp index 0f2dd650f1..2206843c47 100644 --- a/libraries/chain/include/graphene/chain/block_summary_object.hpp +++ b/libraries/chain/include/graphene/chain/block_summary_object.hpp @@ -52,4 +52,4 @@ MAP_OBJECT_ID_TO_TYPE(graphene::chain::block_summary_object) FC_REFLECT_TYPENAME( graphene::chain::block_summary_object ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::block_summary_object ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::chain::block_summary_object ) diff --git a/libraries/chain/include/graphene/chain/budget_record_object.hpp b/libraries/chain/include/graphene/chain/budget_record_object.hpp index 35a8b4af1b..3f8ec3cbcf 100644 --- a/libraries/chain/include/graphene/chain/budget_record_object.hpp +++ b/libraries/chain/include/graphene/chain/budget_record_object.hpp @@ -70,5 +70,5 @@ MAP_OBJECT_ID_TO_TYPE(graphene::chain::budget_record_object) FC_REFLECT_TYPENAME( graphene::chain::budget_record ) FC_REFLECT_TYPENAME( graphene::chain::budget_record_object ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::budget_record ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::budget_record_object ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::chain::budget_record ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::chain::budget_record_object ) diff --git a/libraries/chain/include/graphene/chain/buyback_object.hpp b/libraries/chain/include/graphene/chain/buyback_object.hpp index 60fc2d59e1..a17f6a9ed3 100644 --- a/libraries/chain/include/graphene/chain/buyback_object.hpp +++ b/libraries/chain/include/graphene/chain/buyback_object.hpp @@ -67,4 +67,4 @@ MAP_OBJECT_ID_TO_TYPE(graphene::chain::buyback_object) FC_REFLECT_TYPENAME( graphene::chain::buyback_object ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::buyback_object ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( 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 0e3e8e316e..86dba6b8fd 100644 --- a/libraries/chain/include/graphene/chain/chain_property_object.hpp +++ b/libraries/chain/include/graphene/chain/chain_property_object.hpp @@ -46,4 +46,4 @@ MAP_OBJECT_ID_TO_TYPE(graphene::chain::chain_property_object) FC_REFLECT_TYPENAME( graphene::chain::chain_property_object ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::chain_property_object ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::chain::chain_property_object ) diff --git a/libraries/chain/include/graphene/chain/committee_member_object.hpp b/libraries/chain/include/graphene/chain/committee_member_object.hpp index 89f361c845..8812222fc0 100644 --- a/libraries/chain/include/graphene/chain/committee_member_object.hpp +++ b/libraries/chain/include/graphene/chain/committee_member_object.hpp @@ -75,4 +75,4 @@ MAP_OBJECT_ID_TO_TYPE(graphene::chain::committee_member_object) FC_REFLECT_TYPENAME( graphene::chain::committee_member_object ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::committee_member_object ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::chain::committee_member_object ) diff --git a/libraries/chain/include/graphene/chain/confidential_object.hpp b/libraries/chain/include/graphene/chain/confidential_object.hpp index 7bbdf0575b..9c8fba2150 100644 --- a/libraries/chain/include/graphene/chain/confidential_object.hpp +++ b/libraries/chain/include/graphene/chain/confidential_object.hpp @@ -69,4 +69,4 @@ MAP_OBJECT_ID_TO_TYPE(graphene::chain::blinded_balance_object) FC_REFLECT_TYPENAME( graphene::chain::blinded_balance_object ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::blinded_balance_object ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::chain::blinded_balance_object ) diff --git a/libraries/chain/include/graphene/chain/fba_object.hpp b/libraries/chain/include/graphene/chain/fba_object.hpp index f6cff5b4e9..5558b92a62 100644 --- a/libraries/chain/include/graphene/chain/fba_object.hpp +++ b/libraries/chain/include/graphene/chain/fba_object.hpp @@ -52,4 +52,4 @@ MAP_OBJECT_ID_TO_TYPE(graphene::chain::fba_accumulator_object) FC_REFLECT_TYPENAME( graphene::chain::fba_accumulator_object ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::fba_accumulator_object ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::chain::fba_accumulator_object ) diff --git a/libraries/chain/include/graphene/chain/genesis_state.hpp b/libraries/chain/include/graphene/chain/genesis_state.hpp index 98f9c0de16..98538e824e 100644 --- a/libraries/chain/include/graphene/chain/genesis_state.hpp +++ b/libraries/chain/include/graphene/chain/genesis_state.hpp @@ -138,12 +138,12 @@ FC_REFLECT_TYPENAME( graphene::chain::genesis_state_type::initial_committee_memb FC_REFLECT_TYPENAME( graphene::chain::genesis_state_type::initial_worker_type ) FC_REFLECT_TYPENAME( graphene::chain::genesis_state_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::genesis_state_type::initial_account_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::genesis_state_type::initial_asset_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::genesis_state_type::initial_asset_type::initial_collateral_position ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::genesis_state_type::initial_balance_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::genesis_state_type::initial_vesting_balance_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::genesis_state_type::initial_witness_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::genesis_state_type::initial_committee_member_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::genesis_state_type::initial_worker_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::genesis_state_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::chain::genesis_state_type::initial_account_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::chain::genesis_state_type::initial_asset_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::chain::genesis_state_type::initial_asset_type::initial_collateral_position ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::chain::genesis_state_type::initial_balance_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::chain::genesis_state_type::initial_vesting_balance_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::chain::genesis_state_type::initial_witness_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::chain::genesis_state_type::initial_committee_member_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::chain::genesis_state_type::initial_worker_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::chain::genesis_state_type ) diff --git a/libraries/chain/include/graphene/chain/global_property_object.hpp b/libraries/chain/include/graphene/chain/global_property_object.hpp index 0ce0ca03e9..9141118bd2 100644 --- a/libraries/chain/include/graphene/chain/global_property_object.hpp +++ b/libraries/chain/include/graphene/chain/global_property_object.hpp @@ -130,5 +130,5 @@ MAP_OBJECT_ID_TO_TYPE(graphene::chain::global_property_object) FC_REFLECT_TYPENAME( graphene::chain::dynamic_global_property_object ) FC_REFLECT_TYPENAME( graphene::chain::global_property_object ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::dynamic_global_property_object ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::global_property_object ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::chain::dynamic_global_property_object ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::chain::global_property_object ) diff --git a/libraries/chain/include/graphene/chain/htlc_object.hpp b/libraries/chain/include/graphene/chain/htlc_object.hpp index 3c947aa510..6679c6b636 100644 --- a/libraries/chain/include/graphene/chain/htlc_object.hpp +++ b/libraries/chain/include/graphene/chain/htlc_object.hpp @@ -121,4 +121,4 @@ FC_REFLECT_TYPENAME( graphene::chain::htlc_object::condition_info::time_lock_inf FC_REFLECT_TYPENAME( graphene::chain::htlc_object::condition_info ) FC_REFLECT_TYPENAME( graphene::chain::htlc_object ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::htlc_object ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::chain::htlc_object ) diff --git a/libraries/chain/include/graphene/chain/immutable_chain_parameters.hpp b/libraries/chain/include/graphene/chain/immutable_chain_parameters.hpp index 80346c122d..aeaca7f8a0 100644 --- a/libraries/chain/include/graphene/chain/immutable_chain_parameters.hpp +++ b/libraries/chain/include/graphene/chain/immutable_chain_parameters.hpp @@ -40,4 +40,4 @@ struct immutable_chain_parameters FC_REFLECT_TYPENAME( graphene::chain::immutable_chain_parameters ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::immutable_chain_parameters ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::chain::immutable_chain_parameters ) diff --git a/libraries/chain/include/graphene/chain/market_object.hpp b/libraries/chain/include/graphene/chain/market_object.hpp index d9d8cbb484..0861f0eccc 100644 --- a/libraries/chain/include/graphene/chain/market_object.hpp +++ b/libraries/chain/include/graphene/chain/market_object.hpp @@ -280,7 +280,7 @@ FC_REFLECT_TYPENAME( graphene::chain::call_order_object ) FC_REFLECT_TYPENAME( graphene::chain::force_settlement_object ) FC_REFLECT_TYPENAME( graphene::chain::collateral_bid_object ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::limit_order_object ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::call_order_object ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::force_settlement_object ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::collateral_bid_object ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::chain::limit_order_object ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::chain::call_order_object ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::chain::force_settlement_object ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::chain::collateral_bid_object ) diff --git a/libraries/chain/include/graphene/chain/operation_history_object.hpp b/libraries/chain/include/graphene/chain/operation_history_object.hpp index e514340234..097892d33d 100644 --- a/libraries/chain/include/graphene/chain/operation_history_object.hpp +++ b/libraries/chain/include/graphene/chain/operation_history_object.hpp @@ -144,5 +144,5 @@ MAP_OBJECT_ID_TO_TYPE(graphene::chain::account_transaction_history_object) FC_REFLECT_TYPENAME( graphene::chain::operation_history_object ) FC_REFLECT_TYPENAME( graphene::chain::account_transaction_history_object ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::operation_history_object ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::account_transaction_history_object ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::chain::operation_history_object ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::chain::account_transaction_history_object ) diff --git a/libraries/chain/include/graphene/chain/proposal_object.hpp b/libraries/chain/include/graphene/chain/proposal_object.hpp index 2c708ac48a..8d6bc849da 100644 --- a/libraries/chain/include/graphene/chain/proposal_object.hpp +++ b/libraries/chain/include/graphene/chain/proposal_object.hpp @@ -108,4 +108,4 @@ MAP_OBJECT_ID_TO_TYPE(graphene::chain::proposal_object) FC_REFLECT_TYPENAME( graphene::chain::proposal_object ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::proposal_object ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::chain::proposal_object ) diff --git a/libraries/chain/include/graphene/chain/special_authority_object.hpp b/libraries/chain/include/graphene/chain/special_authority_object.hpp index 2ff0cf170c..1e45bc28dc 100644 --- a/libraries/chain/include/graphene/chain/special_authority_object.hpp +++ b/libraries/chain/include/graphene/chain/special_authority_object.hpp @@ -66,4 +66,4 @@ MAP_OBJECT_ID_TO_TYPE(graphene::chain::special_authority_object) FC_REFLECT_TYPENAME( graphene::chain::special_authority_object ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::special_authority_object ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::chain::special_authority_object ) diff --git a/libraries/chain/include/graphene/chain/transaction_history_object.hpp b/libraries/chain/include/graphene/chain/transaction_history_object.hpp index b29b26e1dc..2f0ebe9fc2 100644 --- a/libraries/chain/include/graphene/chain/transaction_history_object.hpp +++ b/libraries/chain/include/graphene/chain/transaction_history_object.hpp @@ -73,4 +73,4 @@ MAP_OBJECT_ID_TO_TYPE(graphene::chain::transaction_history_object) FC_REFLECT_TYPENAME( graphene::chain::transaction_history_object ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::transaction_history_object ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::chain::transaction_history_object ) diff --git a/libraries/chain/include/graphene/chain/vesting_balance_object.hpp b/libraries/chain/include/graphene/chain/vesting_balance_object.hpp index 2713c31bbc..480922fa90 100644 --- a/libraries/chain/include/graphene/chain/vesting_balance_object.hpp +++ b/libraries/chain/include/graphene/chain/vesting_balance_object.hpp @@ -302,6 +302,6 @@ FC_REFLECT_DERIVED(graphene::chain::vesting_balance_object, (graphene::db::objec FC_REFLECT_ENUM( graphene::chain::vesting_balance_type, (unspecified)(cashback)(worker)(witness)(market_fee_sharing) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::linear_vesting_policy ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::cdd_vesting_policy ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::vesting_balance_object ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::chain::linear_vesting_policy ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::chain::cdd_vesting_policy ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::chain::vesting_balance_object ) diff --git a/libraries/chain/include/graphene/chain/withdraw_permission_object.hpp b/libraries/chain/include/graphene/chain/withdraw_permission_object.hpp index 3763826eef..cb954ad7f3 100644 --- a/libraries/chain/include/graphene/chain/withdraw_permission_object.hpp +++ b/libraries/chain/include/graphene/chain/withdraw_permission_object.hpp @@ -121,4 +121,4 @@ MAP_OBJECT_ID_TO_TYPE(graphene::chain::withdraw_permission_object) FC_REFLECT_TYPENAME( graphene::chain::withdraw_permission_object ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::withdraw_permission_object ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::chain::withdraw_permission_object ) diff --git a/libraries/chain/include/graphene/chain/witness_object.hpp b/libraries/chain/include/graphene/chain/witness_object.hpp index ee49f776e8..0c48f3bc17 100644 --- a/libraries/chain/include/graphene/chain/witness_object.hpp +++ b/libraries/chain/include/graphene/chain/witness_object.hpp @@ -72,4 +72,4 @@ MAP_OBJECT_ID_TO_TYPE(graphene::chain::witness_object) FC_REFLECT_TYPENAME( graphene::chain::witness_object ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::witness_object ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::chain::witness_object ) diff --git a/libraries/chain/include/graphene/chain/witness_schedule_object.hpp b/libraries/chain/include/graphene/chain/witness_schedule_object.hpp index b7f0ec86db..f481e05852 100644 --- a/libraries/chain/include/graphene/chain/witness_schedule_object.hpp +++ b/libraries/chain/include/graphene/chain/witness_schedule_object.hpp @@ -42,4 +42,4 @@ MAP_OBJECT_ID_TO_TYPE(graphene::chain::witness_schedule_object) FC_REFLECT_TYPENAME( graphene::chain::witness_schedule_object ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::witness_schedule_object ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::chain::witness_schedule_object ) diff --git a/libraries/chain/include/graphene/chain/worker_object.hpp b/libraries/chain/include/graphene/chain/worker_object.hpp index 94f228d160..da5c170ca1 100644 --- a/libraries/chain/include/graphene/chain/worker_object.hpp +++ b/libraries/chain/include/graphene/chain/worker_object.hpp @@ -167,4 +167,4 @@ FC_REFLECT_TYPENAME( graphene::chain::burn_worker_type ) FC_REFLECT_TYPENAME( graphene::chain::worker_type ) FC_REFLECT_TYPENAME( graphene::chain::worker_object ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::worker_object ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::chain::worker_object ) diff --git a/libraries/chain/market_object.cpp b/libraries/chain/market_object.cpp index 9739a96da7..0cd19b63f5 100644 --- a/libraries/chain/market_object.cpp +++ b/libraries/chain/market_object.cpp @@ -319,7 +319,7 @@ FC_REFLECT_DERIVED_NO_TYPENAME( graphene::chain::force_settlement_object, FC_REFLECT_DERIVED_NO_TYPENAME( graphene::chain::collateral_bid_object, (graphene::db::object), (bidder)(inv_swan_price) ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::limit_order_object ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::call_order_object ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::force_settlement_object ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::collateral_bid_object ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::chain::limit_order_object ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::chain::call_order_object ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::chain::force_settlement_object ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::chain::collateral_bid_object ) diff --git a/libraries/chain/proposal_object.cpp b/libraries/chain/proposal_object.cpp index 14a738cd13..62502e2736 100644 --- a/libraries/chain/proposal_object.cpp +++ b/libraries/chain/proposal_object.cpp @@ -139,4 +139,4 @@ FC_REFLECT_DERIVED_NO_TYPENAME( graphene::chain::proposal_object, (graphene::cha (available_active_approvals)(required_owner_approvals)(available_owner_approvals) (available_key_approvals)(proposer)(fail_reason) ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::proposal_object ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::chain::proposal_object ) diff --git a/libraries/chain/small_objects.cpp b/libraries/chain/small_objects.cpp index e7a018b55d..ed68a4eaef 100644 --- a/libraries/chain/small_objects.cpp +++ b/libraries/chain/small_objects.cpp @@ -189,24 +189,24 @@ FC_REFLECT_DERIVED_NO_TYPENAME( graphene::chain::worker_object, (graphene::db::o (url) ) -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 ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::budget_record_object ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::buyback_object ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::immutable_chain_parameters ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::chain_property_object ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::committee_member_object ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::blinded_balance_object ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::fba_accumulator_object ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::dynamic_global_property_object ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::global_property_object ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::htlc_object ) -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_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_schedule_object ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::worker_object ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::chain::balance_object ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::chain::block_summary_object ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::chain::budget_record ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::chain::budget_record_object ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::chain::buyback_object ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::chain::immutable_chain_parameters ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::chain::chain_property_object ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::chain::committee_member_object ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::chain::blinded_balance_object ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::chain::fba_accumulator_object ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::chain::dynamic_global_property_object ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::chain::global_property_object ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::chain::htlc_object ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::chain::operation_history_object ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::chain::account_transaction_history_object ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::chain::special_authority_object ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::chain::transaction_history_object ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::chain::withdraw_permission_object ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::chain::witness_object ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::chain::witness_schedule_object ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::chain::worker_object ) diff --git a/libraries/chain/vesting_balance_object.cpp b/libraries/chain/vesting_balance_object.cpp index 7a7acf9728..2bc8e45a78 100644 --- a/libraries/chain/vesting_balance_object.cpp +++ b/libraries/chain/vesting_balance_object.cpp @@ -271,6 +271,6 @@ asset vesting_balance_object::get_allowed_withdraw(const time_point_sec& now)con } } // graphene::chain -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::linear_vesting_policy ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::cdd_vesting_policy ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::vesting_balance_object ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::chain::linear_vesting_policy ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::chain::cdd_vesting_policy ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::chain::vesting_balance_object ) diff --git a/libraries/net/core_messages.cpp b/libraries/net/core_messages.cpp index 1f7b9fce93..fc3017d243 100644 --- a/libraries/net/core_messages.cpp +++ b/libraries/net/core_messages.cpp @@ -129,25 +129,25 @@ FC_REFLECT_DERIVED_NO_TYPENAME(graphene::net::get_current_connections_reply_mess (download_rate_one_hour) (current_connections)) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::net::trx_message ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::net::block_message ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::net::item_id ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::net::item_ids_inventory_message ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::net::blockchain_item_ids_inventory_message ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::net::fetch_blockchain_item_ids_message ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::net::fetch_items_message ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::net::item_not_available_message ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::net::hello_message ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::net::connection_accepted_message ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::net::connection_rejected_message ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::net::address_request_message ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::net::address_info ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::net::address_message ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::net::closing_connection_message ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::net::current_time_request_message ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::net::current_time_reply_message ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::net::check_firewall_message ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::net::check_firewall_reply_message ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::net::get_current_connections_request_message ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::net::current_connection_data ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::net::get_current_connections_reply_message ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::net::trx_message ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::net::block_message ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::net::item_id ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::net::item_ids_inventory_message ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::net::blockchain_item_ids_inventory_message ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::net::fetch_blockchain_item_ids_message ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::net::fetch_items_message ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::net::item_not_available_message ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::net::hello_message ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::net::connection_accepted_message ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::net::connection_rejected_message ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::net::address_request_message ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::net::address_info ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::net::address_message ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::net::closing_connection_message ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::net::current_time_request_message ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::net::current_time_reply_message ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::net::check_firewall_message ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::net::check_firewall_reply_message ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::net::get_current_connections_request_message ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::net::current_connection_data ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::net::get_current_connections_reply_message ) diff --git a/libraries/net/include/graphene/net/core_messages.hpp b/libraries/net/include/graphene/net/core_messages.hpp index c1ec69c44a..88d563e683 100644 --- a/libraries/net/include/graphene/net/core_messages.hpp +++ b/libraries/net/include/graphene/net/core_messages.hpp @@ -464,28 +464,28 @@ FC_REFLECT_TYPENAME( graphene::net::get_current_connections_request_message ) FC_REFLECT_TYPENAME( graphene::net::current_connection_data ) FC_REFLECT_TYPENAME( graphene::net::get_current_connections_reply_message ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::net::trx_message ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::net::block_message ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::net::item_id ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::net::item_ids_inventory_message ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::net::blockchain_item_ids_inventory_message ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::net::fetch_blockchain_item_ids_message ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::net::fetch_items_message ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::net::item_not_available_message ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::net::hello_message ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::net::connection_accepted_message ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::net::connection_rejected_message ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::net::address_request_message ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::net::address_info ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::net::address_message ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::net::closing_connection_message ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::net::current_time_request_message ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::net::current_time_reply_message ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::net::check_firewall_message ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::net::check_firewall_reply_message ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::net::get_current_connections_request_message ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::net::current_connection_data ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::net::get_current_connections_reply_message ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::net::trx_message ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::net::block_message ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::net::item_id ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::net::item_ids_inventory_message ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::net::blockchain_item_ids_inventory_message ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::net::fetch_blockchain_item_ids_message ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::net::fetch_items_message ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::net::item_not_available_message ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::net::hello_message ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::net::connection_accepted_message ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::net::connection_rejected_message ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::net::address_request_message ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::net::address_info ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::net::address_message ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::net::closing_connection_message ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::net::current_time_request_message ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::net::current_time_reply_message ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::net::check_firewall_message ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::net::check_firewall_reply_message ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::net::get_current_connections_request_message ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::net::current_connection_data ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::net::get_current_connections_reply_message ) #include #include diff --git a/libraries/net/include/graphene/net/message.hpp b/libraries/net/include/graphene/net/message.hpp index d8792da758..8ebfd8caa3 100644 --- a/libraries/net/include/graphene/net/message.hpp +++ b/libraries/net/include/graphene/net/message.hpp @@ -117,5 +117,5 @@ namespace graphene { namespace net { FC_REFLECT_TYPENAME( graphene::net::message_header ) FC_REFLECT_TYPENAME( graphene::net::message ) -GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::net::message_header) -GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::net::message) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::net::message_header) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::net::message) diff --git a/libraries/net/include/graphene/net/peer_database.hpp b/libraries/net/include/graphene/net/peer_database.hpp index 931f6e33a7..8b7e18b894 100644 --- a/libraries/net/include/graphene/net/peer_database.hpp +++ b/libraries/net/include/graphene/net/peer_database.hpp @@ -121,4 +121,4 @@ namespace graphene { namespace net { FC_REFLECT_TYPENAME( graphene::net::potential_peer_record ) -GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::net::potential_peer_record) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::net::potential_peer_record) diff --git a/libraries/net/message.cpp b/libraries/net/message.cpp index 74c04eba00..8acef0ac08 100644 --- a/libraries/net/message.cpp +++ b/libraries/net/message.cpp @@ -28,5 +28,5 @@ FC_REFLECT_DERIVED_NO_TYPENAME( graphene::net::message_header, BOOST_PP_SEQ_NIL, (size)(msg_type) ) FC_REFLECT_DERIVED_NO_TYPENAME( graphene::net::message, (graphene::net::message_header), (data) ) -GRAPHENE_EXTERNAL_SERIALIZATION(/*not extern*/, graphene::net::message_header) -GRAPHENE_EXTERNAL_SERIALIZATION(/*not extern*/, graphene::net::message) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::net::message_header) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::net::message) diff --git a/libraries/net/peer_database.cpp b/libraries/net/peer_database.cpp index 76ae9c8c16..0e4867675d 100644 --- a/libraries/net/peer_database.cpp +++ b/libraries/net/peer_database.cpp @@ -284,4 +284,4 @@ FC_REFLECT_DERIVED_NO_TYPENAME( graphene::net::potential_peer_record, BOOST_PP_S (last_connection_attempt_time)(number_of_successful_connection_attempts) (number_of_failed_connection_attempts)(last_error) ) -GRAPHENE_EXTERNAL_SERIALIZATION(/*not extern*/, graphene::net::potential_peer_record) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::net::potential_peer_record) diff --git a/libraries/protocol/account.cpp b/libraries/protocol/account.cpp index c1e07cd194..f51271405b 100644 --- a/libraries/protocol/account.cpp +++ b/libraries/protocol/account.cpp @@ -279,14 +279,14 @@ void account_transfer_operation::validate()const } } // graphene::protocol -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 ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::account_options ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::account_create_operation::fee_parameters_type ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::account_whitelist_operation::fee_parameters_type ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::account_update_operation::fee_parameters_type ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::account_upgrade_operation::fee_parameters_type ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::account_transfer_operation::fee_parameters_type ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::account_create_operation ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::account_whitelist_operation ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::account_update_operation ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::account_upgrade_operation ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::account_transfer_operation ) diff --git a/libraries/protocol/address.cpp b/libraries/protocol/address.cpp index 4647416677..9ab70220ba 100644 --- a/libraries/protocol/address.cpp +++ b/libraries/protocol/address.cpp @@ -110,4 +110,4 @@ namespace fc } } -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::address ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::address ) diff --git a/libraries/protocol/assert.cpp b/libraries/protocol/assert.cpp index 2d5454e0b9..2199b314d8 100644 --- a/libraries/protocol/assert.cpp +++ b/libraries/protocol/assert.cpp @@ -68,5 +68,5 @@ share_type assert_operation::calculate_fee(const fee_parameters_type& k)const } } // namespace graphene::protocol -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::assert_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::assert_operation ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::assert_operation::fee_parameters_type ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::assert_operation ) diff --git a/libraries/protocol/asset.cpp b/libraries/protocol/asset.cpp index 898a8966f5..77f6dd7c12 100644 --- a/libraries/protocol/asset.cpp +++ b/libraries/protocol/asset.cpp @@ -318,6 +318,6 @@ const int64_t scaled_precision_lut[19] = } } // graphene::protocol -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 ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::asset ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::price ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::price_feed ) diff --git a/libraries/protocol/asset_ops.cpp b/libraries/protocol/asset_ops.cpp index 3100db2f71..ba1b7f65f8 100644 --- a/libraries/protocol/asset_ops.cpp +++ b/libraries/protocol/asset_ops.cpp @@ -256,33 +256,33 @@ void asset_claim_pool_operation::validate()const { } } // 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::additional_asset_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_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_issuer_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_pool_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_claim_fees_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_update_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_update_issuer_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 ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::asset_options ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::bitasset_options ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::additional_asset_options ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::asset_create_operation::fee_parameters_type ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::asset_global_settle_operation::fee_parameters_type ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::asset_settle_operation::fee_parameters_type ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::asset_fund_fee_pool_operation::fee_parameters_type ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::asset_claim_pool_operation::fee_parameters_type ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::asset_claim_fees_operation::fee_parameters_type ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::asset_update_operation::fee_parameters_type ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::asset_update_issuer_operation::fee_parameters_type ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::asset_update_bitasset_operation::fee_parameters_type ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::asset_update_feed_producers_operation::fee_parameters_type ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::asset_publish_feed_operation::fee_parameters_type ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::asset_issue_operation::fee_parameters_type ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::asset_reserve_operation::fee_parameters_type ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::asset_create_operation ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::asset_global_settle_operation ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::asset_settle_operation ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::asset_settle_cancel_operation ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::asset_fund_fee_pool_operation ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::asset_claim_pool_operation ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::asset_claim_fees_operation ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::asset_update_operation ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::asset_update_issuer_operation ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::asset_update_bitasset_operation ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::asset_update_feed_producers_operation ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::asset_publish_feed_operation ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::asset_issue_operation ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::asset_reserve_operation ) diff --git a/libraries/protocol/authority.cpp b/libraries/protocol/authority.cpp index c3fd44dd3b..121ad46d9b 100644 --- a/libraries/protocol/authority.cpp +++ b/libraries/protocol/authority.cpp @@ -39,4 +39,4 @@ void add_authority_accounts( } } // graphene::protocol -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::authority ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::authority ) diff --git a/libraries/protocol/block.cpp b/libraries/protocol/block.cpp index 37d8628cd4..307b592d4e 100644 --- a/libraries/protocol/block.cpp +++ b/libraries/protocol/block.cpp @@ -100,6 +100,6 @@ namespace graphene { namespace protocol { } } } -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) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::block_header) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::signed_block_header) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::signed_block) diff --git a/libraries/protocol/chain_parameters.cpp b/libraries/protocol/chain_parameters.cpp index 319d00f2c5..eed40e8416 100644 --- a/libraries/protocol/chain_parameters.cpp +++ b/libraries/protocol/chain_parameters.cpp @@ -80,4 +80,4 @@ namespace graphene { namespace protocol { }} -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::chain_parameters ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::chain_parameters ) diff --git a/libraries/protocol/committee_member.cpp b/libraries/protocol/committee_member.cpp index 3972a44a1a..d48372c944 100644 --- a/libraries/protocol/committee_member.cpp +++ b/libraries/protocol/committee_member.cpp @@ -49,9 +49,9 @@ void committee_member_update_global_parameters_operation::validate() const } } // graphene::protocol -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 ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::committee_member_create_operation::fee_parameters_type ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::committee_member_update_operation::fee_parameters_type ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::committee_member_update_global_parameters_operation::fee_parameters_type ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::committee_member_create_operation ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::committee_member_update_operation ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::committee_member_update_global_parameters_operation ) diff --git a/libraries/protocol/confidential.cpp b/libraries/protocol/confidential.cpp index ce81b43b16..43a8b0587e 100644 --- a/libraries/protocol/confidential.cpp +++ b/libraries/protocol/confidential.cpp @@ -156,9 +156,9 @@ stealth_confirmation::stealth_confirmation( const std::string& base58 ) } } // graphene::protocol -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 ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::transfer_to_blind_operation::fee_parameters_type ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::transfer_from_blind_operation::fee_parameters_type ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::blind_transfer_operation::fee_parameters_type ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::transfer_to_blind_operation ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::transfer_from_blind_operation ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::blind_transfer_operation ) diff --git a/libraries/protocol/custom.cpp b/libraries/protocol/custom.cpp index e3981a7fc1..22ea61f72b 100644 --- a/libraries/protocol/custom.cpp +++ b/libraries/protocol/custom.cpp @@ -38,5 +38,5 @@ share_type custom_operation::calculate_fee(const fee_parameters_type& k)const } } -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::custom_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::custom_operation ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::custom_operation::fee_parameters_type ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::custom_operation ) diff --git a/libraries/protocol/fee_schedule.cpp b/libraries/protocol/fee_schedule.cpp index fd7f429119..336c52a202 100644 --- a/libraries/protocol/fee_schedule.cpp +++ b/libraries/protocol/fee_schedule.cpp @@ -185,4 +185,4 @@ namespace graphene { namespace protocol { } } // graphene::protocol -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::fee_schedule ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::fee_schedule ) diff --git a/libraries/protocol/htlc.cpp b/libraries/protocol/htlc.cpp index 4f332c8593..b7fe9ef4a0 100644 --- a/libraries/protocol/htlc.cpp +++ b/libraries/protocol/htlc.cpp @@ -68,11 +68,11 @@ namespace graphene { namespace protocol { } } } -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::htlc_create_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::htlc_redeem_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::htlc_extend_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::htlc_create_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::htlc_redeem_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::htlc_redeemed_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::htlc_extend_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::htlc_refund_operation ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::htlc_create_operation::fee_parameters_type ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::htlc_redeem_operation::fee_parameters_type ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::htlc_extend_operation::fee_parameters_type ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::htlc_create_operation ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::htlc_redeem_operation ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::htlc_redeemed_operation ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::htlc_extend_operation ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::htlc_refund_operation ) diff --git a/libraries/protocol/include/graphene/protocol/account.hpp b/libraries/protocol/include/graphene/protocol/account.hpp index 0b6d3af114..02aba3a3f7 100644 --- a/libraries/protocol/include/graphene/protocol/account.hpp +++ b/libraries/protocol/include/graphene/protocol/account.hpp @@ -301,14 +301,14 @@ FC_REFLECT( graphene::protocol::account_transfer_operation::fee_parameters_type, 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 ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::account_options ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::account_create_operation::fee_parameters_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::account_whitelist_operation::fee_parameters_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::account_update_operation::fee_parameters_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::account_upgrade_operation::fee_parameters_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::account_transfer_operation::fee_parameters_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::account_create_operation ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::account_whitelist_operation ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::account_update_operation ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::account_upgrade_operation ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::account_transfer_operation ) diff --git a/libraries/protocol/include/graphene/protocol/address.hpp b/libraries/protocol/include/graphene/protocol/address.hpp index 5a473a0851..e118128b55 100644 --- a/libraries/protocol/include/graphene/protocol/address.hpp +++ b/libraries/protocol/include/graphene/protocol/address.hpp @@ -71,4 +71,4 @@ namespace fc FC_REFLECT( graphene::protocol::address, (addr) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::address ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::address ) diff --git a/libraries/protocol/include/graphene/protocol/assert.hpp b/libraries/protocol/include/graphene/protocol/assert.hpp index e12de03891..fead1a7031 100644 --- a/libraries/protocol/include/graphene/protocol/assert.hpp +++ b/libraries/protocol/include/graphene/protocol/assert.hpp @@ -114,5 +114,5 @@ 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::protocol::assert_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::assert_operation ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::assert_operation::fee_parameters_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::assert_operation ) diff --git a/libraries/protocol/include/graphene/protocol/asset.hpp b/libraries/protocol/include/graphene/protocol/asset.hpp index ee1483a88c..657a17c896 100644 --- a/libraries/protocol/include/graphene/protocol/asset.hpp +++ b/libraries/protocol/include/graphene/protocol/asset.hpp @@ -228,6 +228,6 @@ FC_REFLECT( graphene::protocol::price, (base)(quote) ) FC_REFLECT( graphene::protocol::price_feed, GRAPHENE_PRICE_FEED_FIELDS ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::price ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::price_feed ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::asset ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::price ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::price_feed ) diff --git a/libraries/protocol/include/graphene/protocol/asset_ops.hpp b/libraries/protocol/include/graphene/protocol/asset_ops.hpp index 8c22e82137..6dd4545481 100644 --- a/libraries/protocol/include/graphene/protocol/asset_ops.hpp +++ b/libraries/protocol/include/graphene/protocol/asset_ops.hpp @@ -605,33 +605,33 @@ FC_REFLECT( graphene::protocol::asset_reserve_operation, FC_REFLECT( graphene::protocol::asset_fund_fee_pool_operation, (fee)(from_account)(asset_id)(amount)(extensions) ); -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_options ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::bitasset_options ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::additional_asset_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_claim_pool_operation::fee_parameters_type ) -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_issuer_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_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_issuer_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 ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::asset_options ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::bitasset_options ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::additional_asset_options ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::asset_create_operation::fee_parameters_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::asset_global_settle_operation::fee_parameters_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::asset_settle_operation::fee_parameters_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::asset_fund_fee_pool_operation::fee_parameters_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::asset_claim_pool_operation::fee_parameters_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::asset_claim_fees_operation::fee_parameters_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::asset_update_operation::fee_parameters_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::asset_update_issuer_operation::fee_parameters_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::asset_update_bitasset_operation::fee_parameters_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::asset_update_feed_producers_operation::fee_parameters_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::asset_publish_feed_operation::fee_parameters_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::asset_issue_operation::fee_parameters_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::asset_reserve_operation::fee_parameters_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::asset_create_operation ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::asset_global_settle_operation ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::asset_settle_operation ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::asset_settle_cancel_operation ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::asset_fund_fee_pool_operation ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::asset_claim_pool_operation ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::asset_claim_fees_operation ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::asset_update_operation ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::asset_update_issuer_operation ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::asset_update_bitasset_operation ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::asset_update_feed_producers_operation ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::asset_publish_feed_operation ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::asset_issue_operation ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::asset_reserve_operation ) diff --git a/libraries/protocol/include/graphene/protocol/authority.hpp b/libraries/protocol/include/graphene/protocol/authority.hpp index e3fb741eb2..ba309ef9e8 100644 --- a/libraries/protocol/include/graphene/protocol/authority.hpp +++ b/libraries/protocol/include/graphene/protocol/authority.hpp @@ -135,4 +135,4 @@ void add_authority_accounts( 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::protocol::authority ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::authority ) diff --git a/libraries/protocol/include/graphene/protocol/balance.hpp b/libraries/protocol/include/graphene/protocol/balance.hpp index 1ab1453a49..9cc1d6f388 100644 --- a/libraries/protocol/include/graphene/protocol/balance.hpp +++ b/libraries/protocol/include/graphene/protocol/balance.hpp @@ -60,4 +60,4 @@ 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::protocol::balance_claim_operation ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::balance_claim_operation ) diff --git a/libraries/protocol/include/graphene/protocol/block.hpp b/libraries/protocol/include/graphene/protocol/block.hpp index 8b902d8c8f..499d970998 100644 --- a/libraries/protocol/include/graphene/protocol/block.hpp +++ b/libraries/protocol/include/graphene/protocol/block.hpp @@ -71,6 +71,6 @@ FC_REFLECT( graphene::protocol::block_header, (previous)(timestamp)(witness)(tra 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::protocol::block_header) -GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::protocol::signed_block_header) -GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::protocol::signed_block) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::block_header) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::signed_block_header) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::signed_block) diff --git a/libraries/protocol/include/graphene/protocol/buyback.hpp b/libraries/protocol/include/graphene/protocol/buyback.hpp index 9f58beca9b..77960bd17a 100644 --- a/libraries/protocol/include/graphene/protocol/buyback.hpp +++ b/libraries/protocol/include/graphene/protocol/buyback.hpp @@ -51,4 +51,4 @@ struct buyback_account_options FC_REFLECT( graphene::protocol::buyback_account_options, (asset_to_buy)(asset_to_buy_issuer)(markets) ); -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::buyback_account_options ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::buyback_account_options ) diff --git a/libraries/protocol/include/graphene/protocol/chain_parameters.hpp b/libraries/protocol/include/graphene/protocol/chain_parameters.hpp index 4bdb871a08..3ccf499b58 100644 --- a/libraries/protocol/include/graphene/protocol/chain_parameters.hpp +++ b/libraries/protocol/include/graphene/protocol/chain_parameters.hpp @@ -134,4 +134,4 @@ FC_REFLECT( graphene::protocol::chain_parameters, (extensions) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::chain_parameters ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::chain_parameters ) diff --git a/libraries/protocol/include/graphene/protocol/committee_member.hpp b/libraries/protocol/include/graphene/protocol/committee_member.hpp index 5e63e96322..f941a8ff10 100644 --- a/libraries/protocol/include/graphene/protocol/committee_member.hpp +++ b/libraries/protocol/include/graphene/protocol/committee_member.hpp @@ -106,9 +106,9 @@ FC_REFLECT( graphene::protocol::committee_member_update_operation, (fee)(committee_member)(committee_member_account)(new_url) ) FC_REFLECT( graphene::protocol::committee_member_update_global_parameters_operation, (fee)(new_parameters) ); -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 ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::committee_member_create_operation::fee_parameters_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::committee_member_update_operation::fee_parameters_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::committee_member_update_global_parameters_operation::fee_parameters_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::committee_member_create_operation ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::committee_member_update_operation ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::committee_member_update_global_parameters_operation ) diff --git a/libraries/protocol/include/graphene/protocol/confidential.hpp b/libraries/protocol/include/graphene/protocol/confidential.hpp index fbb0a5b207..b47ecf3ca1 100644 --- a/libraries/protocol/include/graphene/protocol/confidential.hpp +++ b/libraries/protocol/include/graphene/protocol/confidential.hpp @@ -284,9 +284,9 @@ FC_REFLECT( graphene::protocol::transfer_to_blind_operation::fee_parameters_type 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::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 ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::transfer_to_blind_operation::fee_parameters_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::transfer_from_blind_operation::fee_parameters_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::blind_transfer_operation::fee_parameters_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::transfer_to_blind_operation ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::transfer_from_blind_operation ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::blind_transfer_operation ) diff --git a/libraries/protocol/include/graphene/protocol/custom.hpp b/libraries/protocol/include/graphene/protocol/custom.hpp index 2fc63f59f7..8be5ab1e60 100644 --- a/libraries/protocol/include/graphene/protocol/custom.hpp +++ b/libraries/protocol/include/graphene/protocol/custom.hpp @@ -58,5 +58,5 @@ namespace graphene { namespace protocol { 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::protocol::custom_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::custom_operation ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::custom_operation::fee_parameters_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::custom_operation ) diff --git a/libraries/protocol/include/graphene/protocol/fba.hpp b/libraries/protocol/include/graphene/protocol/fba.hpp index 22f2a7f51f..0c58c2eb53 100644 --- a/libraries/protocol/include/graphene/protocol/fba.hpp +++ b/libraries/protocol/include/graphene/protocol/fba.hpp @@ -48,4 +48,4 @@ FC_REFLECT( graphene::protocol::fba_distribute_operation::fee_parameters_type, FC_REFLECT( graphene::protocol::fba_distribute_operation, (fee)(account_id)(fba_id)(amount) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::fba_distribute_operation ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::fba_distribute_operation ) diff --git a/libraries/protocol/include/graphene/protocol/fee_schedule.hpp b/libraries/protocol/include/graphene/protocol/fee_schedule.hpp index 2502ecb477..590ae840d5 100644 --- a/libraries/protocol/include/graphene/protocol/fee_schedule.hpp +++ b/libraries/protocol/include/graphene/protocol/fee_schedule.hpp @@ -212,4 +212,4 @@ namespace graphene { namespace protocol { FC_REFLECT_TYPENAME( graphene::protocol::fee_parameters ) FC_REFLECT( graphene::protocol::fee_schedule, (parameters)(scale) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::fee_schedule ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::fee_schedule ) diff --git a/libraries/protocol/include/graphene/protocol/htlc.hpp b/libraries/protocol/include/graphene/protocol/htlc.hpp index 382912e9ab..ac1732cd9d 100644 --- a/libraries/protocol/include/graphene/protocol/htlc.hpp +++ b/libraries/protocol/include/graphene/protocol/htlc.hpp @@ -204,11 +204,11 @@ FC_REFLECT( graphene::protocol::htlc_redeemed_operation, (fee)(htlc_id)(from)(to FC_REFLECT( graphene::protocol::htlc_extend_operation, (fee)(htlc_id)(update_issuer)(seconds_to_add)(extensions)) FC_REFLECT( graphene::protocol::htlc_refund_operation, (fee)(htlc_id)(to)) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::htlc_create_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::htlc_redeem_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::htlc_extend_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::htlc_create_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::htlc_redeem_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::htlc_redeemed_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::htlc_extend_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::htlc_refund_operation ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::htlc_create_operation::fee_parameters_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::htlc_redeem_operation::fee_parameters_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::htlc_extend_operation::fee_parameters_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::htlc_create_operation ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::htlc_redeem_operation ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::htlc_redeemed_operation ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::htlc_extend_operation ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::htlc_refund_operation ) diff --git a/libraries/protocol/include/graphene/protocol/market.hpp b/libraries/protocol/include/graphene/protocol/market.hpp index 0dc7cfad62..b29d8b4fa3 100644 --- a/libraries/protocol/include/graphene/protocol/market.hpp +++ b/libraries/protocol/include/graphene/protocol/market.hpp @@ -233,14 +233,14 @@ FC_REFLECT( graphene::protocol::fill_order_operation, (fee)(order_id)(account_id FC_REFLECT( graphene::protocol::bid_collateral_operation, (fee)(bidder)(additional_collateral)(debt_covered)(extensions) ) FC_REFLECT( graphene::protocol::execute_bid_operation, (fee)(bidder)(debt)(collateral) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::call_order_update_operation::options_type ) -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::bid_collateral_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::bid_collateral_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::fill_order_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::execute_bid_operation ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::call_order_update_operation::options_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::limit_order_create_operation::fee_parameters_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::limit_order_cancel_operation::fee_parameters_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::call_order_update_operation::fee_parameters_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::bid_collateral_operation::fee_parameters_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::limit_order_create_operation ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::limit_order_cancel_operation ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::call_order_update_operation ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::bid_collateral_operation ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::fill_order_operation ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::execute_bid_operation ) diff --git a/libraries/protocol/include/graphene/protocol/memo.hpp b/libraries/protocol/include/graphene/protocol/memo.hpp index d0ef211558..8762fbeb85 100644 --- a/libraries/protocol/include/graphene/protocol/memo.hpp +++ b/libraries/protocol/include/graphene/protocol/memo.hpp @@ -90,5 +90,5 @@ namespace graphene { namespace protocol { FC_REFLECT( graphene::protocol::memo_message, (checksum)(text) ) FC_REFLECT( graphene::protocol::memo_data, (from)(to)(nonce)(message) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::memo_message ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::memo_data ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::memo_message ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::memo_data ) diff --git a/libraries/protocol/include/graphene/protocol/operations.hpp b/libraries/protocol/include/graphene/protocol/operations.hpp index 6c822399c0..3a603ebf64 100644 --- a/libraries/protocol/include/graphene/protocol/operations.hpp +++ b/libraries/protocol/include/graphene/protocol/operations.hpp @@ -134,4 +134,4 @@ namespace graphene { namespace protocol { FC_REFLECT_TYPENAME( graphene::protocol::operation ) FC_REFLECT( graphene::protocol::op_wrapper, (op) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::op_wrapper ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::op_wrapper ) diff --git a/libraries/protocol/include/graphene/protocol/proposal.hpp b/libraries/protocol/include/graphene/protocol/proposal.hpp index 43d3772263..9f862fe46c 100644 --- a/libraries/protocol/include/graphene/protocol/proposal.hpp +++ b/libraries/protocol/include/graphene/protocol/proposal.hpp @@ -181,9 +181,9 @@ FC_REFLECT( graphene::protocol::proposal_update_operation, (fee)(fee_paying_acco (key_approvals_to_add)(key_approvals_to_remove)(extensions) ) FC_REFLECT( graphene::protocol::proposal_delete_operation, (fee)(fee_paying_account)(using_owner_authority)(proposal)(extensions) ) -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 ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::proposal_create_operation::fee_parameters_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::proposal_update_operation::fee_parameters_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::proposal_delete_operation::fee_parameters_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::proposal_create_operation ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::proposal_update_operation ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::proposal_delete_operation ) diff --git a/libraries/protocol/include/graphene/protocol/special_authority.hpp b/libraries/protocol/include/graphene/protocol/special_authority.hpp index 4ac6e34f29..393fae1078 100644 --- a/libraries/protocol/include/graphene/protocol/special_authority.hpp +++ b/libraries/protocol/include/graphene/protocol/special_authority.hpp @@ -48,4 +48,4 @@ 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::protocol::top_holders_special_authority ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::top_holders_special_authority ) diff --git a/libraries/protocol/include/graphene/protocol/transaction.hpp b/libraries/protocol/include/graphene/protocol/transaction.hpp index 3e0ba2277f..17b7874d41 100644 --- a/libraries/protocol/include/graphene/protocol/transaction.hpp +++ b/libraries/protocol/include/graphene/protocol/transaction.hpp @@ -292,7 +292,7 @@ FC_REFLECT_DERIVED( graphene::protocol::signed_transaction, (graphene::protocol: FC_REFLECT_DERIVED( graphene::protocol::precomputable_transaction, (graphene::protocol::signed_transaction), ) FC_REFLECT_DERIVED( graphene::protocol::processed_transaction, (graphene::protocol::precomputable_transaction), (operation_results) ) -GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::protocol::transaction) -GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::protocol::signed_transaction) -GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::protocol::precomputable_transaction) -GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::protocol::processed_transaction) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::transaction) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::signed_transaction) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::precomputable_transaction) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::processed_transaction) diff --git a/libraries/protocol/include/graphene/protocol/transfer.hpp b/libraries/protocol/include/graphene/protocol/transfer.hpp index bd8a0353a9..2125ed4eb6 100644 --- a/libraries/protocol/include/graphene/protocol/transfer.hpp +++ b/libraries/protocol/include/graphene/protocol/transfer.hpp @@ -107,7 +107,7 @@ FC_REFLECT( graphene::protocol::override_transfer_operation::fee_parameters_type 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::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 ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::transfer_operation::fee_parameters_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::override_transfer_operation::fee_parameters_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::transfer_operation ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::override_transfer_operation ) diff --git a/libraries/protocol/include/graphene/protocol/types.hpp b/libraries/protocol/include/graphene/protocol/types.hpp index 6fbf5b3f19..b2067fb833 100644 --- a/libraries/protocol/include/graphene/protocol/types.hpp +++ b/libraries/protocol/include/graphene/protocol/types.hpp @@ -60,16 +60,19 @@ #include #include -#define GRAPHENE_EXTERNAL_SERIALIZATION(ext, type) \ +#define GRAPHENE_EXTERNAL_SERIALIZATION(ext, type, deflt) \ 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 ); \ + ext template void pack< datastream, type >( datastream& s, const type& tx, uint32_t _max_depth deflt ); \ + ext template void pack< sha256::encoder, type >( sha256::encoder& s, const type& tx, uint32_t _max_depth deflt ); \ + ext template void pack< datastream, type >( datastream& s, const type& tx, uint32_t _max_depth deflt ); \ + ext template void unpack< datastream, type >( datastream& s, type& tx, uint32_t _max_depth deflt ); \ } } // fc::raw +#define GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION(type) GRAPHENE_EXTERNAL_SERIALIZATION(extern, type, =FC_PACK_MAX_DEPTH) +#define GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION(type) \ + GRAPHENE_EXTERNAL_SERIALIZATION(/*not extern*/, type, /*=FC_PACK_MAX_DEPTH*/) #define FC_REFLECT_DERIVED_NO_TYPENAME( TYPE, INHERITS, MEMBERS ) \ namespace fc { \ diff --git a/libraries/protocol/include/graphene/protocol/vesting.hpp b/libraries/protocol/include/graphene/protocol/vesting.hpp index b4d213190f..a733506d1d 100644 --- a/libraries/protocol/include/graphene/protocol/vesting.hpp +++ b/libraries/protocol/include/graphene/protocol/vesting.hpp @@ -129,7 +129,7 @@ FC_REFLECT(graphene::protocol::cdd_vesting_policy_initializer, (start_claim)(ves FC_REFLECT_EMPTY( graphene::protocol::instant_vesting_policy_initializer ) FC_REFLECT_TYPENAME( graphene::protocol::vesting_policy_initializer ) -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 ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::vesting_balance_create_operation::fee_parameters_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::vesting_balance_withdraw_operation::fee_parameters_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::vesting_balance_create_operation ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::vesting_balance_withdraw_operation ) diff --git a/libraries/protocol/include/graphene/protocol/vote.hpp b/libraries/protocol/include/graphene/protocol/vote.hpp index 5738e483d7..b9f5c1be44 100644 --- a/libraries/protocol/include/graphene/protocol/vote.hpp +++ b/libraries/protocol/include/graphene/protocol/vote.hpp @@ -142,4 +142,4 @@ FC_REFLECT_TYPENAME( fc::flat_set ) FC_REFLECT_ENUM( graphene::protocol::vote_id_type::vote_type, (witness)(committee)(worker)(VOTE_TYPE_COUNT) ) FC_REFLECT( graphene::protocol::vote_id_type, (content) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::vote_id_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::vote_id_type ) diff --git a/libraries/protocol/include/graphene/protocol/withdraw_permission.hpp b/libraries/protocol/include/graphene/protocol/withdraw_permission.hpp index 01b4207f72..1712490844 100644 --- a/libraries/protocol/include/graphene/protocol/withdraw_permission.hpp +++ b/libraries/protocol/include/graphene/protocol/withdraw_permission.hpp @@ -181,11 +181,11 @@ FC_REFLECT( graphene::protocol::withdraw_permission_claim_operation, (fee)(withd FC_REFLECT( graphene::protocol::withdraw_permission_delete_operation, (fee)(withdraw_from_account)(authorized_account) (withdrawal_permission) ) -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 ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::withdraw_permission_create_operation::fee_parameters_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::withdraw_permission_update_operation::fee_parameters_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::withdraw_permission_claim_operation::fee_parameters_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::withdraw_permission_delete_operation::fee_parameters_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::withdraw_permission_create_operation ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::withdraw_permission_update_operation ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::withdraw_permission_claim_operation ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::withdraw_permission_delete_operation ) diff --git a/libraries/protocol/include/graphene/protocol/witness.hpp b/libraries/protocol/include/graphene/protocol/witness.hpp index 93694d964c..89efe54f70 100644 --- a/libraries/protocol/include/graphene/protocol/witness.hpp +++ b/libraries/protocol/include/graphene/protocol/witness.hpp @@ -83,7 +83,7 @@ FC_REFLECT( graphene::protocol::witness_create_operation, (fee)(witness_account) 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) ) -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 ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::witness_create_operation::fee_parameters_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::witness_update_operation::fee_parameters_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::witness_create_operation ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::witness_update_operation ) diff --git a/libraries/protocol/include/graphene/protocol/worker.hpp b/libraries/protocol/include/graphene/protocol/worker.hpp index eb02155d78..6eabf9258b 100644 --- a/libraries/protocol/include/graphene/protocol/worker.hpp +++ b/libraries/protocol/include/graphene/protocol/worker.hpp @@ -105,5 +105,5 @@ FC_REFLECT( graphene::protocol::worker_create_operation::fee_parameters_type, (f 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::protocol::worker_create_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::worker_create_operation ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::worker_create_operation::fee_parameters_type ) +GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::worker_create_operation ) diff --git a/libraries/protocol/market.cpp b/libraries/protocol/market.cpp index 299b2d0a42..8e8fc721e2 100644 --- a/libraries/protocol/market.cpp +++ b/libraries/protocol/market.cpp @@ -58,14 +58,14 @@ void bid_collateral_operation::validate()const } } // graphene::protocol -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::call_order_update_operation::options_type ) -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::bid_collateral_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::bid_collateral_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::fill_order_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::execute_bid_operation ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::call_order_update_operation::options_type ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::limit_order_create_operation::fee_parameters_type ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::limit_order_cancel_operation::fee_parameters_type ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::call_order_update_operation::fee_parameters_type ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::bid_collateral_operation::fee_parameters_type ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::limit_order_create_operation ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::limit_order_cancel_operation ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::call_order_update_operation ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::bid_collateral_operation ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::fill_order_operation ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::execute_bid_operation ) diff --git a/libraries/protocol/memo.cpp b/libraries/protocol/memo.cpp index f28ce70656..f68585c548 100644 --- a/libraries/protocol/memo.cpp +++ b/libraries/protocol/memo.cpp @@ -91,5 +91,5 @@ memo_message memo_message::deserialize(const string& serial) } } // graphene::protocol -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::memo_message ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::memo_data ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::memo_message ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::memo_data ) diff --git a/libraries/protocol/operations.cpp b/libraries/protocol/operations.cpp index d3063b7e93..8045ed3261 100644 --- a/libraries/protocol/operations.cpp +++ b/libraries/protocol/operations.cpp @@ -95,4 +95,4 @@ void operation_get_required_authorities( const operation& op, } } // namespace graphene::protocol -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::op_wrapper ) +GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::op_wrapper ) diff --git a/libraries/protocol/proposal.cpp b/libraries/protocol/proposal.cpp index 618f9b9431..22d66d44f1 100644 --- a/libraries/protocol/proposal.cpp +++ b/libraries/protocol/proposal.cpp @@ -108,9 +108,9 @@ void proposal_update_operation::get_required_owner_authorities( flat_set Date: Fri, 21 Jun 2019 16:13:28 -0500 Subject: [PATCH 119/133] size_t fix for mac --- libraries/app/database_api.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 286e06a7ba..cf0fd51122 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -933,7 +933,7 @@ std::map database_api_impl::get_full_accounts( const acnt.cashback_balance = account->cashback_balance(_db); } - uint64_t api_limit_get_full_accounts_lists = _app_options->api_limit_get_full_accounts_lists; + size_t api_limit_get_full_accounts_lists = static_cast(_app_options->api_limit_get_full_accounts_lists); // Add the account's proposals auto required_approvals_itr = proposals_by_account._account_to_proposals.find( account->id ); From 107540191ac75af8cd2ee0c42014da4834810e2c Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Fri, 21 Jun 2019 23:22:57 +0200 Subject: [PATCH 120/133] Get rid of default max_depth completely --- .../protocol/include/graphene/protocol/types.hpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/libraries/protocol/include/graphene/protocol/types.hpp b/libraries/protocol/include/graphene/protocol/types.hpp index b2067fb833..8fe0e2de29 100644 --- a/libraries/protocol/include/graphene/protocol/types.hpp +++ b/libraries/protocol/include/graphene/protocol/types.hpp @@ -60,19 +60,18 @@ #include #include -#define GRAPHENE_EXTERNAL_SERIALIZATION(ext, type, deflt) \ +#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 deflt ); \ - ext template void pack< sha256::encoder, type >( sha256::encoder& s, const type& tx, uint32_t _max_depth deflt ); \ - ext template void pack< datastream, type >( datastream& s, const type& tx, uint32_t _max_depth deflt ); \ - ext template void unpack< datastream, type >( datastream& s, type& tx, uint32_t _max_depth deflt ); \ + ext template void pack< datastream, type >( datastream& s, const type& tx, uint32_t _max_depth ); \ + ext template void pack< sha256::encoder, type >( sha256::encoder& s, const type& tx, uint32_t _max_depth ); \ + ext template void pack< datastream, type >( datastream& s, const type& tx, uint32_t _max_depth ); \ + ext template void unpack< datastream, type >( datastream& s, type& tx, uint32_t _max_depth ); \ } } // fc::raw -#define GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION(type) GRAPHENE_EXTERNAL_SERIALIZATION(extern, type, =FC_PACK_MAX_DEPTH) -#define GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION(type) \ - GRAPHENE_EXTERNAL_SERIALIZATION(/*not extern*/, type, /*=FC_PACK_MAX_DEPTH*/) +#define GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION(type) GRAPHENE_EXTERNAL_SERIALIZATION(extern, type) +#define GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION(type) GRAPHENE_EXTERNAL_SERIALIZATION(/*not extern*/, type) #define FC_REFLECT_DERIVED_NO_TYPENAME( TYPE, INHERITS, MEMBERS ) \ namespace fc { \ From 681d5db25dd842903d7d5043b20eadbf8e01b38c Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Fri, 21 Jun 2019 23:31:42 +0200 Subject: [PATCH 121/133] Removed more default arguments --- .../protocol/include/graphene/protocol/pts_address.hpp | 6 +++--- libraries/protocol/include/graphene/protocol/types.hpp | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libraries/protocol/include/graphene/protocol/pts_address.hpp b/libraries/protocol/include/graphene/protocol/pts_address.hpp index 7fce15c890..981440cd16 100644 --- a/libraries/protocol/include/graphene/protocol/pts_address.hpp +++ b/libraries/protocol/include/graphene/protocol/pts_address.hpp @@ -80,9 +80,9 @@ namespace fc namespace raw { extern template void pack( datastream& s, const graphene::protocol::pts_address& tx, - uint32_t _max_depth=FC_PACK_MAX_DEPTH ); + uint32_t _max_depth ); extern template void pack( datastream& s, const graphene::protocol::pts_address& tx, - uint32_t _max_depth=FC_PACK_MAX_DEPTH ); + uint32_t _max_depth ); extern template void unpack( datastream& s, graphene::protocol::pts_address& tx, - uint32_t _max_depth=FC_PACK_MAX_DEPTH ); + uint32_t _max_depth ); } } // fc::raw diff --git a/libraries/protocol/include/graphene/protocol/types.hpp b/libraries/protocol/include/graphene/protocol/types.hpp index 8fe0e2de29..16c589133f 100644 --- a/libraries/protocol/include/graphene/protocol/types.hpp +++ b/libraries/protocol/include/graphene/protocol/types.hpp @@ -275,9 +275,9 @@ FC_REFLECT_ENUM(graphene::protocol::asset_issuer_permission_flags, 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 ); + uint32_t _max_depth ); extern template void pack( datastream& s, const graphene::protocol::public_key_type& tx, - uint32_t _max_depth=FC_PACK_MAX_DEPTH ); + uint32_t _max_depth ); extern template void unpack( datastream& s, graphene::protocol::public_key_type& tx, - uint32_t _max_depth=FC_PACK_MAX_DEPTH ); + uint32_t _max_depth ); } } // fc::raw From 2e7dcc8418819291986ee56a6fbf1a740ad286ae Mon Sep 17 00:00:00 2001 From: John Jones Date: Mon, 14 Jan 2019 12:13:46 -0500 Subject: [PATCH 122/133] make cli_wallet rpc logging work --- programs/cli_wallet/main.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/programs/cli_wallet/main.cpp b/programs/cli_wallet/main.cpp index fbd33fb26b..8a306ce150 100644 --- a/programs/cli_wallet/main.cpp +++ b/programs/cli_wallet/main.cpp @@ -116,28 +116,27 @@ int main( int argc, char** argv ) return 0; } + // set up logging fc::path data_dir; fc::logging_config cfg; fc::path log_dir = data_dir / "logs"; - fc::file_appender::config ac; - ac.filename = log_dir / "rpc" / "rpc.log"; + ac.filename = log_dir / "cli_rpc" / "rpc.log"; ac.flush = true; ac.rotate = true; ac.rotation_interval = fc::hours( 1 ); ac.rotation_limit = fc::days( 1 ); - - std::cout << "Logging RPC to file: " << (data_dir / ac.filename).preferred_string() << "\n"; - cfg.appenders.push_back(fc::appender_config( "default", "console", fc::variant(fc::console_appender::config(), 20))); cfg.appenders.push_back(fc::appender_config( "rpc", "file", fc::variant(ac, 5))); - cfg.loggers = { fc::logger_config("default"), fc::logger_config( "rpc") }; cfg.loggers.front().level = fc::log_level::info; cfg.loggers.front().appenders = {"default"}; cfg.loggers.back().level = fc::log_level::debug; cfg.loggers.back().appenders = {"rpc"}; + std::cout << "Logging RPC to file: " << (data_dir / ac.filename).preferred_string() << "\n"; + fc::configure_logging( cfg ); + // key generation fc::ecc::private_key committee_private_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key"))); idump( (key_to_wif( committee_private_key ) ) ); From b14634481695fe9c98f25c5ca83d4a5e3c6608e5 Mon Sep 17 00:00:00 2001 From: John Jones Date: Tue, 15 Jan 2019 10:44:14 -0500 Subject: [PATCH 123/133] Fix colors, logging directory --- programs/cli_wallet/main.cpp | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/programs/cli_wallet/main.cpp b/programs/cli_wallet/main.cpp index 8a306ce150..47ece01c79 100644 --- a/programs/cli_wallet/main.cpp +++ b/programs/cli_wallet/main.cpp @@ -117,24 +117,36 @@ int main( int argc, char** argv ) } // set up logging - fc::path data_dir; fc::logging_config cfg; - fc::path log_dir = data_dir / "logs"; + // console logger + fc::console_appender::config console_appender_config; + console_appender_config.level_colors.emplace_back( + fc::console_appender::level_color(fc::log_level::debug, + fc::console_appender::color::green)); + console_appender_config.level_colors.emplace_back( + fc::console_appender::level_color(fc::log_level::warn, + fc::console_appender::color::brown)); + console_appender_config.level_colors.emplace_back( + fc::console_appender::level_color(fc::log_level::error, + fc::console_appender::color::red)); + cfg.appenders.push_back(fc::appender_config( "default", "console", fc::variant(console_appender_config, 20))); + cfg.loggers = { fc::logger_config("default"), fc::logger_config( "rpc") }; + cfg.loggers.front().level = fc::log_level::info; + cfg.loggers.front().appenders = {"default"}; + // file logger + fc::path data_dir; + fc::path log_dir = data_dir / "cli_wallet_logs"; fc::file_appender::config ac; - ac.filename = log_dir / "cli_rpc" / "rpc.log"; + ac.filename = log_dir / "rpc.log"; ac.flush = true; ac.rotate = true; ac.rotation_interval = fc::hours( 1 ); ac.rotation_limit = fc::days( 1 ); - cfg.appenders.push_back(fc::appender_config( "default", "console", fc::variant(fc::console_appender::config(), 20))); cfg.appenders.push_back(fc::appender_config( "rpc", "file", fc::variant(ac, 5))); - cfg.loggers = { fc::logger_config("default"), fc::logger_config( "rpc") }; - cfg.loggers.front().level = fc::log_level::info; - cfg.loggers.front().appenders = {"default"}; cfg.loggers.back().level = fc::log_level::debug; cfg.loggers.back().appenders = {"rpc"}; - std::cout << "Logging RPC to file: " << (data_dir / ac.filename).preferred_string() << "\n"; fc::configure_logging( cfg ); + ilog ( "Logging RPC to file: " + (data_dir / ac.filename).preferred_string() ); // key generation fc::ecc::private_key committee_private_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key"))); From 12eccf564a1895e95b3615006909db570975a9a4 Mon Sep 17 00:00:00 2001 From: John Jones Date: Tue, 22 Jan 2019 18:32:14 -0500 Subject: [PATCH 124/133] Move logging setup to separate method --- programs/cli_wallet/main.cpp | 73 +++++++++++++++++++++--------------- 1 file changed, 42 insertions(+), 31 deletions(-) diff --git a/programs/cli_wallet/main.cpp b/programs/cli_wallet/main.cpp index 47ece01c79..3e37da275a 100644 --- a/programs/cli_wallet/main.cpp +++ b/programs/cli_wallet/main.cpp @@ -66,6 +66,47 @@ using namespace graphene::wallet; using namespace std; namespace bpo = boost::program_options; +/*** + * @brief sets up basic logging + * + * Sends most logging messages (up to level "info") to the console and RPC messages + * (including level "debug")to a file + */ +void setup_logging() +{ + // set up logging + fc::logging_config cfg; + // console logger + fc::console_appender::config console_appender_config; + console_appender_config.level_colors.emplace_back( + fc::console_appender::level_color(fc::log_level::debug, + fc::console_appender::color::green)); + console_appender_config.level_colors.emplace_back( + fc::console_appender::level_color(fc::log_level::warn, + fc::console_appender::color::brown)); + console_appender_config.level_colors.emplace_back( + fc::console_appender::level_color(fc::log_level::error, + fc::console_appender::color::red)); + cfg.appenders.push_back(fc::appender_config( "default", "console", fc::variant(console_appender_config, 20))); + cfg.loggers = { fc::logger_config("default"), fc::logger_config( "rpc") }; + cfg.loggers.front().level = fc::log_level::info; + cfg.loggers.front().appenders = {"default"}; + // file logger + fc::path data_dir; + fc::path log_dir = data_dir / "cli_wallet_logs"; + fc::file_appender::config ac; + ac.filename = log_dir / "rpc.log"; + ac.flush = true; + ac.rotate = true; + ac.rotation_interval = fc::hours( 1 ); + ac.rotation_limit = fc::days( 1 ); + cfg.appenders.push_back(fc::appender_config( "rpc", "file", fc::variant(ac, 5))); + cfg.loggers.back().level = fc::log_level::debug; + cfg.loggers.back().appenders = {"rpc"}; + fc::configure_logging( cfg ); + ilog ( "Logging RPC to file: " + (ac.filename).preferred_string() ); +} + int main( int argc, char** argv ) { try { @@ -116,37 +157,7 @@ int main( int argc, char** argv ) return 0; } - // set up logging - fc::logging_config cfg; - // console logger - fc::console_appender::config console_appender_config; - console_appender_config.level_colors.emplace_back( - fc::console_appender::level_color(fc::log_level::debug, - fc::console_appender::color::green)); - console_appender_config.level_colors.emplace_back( - fc::console_appender::level_color(fc::log_level::warn, - fc::console_appender::color::brown)); - console_appender_config.level_colors.emplace_back( - fc::console_appender::level_color(fc::log_level::error, - fc::console_appender::color::red)); - cfg.appenders.push_back(fc::appender_config( "default", "console", fc::variant(console_appender_config, 20))); - cfg.loggers = { fc::logger_config("default"), fc::logger_config( "rpc") }; - cfg.loggers.front().level = fc::log_level::info; - cfg.loggers.front().appenders = {"default"}; - // file logger - fc::path data_dir; - fc::path log_dir = data_dir / "cli_wallet_logs"; - fc::file_appender::config ac; - ac.filename = log_dir / "rpc.log"; - ac.flush = true; - ac.rotate = true; - ac.rotation_interval = fc::hours( 1 ); - ac.rotation_limit = fc::days( 1 ); - cfg.appenders.push_back(fc::appender_config( "rpc", "file", fc::variant(ac, 5))); - cfg.loggers.back().level = fc::log_level::debug; - cfg.loggers.back().appenders = {"rpc"}; - fc::configure_logging( cfg ); - ilog ( "Logging RPC to file: " + (data_dir / ac.filename).preferred_string() ); + setup_logging(); // key generation fc::ecc::private_key committee_private_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key"))); From a2e3e61d1bb9075a93c95432f2a04c389ee7c6a7 Mon Sep 17 00:00:00 2001 From: Alfredo Garcia Date: Wed, 19 Jun 2019 23:19:13 -0300 Subject: [PATCH 125/133] fix indentation in setup_logging() --- programs/cli_wallet/main.cpp | 63 ++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/programs/cli_wallet/main.cpp b/programs/cli_wallet/main.cpp index 3e37da275a..722c04ba9e 100644 --- a/programs/cli_wallet/main.cpp +++ b/programs/cli_wallet/main.cpp @@ -74,37 +74,38 @@ namespace bpo = boost::program_options; */ void setup_logging() { - // set up logging - fc::logging_config cfg; - // console logger - fc::console_appender::config console_appender_config; - console_appender_config.level_colors.emplace_back( - fc::console_appender::level_color(fc::log_level::debug, - fc::console_appender::color::green)); - console_appender_config.level_colors.emplace_back( - fc::console_appender::level_color(fc::log_level::warn, - fc::console_appender::color::brown)); - console_appender_config.level_colors.emplace_back( - fc::console_appender::level_color(fc::log_level::error, - fc::console_appender::color::red)); - cfg.appenders.push_back(fc::appender_config( "default", "console", fc::variant(console_appender_config, 20))); - cfg.loggers = { fc::logger_config("default"), fc::logger_config( "rpc") }; - cfg.loggers.front().level = fc::log_level::info; - cfg.loggers.front().appenders = {"default"}; - // file logger - fc::path data_dir; - fc::path log_dir = data_dir / "cli_wallet_logs"; - fc::file_appender::config ac; - ac.filename = log_dir / "rpc.log"; - ac.flush = true; - ac.rotate = true; - ac.rotation_interval = fc::hours( 1 ); - ac.rotation_limit = fc::days( 1 ); - cfg.appenders.push_back(fc::appender_config( "rpc", "file", fc::variant(ac, 5))); - cfg.loggers.back().level = fc::log_level::debug; - cfg.loggers.back().appenders = {"rpc"}; - fc::configure_logging( cfg ); - ilog ( "Logging RPC to file: " + (ac.filename).preferred_string() ); + fc::logging_config cfg; + + // console logger + fc::console_appender::config console_appender_config; + console_appender_config.level_colors.emplace_back( + fc::console_appender::level_color(fc::log_level::debug, + fc::console_appender::color::green)); + console_appender_config.level_colors.emplace_back( + fc::console_appender::level_color(fc::log_level::warn, + fc::console_appender::color::brown)); + console_appender_config.level_colors.emplace_back( + fc::console_appender::level_color(fc::log_level::error, + fc::console_appender::color::red)); + cfg.appenders.push_back(fc::appender_config( "default", "console", fc::variant(console_appender_config, 20))); + cfg.loggers = { fc::logger_config("default"), fc::logger_config( "rpc") }; + cfg.loggers.front().level = fc::log_level::info; + cfg.loggers.front().appenders = {"default"}; + + // file logger + fc::path data_dir; + fc::path log_dir = data_dir / "cli_wallet_logs"; + fc::file_appender::config ac; + ac.filename = log_dir / "rpc.log"; + ac.flush = true; + ac.rotate = true; + ac.rotation_interval = fc::hours( 1 ); + ac.rotation_limit = fc::days( 1 ); + cfg.appenders.push_back(fc::appender_config( "rpc", "file", fc::variant(ac, 5))); + cfg.loggers.back().level = fc::log_level::debug; + cfg.loggers.back().appenders = {"rpc"}; + fc::configure_logging( cfg ); + ilog ( "Logging RPC to file: " + (ac.filename).preferred_string() ); } int main( int argc, char** argv ) From 06a2c106bfeb174dccae68d58489f560fc80382e Mon Sep 17 00:00:00 2001 From: Alfredo Garcia Date: Thu, 20 Jun 2019 01:13:43 -0300 Subject: [PATCH 126/133] add logging command line options --- programs/cli_wallet/main.cpp | 63 +++++++++++++++++++++++------------- 1 file changed, 40 insertions(+), 23 deletions(-) diff --git a/programs/cli_wallet/main.cpp b/programs/cli_wallet/main.cpp index 722c04ba9e..2402344c8d 100644 --- a/programs/cli_wallet/main.cpp +++ b/programs/cli_wallet/main.cpp @@ -66,13 +66,24 @@ using namespace graphene::wallet; using namespace std; namespace bpo = boost::program_options; -/*** - * @brief sets up basic logging - * - * Sends most logging messages (up to level "info") to the console and RPC messages - * (including level "debug")to a file - */ -void setup_logging() +fc::log_level string_to_level(string level) +{ + fc::log_level result; + if(level == "info") + result = fc::log_level::info; + else if(level == "debug") + result = fc::log_level::debug; + else if(level == "warn") + result = fc::log_level::warn; + else if(level == "error") + result = fc::log_level::error; + else if(level == "all") + result = fc::log_level::all; + + return result; +} + +void setup_logging(string console_level, bool file_logger, string file_level, string file_name) { fc::logging_config cfg; @@ -89,23 +100,25 @@ void setup_logging() fc::console_appender::color::red)); cfg.appenders.push_back(fc::appender_config( "default", "console", fc::variant(console_appender_config, 20))); cfg.loggers = { fc::logger_config("default"), fc::logger_config( "rpc") }; - cfg.loggers.front().level = fc::log_level::info; + cfg.loggers.front().level = string_to_level(console_level); cfg.loggers.front().appenders = {"default"}; // file logger - fc::path data_dir; - fc::path log_dir = data_dir / "cli_wallet_logs"; - fc::file_appender::config ac; - ac.filename = log_dir / "rpc.log"; - ac.flush = true; - ac.rotate = true; - ac.rotation_interval = fc::hours( 1 ); - ac.rotation_limit = fc::days( 1 ); - cfg.appenders.push_back(fc::appender_config( "rpc", "file", fc::variant(ac, 5))); - cfg.loggers.back().level = fc::log_level::debug; - cfg.loggers.back().appenders = {"rpc"}; - fc::configure_logging( cfg ); - ilog ( "Logging RPC to file: " + (ac.filename).preferred_string() ); + if(file_logger) { + fc::path data_dir; + fc::path log_dir = data_dir / "cli_wallet_logs"; + fc::file_appender::config ac; + ac.filename = log_dir / file_name; + ac.flush = true; + ac.rotate = true; + ac.rotation_interval = fc::hours( 1 ); + ac.rotation_limit = fc::days( 1 ); + cfg.appenders.push_back(fc::appender_config( "rpc", "file", fc::variant(ac, 5))); + cfg.loggers.back().level = string_to_level(file_level); + cfg.loggers.back().appenders = {"rpc"}; + fc::configure_logging( cfg ); + ilog ("Logging RPC to file: " + (ac.filename).preferred_string()); + } } int main( int argc, char** argv ) @@ -128,9 +141,12 @@ int main( int argc, char** argv ) ("wallet-file,w", bpo::value()->implicit_value("wallet.json"), "wallet to load") ("chain-id", bpo::value(), "chain ID to connect to") ("suggest-brain-key", "Suggest a safe brain key to use for creating your account") + ("logs-rpc-console-level", bpo::value()->default_value("info"), "Level of console logging") + ("logs-rpc-file", bpo::value()->default_value(true), "Turn on/off file logging") + ("logs-rpc-file-level", bpo::value()->default_value("debug"), "Level of file logging") + ("logs-rpc-file-name", bpo::value()->default_value("rpc.log"), "File name for file rpc logs") ("version,v", "Display version information"); - bpo::variables_map options; bpo::store( bpo::parse_command_line(argc, argv, opts), options ); @@ -158,7 +174,8 @@ int main( int argc, char** argv ) return 0; } - setup_logging(); + setup_logging(options.at("logs-rpc-console-level").as(),options.at("logs-rpc-file").as(), + options.at("logs-rpc-file-level").as(), options.at("logs-rpc-file-name").as()); // key generation fc::ecc::private_key committee_private_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key"))); From 7e1a624e6c268dd1e4d6b1059810341122151f2e Mon Sep 17 00:00:00 2001 From: jmjatlanta Date: Fri, 21 Jun 2019 17:44:03 -0500 Subject: [PATCH 127/133] Fix conflict in cli_wallet main.cpp --- programs/cli_wallet/main.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/programs/cli_wallet/main.cpp b/programs/cli_wallet/main.cpp index 2402344c8d..e956262f8f 100644 --- a/programs/cli_wallet/main.cpp +++ b/programs/cli_wallet/main.cpp @@ -132,11 +132,13 @@ int main( int argc, char** argv ) ("server-rpc-user,u", bpo::value(), "Server Username") ("server-rpc-password,p", bpo::value(), "Server Password") ("rpc-endpoint,r", bpo::value()->implicit_value("127.0.0.1:8091"), - "Endpoint for wallet websocket RPC to listen on (DEPRECATED, use rpc-http-endpoint instead)") - ("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") + "Endpoint for wallet websocket RPC to listen on (DEPRECATED, use rpc-http-endpoint instead)") + ("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 and websocket RPC to listen on") + "Endpoint for wallet HTTP and websocket RPC to listen on") ("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") From eb91d4e4a4399024e9b0973f9d28930b1a4e5630 Mon Sep 17 00:00:00 2001 From: Alfredo Garcia Date: Fri, 21 Jun 2019 14:31:07 -0300 Subject: [PATCH 128/133] add allowed log level values --- programs/cli_wallet/main.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/programs/cli_wallet/main.cpp b/programs/cli_wallet/main.cpp index e956262f8f..630256615a 100644 --- a/programs/cli_wallet/main.cpp +++ b/programs/cli_wallet/main.cpp @@ -79,6 +79,8 @@ fc::log_level string_to_level(string level) result = fc::log_level::error; else if(level == "all") result = fc::log_level::all; + else + FC_THROW("Log level not allowed. Allowed levels are info, debug, warn, error and all."); return result; } @@ -143,9 +145,11 @@ int main( int argc, char** argv ) ("wallet-file,w", bpo::value()->implicit_value("wallet.json"), "wallet to load") ("chain-id", bpo::value(), "chain ID to connect to") ("suggest-brain-key", "Suggest a safe brain key to use for creating your account") - ("logs-rpc-console-level", bpo::value()->default_value("info"), "Level of console logging") - ("logs-rpc-file", bpo::value()->default_value(true), "Turn on/off file logging") - ("logs-rpc-file-level", bpo::value()->default_value("debug"), "Level of file logging") + ("logs-rpc-console-level", bpo::value()->default_value("info"), + "Level of console logging. Allowed levels: info, debug, warn, error, all") + ("logs-rpc-file", bpo::value()->default_value(false), "Turn on/off file logging") + ("logs-rpc-file-level", bpo::value()->default_value("debug"), + "Level of file logging. Allowed levels: info, debug, warn, error, all") ("logs-rpc-file-name", bpo::value()->default_value("rpc.log"), "File name for file rpc logs") ("version,v", "Display version information"); From 01d5c52c46d08bd481427eb377128e372617cfc1 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Fri, 21 Jun 2019 21:38:33 -0300 Subject: [PATCH 129/133] bump the docs --- docs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs b/docs index 0271e72513..2fc5e1ffca 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 0271e725130383b1af3555a17efcc939b48c39e5 +Subproject commit 2fc5e1ffcaaab806b085a591f5c0e50aeae65e66 From 5ddd70a68cf59e339d2715d6a4a8f6bf7e3f4d2e Mon Sep 17 00:00:00 2001 From: Tiago Peralta Date: Sun, 23 Jun 2019 20:32:37 +0100 Subject: [PATCH 130/133] Update Dockerfile to use ubuntu:bionic instead of phusion baseimage, had libcurl issues (have the issue on telegram) Updated bitsharesentry.sh to add support to the BITSHARESD_ES_START_AFTER_BLOCK env var, to tell the witness_node to only start throwing data onto ES after the specified block Updated default_config as per test-3.2.0 release --- Dockerfile | 2 +- docker/bitsharesentry.sh | 5 +++++ docker/default_config.ini | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 25fe0bb418..886be92619 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM phusion/baseimage:0.10.1 +FROM ubuntu:bionic MAINTAINER The bitshares decentralized organisation ENV LANG=en_US.UTF-8 diff --git a/docker/bitsharesentry.sh b/docker/bitsharesentry.sh index 9de94f1cc4..f4ce734db3 100644 --- a/docker/bitsharesentry.sh +++ b/docker/bitsharesentry.sh @@ -18,6 +18,7 @@ VERSION=`cat /etc/bitshares/version` # * $BITSHARESD_PARTIAL_OPERATIONS # * $BITSHARESD_MAX_OPS_PER_ACCOUNT # * $BITSHARESD_ES_NODE_URL +# * $BITSHARESD_ES_START_AFTER_BLOCK # * $BITSHARESD_TRUSTED_NODE # @@ -70,6 +71,10 @@ if [[ ! -z "$BITSHARESD_ES_NODE_URL" ]]; then ARGS+=" --elasticsearch-node-url=${BITSHARESD_ES_NODE_URL}" fi +if [[ ! -z "$BITSHARESD_ES_START_AFTER_BLOCK" ]]; then + ARGS+=" --elasticsearch-start-es-after-block=${BITSHARESD_ES_START_AFTER_BLOCK}" +fi + if [[ ! -z "$BITSHARESD_TRUSTED_NODE" ]]; then ARGS+=" --trusted-node=${BITSHARESD_TRUSTED_NODE}" fi diff --git a/docker/default_config.ini b/docker/default_config.ini index daef0e5a8c..541ede3e06 100644 --- a/docker/default_config.ini +++ b/docker/default_config.ini @@ -35,7 +35,7 @@ rpc-endpoint = 0.0.0.0:8090 enable-stale-production = false # Percent of witnesses (0-99) that must be participating in order to produce blocks -required-participation = false +required-participation = 0 # ID of witness controlled by this node (e.g. "1.6.5", quotes are required, may specify multiple times) # witness-id = From 5d404957cdfca1c30f7bd3aafd889972f1ea3d69 Mon Sep 17 00:00:00 2001 From: Tiago Peralta Date: Mon, 24 Jun 2019 00:29:52 +0100 Subject: [PATCH 131/133] Update required-participation to 33 as requested by oxarbitrage --- docker/default_config.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/default_config.ini b/docker/default_config.ini index 541ede3e06..4288a8aa7c 100644 --- a/docker/default_config.ini +++ b/docker/default_config.ini @@ -35,7 +35,7 @@ rpc-endpoint = 0.0.0.0:8090 enable-stale-production = false # Percent of witnesses (0-99) that must be participating in order to produce blocks -required-participation = 0 +required-participation = 33 # ID of witness controlled by this node (e.g. "1.6.5", quotes are required, may specify multiple times) # witness-id = From 9311c1a08e87cd15a2b2463bdb5631a92b6b7375 Mon Sep 17 00:00:00 2001 From: Tiago Peralta Date: Mon, 24 Jun 2019 16:17:50 +0100 Subject: [PATCH 132/133] Requested Changes: FROM Image is now phusion/baseimage:0.11 Commented Out required-participation from default_config.ini --- Dockerfile | 2 +- docker/default_config.ini | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 886be92619..9c703458ba 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:bionic +FROM phusion/baseimage:0.11 MAINTAINER The bitshares decentralized organisation ENV LANG=en_US.UTF-8 diff --git a/docker/default_config.ini b/docker/default_config.ini index 4288a8aa7c..4d79d099c0 100644 --- a/docker/default_config.ini +++ b/docker/default_config.ini @@ -35,7 +35,7 @@ rpc-endpoint = 0.0.0.0:8090 enable-stale-production = false # Percent of witnesses (0-99) that must be participating in order to produce blocks -required-participation = 33 +# required-participation = 33 # ID of witness controlled by this node (e.g. "1.6.5", quotes are required, may specify multiple times) # witness-id = From cd48296c744fe70e1a91f0a2799b331f59d01f04 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Sun, 14 Jul 2019 18:47:24 -0300 Subject: [PATCH 133/133] rebump docs --- docs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs b/docs index 2fc5e1ffca..3d71528bde 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 2fc5e1ffcaaab806b085a591f5c0e50aeae65e66 +Subproject commit 3d71528bde5c24ddad26edaabbaa183e9ef706e6