From 14f627c014ef827ccd10cb45eb5aca0137d2ca46 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Sat, 13 Apr 2019 23:38:56 -0500 Subject: [PATCH] Ref #1506: Isolate chain/protocol to its own library --- .gitignore | 2 + libraries/CMakeLists.txt | 1 + libraries/app/api.cpp | 2 +- libraries/app/application.cpp | 6 +- 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/plugin.cpp | 2 +- libraries/chain/CMakeLists.txt | 59 +- libraries/chain/block_database.cpp | 2 +- libraries/chain/buyback.cpp | 2 +- .../chain/committee_member_evaluator.cpp | 7 +- libraries/chain/confidential_evaluator.cpp | 2 +- libraries/chain/db_block.cpp | 5 +- libraries/chain/db_init.cpp | 2 - libraries/chain/db_maint.cpp | 2 + libraries/chain/db_management.cpp | 3 +- libraries/chain/db_notify.cpp | 8 +- libraries/chain/db_update.cpp | 2 +- libraries/chain/evaluator.cpp | 4 +- libraries/chain/genesis_state.cpp | 6 +- libraries/chain/get_config.cpp | 2 +- .../include/graphene/chain/account_object.hpp | 10 +- .../graphene/chain/assert_evaluator.hpp | 2 +- .../graphene/chain/asset_evaluator.hpp | 2 +- .../include/graphene/chain/asset_object.hpp | 17 +- .../graphene/chain/balance_evaluator.hpp | 2 +- .../include/graphene/chain/balance_object.hpp | 2 + .../include/graphene/chain/block_database.hpp | 5 +- .../graphene/chain/block_summary_object.hpp | 1 + .../graphene/chain/budget_record_object.hpp | 5 +- .../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 | 4 +- .../graphene/chain/confidential_evaluator.hpp | 5 +- .../graphene/chain/confidential_object.hpp | 5 +- .../chain/include/graphene/chain/config.hpp | 4 +- .../graphene/chain/custom_evaluator.hpp | 2 +- .../chain/include/graphene/chain/database.hpp | 12 + .../include/graphene/chain/evaluator.hpp | 7 +- .../include/graphene/chain/exceptions.hpp | 6 +- .../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 | 5 +- .../graphene/chain/global_property_object.hpp | 7 +- .../chain/include/graphene/chain/impacted.hpp | 6 +- .../graphene/chain/market_evaluator.hpp | 6 +- .../include/graphene/chain/market_object.hpp | 10 +- .../chain/operation_history_object.hpp | 6 +- .../graphene/chain/proposal_evaluator.hpp | 2 +- .../graphene/chain/proposal_object.hpp | 4 +- .../include/graphene/chain/protocol/types.hpp | 535 ------------------ .../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 | 7 +- .../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 | 3 +- .../include/graphene/chain/worker_object.hpp | 7 +- libraries/chain/market_evaluator.cpp | 2 +- libraries/chain/protocol/chain_parameters.cpp | 8 - libraries/chain/special_authority.cpp | 22 +- libraries/chain/witness_evaluator.cpp | 4 +- libraries/chain/worker_evaluator.cpp | 6 +- libraries/db/include/graphene/db/fwd.hpp | 1 + .../db/include/graphene/db/generic_index.hpp | 2 +- .../include/graphene/db/object_database.hpp | 12 +- .../db/include/graphene/db/object_id.hpp | 46 +- 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/net/CMakeLists.txt | 2 +- .../include/graphene/net/core_messages.hpp | 10 +- .../net/include/graphene/net/message.hpp | 2 +- libraries/net/include/graphene/net/node.hpp | 8 +- .../include/graphene/net/peer_database.hpp | 2 +- libraries/net/node.cpp | 5 +- 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 | 54 ++ libraries/{chain => }/protocol/account.cpp | 32 +- libraries/{chain => }/protocol/address.cpp | 20 +- libraries/{chain => }/protocol/assert.cpp | 14 +- libraries/{chain => }/protocol/asset.cpp | 12 +- libraries/{chain => }/protocol/asset_ops.cpp | 59 +- libraries/{chain => }/protocol/authority.cpp | 9 +- .../{chain => }/protocol/betting_market.cpp | 0 libraries/{chain => }/protocol/block.cpp | 5 +- libraries/protocol/chain_parameters.cpp | 8 + .../{chain => }/protocol/committee_member.cpp | 21 +- libraries/{chain => }/protocol/competitor.cpp | 0 .../{chain => }/protocol/confidential.cpp | 22 +- libraries/{chain => }/protocol/custom.cpp | 6 +- .../protocol/custom_account_authority.cpp | 0 .../protocol/custom_permission.cpp | 0 libraries/{chain => }/protocol/event.cpp | 0 .../{chain => }/protocol/event_group.cpp | 0 .../{chain => }/protocol/fee_schedule.cpp | 8 +- .../include/graphene}/protocol/README.md | 0 .../include/graphene}/protocol/account.hpp | 75 +-- .../include/graphene}/protocol/address.hpp | 30 +- .../include/graphene}/protocol/affiliate.hpp | 0 .../include/graphene}/protocol/assert.hpp | 19 +- .../include/graphene}/protocol/asset.hpp | 18 +- .../include/graphene}/protocol/asset_ops.hpp | 141 ++--- .../include/graphene}/protocol/authority.hpp | 14 +- .../include/graphene}/protocol/balance.hpp | 14 +- .../include/graphene}/protocol/base.hpp | 16 +- .../graphene}/protocol/betting_market.hpp | 0 .../include/graphene}/protocol/block.hpp | 18 +- .../include/graphene}/protocol/buyback.hpp | 8 +- .../graphene}/protocol/chain_parameters.hpp | 17 +- .../graphene}/protocol/committee_member.hpp | 32 +- .../graphene}/protocol/confidential.hpp | 39 +- .../include/graphene/protocol/config.hpp | 134 +++++ .../include/graphene}/protocol/custom.hpp | 14 +- .../protocol/custom_account_authority.hpp | 0 .../graphene}/protocol/custom_permission.hpp | 0 .../include/graphene}/protocol/event.hpp | 0 .../graphene}/protocol/event_group.hpp | 0 .../include/graphene/protocol/exceptions.hpp | 48 ++ .../include/graphene}/protocol/ext.hpp | 33 +- .../include/graphene}/protocol/fba.hpp | 14 +- .../graphene}/protocol/fee_schedule.hpp | 14 +- .../graphene}/protocol/lottery_ops.hpp | 0 .../include/graphene}/protocol/market.hpp | 40 +- .../include/graphene}/protocol/memo.hpp | 14 +- .../include/graphene}/protocol/nft_ops.hpp | 0 .../include/graphene}/protocol/offer.hpp | 0 .../include/graphene}/protocol/operations.hpp | 64 +-- .../include/graphene}/protocol/proposal.hpp | 31 +- .../include/graphene}/protocol/protocol.hpp | 0 .../graphene/protocol}/pts_address.hpp | 21 +- .../protocol/rock_paper_scissors.hpp | 0 .../graphene}/protocol/special_authority.hpp | 14 +- .../include/graphene}/protocol/sport.hpp | 0 .../include/graphene}/protocol/tournament.hpp | 0 .../graphene}/protocol/transaction.hpp | 20 +- .../include/graphene}/protocol/transfer.hpp | 25 +- .../include/graphene/protocol/types.hpp | 369 ++++++++++++ .../include/graphene}/protocol/vesting.hpp | 33 +- .../include/graphene}/protocol/vote.hpp | 20 +- .../protocol/withdraw_permission.hpp | 25 +- .../include/graphene}/protocol/witness.hpp | 23 +- .../include/graphene}/protocol/worker.hpp | 17 +- .../{chain => }/protocol/lottery_ops.cpp | 0 libraries/{chain => }/protocol/market.cpp | 20 +- libraries/{chain => }/protocol/memo.cpp | 15 +- libraries/{chain => }/protocol/nft.cpp | 0 libraries/{chain => }/protocol/offer.cpp | 0 libraries/{chain => }/protocol/operations.cpp | 9 +- libraries/{chain => }/protocol/proposal.cpp | 20 +- libraries/{chain => protocol}/pts_address.cpp | 16 +- libraries/{chain => }/protocol/small_ops.cpp | 0 .../special_authority.cpp} | 42 +- libraries/{chain => }/protocol/sport.cpp | 0 libraries/{chain => }/protocol/tournament.cpp | 0 .../{chain => }/protocol/transaction.cpp | 25 +- libraries/{chain => }/protocol/transfer.cpp | 14 +- libraries/{chain => }/protocol/types.cpp | 39 +- .../protocol/config.hpp => protocol/vote.cpp} | 21 +- .../protocol/withdraw_permission.cpp | 22 +- libraries/{chain => }/protocol/witness.cpp | 14 +- libraries/{chain => }/protocol/worker.cpp | 4 +- libraries/wallet/wallet.cpp | 28 +- programs/build_helpers/member_enumerator.cpp | 4 +- programs/genesis_util/convert_address.cpp | 6 +- programs/genesis_util/genesis_update.cpp | 3 +- programs/genesis_util/get_dev_key.cpp | 8 +- programs/js_operation_serializer/main.cpp | 18 +- programs/size_checker/main.cpp | 7 +- tests/common/database_fixture.hpp | 11 +- 183 files changed, 1686 insertions(+), 1468 deletions(-) delete mode 100644 libraries/chain/include/graphene/chain/protocol/types.hpp create mode 100644 libraries/chain/include/graphene/chain/types.hpp delete mode 100644 libraries/chain/protocol/chain_parameters.cpp create mode 100644 libraries/protocol/CMakeLists.txt rename libraries/{chain => }/protocol/account.cpp (89%) rename libraries/{chain => }/protocol/address.cpp (87%) rename libraries/{chain => }/protocol/assert.cpp (81%) rename libraries/{chain => }/protocol/asset.cpp (96%) rename libraries/{chain => }/protocol/asset_ops.cpp (75%) rename libraries/{chain => }/protocol/authority.cpp (86%) rename libraries/{chain => }/protocol/betting_market.cpp (100%) rename libraries/{chain => }/protocol/block.cpp (96%) create mode 100644 libraries/protocol/chain_parameters.cpp rename libraries/{chain => }/protocol/committee_member.cpp (64%) rename libraries/{chain => }/protocol/competitor.cpp (100%) rename libraries/{chain => }/protocol/confidential.cpp (86%) rename libraries/{chain => }/protocol/custom.cpp (93%) rename libraries/{chain => }/protocol/custom_account_authority.cpp (100%) rename libraries/{chain => }/protocol/custom_permission.cpp (100%) rename libraries/{chain => }/protocol/event.cpp (100%) rename libraries/{chain => }/protocol/event_group.cpp (100%) rename libraries/{chain => }/protocol/fee_schedule.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 (79%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/address.hpp (79%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/affiliate.hpp (100%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/assert.hpp (85%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/asset.hpp (94%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/asset_ops.hpp (83%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/authority.hpp (89%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/balance.hpp (85%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/base.hpp (93%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/betting_market.hpp (100%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/block.hpp (80%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/buyback.hpp (85%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/chain_parameters.hpp (97%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/committee_member.hpp (74%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/confidential.hpp (87%) create mode 100644 libraries/protocol/include/graphene/protocol/config.hpp rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/custom.hpp (80%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/custom_account_authority.hpp (100%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/custom_permission.hpp (100%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/event.hpp (100%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/event_group.hpp (100%) create mode 100644 libraries/protocol/include/graphene/protocol/exceptions.hpp rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/ext.hpp (82%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/fba.hpp (78%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/fee_schedule.hpp (87%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/lottery_ops.hpp (100%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/market.hpp (79%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/memo.hpp (89%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/nft_ops.hpp (100%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/offer.hpp (100%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/operations.hpp (80%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/proposal.hpp (87%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/protocol.hpp (100%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene/protocol}/pts_address.hpp (84%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/rock_paper_scissors.hpp (100%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/special_authority.hpp (78%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/sport.hpp (100%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/tournament.hpp (100%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/transaction.hpp (93%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/transfer.hpp (78%) create mode 100644 libraries/protocol/include/graphene/protocol/types.hpp rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/vesting.hpp (76%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/vote.hpp (86%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/withdraw_permission.hpp (89%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/witness.hpp (75%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/worker.hpp (88%) rename libraries/{chain => }/protocol/lottery_ops.cpp (100%) rename libraries/{chain => }/protocol/market.cpp (67%) rename libraries/{chain => }/protocol/memo.cpp (93%) rename libraries/{chain => }/protocol/nft.cpp (100%) rename libraries/{chain => }/protocol/offer.cpp (100%) rename libraries/{chain => }/protocol/operations.cpp (91%) rename libraries/{chain => }/protocol/proposal.cpp (83%) rename libraries/{chain => protocol}/pts_address.cpp (86%) rename libraries/{chain => }/protocol/small_ops.cpp (100%) rename libraries/{chain/protocol/vote.cpp => protocol/special_authority.cpp} (62%) rename libraries/{chain => }/protocol/sport.cpp (100%) rename libraries/{chain => }/protocol/tournament.cpp (100%) rename libraries/{chain => }/protocol/transaction.cpp (94%) rename libraries/{chain => }/protocol/transfer.cpp (79%) rename libraries/{chain => }/protocol/types.cpp (83%) rename libraries/{chain/include/graphene/chain/protocol/config.hpp => protocol/vote.cpp} (74%) rename libraries/{chain => }/protocol/withdraw_permission.cpp (69%) rename libraries/{chain => }/protocol/witness.cpp (73%) rename libraries/{chain => }/protocol/worker.cpp (95%) diff --git a/.gitignore b/.gitignore index 90311de0..a640668b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +build*/ + *.a *.sw* diff --git a/libraries/CMakeLists.txt b/libraries/CMakeLists.txt index 04ad3781..d2ae5c82 100644 --- a/libraries/CMakeLists.txt +++ b/libraries/CMakeLists.txt @@ -8,3 +8,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 a80c4726..949f93d2 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 2a299625..4c83fe96 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -26,8 +26,10 @@ #include #include -#include -#include +#include +#include +#include +#include #include diff --git a/libraries/app/include/graphene/app/api.hpp b/libraries/app/include/graphene/app/api.hpp index 4adf73a3..a1ba96fe 100644 --- a/libraries/app/include/graphene/app/api.hpp +++ b/libraries/app/include/graphene/app/api.hpp @@ -25,8 +25,8 @@ #include -#include -#include +#include +#include #include #include diff --git a/libraries/app/include/graphene/app/database_api.hpp b/libraries/app/include/graphene/app/database_api.hpp index 0b141125..a3218a5b 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 955857b7..7de9daf6 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/plugin.cpp b/libraries/app/plugin.cpp index cae488a6..02d1fdb8 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 f0b0e9e1..2c94b538 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,42 +35,10 @@ 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/lottery_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/tournament.cpp - protocol/small_ops.cpp - protocol/custom_permission.cpp - protocol/custom_account_authority.cpp - protocol/offer.cpp - genesis_state.cpp get_config.cpp exceptions.cpp - pts_address.cpp - evaluator.cpp balance_evaluator.cpp account_evaluator.cpp @@ -105,35 +72,12 @@ add_library( graphene_chain is_authorized_asset.cpp - protocol/sport.cpp - sport_evaluator.cpp - protocol/event_group.cpp - event_group_evaluator.cpp - event_group_object.cpp - protocol/event.cpp - event_evaluator.cpp - event_object.cpp - protocol/betting_market.cpp - betting_market_evaluator.cpp - betting_market_object.cpp - betting_market_group_object.cpp - custom_permission_evaluator.cpp - custom_account_authority_evaluator.cpp - - affiliate_payout.cpp - - offer_object.cpp - offer_evaluator.cpp - nft_evaluator.cpp - protocol/nft.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" ) @@ -149,4 +93,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 2dd9b7a2..d86a5d25 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 09341fe7..152fc7bb 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 01614f99..439285b4 100644 --- a/libraries/chain/committee_member_evaluator.cpp +++ b/libraries/chain/committee_member_evaluator.cpp @@ -25,9 +25,8 @@ #include #include #include -#include -#include -#include +#include +#include #include namespace graphene { namespace chain { @@ -42,7 +41,7 @@ object_id_type committee_member_create_evaluator::do_apply( const committee_memb { try { vote_id_type vote_id; db().modify(db().get_global_properties(), [&vote_id](global_property_object& p) { - vote_id = get_next_vote_id(p, vote_id_type::committee); + vote_id = vote_id_type(vote_id_type::committee, p.next_available_vote_id++); }); const auto& new_del_object = db().create( [&]( committee_member_object& obj ){ diff --git a/libraries/chain/confidential_evaluator.cpp b/libraries/chain/confidential_evaluator.cpp index 9946b492..4be4d0e1 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 11134759..4e1cf289 100644 --- a/libraries/chain/db_block.cpp +++ b/libraries/chain/db_block.cpp @@ -36,11 +36,10 @@ #include #include #include -#include #include #include -#include -#include + +#include namespace { diff --git a/libraries/chain/db_init.cpp b/libraries/chain/db_init.cpp index 9c3102fe..5d67bd8e 100644 --- a/libraries/chain/db_init.cpp +++ b/libraries/chain/db_init.cpp @@ -86,8 +86,6 @@ #include #include -#include - #include #include diff --git a/libraries/chain/db_maint.cpp b/libraries/chain/db_maint.cpp index b222b0de..dacb7c5c 100644 --- a/libraries/chain/db_maint.cpp +++ b/libraries/chain/db_maint.cpp @@ -24,6 +24,8 @@ #include +#include + #include #include #include diff --git a/libraries/chain/db_management.cpp b/libraries/chain/db_management.cpp index c6380b8c..30a38301 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 f56e3d8b..ad4d92c0 100644 --- a/libraries/chain/db_notify.cpp +++ b/libraries/chain/db_notify.cpp @@ -24,10 +24,10 @@ #include -#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 5703d04a..1e9a0c51 100644 --- a/libraries/chain/db_update.cpp +++ b/libraries/chain/db_update.cpp @@ -37,7 +37,7 @@ #include #include -#include +#include namespace graphene { namespace chain { diff --git a/libraries/chain/evaluator.cpp b/libraries/chain/evaluator.cpp index d92564e9..ed32f5ef 100644 --- a/libraries/chain/evaluator.cpp +++ b/libraries/chain/evaluator.cpp @@ -33,7 +33,7 @@ #include #include #include -#include +#include namespace graphene { namespace chain { database& generic_evaluator::db()const { return trx_state->db(); } @@ -56,7 +56,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); if( d.head_block_time() > HARDFORK_419_TIME ) diff --git a/libraries/chain/genesis_state.cpp b/libraries/chain/genesis_state.cpp index 3ad0ec46..a8ab549c 100644 --- a/libraries/chain/genesis_state.cpp +++ b/libraries/chain/genesis_state.cpp @@ -24,10 +24,8 @@ #include -// these are required to serialize a genesis_state -#include - -#include +// this is required to serialize a genesis_state +#include namespace graphene { namespace chain { diff --git a/libraries/chain/get_config.cpp b/libraries/chain/get_config.cpp index c961b950..6c30a534 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 5f24adeb..c547af22 100644 --- a/libraries/chain/include/graphene/chain/account_object.hpp +++ b/libraries/chain/include/graphene/chain/account_object.hpp @@ -22,13 +22,15 @@ * THE SOFTWARE. */ #pragma once -#include +#include #include -#include +#include #include namespace graphene { namespace chain { class database; + class account_object; + class vesting_balance_object; /** * @class account_statistics_object @@ -541,6 +543,10 @@ namespace graphene { namespace chain { }} +MAP_OBJECT_ID_TO_TYPE(graphene::chain::account_object) +MAP_OBJECT_ID_TO_TYPE(graphene::chain::account_balance_object) +MAP_OBJECT_ID_TO_TYPE(graphene::chain::account_statistics_object) + FC_REFLECT_DERIVED( graphene::chain::account_object, (graphene::db::object), (membership_expiration_date)(registrar)(referrer)(lifetime_referrer) diff --git a/libraries/chain/include/graphene/chain/assert_evaluator.hpp b/libraries/chain/include/graphene/chain/assert_evaluator.hpp index b985a849..e4bfdd00 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 d65d37fc..360d1cd0 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 d8c65e89..5e149447 100644 --- a/libraries/chain/include/graphene/chain/asset_object.hpp +++ b/libraries/chain/include/graphene/chain/asset_object.hpp @@ -22,11 +22,10 @@ * THE SOFTWARE. */ #pragma once -#include -#include -#include -#include +#include #include +#include +#include /** * @defgroup prediction_market Prediction Market @@ -39,6 +38,8 @@ */ namespace graphene { namespace chain { + class account_object; + class asset_bitasset_data_object; class database; class transaction_evaluation_state; using namespace graphene::db; @@ -111,13 +112,13 @@ namespace graphene { namespace chain { string amount_to_string(share_type amount)const; /// Convert an asset to a textual representation, i.e. "123.45" string amount_to_string(const asset& amount)const - { FC_ASSERT(amount.asset_id == id); return amount_to_string(amount.amount); } + { FC_ASSERT(amount.asset_id == get_id()); return amount_to_string(amount.amount); } /// Convert an asset to a textual representation with symbol, i.e. "123.45 USD" string amount_to_pretty_string(share_type amount)const { return amount_to_string(amount) + " " + symbol; } /// Convert an asset to a textual representation with symbol, i.e. "123.45 USD" string amount_to_pretty_string(const asset &amount)const - { FC_ASSERT(amount.asset_id == id); return amount_to_pretty_string(amount.amount); } + { FC_ASSERT(amount.asset_id == get_id()); return amount_to_pretty_string(amount.amount); } uint32_t get_issuer_num()const { return issuer.instance.value; } @@ -513,6 +514,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)(sweeps_tickets_sold)(confidential_supply)(accumulated_fees)(fee_pool) ) diff --git a/libraries/chain/include/graphene/chain/balance_evaluator.hpp b/libraries/chain/include/graphene/chain/balance_evaluator.hpp index 9458b173..ef1491b9 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 38a1a649..a0f6ff23 100644 --- a/libraries/chain/include/graphene/chain/balance_object.hpp +++ b/libraries/chain/include/graphene/chain/balance_object.hpp @@ -71,6 +71,8 @@ namespace graphene { namespace chain { using balance_index = generic_index; } } +MAP_OBJECT_ID_TO_TYPE(graphene::chain::balance_object) + FC_REFLECT_DERIVED( graphene::chain::balance_object, (graphene::db::object), (owner)(balance)(vesting_policy)(last_claim_date) ) diff --git a/libraries/chain/include/graphene/chain/block_database.hpp b/libraries/chain/include/graphene/chain/block_database.hpp index c5cf5df9..2580e326 100644 --- a/libraries/chain/include/graphene/chain/block_database.hpp +++ b/libraries/chain/include/graphene/chain/block_database.hpp @@ -23,12 +23,13 @@ */ #pragma once #include -#include +#include #include namespace graphene { namespace chain { - class index_entry; + struct index_entry; + using namespace graphene::protocol; class block_database { diff --git a/libraries/chain/include/graphene/chain/block_summary_object.hpp b/libraries/chain/include/graphene/chain/block_summary_object.hpp index 9f79d43e..62be251d 100644 --- a/libraries/chain/include/graphene/chain/block_summary_object.hpp +++ b/libraries/chain/include/graphene/chain/block_summary_object.hpp @@ -48,6 +48,7 @@ namespace graphene { namespace chain { } } +MAP_OBJECT_ID_TO_TYPE(graphene::chain::block_summary_object) FC_REFLECT_DERIVED( graphene::chain::block_summary_object, (graphene::db::object), (block_id) ) diff --git a/libraries/chain/include/graphene/chain/budget_record_object.hpp b/libraries/chain/include/graphene/chain/budget_record_object.hpp index e3f6d06e..82cd8c76 100644 --- a/libraries/chain/include/graphene/chain/budget_record_object.hpp +++ b/libraries/chain/include/graphene/chain/budget_record_object.hpp @@ -22,7 +22,8 @@ * THE SOFTWARE. */ #pragma once -#include +#include +#include #include namespace graphene { namespace chain { @@ -65,6 +66,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 3d58429b..3de8b039 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,6 +64,8 @@ typedef generic_index< buyback_object, buyback_multi_index_type > buyback_index; } } // graphene::chain +MAP_OBJECT_ID_TO_TYPE(graphene::chain::buyback_object) + FC_REFLECT_DERIVED( graphene::chain::buyback_object, (graphene::db::object), (asset_to_buy) ) GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::buyback_object ) diff --git a/libraries/chain/include/graphene/chain/chain_property_object.hpp b/libraries/chain/include/graphene/chain/chain_property_object.hpp index 3c7a77ff..d0c9e28d 100644 --- a/libraries/chain/include/graphene/chain/chain_property_object.hpp +++ b/libraries/chain/include/graphene/chain/chain_property_object.hpp @@ -42,6 +42,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 fe7968d3..dfbbe979 100644 --- a/libraries/chain/include/graphene/chain/committee_member_object.hpp +++ b/libraries/chain/include/graphene/chain/committee_member_object.hpp @@ -22,9 +22,10 @@ * THE SOFTWARE. */ #pragma once -#include #include #include +#include +#include namespace graphene { namespace chain { using namespace graphene::db; @@ -71,6 +72,7 @@ namespace graphene { namespace chain { using committee_member_index = generic_index; } } // graphene::chain +MAP_OBJECT_ID_TO_TYPE(graphene::chain::committee_member_object) FC_REFLECT_DERIVED( graphene::chain::committee_member_object, (graphene::db::object), (committee_member_account)(vote_id)(total_votes)(url) ) diff --git a/libraries/chain/include/graphene/chain/confidential_evaluator.hpp b/libraries/chain/include/graphene/chain/confidential_evaluator.hpp index bc877faf..136519c7 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 acdb0ba5..90df90de 100644 --- a/libraries/chain/include/graphene/chain/confidential_object.hpp +++ b/libraries/chain/include/graphene/chain/confidential_object.hpp @@ -23,8 +23,8 @@ */ #pragma once -#include -#include +#include +#include #include @@ -65,6 +65,7 @@ typedef generic_index + #define GRAPHENE_SYMBOL "TEST" #define GRAPHENE_ADDRESS_PREFIX "TEST" @@ -243,4 +245,4 @@ #define NFT_TOKEN_MIN_LENGTH 3 #define NFT_TOKEN_MAX_LENGTH 15 -#define NFT_URI_MAX_LENGTH GRAPHENE_MAX_URL_LENGTH \ No newline at end of file +#define NFT_URI_MAX_LENGTH GRAPHENE_MAX_URL_LENGTH diff --git a/libraries/chain/include/graphene/chain/custom_evaluator.hpp b/libraries/chain/include/graphene/chain/custom_evaluator.hpp index 968f6e48..f9efe76e 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 8ecb4b91..7807f479 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 @@ -49,6 +52,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; diff --git a/libraries/chain/include/graphene/chain/evaluator.hpp b/libraries/chain/include/graphene/chain/evaluator.hpp index af90517e..0a1cc986 100644 --- a/libraries/chain/include/graphene/chain/evaluator.hpp +++ b/libraries/chain/include/graphene/chain/evaluator.hpp @@ -24,14 +24,17 @@ #pragma once #include #include -#include +#include namespace graphene { namespace chain { class database; - struct signed_transaction; class generic_evaluator; class transaction_evaluation_state; + class account_object; + class account_statistics_object; + class asset_object; + class asset_dynamic_data_object; class generic_evaluator { diff --git a/libraries/chain/include/graphene/chain/exceptions.hpp b/libraries/chain/include/graphene/chain/exceptions.hpp index d89626ad..8ae9edff 100644 --- a/libraries/chain/include/graphene/chain/exceptions.hpp +++ b/libraries/chain/include/graphene/chain/exceptions.hpp @@ -24,7 +24,10 @@ #pragma once #include -#include +#include +#include +#include +#include #define GRAPHENE_ASSERT( expr, exc_type, FORMAT, ... ) \ FC_MULTILINE_MACRO_BEGIN \ @@ -32,7 +35,6 @@ FC_THROW_EXCEPTION( exc_type, FORMAT, __VA_ARGS__ ); \ FC_MULTILINE_MACRO_END - #define GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( op_name ) \ FC_DECLARE_DERIVED_EXCEPTION( \ op_name ## _validate_exception, \ diff --git a/libraries/chain/include/graphene/chain/fba_accumulator_id.hpp b/libraries/chain/include/graphene/chain/fba_accumulator_id.hpp index 9bc0cf23..f0eefdbe 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 3d1e1be0..0927b235 100644 --- a/libraries/chain/include/graphene/chain/fba_object.hpp +++ b/libraries/chain/include/graphene/chain/fba_object.hpp @@ -23,7 +23,7 @@ */ #pragma once -#include +#include #include #include @@ -49,6 +49,8 @@ class fba_accumulator_object : public graphene::db::abstract_object< fba_accumul } } // graphene::chain +MAP_OBJECT_ID_TO_TYPE(graphene::chain::fba_accumulator_object) + FC_REFLECT_DERIVED( graphene::chain::fba_accumulator_object, (graphene::db::object), (accumulated_fba_fees)(designated_asset) ) diff --git a/libraries/chain/include/graphene/chain/fork_database.hpp b/libraries/chain/include/graphene/chain/fork_database.hpp index 4007ca09..5e811e3d 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 b2f76118..2eadba2f 100644 --- a/libraries/chain/include/graphene/chain/genesis_state.hpp +++ b/libraries/chain/include/graphene/chain/genesis_state.hpp @@ -23,9 +23,8 @@ */ #pragma once -#include -#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 789b1bd1..e53837ae 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 @@ -123,6 +123,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/impacted.hpp b/libraries/chain/include/graphene/chain/impacted.hpp index 2a22cbd1..9d986cb8 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 9d653c07..778f012c 100644 --- a/libraries/chain/include/graphene/chain/market_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/market_evaluator.hpp @@ -23,7 +23,7 @@ */ #pragma once #include -#include +#include namespace graphene { namespace chain { @@ -31,9 +31,7 @@ namespace graphene { namespace chain { class asset_object; class asset_bitasset_data_object; class call_order_object; - struct call_order_update_operation; - struct limit_order_cancel_operation; - struct limit_order_create_operation; + class limit_order_object; class limit_order_create_evaluator : public evaluator { diff --git a/libraries/chain/include/graphene/chain/market_object.hpp b/libraries/chain/include/graphene/chain/market_object.hpp index 4bd3e048..9d058638 100644 --- a/libraries/chain/include/graphene/chain/market_object.hpp +++ b/libraries/chain/include/graphene/chain/market_object.hpp @@ -23,10 +23,10 @@ */ #pragma once -#include -#include #include #include +#include +#include #include @@ -65,7 +65,6 @@ class limit_order_object : public abstract_object asset amount_to_receive()const { return amount_for_sale() * sell_price; } }; -struct by_id; struct by_price; struct by_expiration; struct by_account; @@ -205,6 +204,11 @@ typedef generic_index +#include #include #include @@ -139,6 +138,9 @@ typedef generic_index +#include #include #include #include diff --git a/libraries/chain/include/graphene/chain/proposal_object.hpp b/libraries/chain/include/graphene/chain/proposal_object.hpp index d17d2c40..b05e9e44 100644 --- a/libraries/chain/include/graphene/chain/proposal_object.hpp +++ b/libraries/chain/include/graphene/chain/proposal_object.hpp @@ -23,7 +23,7 @@ */ #pragma once -#include +#include #include #include @@ -94,6 +94,8 @@ typedef generic_index proposal_ } } // graphene::chain +MAP_OBJECT_ID_TO_TYPE(graphene::chain::proposal_object) + FC_REFLECT_DERIVED( graphene::chain::proposal_object, (graphene::chain::object), (expiration_time)(review_period_time)(proposed_transaction)(required_active_approvals) (available_active_approvals)(required_owner_approvals)(available_owner_approvals) diff --git a/libraries/chain/include/graphene/chain/protocol/types.hpp b/libraries/chain/include/graphene/chain/protocol/types.hpp deleted file mode 100644 index 47f22878..00000000 --- a/libraries/chain/include/graphene/chain/protocol/types.hpp +++ /dev/null @@ -1,535 +0,0 @@ -/* - * Copyright (c) 2015 Cryptonomex, Inc., and contributors. - * - * The MIT License - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#pragma once -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include -#include -#include -#include -#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 - -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; - - enum asset_issuer_permission_flags - { - charge_market_fee = 0x01, /**< an issuer-specified percentage of all market trades in this asset is paid to the issuer */ - white_list = 0x02, /**< accounts must be whitelisted in order to hold this asset */ - override_authority = 0x04, /**< issuer may transfer asset back to himself */ - transfer_restricted = 0x08, /**< require the issuer to be one party to every transfer */ - disable_force_settle = 0x10, /**< disable force settling */ - global_settle = 0x20, /**< allow the bitasset issuer to force a global settling -- this may be set in permissions, but not flags */ - disable_confidential = 0x40, /**< allow the asset to be used with confidential transactions */ - witness_fed_asset = 0x80, /**< allow the asset to be fed by witnesses */ - committee_fed_asset = 0x100 /**< allow the asset to be fed by the committee */ - }; - const static uint32_t ASSET_ISSUER_PERMISSION_MASK = charge_market_fee|white_list|override_authority|transfer_restricted|disable_force_settle|global_settle|disable_confidential - |witness_fed_asset|committee_fed_asset; - const static uint32_t UIA_ASSET_ISSUER_PERMISSION_MASK = charge_market_fee|white_list|override_authority|transfer_restricted|disable_confidential; - - enum reserved_spaces - { - relative_protocol_ids = 0, - protocol_ids = 1, - implementation_ids = 2 - }; - - inline bool is_relative( object_id_type o ){ return o.space() == 0; } - - /** - * List all object types from all namespaces here so they can - * be easily reflected and displayed in debug output. If a 3rd party - * wants to extend the core code then they will have to change the - * packed_object::type field from enum_type to uint16 to avoid - * warnings when converting packed_objects to/from json. - */ - enum object_type - { - null_object_type, - base_object_type, - account_object_type, - asset_object_type, - force_settlement_object_type, - committee_member_object_type, - witness_object_type, - limit_order_object_type, - call_order_object_type, - custom_object_type, - proposal_object_type, - operation_history_object_type, - withdraw_permission_object_type, - vesting_balance_object_type, - worker_object_type, - balance_object_type, - tournament_object_type, - tournament_details_object_type, - match_object_type, - game_object_type, - sport_object_type, - event_group_object_type, - event_object_type, - betting_market_rules_object_type, - betting_market_group_object_type, - betting_market_object_type, - bet_object_type, - custom_permission_object_type, - custom_account_authority_object_type, - offer_object_type, - nft_metadata_type, - nft_object_type, - OBJECT_TYPE_COUNT ///< Sentry value which contains the number of different object types - }; - - enum impl_object_type - { - impl_global_property_object_type, - impl_dynamic_global_property_object_type, - impl_reserved0_object_type, // formerly index_meta_object_type, TODO: delete me - impl_asset_dynamic_data_type, - impl_asset_bitasset_data_type, - impl_account_balance_object_type, - impl_account_statistics_object_type, - impl_transaction_object_type, - impl_block_summary_object_type, - impl_account_transaction_history_object_type, - impl_blinded_balance_object_type, - impl_chain_property_object_type, - impl_witness_schedule_object_type, - impl_budget_record_object_type, - impl_special_authority_object_type, - impl_buyback_object_type, - impl_fba_accumulator_object_type, - impl_asset_dividend_data_type, - impl_pending_dividend_payout_balance_for_holder_object_type, - impl_distributed_dividend_balance_data_type, - impl_betting_market_position_object_type, - impl_global_betting_statistics_object_type, - impl_lottery_balance_object_type, - impl_sweeps_vesting_balance_object_type, - impl_offer_history_object_type - }; - - //typedef fc::unsigned_int object_id_type; - //typedef uint64_t object_id_type; - class account_object; - class committee_member_object; - class witness_object; - class asset_object; - class force_settlement_object; - class limit_order_object; - class call_order_object; - class custom_object; - class proposal_object; - class operation_history_object; - class withdraw_permission_object; - class vesting_balance_object; - class worker_object; - class balance_object; - class blinded_balance_object; - class tournament_object; - class tournament_details_object; - class match_object; - class game_object; - class sport_object; - class event_group_object; - class event_object; - class betting_market_rules_object; - class betting_market_group_object; - class betting_market_object; - class bet_object; - class custom_permission_object; - class custom_account_authority_object; - class offer_object; - class nft_metadata_object; - class nft_object; - - typedef object_id< protocol_ids, account_object_type, account_object> account_id_type; - typedef object_id< protocol_ids, asset_object_type, asset_object> asset_id_type; - typedef object_id< protocol_ids, force_settlement_object_type, force_settlement_object> force_settlement_id_type; - typedef object_id< protocol_ids, committee_member_object_type, committee_member_object> committee_member_id_type; - typedef object_id< protocol_ids, witness_object_type, witness_object> witness_id_type; - typedef object_id< protocol_ids, limit_order_object_type, limit_order_object> limit_order_id_type; - typedef object_id< protocol_ids, call_order_object_type, call_order_object> call_order_id_type; - typedef object_id< protocol_ids, custom_object_type, custom_object> custom_id_type; - typedef object_id< protocol_ids, proposal_object_type, proposal_object> proposal_id_type; - typedef object_id< protocol_ids, operation_history_object_type, operation_history_object> operation_history_id_type; - typedef object_id< protocol_ids, withdraw_permission_object_type,withdraw_permission_object> withdraw_permission_id_type; - typedef object_id< protocol_ids, vesting_balance_object_type, vesting_balance_object> vesting_balance_id_type; - typedef object_id< protocol_ids, worker_object_type, worker_object> worker_id_type; - typedef object_id< protocol_ids, balance_object_type, balance_object> balance_id_type; - typedef object_id< protocol_ids, tournament_object_type, tournament_object> tournament_id_type; - typedef object_id< protocol_ids, tournament_details_object_type, tournament_details_object> tournament_details_id_type; - typedef object_id< protocol_ids, match_object_type, match_object> match_id_type; - typedef object_id< protocol_ids, game_object_type, game_object> game_id_type; - typedef object_id< protocol_ids, sport_object_type, sport_object> sport_id_type; - typedef object_id< protocol_ids, event_group_object_type, event_group_object> event_group_id_type; - typedef object_id< protocol_ids, event_object_type, event_object> event_id_type; - typedef object_id< protocol_ids, betting_market_rules_object_type, betting_market_rules_object> betting_market_rules_id_type; - typedef object_id< protocol_ids, betting_market_group_object_type, betting_market_group_object> betting_market_group_id_type; - typedef object_id< protocol_ids, betting_market_object_type, betting_market_object> betting_market_id_type; - typedef object_id< protocol_ids, bet_object_type, bet_object> bet_id_type; - typedef object_id< protocol_ids, custom_permission_object_type, custom_permission_object> custom_permission_id_type; - typedef object_id< protocol_ids, custom_account_authority_object_type, custom_account_authority_object> custom_account_authority_id_type; - typedef object_id< protocol_ids, offer_object_type, offer_object> offer_id_type; - typedef object_id< protocol_ids, nft_metadata_type, nft_metadata_object> nft_metadata_id_type; - typedef object_id< protocol_ids, nft_object_type, nft_object> nft_id_type; - - // implementation types - class global_property_object; - class dynamic_global_property_object; - class asset_dynamic_data_object; - class asset_bitasset_data_object; - class account_balance_object; - class account_statistics_object; - class transaction_object; - class block_summary_object; - class account_transaction_history_object; - class chain_property_object; - class witness_schedule_object; - class budget_record_object; - class special_authority_object; - class buyback_object; - class fba_accumulator_object; - class asset_dividend_data_object; - class pending_dividend_payout_balance_for_holder_object; - class betting_market_position_object; - class global_betting_statistics_object; - class lottery_balance_object; - class sweeps_vesting_balance_object; - class offer_history_object; - - typedef object_id< implementation_ids, impl_global_property_object_type, global_property_object> global_property_id_type; - typedef object_id< implementation_ids, impl_dynamic_global_property_object_type, dynamic_global_property_object> dynamic_global_property_id_type; - typedef object_id< implementation_ids, impl_asset_dynamic_data_type, asset_dynamic_data_object> asset_dynamic_data_id_type; - typedef object_id< implementation_ids, impl_asset_bitasset_data_type, asset_bitasset_data_object> asset_bitasset_data_id_type; - typedef object_id< implementation_ids, impl_asset_dividend_data_type, asset_dividend_data_object> asset_dividend_data_id_type; - typedef object_id< implementation_ids, - impl_pending_dividend_payout_balance_for_holder_object_type, - pending_dividend_payout_balance_for_holder_object> pending_dividend_payout_balance_for_holder_object_type; - typedef object_id< implementation_ids, impl_account_balance_object_type, account_balance_object> account_balance_id_type; - typedef object_id< implementation_ids, impl_account_statistics_object_type, account_statistics_object> account_statistics_id_type; - typedef object_id< implementation_ids, impl_transaction_object_type, transaction_object> transaction_obj_id_type; - typedef object_id< implementation_ids, impl_block_summary_object_type, block_summary_object> block_summary_id_type; - - typedef object_id< implementation_ids, - impl_account_transaction_history_object_type, - account_transaction_history_object> account_transaction_history_id_type; - typedef object_id< implementation_ids, impl_chain_property_object_type, chain_property_object> chain_property_id_type; - typedef object_id< implementation_ids, impl_witness_schedule_object_type, witness_schedule_object> witness_schedule_id_type; - typedef object_id< implementation_ids, impl_budget_record_object_type, budget_record_object > budget_record_id_type; - typedef object_id< implementation_ids, impl_blinded_balance_object_type, blinded_balance_object > blinded_balance_id_type; - typedef object_id< implementation_ids, impl_special_authority_object_type, special_authority_object > special_authority_id_type; - typedef object_id< implementation_ids, impl_buyback_object_type, buyback_object > buyback_id_type; - typedef object_id< implementation_ids, impl_fba_accumulator_object_type, fba_accumulator_object > fba_accumulator_id_type; - typedef object_id< implementation_ids, impl_betting_market_position_object_type, betting_market_position_object > betting_market_position_id_type; - typedef object_id< implementation_ids, impl_global_betting_statistics_object_type, global_betting_statistics_object > global_betting_statistics_id_type; - typedef object_id< implementation_ids, impl_lottery_balance_object_type, lottery_balance_object > lottery_balance_id_type; - typedef object_id< implementation_ids, impl_sweeps_vesting_balance_object_type, sweeps_vesting_balance_object> sweeps_vesting_balance_id_type; - typedef object_id< implementation_ids, impl_offer_history_object_type, offer_history_object> offer_history_id_type; - - typedef fc::ripemd160 block_id_type; - typedef fc::ripemd160 checksum_type; - typedef fc::ripemd160 transaction_id_type; - typedef fc::sha256 digest_type; - typedef fc::ecc::compact_signature signature_type; - typedef safe share_type; - typedef fc::ripemd160 secret_hash_type; - typedef uint16_t weight_type; - - struct public_key_type - { - struct binary_key - { - binary_key() {} - uint32_t check = 0; - fc::ecc::public_key_data data; - }; - fc::ecc::public_key_data key_data; - public_key_type(); - public_key_type( const fc::ecc::public_key_data& data ); - public_key_type( const fc::ecc::public_key& pubkey ); - explicit public_key_type( const std::string& base58str ); - operator fc::ecc::public_key_data() const; - operator fc::ecc::public_key() const; - explicit operator std::string() const; - friend bool operator == ( const public_key_type& p1, const fc::ecc::public_key& p2); - friend bool operator == ( const public_key_type& p1, const public_key_type& p2); - friend bool operator != ( const public_key_type& p1, const public_key_type& p2); - // TODO: This is temporary for testing - bool is_valid_v1( const std::string& base58str ); - bool is_valid_muse( const std::string& base58str ); - }; - - struct extended_public_key_type - { - struct binary_key - { - binary_key() {} - uint32_t check = 0; - fc::ecc::extended_key_data data; - }; - - fc::ecc::extended_key_data key_data; - - extended_public_key_type(); - extended_public_key_type( const fc::ecc::extended_key_data& data ); - extended_public_key_type( const fc::ecc::extended_public_key& extpubkey ); - explicit extended_public_key_type( const std::string& base58str ); - operator fc::ecc::extended_public_key() const; - explicit operator std::string() const; - friend bool operator == ( const extended_public_key_type& p1, const fc::ecc::extended_public_key& p2); - friend bool operator == ( const extended_public_key_type& p1, const extended_public_key_type& p2); - friend bool operator != ( const extended_public_key_type& p1, const extended_public_key_type& p2); - }; - - struct extended_private_key_type - { - struct binary_key - { - binary_key() {} - uint32_t check = 0; - fc::ecc::extended_key_data data; - }; - - fc::ecc::extended_key_data key_data; - - extended_private_key_type(); - extended_private_key_type( const fc::ecc::extended_key_data& data ); - extended_private_key_type( const fc::ecc::extended_private_key& extprivkey ); - explicit extended_private_key_type( const std::string& base58str ); - operator fc::ecc::extended_private_key() const; - explicit operator std::string() const; - friend bool operator == ( const extended_private_key_type& p1, const fc::ecc::extended_private_key& p2); - friend bool operator == ( const extended_private_key_type& p1, const extended_private_key_type& p2); - friend bool operator != ( const extended_private_key_type& p1, const extended_private_key_type& p2); - }; - - typedef flat_map internationalized_string_type; - - typedef uint32_t bet_multiplier_type; -} } // graphene::chain - -namespace fc -{ - void to_variant( const graphene::chain::public_key_type& var, fc::variant& vo, uint32_t max_depth = 2 ); - void from_variant( const fc::variant& var, graphene::chain::public_key_type& vo, uint32_t max_depth = 2 ); - void to_variant( const graphene::chain::extended_public_key_type& var, fc::variant& vo, uint32_t max_depth = 2 ); - void from_variant( const fc::variant& var, graphene::chain::extended_public_key_type& vo, uint32_t max_depth = 2 ); - void to_variant( const graphene::chain::extended_private_key_type& var, fc::variant& vo, uint32_t max_depth = 2 ); - void from_variant( const fc::variant& var, graphene::chain::extended_private_key_type& vo, uint32_t max_depth = 2 ); -} - -FC_REFLECT( graphene::chain::public_key_type, (key_data) ) -FC_REFLECT( graphene::chain::public_key_type::binary_key, (data)(check) ) -FC_REFLECT( graphene::chain::extended_public_key_type, (key_data) ) -FC_REFLECT( graphene::chain::extended_public_key_type::binary_key, (check)(data) ) -FC_REFLECT( graphene::chain::extended_private_key_type, (key_data) ) -FC_REFLECT( graphene::chain::extended_private_key_type::binary_key, (check)(data) ) - -FC_REFLECT_ENUM( graphene::chain::object_type, - (null_object_type) - (base_object_type) - (account_object_type) - (force_settlement_object_type) - (asset_object_type) - (committee_member_object_type) - (witness_object_type) - (limit_order_object_type) - (call_order_object_type) - (custom_object_type) - (proposal_object_type) - (operation_history_object_type) - (withdraw_permission_object_type) - (vesting_balance_object_type) - (worker_object_type) - (balance_object_type) - (tournament_object_type) - (tournament_details_object_type) - (match_object_type) - (game_object_type) - (sport_object_type) - (event_group_object_type) - (event_object_type) - (betting_market_rules_object_type) - (betting_market_group_object_type) - (betting_market_object_type) - (bet_object_type) - (custom_permission_object_type) - (custom_account_authority_object_type) - (offer_object_type) - (nft_metadata_type) - (nft_object_type) - (OBJECT_TYPE_COUNT) - ) -FC_REFLECT_ENUM( graphene::chain::impl_object_type, - (impl_global_property_object_type) - (impl_dynamic_global_property_object_type) - (impl_reserved0_object_type) - (impl_asset_dynamic_data_type) - (impl_asset_bitasset_data_type) - (impl_account_balance_object_type) - (impl_account_statistics_object_type) - (impl_transaction_object_type) - (impl_block_summary_object_type) - (impl_account_transaction_history_object_type) - (impl_blinded_balance_object_type) - (impl_chain_property_object_type) - (impl_witness_schedule_object_type) - (impl_budget_record_object_type) - (impl_special_authority_object_type) - (impl_buyback_object_type) - (impl_fba_accumulator_object_type) - (impl_asset_dividend_data_type) - (impl_pending_dividend_payout_balance_for_holder_object_type) - (impl_distributed_dividend_balance_data_type) - (impl_betting_market_position_object_type) - (impl_global_betting_statistics_object_type) - (impl_lottery_balance_object_type) - (impl_sweeps_vesting_balance_object_type) - (impl_offer_history_object_type) - ) - -FC_REFLECT_TYPENAME( graphene::chain::share_type ) - -FC_REFLECT_TYPENAME( graphene::chain::account_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::asset_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::force_settlement_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::committee_member_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::witness_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::limit_order_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::call_order_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::custom_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::proposal_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::operation_history_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::withdraw_permission_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::vesting_balance_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::worker_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::balance_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::sport_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::event_group_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::event_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::betting_market_rules_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::betting_market_group_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::betting_market_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::bet_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::tournament_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::offer_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::global_property_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::dynamic_global_property_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::asset_dynamic_data_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::asset_bitasset_data_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::account_balance_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::account_statistics_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::transaction_obj_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::block_summary_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::account_transaction_history_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::budget_record_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::special_authority_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::buyback_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::fba_accumulator_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::betting_market_position_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::global_betting_statistics_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::tournament_details_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::custom_permission_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::custom_account_authority_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::offer_history_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::nft_metadata_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::nft_id_type ) - -FC_REFLECT( 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 f091f736..931b35a7 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 75093f3a..d1d999ee 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 5ffb4bb7..53c6f3eb 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; - struct signed_transaction; + using protocol::signed_transaction; /** * Place holder for state tracked while processing a transaction. This class provides helper methods that are diff --git a/libraries/chain/include/graphene/chain/transaction_object.hpp b/libraries/chain/include/graphene/chain/transaction_object.hpp index aaaa31f1..a613e07c 100644 --- a/libraries/chain/include/graphene/chain/transaction_object.hpp +++ b/libraries/chain/include/graphene/chain/transaction_object.hpp @@ -23,7 +23,7 @@ */ #pragma once -#include +#include #include #include @@ -55,7 +55,6 @@ namespace graphene { namespace chain { }; struct by_expiration; - struct by_id; struct by_trx_id; typedef multi_index_container< transaction_object, @@ -69,6 +68,8 @@ 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) ) GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::transaction_object ) diff --git a/libraries/chain/include/graphene/chain/transfer_evaluator.hpp b/libraries/chain/include/graphene/chain/transfer_evaluator.hpp index 900ab074..6c2bc7ee 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 00000000..c84608a2 --- /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 19acc0e7..11b689df 100644 --- a/libraries/chain/include/graphene/chain/vesting_balance_object.hpp +++ b/libraries/chain/include/graphene/chain/vesting_balance_object.hpp @@ -23,9 +23,7 @@ */ #pragma once -#include -#include - +#include #include #include @@ -37,6 +35,7 @@ namespace graphene { namespace chain { using namespace graphene::db; + using namespace graphene::protocol; struct vesting_policy_context { @@ -210,6 +209,8 @@ namespace graphene { namespace chain { } } // graphene::chain +MAP_OBJECT_ID_TO_TYPE(graphene::chain::vesting_balance_object) + FC_REFLECT(graphene::chain::linear_vesting_policy, (begin_timestamp) (vesting_cliff_seconds) diff --git a/libraries/chain/include/graphene/chain/vote_count.hpp b/libraries/chain/include/graphene/chain/vote_count.hpp index f76a784d..ed8ed130 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 a6fee0c5..5b723113 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 @@ -105,6 +105,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 7928b46e..2647dcd8 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 1702212d..2415f82f 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 #include @@ -73,6 +73,7 @@ class witness_schedule_object : public graphene::db::abstract_object #include -#include +#include +#include namespace graphene { namespace chain { +class database; /** * @defgroup worker_types Implementations of the various worker types in the system @@ -159,6 +160,8 @@ using worker_index = generic_index #include -#include +#include #include diff --git a/libraries/chain/protocol/chain_parameters.cpp b/libraries/chain/protocol/chain_parameters.cpp deleted file mode 100644 index 2bfa624f..00000000 --- a/libraries/chain/protocol/chain_parameters.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include -#include - -namespace graphene { namespace chain { - chain_parameters::chain_parameters() { - current_fees = std::make_shared(); - } -}} \ No newline at end of file diff --git a/libraries/chain/special_authority.cpp b/libraries/chain/special_authority.cpp index 74889f80..a92cc5e9 100644 --- a/libraries/chain/special_authority.cpp +++ b/libraries/chain/special_authority.cpp @@ -22,31 +22,13 @@ * THE SOFTWARE. */ -#include +#include #include #include namespace graphene { namespace chain { -struct special_authority_validate_visitor -{ - typedef void result_type; - - void operator()( const no_special_authority& a ) {} - - void operator()( const top_holders_special_authority& a ) - { - FC_ASSERT( a.num_top_holders > 0 ); - } -}; - -void validate_special_authority( const special_authority& a ) -{ - special_authority_validate_visitor vtor; - a.visit( vtor ); -} - struct special_authority_evaluate_visitor { typedef void result_type; @@ -57,7 +39,7 @@ struct special_authority_evaluate_visitor void operator()( const top_holders_special_authority& a ) { - a.asset(db); // require asset to exist + db.get(a.asset); // require asset to exist } const database& db; diff --git a/libraries/chain/witness_evaluator.cpp b/libraries/chain/witness_evaluator.cpp index 7bd261bb..dd45e743 100644 --- a/libraries/chain/witness_evaluator.cpp +++ b/libraries/chain/witness_evaluator.cpp @@ -26,7 +26,7 @@ #include #include #include -#include +#include namespace graphene { namespace chain { @@ -40,7 +40,7 @@ object_id_type witness_create_evaluator::do_apply( const witness_create_operatio { try { vote_id_type vote_id; db().modify(db().get_global_properties(), [&vote_id](global_property_object& p) { - vote_id = get_next_vote_id(p, vote_id_type::witness); + vote_id = vote_id_type(vote_id_type::witness, p.next_available_vote_id++); }); const auto& new_witness_object = db().create( [&]( witness_object& obj ) { diff --git a/libraries/chain/worker_evaluator.cpp b/libraries/chain/worker_evaluator.cpp index b5aea8f3..b57396cf 100644 --- a/libraries/chain/worker_evaluator.cpp +++ b/libraries/chain/worker_evaluator.cpp @@ -28,7 +28,7 @@ #include #include -#include +#include namespace graphene { namespace chain { @@ -84,8 +84,8 @@ object_id_type worker_create_evaluator::do_apply(const worker_create_evaluator:: database& d = db(); vote_id_type for_id, against_id; d.modify(d.get_global_properties(), [&for_id, &against_id](global_property_object& p) { - for_id = get_next_vote_id(p, vote_id_type::worker); - against_id = get_next_vote_id(p, vote_id_type::worker); + for_id = vote_id_type(vote_id_type::worker, p.next_available_vote_id++); + against_id = vote_id_type(vote_id_type::worker, p.next_available_vote_id++); }); return d.create([&](worker_object& w) { diff --git a/libraries/db/include/graphene/db/fwd.hpp b/libraries/db/include/graphene/db/fwd.hpp index 36b4e713..76c514dd 100644 --- a/libraries/db/include/graphene/db/fwd.hpp +++ b/libraries/db/include/graphene/db/fwd.hpp @@ -33,3 +33,4 @@ namespace graphene { namespace db { typedef std::shared_ptr peer_ram_ptr; }} // namespace graphene::db + diff --git a/libraries/db/include/graphene/db/generic_index.hpp b/libraries/db/include/graphene/db/generic_index.hpp index 2f760ee2..c272ec5b 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 fa2109aa..8e91dbf4 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 255ef048..2d351181 100644 --- a/libraries/db/include/graphene/db/object_id.hpp +++ b/libraries/db/include/graphene/db/object_id.hpp @@ -93,14 +93,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) { @@ -117,14 +126,18 @@ namespace graphene { namespace db { explicit operator uint64_t()const { return object_id_type( *this ).number; } template - const T& operator()(const DB& db)const { return db.get(*this); } + auto operator()(const DB& db)const -> const decltype(db.get(*this))& { return db.get(*this); } friend bool operator == ( const object_id& a, const object_id& b ) { return a.instance == b.instance; } friend bool operator != ( const object_id& a, const object_id& b ) { return a.instance != b.instance; } friend bool operator == ( const object_id_type& a, const object_id& b ) { return a == object_id_type(b); } friend bool operator != ( const object_id_type& a, const object_id& b ) { return a != object_id_type(b); } - friend bool operator == ( const object_id& b, const object_id_type& a ) { return a == object_id_type(b); } - friend bool operator != ( const object_id& b, const object_id_type& a ) { return a != object_id_type(b); } + friend bool operator == ( const object_id& a, const object_id_type& b ) { return object_id_type(a) == b; } + friend bool operator != ( const object_id& a, const object_id_type& b ) { return object_id_type(a) != b; } + friend bool operator == ( const object_id& a, const fc::unsigned_int& b ) { return a.instance == b; } + friend bool operator != ( const object_id& a, const fc::unsigned_int& b ) { return a.instance != b; } + friend bool operator == ( const fc::unsigned_int& a, const object_id& b ) { return a == b.instance; } + friend bool operator != ( const fc::unsigned_int& a, const object_id& b ) { return a != b.instance; } friend bool operator < ( const object_id& a, const object_id& b ) { return a.instance.value < b.instance.value; } friend bool operator > ( const object_id& a, const object_id& b ) { return a.instance.value > b.instance.value; } @@ -140,8 +153,8 @@ FC_REFLECT( graphene::db::object_id_type, (number) ) // REFLECT object_id manually because it has 2 template params namespace fc { -template -struct get_typename> +template +struct get_typename> { static const char* name() { return typeid(get_typename).name(); @@ -150,12 +163,11 @@ struct get_typename> } }; -template -struct reflector > +template +struct reflector > { - typedef graphene::db::object_id type; - typedef fc::true_type is_defined; - typedef fc::false_type is_enum; + typedef graphene::db::object_id type; + typedef std::true_type is_defined; enum member_count_enum { local_member_count = 1, total_member_count = 1 @@ -190,13 +202,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 bd590eb3..bb4a7e58 100644 --- a/libraries/egenesis/egenesis_brief.cpp.tmpl +++ b/libraries/egenesis/egenesis_brief.cpp.tmpl @@ -17,7 +17,7 @@ ${generated_file_banner} * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #include namespace graphene { namespace egenesis { diff --git a/libraries/egenesis/egenesis_full.cpp.tmpl b/libraries/egenesis/egenesis_full.cpp.tmpl index 83285f11..2b172fa0 100644 --- a/libraries/egenesis/egenesis_full.cpp.tmpl +++ b/libraries/egenesis/egenesis_full.cpp.tmpl @@ -17,7 +17,7 @@ ${generated_file_banner} * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #include namespace graphene { namespace egenesis { diff --git a/libraries/egenesis/embed_genesis.cpp b/libraries/egenesis/embed_genesis.cpp index c2ffd686..b4c7d91c 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 848a4d29..8d575301 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/net/CMakeLists.txt b/libraries/net/CMakeLists.txt index 2594b053..202a792d 100644 --- a/libraries/net/CMakeLists.txt +++ b/libraries/net/CMakeLists.txt @@ -12,7 +12,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_CURRENT_SOURCE_DIR}/../chain/include" "${CMAKE_CURRENT_BINARY_DIR}/../chain/include" diff --git a/libraries/net/include/graphene/net/core_messages.hpp b/libraries/net/include/graphene/net/core_messages.hpp index 8af0c344..39d68fba 100644 --- a/libraries/net/include/graphene/net/core_messages.hpp +++ b/libraries/net/include/graphene/net/core_messages.hpp @@ -24,7 +24,7 @@ #pragma once #include -#include +#include #include #include @@ -40,10 +40,10 @@ #include namespace graphene { namespace net { - using graphene::chain::signed_transaction; - using graphene::chain::block_id_type; - using graphene::chain::transaction_id_type; - using graphene::chain::signed_block; + using graphene::protocol::signed_transaction; + using graphene::protocol::block_id_type; + using graphene::protocol::transaction_id_type; + using graphene::protocol::signed_block; typedef fc::ecc::public_key_data node_id_t; typedef fc::ripemd160 item_hash_t; diff --git a/libraries/net/include/graphene/net/message.hpp b/libraries/net/include/graphene/net/message.hpp index 8f6d2b6e..1807eb16 100644 --- a/libraries/net/include/graphene/net/message.hpp +++ b/libraries/net/include/graphene/net/message.hpp @@ -24,7 +24,7 @@ #pragma once #include -#include +#include #include #include diff --git a/libraries/net/include/graphene/net/node.hpp b/libraries/net/include/graphene/net/node.hpp index e17af148..f68f3574 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/include/graphene/net/peer_database.hpp b/libraries/net/include/graphene/net/peer_database.hpp index ff7f4036..931f6e33 100644 --- a/libraries/net/include/graphene/net/peer_database.hpp +++ b/libraries/net/include/graphene/net/peer_database.hpp @@ -24,7 +24,7 @@ #pragma once #include -#include +#include #include #include diff --git a/libraries/net/node.cpp b/libraries/net/node.cpp index c15b0e08..c7177251 100644 --- a/libraries/net/node.cpp +++ b/libraries/net/node.cpp @@ -79,7 +79,10 @@ #include #include -#include +// 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 diff --git a/libraries/net/peer_connection.cpp b/libraries/net/peer_connection.cpp index 9b753e6c..e5099e79 100644 --- a/libraries/net/peer_connection.cpp +++ b/libraries/net/peer_connection.cpp @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include diff --git a/libraries/plugins/account_history/include/graphene/account_history/account_history_plugin.hpp b/libraries/plugins/account_history/include/graphene/account_history/account_history_plugin.hpp index 784c7e45..986869ff 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 @@ -94,7 +94,7 @@ class affiliate_reward_index : public secondary_index } } //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 907d26ae..0965345e 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 599fc65c..413f6b9d 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 48c215f0..baa6c3c2 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 00000000..51932639 --- /dev/null +++ b/libraries/protocol/CMakeLists.txt @@ -0,0 +1,54 @@ +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 + betting_market.cpp + competitor.cpp + event.cpp + event_group.cpp + lottery_ops.cpp + small_ops.cpp + sport.cpp + tournament.cpp + small_ops.cpp + custom_permission.cpp + custom_account_authority.cpp + offer.cpp + ) + + +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 89% rename from libraries/chain/protocol/account.cpp rename to libraries/protocol/account.cpp index c79811b9..b5180978 100644 --- a/libraries/chain/protocol/account.cpp +++ b/libraries/protocol/account.cpp @@ -21,13 +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 chain { +namespace graphene { namespace protocol { /** * Names must comply with the following grammar (RFC 1035): @@ -322,16 +318,16 @@ void account_transfer_operation::validate()const } -} } // graphene::chain +} } // graphene::protocol -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::account_options ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::account_create_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::account_whitelist_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::account_update_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::account_upgrade_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::account_transfer_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::account_create_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::account_whitelist_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::account_update_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::account_upgrade_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::account_transfer_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::account_options ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::account_create_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::account_whitelist_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::account_update_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::account_upgrade_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::account_transfer_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::account_create_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::account_whitelist_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::account_update_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::account_upgrade_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::account_transfer_operation ) diff --git a/libraries/chain/protocol/address.cpp b/libraries/protocol/address.cpp similarity index 87% rename from libraries/chain/protocol/address.cpp rename to libraries/protocol/address.cpp index 3065d80b..7f1fb301 100644 --- a/libraries/chain/protocol/address.cpp +++ b/libraries/protocol/address.cpp @@ -21,17 +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 -#include - -namespace graphene { - namespace chain { - +namespace graphene { namespace protocol { address::address( const std::string& base58str ) { std::string prefix( GRAPHENE_ADDRESS_PREFIX ); @@ -84,7 +80,7 @@ namespace graphene { addr = fc::ripemd160::hash( fc::sha512::hash( (char*) pub.data(), pub.size() ) ); } - address::address( const graphene::chain::public_key_type& pub ) + address::address( const graphene::protocol::public_key_type& pub ) { addr = fc::ripemd160::hash( fc::sha512::hash( (char*) pub.key_data.data(), pub.key_data.size() ) ); } @@ -99,17 +95,17 @@ namespace graphene { return GRAPHENE_ADDRESS_PREFIX + fc::to_base58( bin_addr.data(), bin_addr.size() ); } -} } // namespace graphene::chain +} } // namespace graphene::protocol namespace fc { - void to_variant( const graphene::chain::address& var, variant& vo, uint32_t max_depth ) + void to_variant( const graphene::protocol::address& var, variant& vo, uint32_t max_depth ) { vo = std::string(var); } - void from_variant( const variant& var, graphene::chain::address& vo, uint32_t max_depth ) + void from_variant( const variant& var, graphene::protocol::address& vo, uint32_t max_depth ) { - vo = graphene::chain::address( var.as_string() ); + vo = graphene::protocol::address( var.as_string() ); } } diff --git a/libraries/chain/protocol/assert.cpp b/libraries/protocol/assert.cpp similarity index 81% rename from libraries/chain/protocol/assert.cpp rename to libraries/protocol/assert.cpp index 5ce61e45..6ab539a8 100644 --- a/libraries/chain/protocol/assert.cpp +++ b/libraries/protocol/assert.cpp @@ -21,13 +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 chain { +namespace graphene { namespace protocol { bool account_name_eq_lit_predicate::validate()const { @@ -66,7 +62,7 @@ share_type assert_operation::calculate_fee(const fee_parameters_type& k)const return k.fee * predicates.size(); } -} } // namespace graphene::chain +} } // namespace graphene::protocol -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::assert_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::assert_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::assert_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::assert_operation ) diff --git a/libraries/chain/protocol/asset.cpp b/libraries/protocol/asset.cpp similarity index 96% rename from libraries/chain/protocol/asset.cpp rename to libraries/protocol/asset.cpp index ebff3518..d7f52813 100644 --- a/libraries/chain/protocol/asset.cpp +++ b/libraries/protocol/asset.cpp @@ -21,13 +21,13 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include +#include #include #include #include #include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { typedef boost::multiprecision::uint128_t uint128_t; typedef boost::multiprecision::int128_t int128_t; @@ -207,8 +207,8 @@ const int64_t scaled_precision_lut[19] = p10< 16 >::v, p10< 17 >::v, p10< 18 >::v }; -} } // graphene::chain +} } // graphene::protocol -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::price ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::price_feed ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::price ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::price_feed ) diff --git a/libraries/chain/protocol/asset_ops.cpp b/libraries/protocol/asset_ops.cpp similarity index 75% rename from libraries/chain/protocol/asset_ops.cpp rename to libraries/protocol/asset_ops.cpp index 5dfd09ee..614d54b2 100644 --- a/libraries/chain/protocol/asset_ops.cpp +++ b/libraries/protocol/asset_ops.cpp @@ -21,12 +21,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include -#include +#include #include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * Valid symbols can contain [A-Z0-9], and '.' @@ -289,31 +288,31 @@ void lottery_asset_options::validate() const FC_ASSERT( total == GRAPHENE_100_PERCENT, "distribution amount not equals GRAPHENE_100_PERCENT" ); } -} } // namespace graphene::chain +} } // namespace graphene::protocol -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_options ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::bitasset_options ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_create_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_global_settle_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_settle_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_fund_fee_pool_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_claim_fees_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_update_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_update_bitasset_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_update_feed_producers_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_publish_feed_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_issue_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_reserve_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_create_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_global_settle_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_settle_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_settle_cancel_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_fund_fee_pool_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_claim_fees_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_dividend_distribution_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_update_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_update_bitasset_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_update_feed_producers_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_publish_feed_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_issue_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_reserve_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_options ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::bitasset_options ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_create_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_global_settle_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_settle_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_fund_fee_pool_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_claim_fees_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_update_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_update_bitasset_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_update_feed_producers_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_publish_feed_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_issue_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_reserve_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_create_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_global_settle_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_settle_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_settle_cancel_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_fund_fee_pool_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_claim_fees_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_dividend_distribution_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_update_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_update_bitasset_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_update_feed_producers_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_publish_feed_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_issue_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_reserve_operation ) diff --git a/libraries/chain/protocol/authority.cpp b/libraries/protocol/authority.cpp similarity index 86% rename from libraries/chain/protocol/authority.cpp rename to libraries/protocol/authority.cpp index 6cfed2ec..241942fc 100644 --- a/libraries/chain/protocol/authority.cpp +++ b/libraries/protocol/authority.cpp @@ -22,10 +22,9 @@ * THE SOFTWARE. */ -#include -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { void add_authority_accounts( flat_set& result, @@ -36,6 +35,6 @@ void add_authority_accounts( result.insert( item.first ); } -} } // graphene::chain +} } // graphene::protocol -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::authority ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::authority ) diff --git a/libraries/chain/protocol/betting_market.cpp b/libraries/protocol/betting_market.cpp similarity index 100% rename from libraries/chain/protocol/betting_market.cpp rename to libraries/protocol/betting_market.cpp diff --git a/libraries/chain/protocol/block.cpp b/libraries/protocol/block.cpp similarity index 96% rename from libraries/chain/protocol/block.cpp rename to libraries/protocol/block.cpp index 11680bb5..ddf6ae6d 100644 --- a/libraries/chain/protocol/block.cpp +++ b/libraries/protocol/block.cpp @@ -21,13 +21,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include -#include +#include #include #include #include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { digest_type block_header::digest()const { return digest_type::hash(*this); diff --git a/libraries/protocol/chain_parameters.cpp b/libraries/protocol/chain_parameters.cpp new file mode 100644 index 00000000..7203d76e --- /dev/null +++ b/libraries/protocol/chain_parameters.cpp @@ -0,0 +1,8 @@ +#include +#include + +namespace graphene { namespace protocol { + chain_parameters::chain_parameters() { + current_fees = std::make_shared(); + } +}} \ No newline at end of file diff --git a/libraries/chain/protocol/committee_member.cpp b/libraries/protocol/committee_member.cpp similarity index 64% rename from libraries/chain/protocol/committee_member.cpp rename to libraries/protocol/committee_member.cpp index 3ce62783..12d32a71 100644 --- a/libraries/chain/protocol/committee_member.cpp +++ b/libraries/protocol/committee_member.cpp @@ -21,12 +21,9 @@ * 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 { void committee_member_create_operation::validate()const { @@ -47,11 +44,11 @@ void committee_member_update_global_parameters_operation::validate() const new_parameters.validate(); } -} } // graphene::chain +} } // graphene::protocol -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::committee_member_create_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::committee_member_update_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::committee_member_update_global_parameters_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::committee_member_create_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::committee_member_update_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::committee_member_update_global_parameters_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::committee_member_create_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::committee_member_update_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::committee_member_update_global_parameters_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::committee_member_create_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::committee_member_update_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::committee_member_update_global_parameters_operation ) diff --git a/libraries/chain/protocol/competitor.cpp b/libraries/protocol/competitor.cpp similarity index 100% rename from libraries/chain/protocol/competitor.cpp rename to libraries/protocol/competitor.cpp diff --git a/libraries/chain/protocol/confidential.cpp b/libraries/protocol/confidential.cpp similarity index 86% rename from libraries/chain/protocol/confidential.cpp rename to libraries/protocol/confidential.cpp index 2e8fbc68..f7d03f58 100644 --- a/libraries/chain/protocol/confidential.cpp +++ b/libraries/protocol/confidential.cpp @@ -21,14 +21,13 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include -#include -#include + +#include #include #include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { void transfer_to_blind_operation::validate()const { @@ -155,11 +154,12 @@ stealth_confirmation::stealth_confirmation( const std::string& base58 ) *this = fc::raw::unpack( fc::from_base58( base58 ) ); } -} } // graphene::chain +} } // graphene::protocol + +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::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_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::transfer_to_blind_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::transfer_from_blind_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::blind_transfer_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::transfer_to_blind_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::transfer_from_blind_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::blind_transfer_operation ) diff --git a/libraries/chain/protocol/custom.cpp b/libraries/protocol/custom.cpp similarity index 93% rename from libraries/chain/protocol/custom.cpp rename to libraries/protocol/custom.cpp index 72f8dd44..c64e2e4c 100644 --- a/libraries/chain/protocol/custom.cpp +++ b/libraries/protocol/custom.cpp @@ -21,11 +21,9 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include +#include -#include - -namespace graphene { namespace chain { +namespace graphene { namespace protocol { void custom_operation::validate()const { diff --git a/libraries/chain/protocol/custom_account_authority.cpp b/libraries/protocol/custom_account_authority.cpp similarity index 100% rename from libraries/chain/protocol/custom_account_authority.cpp rename to libraries/protocol/custom_account_authority.cpp diff --git a/libraries/chain/protocol/custom_permission.cpp b/libraries/protocol/custom_permission.cpp similarity index 100% rename from libraries/chain/protocol/custom_permission.cpp rename to libraries/protocol/custom_permission.cpp diff --git a/libraries/chain/protocol/event.cpp b/libraries/protocol/event.cpp similarity index 100% rename from libraries/chain/protocol/event.cpp rename to libraries/protocol/event.cpp diff --git a/libraries/chain/protocol/event_group.cpp b/libraries/protocol/event_group.cpp similarity index 100% rename from libraries/chain/protocol/event_group.cpp rename to libraries/protocol/event_group.cpp diff --git a/libraries/chain/protocol/fee_schedule.cpp b/libraries/protocol/fee_schedule.cpp similarity index 97% rename from libraries/chain/protocol/fee_schedule.cpp rename to libraries/protocol/fee_schedule.cpp index 7410cddf..5375637b 100644 --- a/libraries/chain/protocol/fee_schedule.cpp +++ b/libraries/protocol/fee_schedule.cpp @@ -22,14 +22,14 @@ * THE SOFTWARE. */ #include -#include +#include #include #include #define MAX_FEE_STABILIZATION_ITERATION 4 -namespace graphene { namespace chain { +namespace graphene { namespace protocol { fee_schedule::fee_schedule() { @@ -195,6 +195,6 @@ namespace graphene { namespace chain { } } -} } // graphene::chain +} } // graphene::protocol -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::fee_schedule ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::fee_schedule ) diff --git a/libraries/chain/include/graphene/chain/protocol/README.md b/libraries/protocol/include/graphene/protocol/README.md similarity index 100% rename from libraries/chain/include/graphene/chain/protocol/README.md rename to libraries/protocol/include/graphene/protocol/README.md diff --git a/libraries/chain/include/graphene/chain/protocol/account.hpp b/libraries/protocol/include/graphene/protocol/account.hpp similarity index 79% rename from libraries/chain/include/graphene/chain/protocol/account.hpp rename to libraries/protocol/include/graphene/protocol/account.hpp index 36926480..6eacf675 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 ); @@ -284,49 +284,50 @@ namespace graphene { namespace chain { void validate()const; }; -} } // graphene::chain +} } // graphene::protocol -FC_REFLECT(graphene::chain::account_options, (memo_key)(voting_account)(num_witness)(num_committee)(votes)(extensions)) -// FC_REFLECT_TYPENAME( graphene::chain::account_whitelist_operation::account_listing) -FC_REFLECT_ENUM( graphene::chain::account_whitelist_operation::account_listing, +FC_REFLECT(graphene::protocol::account_options, (memo_key)(voting_account)(num_witness)(num_committee)(votes)(extensions)) +FC_REFLECT_ENUM( graphene::protocol::account_whitelist_operation::account_listing, (no_listing)(white_listed)(black_listed)(white_and_black_listed)) -FC_REFLECT_ENUM( graphene::chain::app_tag, (bookie)(rps) ) -FC_REFLECT( graphene::chain::affiliate_reward_distribution, (_dist) ); -FC_REFLECT( graphene::chain::affiliate_reward_distributions, (_dists) ); +FC_REFLECT_ENUM( graphene::protocol::app_tag, (bookie)(rps) ) +FC_REFLECT( graphene::protocol::affiliate_reward_distribution, (_dist) ); +FC_REFLECT( graphene::protocol::affiliate_reward_distributions, (_dists) ); -FC_REFLECT(graphene::chain::account_create_operation::ext, (null_ext)(owner_special_authority)(active_special_authority)(buyback_options) ) -FC_REFLECT( graphene::chain::account_create_operation, +FC_REFLECT(graphene::protocol::account_create_operation::ext, (null_ext)(owner_special_authority)(active_special_authority)(buyback_options) ) +FC_REFLECT_TYPENAME(graphene::protocol::extension) +FC_REFLECT( graphene::protocol::account_create_operation, (fee)(registrar) (referrer)(referrer_percent) (name)(owner)(active)(options)(extensions) ) -FC_REFLECT(graphene::chain::account_update_operation::ext, (null_ext)(owner_special_authority)(active_special_authority)(update_last_voting_time) ) -FC_REFLECT( graphene::chain::account_update_operation, +FC_REFLECT(graphene::protocol::account_update_operation::ext, (null_ext)(owner_special_authority)(active_special_authority) ) +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::chain::account_transfer_operation, (fee)(account_id)(new_owner)(extensions) ) +FC_REFLECT( graphene::protocol::account_create_operation::fee_parameters_type, (basic_fee)(premium_fee)(price_per_kbyte) ) +FC_REFLECT( graphene::protocol::account_whitelist_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::account_update_operation::fee_parameters_type, (fee)(price_per_kbyte) ) +FC_REFLECT( graphene::protocol::account_upgrade_operation::fee_parameters_type, (membership_annual_fee)(membership_lifetime_fee) ) +FC_REFLECT( graphene::protocol::account_transfer_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::account_transfer_operation, (fee)(account_id)(new_owner)(extensions) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::account_options ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::account_create_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::account_whitelist_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::account_update_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::account_upgrade_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::account_transfer_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::account_create_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::account_whitelist_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::account_update_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::account_upgrade_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::account_transfer_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::account_options ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::account_create_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::account_whitelist_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::account_update_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::account_upgrade_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::account_transfer_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::account_create_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::account_whitelist_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::account_update_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::account_upgrade_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::account_transfer_operation ) diff --git a/libraries/chain/include/graphene/chain/protocol/address.hpp b/libraries/protocol/include/graphene/protocol/address.hpp similarity index 79% rename from libraries/chain/include/graphene/chain/protocol/address.hpp rename to libraries/protocol/include/graphene/protocol/address.hpp index 39e3bf36..e29743ab 100644 --- a/libraries/chain/include/graphene/chain/protocol/address.hpp +++ b/libraries/protocol/include/graphene/protocol/address.hpp @@ -23,14 +23,13 @@ */ #pragma once -#include -#include -#include +#include +#include #include #include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { struct public_key_type; @@ -70,15 +69,28 @@ 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 + { + 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::chain::address, (addr) ) +FC_REFLECT( graphene::protocol::address, (addr) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::address ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::address ) diff --git a/libraries/chain/include/graphene/chain/protocol/affiliate.hpp b/libraries/protocol/include/graphene/protocol/affiliate.hpp similarity index 100% rename from libraries/chain/include/graphene/chain/protocol/affiliate.hpp rename to libraries/protocol/include/graphene/protocol/affiliate.hpp diff --git a/libraries/chain/include/graphene/chain/protocol/assert.hpp b/libraries/protocol/include/graphene/protocol/assert.hpp similarity index 85% rename from libraries/chain/include/graphene/chain/protocol/assert.hpp rename to libraries/protocol/include/graphene/protocol/assert.hpp index ce758862..0e780247 100644 --- a/libraries/chain/include/graphene/chain/protocol/assert.hpp +++ b/libraries/protocol/include/graphene/protocol/assert.hpp @@ -22,10 +22,9 @@ * THE SOFTWARE. */ #pragma once -#include -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * Used to verify that account_id->name is equal to the given string literal. @@ -104,14 +103,14 @@ namespace graphene { namespace chain { share_type calculate_fee(const fee_parameters_type& k)const; }; -} } // graphene::chain +} } // graphene::protocol -FC_REFLECT( graphene::chain::assert_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::account_name_eq_lit_predicate, (account_id)(name) ) -FC_REFLECT( graphene::chain::asset_symbol_eq_lit_predicate, (asset_id)(symbol) ) -FC_REFLECT( graphene::chain::block_id_predicate, (id) ) -FC_REFLECT_TYPENAME( graphene::chain::predicate ) -FC_REFLECT( graphene::chain::assert_operation, (fee)(fee_paying_account)(predicates)(required_auths)(extensions) ) +FC_REFLECT( graphene::protocol::assert_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::account_name_eq_lit_predicate, (account_id)(name) ) +FC_REFLECT( graphene::protocol::asset_symbol_eq_lit_predicate, (asset_id)(symbol) ) +FC_REFLECT( graphene::protocol::block_id_predicate, (id) ) +FC_REFLECT_TYPENAME( graphene::protocol::predicate ) +FC_REFLECT( graphene::protocol::assert_operation, (fee)(fee_paying_account)(predicates)(required_auths)(extensions) ) GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::assert_operation::fee_parameters_type ) GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::assert_operation ) diff --git a/libraries/chain/include/graphene/chain/protocol/asset.hpp b/libraries/protocol/include/graphene/protocol/asset.hpp similarity index 94% rename from libraries/chain/include/graphene/chain/protocol/asset.hpp rename to libraries/protocol/include/graphene/protocol/asset.hpp index 60bd3cd0..9798e520 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[]; @@ -211,14 +211,14 @@ namespace graphene { namespace chain { } } -FC_REFLECT( graphene::chain::asset, (amount)(asset_id) ) -FC_REFLECT( graphene::chain::price, (base)(quote) ) +FC_REFLECT( graphene::protocol::asset, (amount)(asset_id) ) +FC_REFLECT( graphene::protocol::price, (base)(quote) ) #define GRAPHENE_PRICE_FEED_FIELDS (settlement_price)(maintenance_collateral_ratio)(maximum_short_squeeze_ratio) \ (core_exchange_rate) -FC_REFLECT( graphene::chain::price_feed, GRAPHENE_PRICE_FEED_FIELDS ) +FC_REFLECT( graphene::protocol::price_feed, GRAPHENE_PRICE_FEED_FIELDS ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::price ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::price_feed ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::price ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::price_feed ) diff --git a/libraries/chain/include/graphene/chain/protocol/asset_ops.hpp b/libraries/protocol/include/graphene/protocol/asset_ops.hpp similarity index 83% rename from libraries/chain/include/graphene/chain/protocol/asset_ops.hpp rename to libraries/protocol/include/graphene/protocol/asset_ops.hpp index ae5dc211..743197ae 100644 --- a/libraries/chain/include/graphene/chain/protocol/asset_ops.hpp +++ b/libraries/protocol/include/graphene/protocol/asset_ops.hpp @@ -22,11 +22,10 @@ * THE SOFTWARE. */ #pragma once -#include -#include +#include +#include -namespace graphene { namespace chain { - class database; +namespace graphene { namespace protocol { bool is_valid_symbol( const string& symbol ); @@ -646,15 +645,15 @@ namespace graphene { namespace chain { void validate()const {}; }; -} } // graphene::chain +} } // graphene::protocol -FC_REFLECT( graphene::chain::sweeps_vesting_claim_operation, (fee)(account)(amount_to_claim)(extensions) ) -FC_REFLECT( graphene::chain::sweeps_vesting_claim_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::sweeps_vesting_claim_operation, (fee)(account)(amount_to_claim)(extensions) ) +FC_REFLECT( graphene::protocol::sweeps_vesting_claim_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::asset_claim_fees_operation, (fee)(issuer)(amount_to_claim)(extensions) ) -FC_REFLECT( graphene::chain::asset_claim_fees_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::asset_claim_fees_operation, (fee)(issuer)(amount_to_claim)(extensions) ) +FC_REFLECT( graphene::protocol::asset_claim_fees_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::asset_options, +FC_REFLECT( graphene::protocol::asset_options, (max_supply) (market_fee_percent) (max_market_fee) @@ -669,7 +668,7 @@ FC_REFLECT( graphene::chain::asset_options, (extensions) ) -FC_REFLECT( graphene::chain::dividend_asset_options, +FC_REFLECT( graphene::protocol::dividend_asset_options, (next_payout_time) (payout_interval) (minimum_fee_percentage) @@ -677,7 +676,7 @@ FC_REFLECT( graphene::chain::dividend_asset_options, (extensions) ) -FC_REFLECT( graphene::chain::bitasset_options, +FC_REFLECT( graphene::protocol::bitasset_options, (feed_lifetime_sec) (minimum_feeds) (force_settlement_delay_sec) @@ -687,27 +686,26 @@ FC_REFLECT( graphene::chain::bitasset_options, (extensions) ) -FC_REFLECT( graphene::chain::benefactor, (id)(share) ) +FC_REFLECT( graphene::protocol::benefactor, (id)(share) ) -FC_REFLECT( graphene::chain::lottery_asset_options, (benefactors)(owner)(winning_tickets)(ticket_price)(end_date)(ending_on_soldout)(is_active) ) +FC_REFLECT( graphene::protocol::lottery_asset_options, (benefactors)(owner)(winning_tickets)(ticket_price)(end_date)(ending_on_soldout)(is_active) ) +FC_REFLECT( graphene::protocol::asset_create_operation::fee_parameters_type, (symbol3)(symbol4)(long_symbol)(price_per_kbyte) ) +FC_REFLECT( graphene::protocol::lottery_asset_create_operation::fee_parameters_type, (lottery_asset)(price_per_kbyte) ) +FC_REFLECT( graphene::protocol::asset_global_settle_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::asset_settle_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::asset_settle_cancel_operation::fee_parameters_type, ) +FC_REFLECT( graphene::protocol::asset_fund_fee_pool_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::asset_update_operation::fee_parameters_type, (fee)(price_per_kbyte) ) +FC_REFLECT( graphene::protocol::asset_update_bitasset_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::asset_update_dividend_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::asset_update_feed_producers_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::asset_publish_feed_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::asset_issue_operation::fee_parameters_type, (fee)(price_per_kbyte) ) +FC_REFLECT( graphene::protocol::asset_reserve_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::asset_dividend_distribution_operation::fee_parameters_type, (distribution_base_fee)(distribution_fee_per_holder)) -FC_REFLECT( graphene::chain::asset_create_operation::fee_parameters_type, (symbol3)(symbol4)(long_symbol)(price_per_kbyte) ) -FC_REFLECT( graphene::chain::lottery_asset_create_operation::fee_parameters_type, (lottery_asset)(price_per_kbyte) ) -FC_REFLECT( graphene::chain::asset_global_settle_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::asset_settle_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::asset_settle_cancel_operation::fee_parameters_type, ) -FC_REFLECT( graphene::chain::asset_fund_fee_pool_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::asset_update_operation::fee_parameters_type, (fee)(price_per_kbyte) ) -FC_REFLECT( graphene::chain::asset_update_bitasset_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::asset_update_dividend_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::asset_update_feed_producers_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::asset_publish_feed_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::asset_issue_operation::fee_parameters_type, (fee)(price_per_kbyte) ) -FC_REFLECT( graphene::chain::asset_reserve_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::asset_dividend_distribution_operation::fee_parameters_type, (distribution_base_fee)(distribution_fee_per_holder)) - -FC_REFLECT( graphene::chain::asset_create_operation, +FC_REFLECT( graphene::protocol::asset_create_operation, (fee) (issuer) (symbol) @@ -717,7 +715,7 @@ FC_REFLECT( graphene::chain::asset_create_operation, (is_prediction_market) (extensions) ) -FC_REFLECT( graphene::chain::lottery_asset_create_operation, +FC_REFLECT( graphene::protocol::lottery_asset_create_operation, (fee) (issuer) (symbol) @@ -727,7 +725,7 @@ FC_REFLECT( graphene::chain::lottery_asset_create_operation, (is_prediction_market) (extensions) ) -FC_REFLECT( graphene::chain::asset_update_operation, +FC_REFLECT( graphene::protocol::asset_update_operation, (fee) (issuer) (asset_to_update) @@ -735,7 +733,7 @@ FC_REFLECT( graphene::chain::asset_update_operation, (new_options) (extensions) ) -FC_REFLECT( graphene::chain::asset_update_bitasset_operation, +FC_REFLECT( graphene::protocol::asset_update_issuer_operation, (fee) (issuer) (asset_to_update) @@ -749,45 +747,52 @@ FC_REFLECT( graphene::chain::asset_update_dividend_operation, (new_options) (extensions) ) -FC_REFLECT( graphene::chain::asset_update_feed_producers_operation, +FC_REFLECT( graphene::protocol::asset_update_bitasset_operation, + (fee) + (issuer) + (asset_to_update) + (new_options) + (extensions) + ) +FC_REFLECT( graphene::protocol::asset_update_feed_producers_operation, (fee)(issuer)(asset_to_update)(new_feed_producers)(extensions) ) -FC_REFLECT( graphene::chain::asset_publish_feed_operation, +FC_REFLECT( graphene::protocol::asset_publish_feed_operation, (fee)(publisher)(asset_id)(feed)(extensions) ) -FC_REFLECT( graphene::chain::asset_settle_operation, (fee)(account)(amount)(extensions) ) -FC_REFLECT( graphene::chain::asset_settle_cancel_operation, (fee)(settlement)(account)(amount)(extensions) ) -FC_REFLECT( graphene::chain::asset_global_settle_operation, (fee)(issuer)(asset_to_settle)(settle_price)(extensions) ) -FC_REFLECT( graphene::chain::asset_issue_operation, +FC_REFLECT( graphene::protocol::asset_settle_operation, (fee)(account)(amount)(extensions) ) +FC_REFLECT( graphene::protocol::asset_settle_cancel_operation, (fee)(settlement)(account)(amount)(extensions) ) +FC_REFLECT( graphene::protocol::asset_global_settle_operation, (fee)(issuer)(asset_to_settle)(settle_price)(extensions) ) +FC_REFLECT( graphene::protocol::asset_issue_operation, (fee)(issuer)(asset_to_issue)(issue_to_account)(memo)(extensions) ) -FC_REFLECT( graphene::chain::asset_reserve_operation, +FC_REFLECT( graphene::protocol::asset_reserve_operation, (fee)(payer)(amount_to_reserve)(extensions) ) -FC_REFLECT( graphene::chain::asset_fund_fee_pool_operation, (fee)(from_account)(asset_id)(amount)(extensions) ); -FC_REFLECT( graphene::chain::asset_dividend_distribution_operation, (fee)(dividend_asset_id)(account_id)(amounts)(extensions) ); +FC_REFLECT( graphene::protocol::asset_fund_fee_pool_operation, (fee)(from_account)(asset_id)(amount)(extensions) ); +FC_REFLECT( graphene::protocol::asset_dividend_distribution_operation, (fee)(dividend_asset_id)(account_id)(amounts)(extensions) ); -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_options ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::bitasset_options ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_create_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_global_settle_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_settle_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_fund_fee_pool_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_dividend_distribution_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_claim_fees_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_update_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_update_bitasset_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_update_feed_producers_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_publish_feed_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_issue_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_reserve_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_create_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_global_settle_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_settle_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_settle_cancel_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_fund_fee_pool_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_claim_fees_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_update_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_update_bitasset_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_update_feed_producers_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_publish_feed_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_issue_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_reserve_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_options ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::bitasset_options ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_create_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_global_settle_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_settle_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_fund_fee_pool_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_dividend_distribution_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_claim_fees_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_update_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_update_bitasset_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_update_feed_producers_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_publish_feed_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_issue_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_reserve_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_create_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_global_settle_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_settle_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_settle_cancel_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_fund_fee_pool_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_claim_fees_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_update_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_update_bitasset_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_update_feed_producers_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_publish_feed_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_issue_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_reserve_operation ) diff --git a/libraries/chain/include/graphene/chain/protocol/authority.hpp b/libraries/protocol/include/graphene/protocol/authority.hpp similarity index 89% rename from libraries/chain/include/graphene/chain/protocol/authority.hpp rename to libraries/protocol/include/graphene/protocol/authority.hpp index d279402d..944f7a79 100644 --- a/libraries/chain/include/graphene/chain/protocol/authority.hpp +++ b/libraries/protocol/include/graphene/protocol/authority.hpp @@ -22,10 +22,9 @@ * THE SOFTWARE. */ #pragma once -#include -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * @class authority @@ -130,10 +129,9 @@ void add_authority_accounts( const authority& a ); -} } // namespace graphene::chain +} } // namespace graphene::protocol -FC_REFLECT( graphene::chain::authority, (weight_threshold)(account_auths)(key_auths)(address_auths) ) -// FC_REFLECT_TYPENAME( graphene::chain::authority::classification ) -FC_REFLECT_ENUM( graphene::chain::authority::classification, (owner)(active)(key) ) +FC_REFLECT( graphene::protocol::authority, (weight_threshold)(account_auths)(key_auths)(address_auths) ) +FC_REFLECT_ENUM( graphene::protocol::authority::classification, (owner)(active)(key) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::authority ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::authority ) diff --git a/libraries/chain/include/graphene/chain/protocol/balance.hpp b/libraries/protocol/include/graphene/protocol/balance.hpp similarity index 85% rename from libraries/chain/include/graphene/chain/protocol/balance.hpp rename to libraries/protocol/include/graphene/protocol/balance.hpp index 9d0b252f..076697d9 100644 --- a/libraries/chain/include/graphene/chain/protocol/balance.hpp +++ b/libraries/protocol/include/graphene/protocol/balance.hpp @@ -22,14 +22,12 @@ * THE SOFTWARE. */ #pragma once -#include -#include -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** - * @brief Claim a balance in a @ref balanc_object + * @brief Claim a balance in a @ref balance_object * * This operation is used to claim the balance in a given @ref balance_object. If the balance object contains a * vesting balance, @ref total_claimed must not exceed @ref balance_object::available at the time of evaluation. If @@ -54,10 +52,10 @@ namespace graphene { namespace chain { } }; -} } // graphene::chain +} } // graphene::protocol -FC_REFLECT( graphene::chain::balance_claim_operation::fee_parameters_type, ) -FC_REFLECT( graphene::chain::balance_claim_operation, +FC_REFLECT( graphene::protocol::balance_claim_operation::fee_parameters_type, ) +FC_REFLECT( graphene::protocol::balance_claim_operation, (fee)(deposit_to_account)(balance_to_claim)(balance_owner_key)(total_claimed) ) GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::balance_claim_operation ) 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 676d28ff..29d2b237 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 { struct asset; struct authority; @@ -122,8 +122,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/betting_market.hpp b/libraries/protocol/include/graphene/protocol/betting_market.hpp similarity index 100% rename from libraries/chain/include/graphene/chain/protocol/betting_market.hpp rename to libraries/protocol/include/graphene/protocol/betting_market.hpp diff --git a/libraries/chain/include/graphene/chain/protocol/block.hpp b/libraries/protocol/include/graphene/protocol/block.hpp similarity index 80% rename from libraries/chain/include/graphene/chain/protocol/block.hpp rename to libraries/protocol/include/graphene/protocol/block.hpp index ad5b0327..67c633ed 100644 --- a/libraries/chain/include/graphene/chain/protocol/block.hpp +++ b/libraries/protocol/include/graphene/protocol/block.hpp @@ -22,9 +22,9 @@ * THE SOFTWARE. */ #pragma once -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { struct block_header { @@ -57,9 +57,9 @@ namespace graphene { namespace chain { vector transactions; }; -} } // graphene::chain +} } // graphene::protocol -FC_REFLECT( graphene::chain::block_header, +FC_REFLECT( graphene::protocol::block_header, (previous) (timestamp) (witness) @@ -67,10 +67,10 @@ FC_REFLECT( graphene::chain::block_header, (previous_secret) (transaction_merkle_root) (extensions) ) -FC_REFLECT_DERIVED( graphene::chain::signed_block_header, (graphene::chain::block_header), (witness_signature) ) -FC_REFLECT_DERIVED( graphene::chain::signed_block, (graphene::chain::signed_block_header), (transactions) ) +FC_REFLECT_DERIVED( graphene::protocol::signed_block_header, (graphene::protocol::block_header), (witness_signature) ) +FC_REFLECT_DERIVED( graphene::protocol::signed_block, (graphene::protocol::signed_block_header), (transactions) ) -GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::chain::block_header) -GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::chain::signed_block_header) -GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::chain::signed_block) +GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::protocol::block_header) +GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::protocol::signed_block_header) +GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::protocol::signed_block) diff --git a/libraries/chain/include/graphene/chain/protocol/buyback.hpp b/libraries/protocol/include/graphene/protocol/buyback.hpp similarity index 85% rename from libraries/chain/include/graphene/chain/protocol/buyback.hpp rename to libraries/protocol/include/graphene/protocol/buyback.hpp index 4a51e8c7..9f58beca 100644 --- a/libraries/chain/include/graphene/chain/protocol/buyback.hpp +++ b/libraries/protocol/include/graphene/protocol/buyback.hpp @@ -23,9 +23,9 @@ */ #pragma once -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { struct buyback_account_options { @@ -49,6 +49,6 @@ struct buyback_account_options } } -FC_REFLECT( graphene::chain::buyback_account_options, (asset_to_buy)(asset_to_buy_issuer)(markets) ); +FC_REFLECT( graphene::protocol::buyback_account_options, (asset_to_buy)(asset_to_buy_issuer)(markets) ); -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::buyback_account_options ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::buyback_account_options ) diff --git a/libraries/chain/include/graphene/chain/protocol/chain_parameters.hpp b/libraries/protocol/include/graphene/protocol/chain_parameters.hpp similarity index 97% rename from libraries/chain/include/graphene/chain/protocol/chain_parameters.hpp rename to libraries/protocol/include/graphene/protocol/chain_parameters.hpp index d07f613b..2121dca2 100644 --- a/libraries/chain/include/graphene/chain/protocol/chain_parameters.hpp +++ b/libraries/protocol/include/graphene/protocol/chain_parameters.hpp @@ -22,17 +22,16 @@ * THE SOFTWARE. */ #pragma once -#include -#include -#include -#include +#include #include <../hardfork.d/GPOS.hf> #include +#include +#include -namespace graphene { namespace chain { struct fee_schedule; } } +namespace graphene { namespace protocol { + struct fee_schedule; -namespace graphene { namespace chain { struct parameter_extension { optional< bet_multiplier_type > min_bet_multiplier; @@ -153,9 +152,9 @@ namespace graphene { namespace chain { } }; -} } // graphene::chain +} } // graphene::protocol -FC_REFLECT( graphene::chain::parameter_extension, +FC_REFLECT( graphene::protocol::parameter_extension, (min_bet_multiplier) (max_bet_multiplier) (betting_rake_fee_percentage) @@ -173,7 +172,7 @@ FC_REFLECT( graphene::chain::parameter_extension, (rbac_max_authorities_per_permission) ) -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 74% rename from libraries/chain/include/graphene/chain/protocol/committee_member.hpp rename to libraries/protocol/include/graphene/protocol/committee_member.hpp index 8aaed748..748994dd 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,21 +93,21 @@ namespace graphene { namespace chain { /// TODO: committee_member_resign_operation : public base_operation -} } // graphene::chain -FC_REFLECT( graphene::chain::committee_member_create_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::committee_member_update_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::committee_member_update_global_parameters_operation::fee_parameters_type, (fee) ) +} } // graphene::protocol +FC_REFLECT( graphene::protocol::committee_member_create_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::committee_member_update_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::committee_member_update_global_parameters_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::committee_member_create_operation, +FC_REFLECT( graphene::protocol::committee_member_create_operation, (fee)(committee_member_account)(url) ) -FC_REFLECT( graphene::chain::committee_member_update_operation, +FC_REFLECT( graphene::protocol::committee_member_update_operation, (fee)(committee_member)(committee_member_account)(new_url) ) -FC_REFLECT( graphene::chain::committee_member_update_global_parameters_operation, (fee)(new_parameters) ); +FC_REFLECT( graphene::protocol::committee_member_update_global_parameters_operation, (fee)(new_parameters) ); -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::committee_member_create_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::committee_member_update_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::committee_member_update_global_parameters_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::committee_member_create_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::committee_member_update_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::committee_member_update_global_parameters_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::committee_member_create_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::committee_member_update_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::committee_member_update_global_parameters_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::committee_member_create_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::committee_member_update_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::committee_member_update_global_parameters_operation ) diff --git a/libraries/chain/include/graphene/chain/protocol/confidential.hpp b/libraries/protocol/include/graphene/protocol/confidential.hpp similarity index 87% rename from libraries/chain/include/graphene/chain/protocol/confidential.hpp rename to libraries/protocol/include/graphene/protocol/confidential.hpp index 697ef35b..5d407420 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,33 +258,34 @@ 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::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) ) FC_REFLECT( graphene::chain::blind_transfer_operation::fee_parameters_type, (fee)(price_per_output) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::transfer_to_blind_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::transfer_from_blind_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::blind_transfer_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::transfer_to_blind_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::transfer_from_blind_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::blind_transfer_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::transfer_to_blind_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::transfer_from_blind_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::blind_transfer_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::transfer_to_blind_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::transfer_from_blind_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::blind_transfer_operation ) diff --git a/libraries/protocol/include/graphene/protocol/config.hpp b/libraries/protocol/include/graphene/protocol/config.hpp new file mode 100644 index 00000000..6f1f6da4 --- /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 80% rename from libraries/chain/include/graphene/chain/protocol/custom.hpp rename to libraries/protocol/include/graphene/protocol/custom.hpp index 5596aaad..dc31168e 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,10 +52,10 @@ 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) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::custom_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::custom_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::custom_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::custom_operation ) diff --git a/libraries/chain/include/graphene/chain/protocol/custom_account_authority.hpp b/libraries/protocol/include/graphene/protocol/custom_account_authority.hpp similarity index 100% rename from libraries/chain/include/graphene/chain/protocol/custom_account_authority.hpp rename to libraries/protocol/include/graphene/protocol/custom_account_authority.hpp diff --git a/libraries/chain/include/graphene/chain/protocol/custom_permission.hpp b/libraries/protocol/include/graphene/protocol/custom_permission.hpp similarity index 100% rename from libraries/chain/include/graphene/chain/protocol/custom_permission.hpp rename to libraries/protocol/include/graphene/protocol/custom_permission.hpp diff --git a/libraries/chain/include/graphene/chain/protocol/event.hpp b/libraries/protocol/include/graphene/protocol/event.hpp similarity index 100% rename from libraries/chain/include/graphene/chain/protocol/event.hpp rename to libraries/protocol/include/graphene/protocol/event.hpp diff --git a/libraries/chain/include/graphene/chain/protocol/event_group.hpp b/libraries/protocol/include/graphene/protocol/event_group.hpp similarity index 100% rename from libraries/chain/include/graphene/chain/protocol/event_group.hpp rename to libraries/protocol/include/graphene/protocol/event_group.hpp diff --git a/libraries/protocol/include/graphene/protocol/exceptions.hpp b/libraries/protocol/include/graphene/protocol/exceptions.hpp new file mode 100644 index 00000000..5141151d --- /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 82% rename from libraries/chain/include/graphene/chain/protocol/ext.hpp rename to libraries/protocol/include/graphene/protocol/ext.hpp index 75364525..7cb47cfc 100644 --- a/libraries/chain/include/graphene/chain/protocol/ext.hpp +++ b/libraries/protocol/include/graphene/protocol/ext.hpp @@ -26,8 +26,9 @@ #include #include #include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { using fc::unsigned_int; @@ -129,7 +130,7 @@ struct graphene_extension_unpack_visitor const uint32_t max_depth; }; -} } // graphene::chain +} } // graphene::protocol namespace fc { @@ -162,9 +163,9 @@ struct graphene_extension_from_variant_visitor }; template< typename T > -void from_variant( const fc::variant& var, graphene::chain::extension& value, uint32_t max_depth ) +void from_variant( const fc::variant& var, graphene::protocol::extension& value, uint32_t max_depth ) { - value = graphene::chain::extension(); + value = graphene::protocol::extension(); if( var.is_null() ) return; if( var.is_array() ) @@ -195,7 +196,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 ); @@ -205,29 +206,39 @@ 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::protocol::extension > +{ + static const char* name() + { + static std::string n = std::string("graphene::protocol::extension<") + + fc::get_typename::name() + std::string(">"); + return n.c_str(); + } +}; + } // fc diff --git a/libraries/chain/include/graphene/chain/protocol/fba.hpp b/libraries/protocol/include/graphene/protocol/fba.hpp similarity index 78% rename from libraries/chain/include/graphene/chain/protocol/fba.hpp rename to libraries/protocol/include/graphene/protocol/fba.hpp index dc672436..0f5425bf 100644 --- a/libraries/chain/include/graphene/chain/protocol/fba.hpp +++ b/libraries/protocol/include/graphene/protocol/fba.hpp @@ -22,10 +22,9 @@ * THE SOFTWARE. */ #pragma once -#include -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { struct fba_distribute_operation : public base_operation { @@ -33,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; } @@ -43,8 +42,7 @@ struct fba_distribute_operation : public base_operation } } -FC_REFLECT( graphene::chain::fba_distribute_operation::fee_parameters_type, ) +FC_REFLECT( graphene::protocol::fba_distribute_operation::fee_parameters_type, ) +FC_REFLECT( graphene::protocol::fba_distribute_operation, (fee)(account_id)(fba_id)(amount) ) -FC_REFLECT( graphene::chain::fba_distribute_operation, (fee)(account_id)(fba_id)(amount) ) - -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::fba_distribute_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::fba_distribute_operation ) diff --git a/libraries/chain/include/graphene/chain/protocol/fee_schedule.hpp b/libraries/protocol/include/graphene/protocol/fee_schedule.hpp similarity index 87% rename from libraries/chain/include/graphene/chain/protocol/fee_schedule.hpp rename to libraries/protocol/include/graphene/protocol/fee_schedule.hpp index 1587d1ba..deb5a087 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 @@ -81,13 +81,13 @@ namespace graphene { namespace chain { typedef fee_schedule fee_schedule_type; -} } // graphene::chain +} } // graphene::protocol namespace fc { - template<> struct get_typename> { static const char* name() { return "shared_ptr"; } }; + template<> struct get_typename> { static const char* name() { return "shared_ptr"; } }; } -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) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::fee_schedule ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::fee_schedule ) diff --git a/libraries/chain/include/graphene/chain/protocol/lottery_ops.hpp b/libraries/protocol/include/graphene/protocol/lottery_ops.hpp similarity index 100% rename from libraries/chain/include/graphene/chain/protocol/lottery_ops.hpp rename to libraries/protocol/include/graphene/protocol/lottery_ops.hpp diff --git a/libraries/chain/include/graphene/chain/protocol/market.hpp b/libraries/protocol/include/graphene/protocol/market.hpp similarity index 79% rename from libraries/chain/include/graphene/chain/protocol/market.hpp rename to libraries/protocol/include/graphene/protocol/market.hpp index 2bff8c56..4dee59f0 100644 --- a/libraries/chain/include/graphene/chain/protocol/market.hpp +++ b/libraries/protocol/include/graphene/protocol/market.hpp @@ -22,10 +22,10 @@ * THE SOFTWARE. */ #pragma once -#include -#include +#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * @class limit_order_create_operation @@ -73,7 +73,6 @@ namespace graphene { namespace chain { price get_price()const { return amount_to_sell / min_to_receive; } }; - /** * @ingroup operations * Used to cancel an existing limit order. Both fee_pay_account and the @@ -159,22 +158,23 @@ namespace graphene { namespace chain { share_type calculate_fee(const fee_parameters_type& k)const { return 0; } }; -} } // graphene::chain +} } // graphene::protocol -FC_REFLECT( graphene::chain::limit_order_create_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::limit_order_cancel_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::call_order_update_operation::fee_parameters_type, (fee) ) -/// THIS IS THE ONLY VIRTUAL OPERATION THUS FAR... -FC_REFLECT( graphene::chain::fill_order_operation::fee_parameters_type, ) -FC_REFLECT( graphene::chain::limit_order_create_operation,(fee)(seller)(amount_to_sell)(min_to_receive)(expiration)(fill_or_kill)(extensions)) -FC_REFLECT( graphene::chain::limit_order_cancel_operation,(fee)(fee_paying_account)(order)(extensions) ) -FC_REFLECT( graphene::chain::call_order_update_operation, (fee)(funding_account)(delta_collateral)(delta_debt)(extensions) ) +FC_REFLECT( graphene::protocol::limit_order_create_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::limit_order_cancel_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::call_order_update_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::fill_order_operation::fee_parameters_type, ) // VIRTUAL +FC_REFLECT( graphene::protocol::limit_order_create_operation,(fee)(seller)(amount_to_sell)(min_to_receive)(expiration)(fill_or_kill)(extensions)) +FC_REFLECT( graphene::protocol::limit_order_cancel_operation,(fee)(fee_paying_account)(order)(extensions) ) +FC_REFLECT( graphene::protocol::call_order_update_operation, (fee)(funding_account)(delta_collateral)(delta_debt)(extensions) ) +FC_REFLECT( graphene::protocol::fill_order_operation, (fee)(order_id)(account_id)(pays)(receives)(fill_price)(is_maker) ) FC_REFLECT( graphene::chain::fill_order_operation, (fee)(order_id)(account_id)(pays)(receives) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::limit_order_create_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::limit_order_cancel_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::call_order_update_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::limit_order_create_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::limit_order_cancel_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::call_order_update_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::fill_order_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::limit_order_create_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::limit_order_cancel_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::call_order_update_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::limit_order_create_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::limit_order_cancel_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::call_order_update_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::fill_order_operation ) + diff --git a/libraries/chain/include/graphene/chain/protocol/memo.hpp b/libraries/protocol/include/graphene/protocol/memo.hpp similarity index 89% rename from libraries/chain/include/graphene/chain/protocol/memo.hpp rename to libraries/protocol/include/graphene/protocol/memo.hpp index 6c5b69fb..d0ef2115 100644 --- a/libraries/chain/include/graphene/chain/protocol/memo.hpp +++ b/libraries/protocol/include/graphene/protocol/memo.hpp @@ -22,9 +22,9 @@ * THE SOFTWARE. */ #pragma once -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * @brief defines the keys used to derive the shared secret @@ -85,10 +85,10 @@ namespace graphene { namespace chain { static memo_message deserialize(const string& serial); }; -} } // namespace graphene::chain +} } // namespace graphene::protocol -FC_REFLECT( graphene::chain::memo_message, (checksum)(text) ) -FC_REFLECT( graphene::chain::memo_data, (from)(to)(nonce)(message) ) +FC_REFLECT( graphene::protocol::memo_message, (checksum)(text) ) +FC_REFLECT( graphene::protocol::memo_data, (from)(to)(nonce)(message) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::memo_message ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::memo_data ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::memo_message ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::memo_data ) diff --git a/libraries/chain/include/graphene/chain/protocol/nft_ops.hpp b/libraries/protocol/include/graphene/protocol/nft_ops.hpp similarity index 100% rename from libraries/chain/include/graphene/chain/protocol/nft_ops.hpp rename to libraries/protocol/include/graphene/protocol/nft_ops.hpp diff --git a/libraries/chain/include/graphene/chain/protocol/offer.hpp b/libraries/protocol/include/graphene/protocol/offer.hpp similarity index 100% rename from libraries/chain/include/graphene/chain/protocol/offer.hpp rename to libraries/protocol/include/graphene/protocol/offer.hpp diff --git a/libraries/chain/include/graphene/chain/protocol/operations.hpp b/libraries/protocol/include/graphene/protocol/operations.hpp similarity index 80% rename from libraries/chain/include/graphene/chain/protocol/operations.hpp rename to libraries/protocol/include/graphene/protocol/operations.hpp index 1285d353..ae61643c 100644 --- a/libraries/chain/include/graphene/chain/protocol/operations.hpp +++ b/libraries/protocol/include/graphene/protocol/operations.hpp @@ -22,35 +22,35 @@ * THE SOFTWARE. */ #pragma once -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * @ingroup operations @@ -183,9 +183,9 @@ namespace graphene { namespace chain { operation op; }; -} } // graphene::chain +} } // graphene::protocol -FC_REFLECT_TYPENAME( graphene::chain::operation ) -FC_REFLECT( graphene::chain::op_wrapper, (op) ) +FC_REFLECT_TYPENAME( graphene::protocol::operation ) +FC_REFLECT( graphene::protocol::op_wrapper, (op) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::op_wrapper ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::op_wrapper ) diff --git a/libraries/chain/include/graphene/chain/protocol/proposal.hpp b/libraries/protocol/include/graphene/protocol/proposal.hpp similarity index 87% rename from libraries/chain/include/graphene/chain/protocol/proposal.hpp rename to libraries/protocol/include/graphene/protocol/proposal.hpp index 141ec35f..c18a06b3 100644 --- a/libraries/chain/include/graphene/chain/protocol/proposal.hpp +++ b/libraries/protocol/include/graphene/protocol/proposal.hpp @@ -22,10 +22,9 @@ * THE SOFTWARE. */ #pragma once -#include -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * @defgroup proposed_transactions The Graphene Transaction Proposal Protocol * @ingroup operations @@ -168,22 +167,22 @@ namespace graphene { namespace chain { }; ///@} -}} // graphene::chain +}} // graphene::protocol -FC_REFLECT( graphene::chain::proposal_create_operation::fee_parameters_type, (fee)(price_per_kbyte) ) -FC_REFLECT( graphene::chain::proposal_update_operation::fee_parameters_type, (fee)(price_per_kbyte) ) -FC_REFLECT( graphene::chain::proposal_delete_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::proposal_create_operation::fee_parameters_type, (fee)(price_per_kbyte) ) +FC_REFLECT( graphene::protocol::proposal_update_operation::fee_parameters_type, (fee)(price_per_kbyte) ) +FC_REFLECT( graphene::protocol::proposal_delete_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::proposal_create_operation, (fee)(fee_paying_account)(expiration_time) +FC_REFLECT( graphene::protocol::proposal_create_operation, (fee)(fee_paying_account)(expiration_time) (proposed_ops)(review_period_seconds)(extensions) ) -FC_REFLECT( graphene::chain::proposal_update_operation, (fee)(fee_paying_account)(proposal) +FC_REFLECT( graphene::protocol::proposal_update_operation, (fee)(fee_paying_account)(proposal) (active_approvals_to_add)(active_approvals_to_remove)(owner_approvals_to_add)(owner_approvals_to_remove) (key_approvals_to_add)(key_approvals_to_remove)(extensions) ) -FC_REFLECT( graphene::chain::proposal_delete_operation, (fee)(fee_paying_account)(using_owner_authority)(proposal)(extensions) ) +FC_REFLECT( graphene::protocol::proposal_delete_operation, (fee)(fee_paying_account)(using_owner_authority)(proposal)(extensions) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::proposal_create_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::proposal_update_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::proposal_delete_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::proposal_create_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::proposal_update_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::proposal_delete_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::proposal_create_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::proposal_update_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::proposal_delete_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::proposal_create_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::proposal_update_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::proposal_delete_operation ) diff --git a/libraries/chain/include/graphene/chain/protocol/protocol.hpp b/libraries/protocol/include/graphene/protocol/protocol.hpp similarity index 100% rename from libraries/chain/include/graphene/chain/protocol/protocol.hpp rename to libraries/protocol/include/graphene/protocol/protocol.hpp diff --git a/libraries/chain/include/graphene/chain/pts_address.hpp b/libraries/protocol/include/graphene/protocol/pts_address.hpp similarity index 84% rename from libraries/chain/include/graphene/chain/pts_address.hpp rename to libraries/protocol/include/graphene/protocol/pts_address.hpp index faa55816..7544d98a 100644 --- a/libraries/chain/include/graphene/chain/pts_address.hpp +++ b/libraries/protocol/include/graphene/protocol/pts_address.hpp @@ -33,7 +33,7 @@ namespace fc { namespace ecc { class public_key; } } -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * Implements address stringification and validation from PTS @@ -56,15 +56,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; std::memcpy( (char*)&s, a.addr.data() + a.addr.size() - sizeof(s), sizeof(s) ); @@ -74,17 +74,18 @@ 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 ); namespace raw { - extern template void pack( datastream& s, const graphene::chain::pts_address& tx, + extern template void pack( datastream& s, const graphene::protocol::pts_address& tx, uint32_t _max_depth=FC_PACK_MAX_DEPTH ); - extern template void pack( datastream& s, const graphene::chain::pts_address& tx, + extern template void pack( datastream& s, const graphene::protocol::pts_address& tx, uint32_t _max_depth=FC_PACK_MAX_DEPTH ); - extern template void unpack( datastream& s, graphene::chain::pts_address& tx, + extern template void unpack( datastream& s, graphene::protocol::pts_address& tx, uint32_t _max_depth=FC_PACK_MAX_DEPTH ); } } // fc::raw + diff --git a/libraries/chain/include/graphene/chain/protocol/rock_paper_scissors.hpp b/libraries/protocol/include/graphene/protocol/rock_paper_scissors.hpp similarity index 100% rename from libraries/chain/include/graphene/chain/protocol/rock_paper_scissors.hpp rename to libraries/protocol/include/graphene/protocol/rock_paper_scissors.hpp diff --git a/libraries/chain/include/graphene/chain/protocol/special_authority.hpp b/libraries/protocol/include/graphene/protocol/special_authority.hpp similarity index 78% rename from libraries/chain/include/graphene/chain/protocol/special_authority.hpp rename to libraries/protocol/include/graphene/protocol/special_authority.hpp index 05a80719..f6e925cb 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,10 +43,10 @@ typedef static_variant< void validate_special_authority( const special_authority& auth ); -} } // graphene::chain +} } // graphene::protocol -FC_REFLECT( graphene::chain::no_special_authority, ) -FC_REFLECT( graphene::chain::top_holders_special_authority, (asset)(num_top_holders) ) -FC_REFLECT_TYPENAME( graphene::chain::special_authority ) +FC_REFLECT( graphene::protocol::no_special_authority, ) +FC_REFLECT( graphene::protocol::top_holders_special_authority, (asset)(num_top_holders) ) +FC_REFLECT_TYPENAME( graphene::protocol::special_authority ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::top_holders_special_authority ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::top_holders_special_authority ) diff --git a/libraries/chain/include/graphene/chain/protocol/sport.hpp b/libraries/protocol/include/graphene/protocol/sport.hpp similarity index 100% rename from libraries/chain/include/graphene/chain/protocol/sport.hpp rename to libraries/protocol/include/graphene/protocol/sport.hpp diff --git a/libraries/chain/include/graphene/chain/protocol/tournament.hpp b/libraries/protocol/include/graphene/protocol/tournament.hpp similarity index 100% rename from libraries/chain/include/graphene/chain/protocol/tournament.hpp rename to libraries/protocol/include/graphene/protocol/tournament.hpp diff --git a/libraries/chain/include/graphene/chain/protocol/transaction.hpp b/libraries/protocol/include/graphene/protocol/transaction.hpp similarity index 93% rename from libraries/chain/include/graphene/chain/protocol/transaction.hpp rename to libraries/protocol/include/graphene/protocol/transaction.hpp index ec8f3f53..8bb689ec 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 @@ -228,14 +228,14 @@ namespace graphene { namespace chain { /// @} transactions group -} } // graphene::chain +} } // graphene::protocol -FC_REFLECT( graphene::chain::transaction, (ref_block_num)(ref_block_prefix)(expiration)(operations)(extensions) ) +FC_REFLECT( graphene::protocol::transaction, (ref_block_num)(ref_block_prefix)(expiration)(operations)(extensions) ) // Note: not reflecting signees field for backward compatibility; in addition, it should not be in p2p messages -FC_REFLECT_DERIVED( graphene::chain::signed_transaction, (graphene::chain::transaction), (signatures) ) -FC_REFLECT_DERIVED( graphene::chain::processed_transaction, (graphene::chain::signed_transaction), (operation_results) ) +FC_REFLECT_DERIVED( graphene::protocol::signed_transaction, (graphene::protocol::transaction), (signatures) ) +FC_REFLECT_DERIVED( graphene::protocol::processed_transaction, (graphene::protocol::precomputable_transaction), (operation_results) ) -GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::chain::transaction) -GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::chain::signed_transaction) -GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::chain::processed_transaction) +GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::protocol::transaction) +GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::protocol::signed_transaction) +GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::protocol::processed_transaction) diff --git a/libraries/chain/include/graphene/chain/protocol/transfer.hpp b/libraries/protocol/include/graphene/protocol/transfer.hpp similarity index 78% rename from libraries/chain/include/graphene/chain/protocol/transfer.hpp rename to libraries/protocol/include/graphene/protocol/transfer.hpp index 5366a7ab..76fc6bb4 100644 --- a/libraries/chain/include/graphene/chain/protocol/transfer.hpp +++ b/libraries/protocol/include/graphene/protocol/transfer.hpp @@ -22,11 +22,10 @@ * THE SOFTWARE. */ #pragma once -#include -#include -#include +#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * @ingroup operations @@ -99,15 +98,15 @@ namespace graphene { namespace chain { share_type calculate_fee(const fee_parameters_type& k)const; }; -}} // graphene::chain +}} // graphene::protocol -FC_REFLECT( graphene::chain::transfer_operation::fee_parameters_type, (fee)(price_per_kbyte) ) -FC_REFLECT( graphene::chain::override_transfer_operation::fee_parameters_type, (fee)(price_per_kbyte) ) +FC_REFLECT( graphene::protocol::transfer_operation::fee_parameters_type, (fee)(price_per_kbyte) ) +FC_REFLECT( graphene::protocol::override_transfer_operation::fee_parameters_type, (fee)(price_per_kbyte) ) -FC_REFLECT( graphene::chain::override_transfer_operation, (fee)(issuer)(from)(to)(amount)(memo)(extensions) ) -FC_REFLECT( graphene::chain::transfer_operation, (fee)(from)(to)(amount)(memo)(extensions) ) +FC_REFLECT( graphene::protocol::override_transfer_operation, (fee)(issuer)(from)(to)(amount)(memo)(extensions) ) +FC_REFLECT( graphene::protocol::transfer_operation, (fee)(from)(to)(amount)(memo)(extensions) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::transfer_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::override_transfer_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::transfer_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::override_transfer_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::transfer_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::override_transfer_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::transfer_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::override_transfer_operation ) diff --git a/libraries/protocol/include/graphene/protocol/types.hpp b/libraries/protocol/include/graphene/protocol/types.hpp new file mode 100644 index 00000000..2ef4f290 --- /dev/null +++ b/libraries/protocol/include/graphene/protocol/types.hpp @@ -0,0 +1,369 @@ +/* + * 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, + tournament_object_type, + tournament_details_object_type, + match_object_type, + game_object_type, + sport_object_type, + event_group_object_type, + event_object_type, + betting_market_rules_object_type, + betting_market_group_object_type, + betting_market_object_type, + bet_object_type, + custom_permission_object_type, + custom_account_authority_object_type, + offer_object_type, + nft_metadata_type, + nft_object_type, +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) + (tournament_object_type) + (tournament_details_object_type) + (match_object_type) + (game_object_type) + (sport_object_type) + (event_group_object_type) + (event_object_type) + (betting_market_rules_object_type) + (betting_market_group_object_type) + (betting_market_object_type) + (bet_object_type) + (custom_permission_object_type) + (custom_account_authority_object_type) + (offer_object_type) + (nft_metadata_type) + (nft_object_type) + (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::tournament_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::tournament_details_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::match_id_type)) +FC_REFLECT_TYPENAME(graphene::protocol::game_id_type)) +FC_REFLECT_TYPENAME(graphene::protocol::sport_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::event_group_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::event_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::betting_market_rules_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::betting_market_group_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::betting_market_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::bet_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::custom_permission_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::custom_account_authority_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::offer_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::nft_metadata_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::nft_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 76% rename from libraries/chain/include/graphene/chain/protocol/vesting.hpp rename to libraries/protocol/include/graphene/protocol/vesting.hpp index 4dffb253..1f5779be 100644 --- a/libraries/chain/include/graphene/chain/protocol/vesting.hpp +++ b/libraries/protocol/include/graphene/protocol/vesting.hpp @@ -22,10 +22,10 @@ * THE SOFTWARE. */ #pragma once -#include -#include -namespace graphene { namespace chain { +#include + +namespace graphene { namespace protocol { enum class vesting_balance_type { normal, gpos }; @@ -121,21 +121,22 @@ namespace graphene { namespace chain { } }; -} } // graphene::chain +} } // graphene::protocol -FC_REFLECT( graphene::chain::vesting_balance_create_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::vesting_balance_withdraw_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::vesting_balance_create_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::vesting_balance_withdraw_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::vesting_balance_create_operation, (fee)(creator)(owner)(amount)(policy)(balance_type) ) -FC_REFLECT( graphene::chain::vesting_balance_withdraw_operation, (fee)(vesting_balance)(owner)(amount)) +FC_REFLECT( graphene::protocol::vesting_balance_create_operation, (fee)(creator)(owner)(amount)(policy) ) +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_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 ) -FC_REFLECT_ENUM( graphene::chain::vesting_balance_type, (normal)(gpos) ) +FC_REFLECT_ENUM( graphene::protocol::vesting_balance_type, (normal)(gpos) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::vesting_balance_create_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::vesting_balance_withdraw_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::vesting_balance_create_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::vesting_balance_withdraw_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::vesting_balance_create_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::vesting_balance_withdraw_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::vesting_balance_create_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::vesting_balance_withdraw_operation ) diff --git a/libraries/chain/include/graphene/chain/protocol/vote.hpp b/libraries/protocol/include/graphene/protocol/vote.hpp similarity index 86% rename from libraries/chain/include/graphene/chain/protocol/vote.hpp rename to libraries/protocol/include/graphene/protocol/vote.hpp index 7d733e45..0c69dddd 100644 --- a/libraries/chain/include/graphene/chain/protocol/vote.hpp +++ b/libraries/protocol/include/graphene/protocol/vote.hpp @@ -26,7 +26,7 @@ #include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * @brief An ID for some votable object @@ -125,25 +125,21 @@ struct vote_id_type } }; -class global_property_object; - -vote_id_type get_next_vote_id( global_property_object& gpo, vote_id_type::vote_type type ); - -} } // graphene::chain +} } // graphene::protocol namespace fc { class variant; -void to_variant( const graphene::chain::vote_id_type& var, fc::variant& vo, uint32_t max_depth = 1 ); -void from_variant( const fc::variant& var, graphene::chain::vote_id_type& vo, uint32_t max_depth = 1 ); +void to_variant( const graphene::protocol::vote_id_type& var, fc::variant& vo, uint32_t max_depth = 1 ); +void from_variant( const fc::variant& var, graphene::protocol::vote_id_type& vo, uint32_t max_depth = 1 ); } // fc -FC_REFLECT_TYPENAME( fc::flat_set ) +FC_REFLECT_TYPENAME( fc::flat_set ) -FC_REFLECT_ENUM( graphene::chain::vote_id_type::vote_type, (witness)(committee)(worker)(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) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::vote_id_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::vote_id_type ) diff --git a/libraries/chain/include/graphene/chain/protocol/withdraw_permission.hpp b/libraries/protocol/include/graphene/protocol/withdraw_permission.hpp similarity index 89% rename from libraries/chain/include/graphene/chain/protocol/withdraw_permission.hpp rename to libraries/protocol/include/graphene/protocol/withdraw_permission.hpp index 7963e99f..0041379c 100644 --- a/libraries/chain/include/graphene/chain/protocol/withdraw_permission.hpp +++ b/libraries/protocol/include/graphene/protocol/withdraw_permission.hpp @@ -22,11 +22,10 @@ * THE SOFTWARE. */ #pragma once -#include -#include -#include +#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * @brief Create a new withdrawal permission @@ -166,19 +165,19 @@ namespace graphene { namespace chain { void validate()const; }; -} } // graphene::chain +} } // graphene::protocol -FC_REFLECT( graphene::chain::withdraw_permission_create_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::withdraw_permission_update_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::withdraw_permission_claim_operation::fee_parameters_type, (fee)(price_per_kbyte) ) -FC_REFLECT( graphene::chain::withdraw_permission_delete_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::withdraw_permission_create_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::withdraw_permission_update_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::withdraw_permission_claim_operation::fee_parameters_type, (fee)(price_per_kbyte) ) +FC_REFLECT( graphene::protocol::withdraw_permission_delete_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::withdraw_permission_create_operation, (fee)(withdraw_from_account)(authorized_account) +FC_REFLECT( graphene::protocol::withdraw_permission_create_operation, (fee)(withdraw_from_account)(authorized_account) (withdrawal_limit)(withdrawal_period_sec)(periods_until_expiration)(period_start_time) ) -FC_REFLECT( graphene::chain::withdraw_permission_update_operation, (fee)(withdraw_from_account)(authorized_account) +FC_REFLECT( graphene::protocol::withdraw_permission_update_operation, (fee)(withdraw_from_account)(authorized_account) (permission_to_update)(withdrawal_limit)(withdrawal_period_sec)(period_start_time)(periods_until_expiration) ) -FC_REFLECT( graphene::chain::withdraw_permission_claim_operation, (fee)(withdraw_permission)(withdraw_from_account)(withdraw_to_account)(amount_to_withdraw)(memo) ); -FC_REFLECT( graphene::chain::withdraw_permission_delete_operation, (fee)(withdraw_from_account)(authorized_account) +FC_REFLECT( graphene::protocol::withdraw_permission_claim_operation, (fee)(withdraw_permission)(withdraw_from_account)(withdraw_to_account)(amount_to_withdraw)(memo) ); +FC_REFLECT( graphene::protocol::withdraw_permission_delete_operation, (fee)(withdraw_from_account)(authorized_account) (withdrawal_permission) ) GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::withdraw_permission_create_operation::fee_parameters_type ) diff --git a/libraries/chain/include/graphene/chain/protocol/witness.hpp b/libraries/protocol/include/graphene/protocol/witness.hpp similarity index 75% rename from libraries/chain/include/graphene/chain/protocol/witness.hpp rename to libraries/protocol/include/graphene/protocol/witness.hpp index 2b5e88b0..33472a3f 100644 --- a/libraries/chain/include/graphene/chain/protocol/witness.hpp +++ b/libraries/protocol/include/graphene/protocol/witness.hpp @@ -22,10 +22,9 @@ * THE SOFTWARE. */ #pragma once -#include -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * @brief Create a witness object, as a bid to hold a witness position on the network. @@ -78,15 +77,15 @@ namespace graphene { namespace chain { /// TODO: witness_resign_operation : public base_operation -} } // graphene::chain +} } // graphene::protocol -FC_REFLECT( graphene::chain::witness_create_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::witness_create_operation, (fee)(witness_account)(url)(block_signing_key)(initial_secret) ) +FC_REFLECT( graphene::protocol::witness_create_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::witness_create_operation, (fee)(witness_account)(url)(block_signing_key) ) -FC_REFLECT( graphene::chain::witness_update_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::witness_update_operation, (fee)(witness)(witness_account)(new_url)(new_signing_key)(new_initial_secret) ) +FC_REFLECT( graphene::protocol::witness_update_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::witness_update_operation, (fee)(witness)(witness_account)(new_url)(new_signing_key) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::witness_create_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::witness_update_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::witness_create_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::witness_update_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::witness_create_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::witness_update_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::witness_create_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::witness_update_operation ) diff --git a/libraries/chain/include/graphene/chain/protocol/worker.hpp b/libraries/protocol/include/graphene/protocol/worker.hpp similarity index 88% rename from libraries/chain/include/graphene/chain/protocol/worker.hpp rename to libraries/protocol/include/graphene/protocol/worker.hpp index 11e0aa05..ccc59e8d 100644 --- a/libraries/chain/include/graphene/chain/protocol/worker.hpp +++ b/libraries/protocol/include/graphene/protocol/worker.hpp @@ -22,10 +22,9 @@ * THE SOFTWARE. */ #pragma once -#include -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * @defgroup workers The Blockchain Worker System @@ -96,13 +95,13 @@ namespace graphene { namespace chain { } } -FC_REFLECT( graphene::chain::vesting_balance_worker_initializer, (pay_vesting_period_days) ) -FC_REFLECT( graphene::chain::burn_worker_initializer, ) -FC_REFLECT( graphene::chain::refund_worker_initializer, ) -FC_REFLECT_TYPENAME( graphene::chain::worker_initializer ) +FC_REFLECT( graphene::protocol::vesting_balance_worker_initializer, (pay_vesting_period_days) ) +FC_REFLECT( graphene::protocol::burn_worker_initializer, ) +FC_REFLECT( graphene::protocol::refund_worker_initializer, ) +FC_REFLECT_TYPENAME( graphene::protocol::worker_initializer ) -FC_REFLECT( graphene::chain::worker_create_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::worker_create_operation, +FC_REFLECT( graphene::protocol::worker_create_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::worker_create_operation, (fee)(owner)(work_begin_date)(work_end_date)(daily_pay)(name)(url)(initializer) ) GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::worker_create_operation::fee_parameters_type ) diff --git a/libraries/chain/protocol/lottery_ops.cpp b/libraries/protocol/lottery_ops.cpp similarity index 100% rename from libraries/chain/protocol/lottery_ops.cpp rename to libraries/protocol/lottery_ops.cpp diff --git a/libraries/chain/protocol/market.cpp b/libraries/protocol/market.cpp similarity index 67% rename from libraries/chain/protocol/market.cpp rename to libraries/protocol/market.cpp index ae0a3a68..5c72baea 100644 --- a/libraries/chain/protocol/market.cpp +++ b/libraries/protocol/market.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 limit_order_create_operation::validate()const { @@ -46,12 +46,12 @@ void call_order_update_operation::validate()const FC_ASSERT( delta_collateral.amount != 0 || delta_debt.amount != 0 ); } FC_CAPTURE_AND_RETHROW((*this)) } -} } // graphene::chain +} } // graphene::protocol -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::limit_order_create_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::limit_order_cancel_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::call_order_update_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::limit_order_create_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::limit_order_cancel_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::call_order_update_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::fill_order_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::limit_order_create_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::limit_order_cancel_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::call_order_update_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::limit_order_create_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::limit_order_cancel_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::call_order_update_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::fill_order_operation ) diff --git a/libraries/chain/protocol/memo.cpp b/libraries/protocol/memo.cpp similarity index 93% rename from libraries/chain/protocol/memo.cpp rename to libraries/protocol/memo.cpp index 387c095f..6780cadd 100644 --- a/libraries/chain/protocol/memo.cpp +++ b/libraries/protocol/memo.cpp @@ -21,12 +21,15 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include -#include + +#include + #include #include -namespace graphene { namespace chain { +#include + +namespace graphene { namespace protocol { void memo_data::set_message(const fc::ecc::private_key& priv, const fc::ecc::public_key& pub, const string& msg, uint64_t custom_nonce) @@ -89,7 +92,7 @@ memo_message memo_message::deserialize(const string& serial) return result; } -} } // graphene::chain +} } // graphene::protocol -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::memo_message ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::memo_data ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::memo_message ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::memo_data ) diff --git a/libraries/chain/protocol/nft.cpp b/libraries/protocol/nft.cpp similarity index 100% rename from libraries/chain/protocol/nft.cpp rename to libraries/protocol/nft.cpp diff --git a/libraries/chain/protocol/offer.cpp b/libraries/protocol/offer.cpp similarity index 100% rename from libraries/chain/protocol/offer.cpp rename to libraries/protocol/offer.cpp diff --git a/libraries/chain/protocol/operations.cpp b/libraries/protocol/operations.cpp similarity index 91% rename from libraries/chain/protocol/operations.cpp rename to libraries/protocol/operations.cpp index e513028c..335abc36 100644 --- a/libraries/chain/protocol/operations.cpp +++ b/libraries/protocol/operations.cpp @@ -21,12 +21,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include -#include #include #include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { uint64_t base_operation::calculate_data_fee( uint64_t bytes, uint64_t price_per_kbyte ) { @@ -87,6 +86,6 @@ void operation_get_required_authorities( const operation& op, op.visit( operation_get_required_auth( active, owner, other ) ); } -} } // namespace graphene::chain +} } // namespace graphene::protocol -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::op_wrapper ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::op_wrapper ) diff --git a/libraries/chain/protocol/proposal.cpp b/libraries/protocol/proposal.cpp similarity index 83% rename from libraries/chain/protocol/proposal.cpp rename to libraries/protocol/proposal.cpp index f14f057a..a1a40187 100644 --- a/libraries/chain/protocol/proposal.cpp +++ b/libraries/protocol/proposal.cpp @@ -21,12 +21,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include -#include +#include +#include #include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { proposal_create_operation proposal_create_operation::committee_proposal(const chain_parameters& global_params, fc::time_point_sec head_block_time ) { @@ -105,11 +105,11 @@ void proposal_update_operation::get_required_owner_authorities( flat_set -#include +#include #include #include @@ -30,7 +29,7 @@ #include #include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { pts_address::pts_address() { @@ -43,10 +42,7 @@ namespace graphene { namespace chain { if( v.size() ) memcpy( addr.data(), v.data(), std::min( v.size(), addr.size() ) ); - if( !is_valid() ) - { - FC_THROW_EXCEPTION( invalid_pts_address, "invalid pts_address ${a}", ("a", base58str) ); - } + FC_ASSERT(is_valid(), "invalid pts_address ${a}", ("a", base58str)); } pts_address::pts_address( const fc::ecc::public_key& pub, bool compressed, uint8_t version ) @@ -90,13 +86,13 @@ 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() ); } namespace raw { diff --git a/libraries/chain/protocol/small_ops.cpp b/libraries/protocol/small_ops.cpp similarity index 100% rename from libraries/chain/protocol/small_ops.cpp rename to libraries/protocol/small_ops.cpp diff --git a/libraries/chain/protocol/vote.cpp b/libraries/protocol/special_authority.cpp similarity index 62% rename from libraries/chain/protocol/vote.cpp rename to libraries/protocol/special_authority.cpp index 68f476f5..2f7b4f91 100644 --- a/libraries/chain/protocol/vote.cpp +++ b/libraries/protocol/special_authority.cpp @@ -22,32 +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++ ); + 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 ); } -} } // graphene::chain - -namespace fc -{ - -void to_variant( const graphene::chain::vote_id_type& var, variant& vo, uint32_t max_depth ) -{ - vo = string(var); -} - -void from_variant( const variant& var, graphene::chain::vote_id_type& vo, uint32_t max_depth ) -{ - vo = graphene::chain::vote_id_type(var.as_string()); -} - -} // fc - -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::vote_id_type ) +} } // graphene::protocol diff --git a/libraries/chain/protocol/sport.cpp b/libraries/protocol/sport.cpp similarity index 100% rename from libraries/chain/protocol/sport.cpp rename to libraries/protocol/sport.cpp diff --git a/libraries/chain/protocol/tournament.cpp b/libraries/protocol/tournament.cpp similarity index 100% rename from libraries/chain/protocol/tournament.cpp rename to libraries/protocol/tournament.cpp 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 94c6ded9..8fe191ca 100644 --- a/libraries/chain/protocol/transaction.cpp +++ b/libraries/protocol/transaction.cpp @@ -21,14 +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 -namespace graphene { namespace chain { +namespace graphene { namespace protocol { digest_type processed_transaction::merkle_digest()const { @@ -67,7 +69,7 @@ graphene::chain::transaction_id_type graphene::chain::transaction::id() const return result; } -const signature_type& graphene::chain::signed_transaction::sign(const private_key_type& key, const chain_id_type& chain_id) +const signature_type& graphene::protocol::signed_transaction::sign(const private_key_type& key, const chain_id_type& chain_id) { digest_type h = sig_digest( chain_id ); signatures.push_back(key.sign_compact(h)); @@ -75,7 +77,7 @@ const signature_type& graphene::chain::signed_transaction::sign(const private_ke return signatures.back(); } -signature_type graphene::chain::signed_transaction::sign(const private_key_type& key, const chain_id_type& chain_id)const +signature_type graphene::protocol::signed_transaction::sign(const private_key_type& key, const chain_id_type& chain_id)const { digest_type::encoder enc; fc::raw::pack( enc, chain_id ); @@ -417,7 +419,7 @@ set signed_transaction::minimize_required_signatures( result.erase( k ); try { - graphene::chain::verify_authority( operations, result, get_active, get_owner, get_custom, max_recursion ); + graphene::protocol::verify_authority( operations, result, get_active, get_owner, get_custom, max_recursion ); continue; // element stays erased if verify_authority is ok } catch( const tx_missing_owner_auth& e ) {} @@ -435,11 +437,12 @@ void signed_transaction::verify_authority( const std::function(account_id_type, const operation&)>& get_custom, uint32_t max_recursion )const { try { - graphene::chain::verify_authority( operations, get_signature_keys( chain_id ), get_active, get_owner, get_custom, max_recursion ); + graphene::protocol::verify_authority( operations, get_signature_keys( chain_id ), get_active, get_owner, get_custom, max_recursion ); } FC_CAPTURE_AND_RETHROW( (*this) ) } -} } // graphene::chain +} } // 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::processed_transaction) -GRAPHENE_EXTERNAL_SERIALIZATION(/*not extern*/, graphene::chain::transaction) -GRAPHENE_EXTERNAL_SERIALIZATION(/*not extern*/, graphene::chain::signed_transaction) -GRAPHENE_EXTERNAL_SERIALIZATION(/*not extern*/, graphene::chain::processed_transaction) diff --git a/libraries/chain/protocol/transfer.cpp b/libraries/protocol/transfer.cpp similarity index 79% rename from libraries/chain/protocol/transfer.cpp rename to libraries/protocol/transfer.cpp index 0fb0aefa..cc63146b 100644 --- a/libraries/chain/protocol/transfer.cpp +++ b/libraries/protocol/transfer.cpp @@ -21,11 +21,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include +#include #include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { share_type transfer_operation::calculate_fee( const fee_parameters_type& schedule )const { @@ -62,9 +62,9 @@ void override_transfer_operation::validate()const FC_ASSERT( issuer != from ); } -} } // graphene::chain +} } // graphene::protocol -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::transfer_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::override_transfer_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::transfer_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::override_transfer_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::transfer_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::override_transfer_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::transfer_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::override_transfer_operation ) diff --git a/libraries/chain/protocol/types.cpp b/libraries/protocol/types.cpp similarity index 83% rename from libraries/chain/protocol/types.cpp rename to libraries/protocol/types.cpp index d5c04992..e07f7c64 100644 --- a/libraries/chain/protocol/types.cpp +++ b/libraries/protocol/types.cpp @@ -21,15 +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 -namespace graphene { namespace chain { +namespace graphene { namespace protocol { public_key_type::public_key_type():key_data(){}; @@ -191,7 +192,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 ){}; @@ -243,38 +244,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, + uint32_t max_depth ) { + // If it's null, just make a new one + if (!vo) vo = std::make_shared(); + // Convert the non-const shared_ptr to a non-const fee_schedule& so we can write it + // Don't decrement max_depth since we're not actually deserializing at this step + from_variant(var, const_cast(*vo), max_depth); + } + } // 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 870b08fe..ae1755c1 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 69% rename from libraries/chain/protocol/withdraw_permission.cpp rename to libraries/protocol/withdraw_permission.cpp index b36c378d..1155e3d5 100644 --- a/libraries/chain/protocol/withdraw_permission.cpp +++ b/libraries/protocol/withdraw_permission.cpp @@ -21,11 +21,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include +#include #include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { void withdraw_permission_update_operation::validate()const { @@ -67,13 +67,13 @@ void withdraw_permission_delete_operation::validate() const FC_ASSERT( withdraw_from_account != authorized_account ); } -} } // graphene::chain +} } // graphene::protocol -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::withdraw_permission_create_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::withdraw_permission_update_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::withdraw_permission_claim_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::withdraw_permission_delete_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::withdraw_permission_create_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::withdraw_permission_update_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::withdraw_permission_claim_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::withdraw_permission_delete_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::withdraw_permission_create_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::withdraw_permission_update_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::withdraw_permission_claim_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::withdraw_permission_delete_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::withdraw_permission_create_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::withdraw_permission_update_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::withdraw_permission_claim_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::withdraw_permission_delete_operation ) diff --git a/libraries/chain/protocol/witness.cpp b/libraries/protocol/witness.cpp similarity index 73% rename from libraries/chain/protocol/witness.cpp rename to libraries/protocol/witness.cpp index 90583cd8..eb8d4661 100644 --- a/libraries/chain/protocol/witness.cpp +++ b/libraries/protocol/witness.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 witness_create_operation::validate() const { @@ -39,9 +39,9 @@ void witness_update_operation::validate() const FC_ASSERT(new_url->size() < GRAPHENE_MAX_URL_LENGTH ); } -} } // graphene::chain +} } // graphene::protocol -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::witness_create_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::witness_update_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::witness_create_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::witness_update_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::witness_create_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::witness_update_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::witness_create_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::witness_update_operation ) diff --git a/libraries/chain/protocol/worker.cpp b/libraries/protocol/worker.cpp similarity index 95% rename from libraries/chain/protocol/worker.cpp rename to libraries/protocol/worker.cpp index 932148ec..86de8bc4 100644 --- a/libraries/chain/protocol/worker.cpp +++ b/libraries/protocol/worker.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 worker_create_operation::validate() const { diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index f3bdec4a..1b7a57b9 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -62,16 +62,14 @@ #include #include #include -<<<<<<< HEAD #include -======= #include #include #include ->>>>>>> 8f1eca14... Replace fc::uint128 with boost::multiprecision::uint128_t #include #include +#include #include #include @@ -81,7 +79,8 @@ #include -#include +#include +#include #include #include #include @@ -659,11 +658,11 @@ public: 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 std::shared_ptr s ) @@ -685,13 +684,9 @@ public: " old"); result["next_maintenance_time"] = fc::get_approximate_relative_time_string(dynamic_props.next_maintenance_time); result["chain_id"] = chain_props.chain_id; -<<<<<<< HEAD - result["participation"] = (100*dynamic_props.recent_slots_filled.popcount()) / 128.0; -======= stringstream participation; participation << fixed << std::setprecision(2) << (100.0*fc::popcount(dynamic_props.recent_slots_filled)) / 128.0; result["participation"] = participation.str(); ->>>>>>> 8f1eca14... Replace fc::uint128 with boost::multiprecision::uint128_t 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["entropy"] = fc::variant(dynamic_props.random, GRAPHENE_MAX_NESTED_OBJECTS); @@ -1195,7 +1190,7 @@ public: total_fee += gprops.current_fees->set_fee( op, fee_asset_obj.options.core_exchange_rate ); FC_ASSERT((total_fee * fee_asset_obj.options.core_exchange_rate).amount <= - get_object(fee_asset_obj.dynamic_asset_data_id).fee_pool, + get_object(fee_asset_obj.dynamic_asset_data_id).fee_pool, "Cannot pay fees in ${asset}, as this asset's fee pool is insufficiently funded.", ("asset", fee_asset_obj.symbol)); } else { @@ -2087,7 +2082,7 @@ public: if( vbid ) { - result.emplace_back( get_object(*vbid), now ); + result.emplace_back( get_object(*vbid), now ); return result; } @@ -2606,14 +2601,13 @@ public: return sign_transaction(trx, broadcast); } - signed_transaction cancel_order(object_id_type order_id, bool broadcast = false) + signed_transaction cancel_order(limit_order_id_type order_id, bool broadcast = false) { try { FC_ASSERT(!is_locked()); - FC_ASSERT(order_id.space() == protocol_ids, "Invalid order ID ${id}", ("id", order_id)); signed_transaction trx; limit_order_cancel_operation op; - op.fee_paying_account = get_object(order_id).seller; + op.fee_paying_account = get_object(order_id).seller; op.order = order_id; trx.operations = {op}; set_operation_fees( trx, _remote_db->get_global_properties().parameters.current_fees); @@ -4130,7 +4124,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 d956af38..44e8cfac 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 7f73acdb..f8224cc8 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 4df7091f..136603a4 100644 --- a/programs/genesis_util/genesis_update.cpp +++ b/programs/genesis_util/genesis_update.cpp @@ -32,8 +32,7 @@ #include #include -#include -#include +#include #include #include diff --git a/programs/genesis_util/get_dev_key.cpp b/programs/genesis_util/get_dev_key.cpp index ea7cdf9f..4fc6a42f 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 d7c5c2f9..9ce86cfa 100644 --- a/programs/js_operation_serializer/main.cpp +++ b/programs/js_operation_serializer/main.cpp @@ -21,8 +21,9 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include -#include + +#include +#include #include #include @@ -136,11 +137,16 @@ 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(){ +<<<<<<< HEAD return "protocol_id_type \"" + remove_namespace(fc::get_typename::name()) + "\""; +======= + return "protocol_id_type(\"" + + remove_namespace(fc::get_typename>>::name()) + "\")"; +>>>>>>> eec1da5b... Ref #1506: Isolate chain/protocol to its own library }; }; @@ -283,8 +289,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 3015e1cd..a7c09308 100644 --- a/programs/size_checker/main.cpp +++ b/programs/size_checker/main.cpp @@ -27,7 +27,8 @@ #include #include -#include +#include +#include #include #include @@ -35,7 +36,7 @@ #include #include -using namespace graphene::chain; +using namespace graphene::protocol; vector< fc::variant_object > g_op_types; @@ -68,7 +69,7 @@ int main( int argc, char** argv ) { try { - graphene::chain::operation op; + graphene::protocol::operation op; vector witnesses; witnesses.resize(50); diff --git a/tests/common/database_fixture.hpp b/tests/common/database_fixture.hpp index 487b66dc..5f1ebc16 100644 --- a/tests/common/database_fixture.hpp +++ b/tests/common/database_fixture.hpp @@ -23,12 +23,19 @@ */ #pragma once -#include -#include #include +#include +#include + +#include +#include #include +#include +#include +#include + #include #include