diff --git a/CMakeLists.txt b/CMakeLists.txt index 9acff8a0..debcd378 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ set( CLI_CLIENT_EXECUTABLE_NAME graphene_client ) set( GUI_CLIENT_EXECUTABLE_NAME BitShares ) set( CUSTOM_URL_SCHEME "gcs" ) set( INSTALLER_APP_ID "68ad7005-8eee-49c9-95ce-9eed97e5b347" ) -set( CMAKE_CXX_VERSION 14 ) +set( CMAKE_CXX_STANDARD 14 ) # http://stackoverflow.com/a/18369825 if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") diff --git a/libraries/app/CMakeLists.txt b/libraries/app/CMakeLists.txt index 1a90aa0f..55985589 100644 --- a/libraries/app/CMakeLists.txt +++ b/libraries/app/CMakeLists.txt @@ -12,7 +12,12 @@ add_library( graphene_app ) # need to link graphene_debug_witness because plugins aren't sufficiently isolated #246 -target_link_libraries( graphene_app graphene_market_history graphene_account_history graphene_accounts_list graphene_affiliate_stats graphene_chain fc graphene_db graphene_net graphene_utilities graphene_debug_witness graphene_bookie graphene_elasticsearch peerplays_sidechain ) +target_link_libraries( graphene_app + PUBLIC graphene_chain graphene_net graphene_utilities + fc graphene_db peerplays_sidechain + graphene_account_history graphene_accounts_list graphene_affiliate_stats graphene_bookie graphene_debug_witness graphene_elasticsearch + graphene_es_objects graphene_generate_genesis graphene_market_history ) + target_include_directories( graphene_app PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" "${CMAKE_CURRENT_SOURCE_DIR}/../egenesis/include" ) @@ -29,3 +34,26 @@ INSTALL( TARGETS ARCHIVE DESTINATION lib ) INSTALL( FILES ${HEADERS} DESTINATION "include/graphene/app" ) + + + +add_library( graphene_plugin + plugin.cpp + + include/graphene/app/plugin.hpp + ) + +target_link_libraries( graphene_plugin + PUBLIC graphene_chain graphene_net graphene_utilities ) + +target_include_directories( graphene_plugin + PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) + +INSTALL( TARGETS + graphene_app + + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib +) + diff --git a/libraries/app/include/graphene/app/custom_account_authority.hpp b/libraries/app/include/graphene/app/custom_account_authority.hpp deleted file mode 100644 index b3fe2903..00000000 --- a/libraries/app/include/graphene/app/custom_account_authority.hpp +++ /dev/null @@ -1,76 +0,0 @@ -#pragma once -#include - -namespace graphene -{ -namespace chain -{ - -struct custom_account_authority_create_operation : public base_operation -{ - struct fee_parameters_type - { - uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; - uint32_t price_per_kbyte = GRAPHENE_BLOCKCHAIN_PRECISION; - }; - - asset fee; - custom_permission_id_type permission_id; - int operation_type; - time_point_sec valid_from; - time_point_sec valid_to; - account_id_type owner_account; - extensions_type extensions; - - account_id_type fee_payer() const { return owner_account; } - void validate() const; - share_type calculate_fee(const fee_parameters_type &k) const; -}; - -struct custom_account_authority_update_operation : public base_operation -{ - struct fee_parameters_type - { - uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; - }; - - asset fee; - custom_account_authority_id_type auth_id; - optional new_valid_from; - optional new_valid_to; - account_id_type owner_account; - extensions_type extensions; - - account_id_type fee_payer() const { return owner_account; } - void validate() const; - share_type calculate_fee(const fee_parameters_type &k) const { return k.fee; } -}; - -struct custom_account_authority_delete_operation : public base_operation -{ - struct fee_parameters_type - { - uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; - }; - - asset fee; - custom_account_authority_id_type auth_id; - account_id_type owner_account; - extensions_type extensions; - - account_id_type fee_payer() const { return owner_account; } - void validate() const; - share_type calculate_fee(const fee_parameters_type &k) const { return k.fee; } -}; - -} // namespace chain -} // namespace graphene - -FC_REFLECT(graphene::chain::custom_account_authority_create_operation::fee_parameters_type, (fee)(price_per_kbyte)) -FC_REFLECT(graphene::chain::custom_account_authority_create_operation, (fee)(permission_id)(operation_type)(valid_from)(valid_to)(owner_account)(extensions)) - -FC_REFLECT(graphene::chain::custom_account_authority_update_operation::fee_parameters_type, (fee)) -FC_REFLECT(graphene::chain::custom_account_authority_update_operation, (fee)(auth_id)(new_valid_from)(new_valid_to)(owner_account)(extensions)) - -FC_REFLECT(graphene::chain::custom_account_authority_delete_operation::fee_parameters_type, (fee)) -FC_REFLECT(graphene::chain::custom_account_authority_delete_operation, (fee)(auth_id)(owner_account)(extensions)) diff --git a/libraries/app/include/graphene/app/custom_permission.hpp b/libraries/app/include/graphene/app/custom_permission.hpp deleted file mode 100644 index d61384c2..00000000 --- a/libraries/app/include/graphene/app/custom_permission.hpp +++ /dev/null @@ -1,73 +0,0 @@ -#pragma once -#include - -namespace graphene -{ -namespace chain -{ - -struct custom_permission_create_operation : public base_operation -{ - struct fee_parameters_type - { - uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; - uint32_t price_per_kbyte = GRAPHENE_BLOCKCHAIN_PRECISION; - }; - - asset fee; - account_id_type owner_account; - string permission_name; - authority auth; - extensions_type extensions; - - account_id_type fee_payer() const { return owner_account; } - void validate() const; - share_type calculate_fee(const fee_parameters_type &k) const; -}; - -struct custom_permission_update_operation : public base_operation -{ - struct fee_parameters_type - { - uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; - }; - - asset fee; - custom_permission_id_type permission_id; - optional new_auth; - account_id_type owner_account; - extensions_type extensions; - - account_id_type fee_payer() const { return owner_account; } - void validate() const; - share_type calculate_fee(const fee_parameters_type &k) const { return k.fee; } -}; - -struct custom_permission_delete_operation : public base_operation -{ - struct fee_parameters_type - { - uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; - }; - - asset fee; - custom_permission_id_type permission_id; - account_id_type owner_account; - extensions_type extensions; - - account_id_type fee_payer() const { return owner_account; } - void validate() const; - share_type calculate_fee(const fee_parameters_type &k) const { return k.fee; } -}; - -} // namespace chain -} // namespace graphene - -FC_REFLECT(graphene::chain::custom_permission_create_operation::fee_parameters_type, (fee)(price_per_kbyte)) -FC_REFLECT(graphene::chain::custom_permission_create_operation, (fee)(owner_account)(permission_name)(auth)(extensions)) - -FC_REFLECT(graphene::chain::custom_permission_update_operation::fee_parameters_type, (fee)) -FC_REFLECT(graphene::chain::custom_permission_update_operation, (fee)(permission_id)(new_auth)(owner_account)(extensions)) - -FC_REFLECT(graphene::chain::custom_permission_delete_operation::fee_parameters_type, (fee)) -FC_REFLECT(graphene::chain::custom_permission_delete_operation, (fee)(permission_id)(owner_account)(extensions)) diff --git a/libraries/app/include/graphene/app/full_account.hpp b/libraries/app/include/graphene/app/full_account.hpp index 43c7f803..200a77d7 100644 --- a/libraries/app/include/graphene/app/full_account.hpp +++ b/libraries/app/include/graphene/app/full_account.hpp @@ -69,7 +69,6 @@ FC_REFLECT( graphene::app::full_account, (limit_orders) (call_orders) (settle_orders) - (proposals) (assets) (withdraws) (pending_dividend_payments) diff --git a/libraries/app/include/graphene/app/nft_ops.hpp b/libraries/app/include/graphene/app/nft_ops.hpp deleted file mode 100644 index 4facf51a..00000000 --- a/libraries/app/include/graphene/app/nft_ops.hpp +++ /dev/null @@ -1,148 +0,0 @@ -#pragma once -#include -#include - -namespace graphene { namespace chain { - - struct nft_metadata_create_operation : public base_operation - { - struct fee_parameters_type - { - uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; - uint32_t price_per_kbyte = GRAPHENE_BLOCKCHAIN_PRECISION; - }; - asset fee; - - account_id_type owner; - std::string name; - std::string symbol; - std::string base_uri; - optional revenue_partner; - optional revenue_split; - bool is_transferable = false; - bool is_sellable = true; - // Accounts Role - optional account_role; - extensions_type extensions; - - account_id_type fee_payer()const { return owner; } - void validate() const; - share_type calculate_fee(const fee_parameters_type &k) const; - }; - - struct nft_metadata_update_operation : public base_operation - { - struct fee_parameters_type - { - uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; - uint32_t price_per_kbyte = GRAPHENE_BLOCKCHAIN_PRECISION; - }; - asset fee; - - account_id_type owner; - nft_metadata_id_type nft_metadata_id; - optional name; - optional symbol; - optional base_uri; - optional revenue_partner; - optional revenue_split; - optional is_transferable; - optional is_sellable; - // Accounts Role - optional account_role; - extensions_type extensions; - - account_id_type fee_payer()const { return owner; } - void validate() const; - share_type calculate_fee(const fee_parameters_type &k) const; - }; - - struct nft_mint_operation : public base_operation - { - struct fee_parameters_type - { - uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; - uint32_t price_per_kbyte = GRAPHENE_BLOCKCHAIN_PRECISION; - }; - asset fee; - - account_id_type payer; - - nft_metadata_id_type nft_metadata_id; - account_id_type owner; - account_id_type approved; - vector approved_operators; - std::string token_uri; - extensions_type extensions; - - account_id_type fee_payer()const { return payer; } - void validate() const; - share_type calculate_fee(const fee_parameters_type &k) const; - }; - - struct nft_safe_transfer_from_operation : public base_operation - { - struct fee_parameters_type - { - uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; - uint32_t price_per_kbyte = GRAPHENE_BLOCKCHAIN_PRECISION; - }; - asset fee; - - account_id_type operator_; - - account_id_type from; - account_id_type to; - nft_id_type token_id; - string data; - extensions_type extensions; - - account_id_type fee_payer()const { return operator_; } - share_type calculate_fee(const fee_parameters_type &k) const; - }; - - struct nft_approve_operation : public base_operation - { - struct fee_parameters_type { uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; }; - asset fee; - - account_id_type operator_; - - account_id_type approved; - nft_id_type token_id; - extensions_type extensions; - - account_id_type fee_payer()const { return operator_; } - share_type calculate_fee(const fee_parameters_type &k) const; - }; - - struct nft_set_approval_for_all_operation : public base_operation - { - struct fee_parameters_type { uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; }; - asset fee; - - account_id_type owner; - - account_id_type operator_; - bool approved; - extensions_type extensions; - - account_id_type fee_payer()const { return owner; } - share_type calculate_fee(const fee_parameters_type &k) const; - }; - -} } // graphene::chain - -FC_REFLECT( graphene::chain::nft_metadata_create_operation::fee_parameters_type, (fee) (price_per_kbyte) ) -FC_REFLECT( graphene::chain::nft_metadata_update_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::nft_mint_operation::fee_parameters_type, (fee) (price_per_kbyte) ) -FC_REFLECT( graphene::chain::nft_safe_transfer_from_operation::fee_parameters_type, (fee) (price_per_kbyte) ) -FC_REFLECT( graphene::chain::nft_approve_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::nft_set_approval_for_all_operation::fee_parameters_type, (fee) ) - -FC_REFLECT( graphene::chain::nft_metadata_create_operation, (fee) (owner) (name) (symbol) (base_uri) (revenue_partner) (revenue_split) (is_transferable) (is_sellable) (account_role) (extensions) ) -FC_REFLECT( graphene::chain::nft_metadata_update_operation, (fee) (owner) (nft_metadata_id) (name) (symbol) (base_uri) (revenue_partner) (revenue_split) (is_transferable) (is_sellable) (account_role) (extensions) ) -FC_REFLECT( graphene::chain::nft_mint_operation, (fee) (payer) (nft_metadata_id) (owner) (approved) (approved_operators) (token_uri) (extensions) ) -FC_REFLECT( graphene::chain::nft_safe_transfer_from_operation, (fee) (operator_) (from) (to) (token_id) (data) (extensions) ) -FC_REFLECT( graphene::chain::nft_approve_operation, (fee) (operator_) (approved) (token_id) (extensions) ) -FC_REFLECT( graphene::chain::nft_set_approval_for_all_operation, (fee) (owner) (operator_) (approved) (extensions) ) diff --git a/libraries/app/include/graphene/app/offer.hpp b/libraries/app/include/graphene/app/offer.hpp deleted file mode 100644 index 2bf3dfc2..00000000 --- a/libraries/app/include/graphene/app/offer.hpp +++ /dev/null @@ -1,143 +0,0 @@ -#pragma once -#include -#include - -namespace graphene -{ - namespace chain - { - - /* - * @class offer_operation - * @brief To place an offer to buy or sell an item, a user broadcasts a - * proposed transaction - * @ingroup operations - * operation - */ - struct offer_operation : public base_operation - { - struct fee_parameters_type - { - uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; - uint32_t price_per_kbyte = GRAPHENE_BLOCKCHAIN_PRECISION; /// only required for large memos. - }; - asset fee; - set item_ids; - // /** - // * minimum_price.asset_id == maximum_price.asset_id. - // * to set fixed price without auction minimum_price == maximum_price - // * If buying_item is true, and minimum_price != maximum_price, the user is - // proposing a “reverse auction” - // * where bidders can offer to sell the item for progressively lower prices. - // * In this case, minimum_price functions as the sell-it-now price for the - // reverse auction - // */ - account_id_type issuer; - /// minimum_price is minimum bid price. 0 if no minimum_price required - asset minimum_price; - /// buy_it_now price. 0 if no maximum price - asset maximum_price; - /// true means user wants to buy item, false mean user is selling item - bool buying_item; - /// not transaction expiration date - fc::time_point_sec offer_expiration_date; - - /// User provided data encrypted to the memo key of the "to" account - optional memo; - extensions_type extensions; - - account_id_type fee_payer() const { return issuer; } - void validate() const; - share_type calculate_fee(const fee_parameters_type &k) const; - }; - - struct bid_operation : public base_operation - { - struct fee_parameters_type - { - uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; - }; - - asset fee; - account_id_type bidder; - - asset bid_price; - offer_id_type offer_id; - - extensions_type extensions; - - account_id_type fee_payer() const { return bidder; } - void validate() const; - share_type calculate_fee(const fee_parameters_type &k) const; - }; - - struct cancel_offer_operation : public base_operation - { - struct fee_parameters_type - { - uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; - }; - - asset fee; - - account_id_type issuer; - offer_id_type offer_id; - - extensions_type extensions; - - account_id_type fee_payer() const { return issuer; } - void validate() const; - share_type calculate_fee(const fee_parameters_type &k) const; - }; - - enum class result_type - { - Expired = 0, - ExpiredNoBid = 1, - Cancelled = 2 - }; - - struct finalize_offer_operation : public base_operation - { - struct fee_parameters_type - { - uint64_t fee = 0; - }; - - asset fee; - account_id_type fee_paying_account; - - offer_id_type offer_id; - - result_type result; - - extensions_type extensions; - - account_id_type fee_payer() const { return fee_paying_account; } - void validate() const; - share_type calculate_fee(const fee_parameters_type &k) const; - }; - - } // namespace chain -} // namespace graphene - -FC_REFLECT(graphene::chain::offer_operation::fee_parameters_type, - (fee)(price_per_kbyte)); -FC_REFLECT(graphene::chain::offer_operation, - (fee)(item_ids)(issuer)(minimum_price)(maximum_price)(buying_item)(offer_expiration_date)(memo)(extensions)); - -FC_REFLECT(graphene::chain::bid_operation::fee_parameters_type, - (fee)); -FC_REFLECT(graphene::chain::bid_operation, - (fee)(bidder)(bid_price)(offer_id)(extensions)); - -FC_REFLECT(graphene::chain::cancel_offer_operation::fee_parameters_type, - (fee)); -FC_REFLECT(graphene::chain::cancel_offer_operation, - (fee)(issuer)(offer_id)(extensions)); - -FC_REFLECT_ENUM(graphene::chain::result_type, (Expired)(ExpiredNoBid)(Cancelled)); -FC_REFLECT(graphene::chain::finalize_offer_operation::fee_parameters_type, - (fee)); -FC_REFLECT(graphene::chain::finalize_offer_operation, - (fee)(fee_paying_account)(offer_id)(result)(extensions)); diff --git a/libraries/app/include/graphene/app/sidechain_address.hpp b/libraries/app/include/graphene/app/sidechain_address.hpp deleted file mode 100644 index a5e12a03..00000000 --- a/libraries/app/include/graphene/app/sidechain_address.hpp +++ /dev/null @@ -1,80 +0,0 @@ -#pragma once -#include - -#include - -namespace graphene { namespace chain { - - struct sidechain_address_add_operation : public base_operation - { - struct fee_parameters_type { uint64_t fee = 0; }; - - asset fee; - account_id_type payer; - - account_id_type sidechain_address_account; - sidechain_type sidechain; - string deposit_public_key; - string deposit_address; - string deposit_address_data; - string withdraw_public_key; - string withdraw_address; - - account_id_type fee_payer()const { return payer; } - share_type calculate_fee(const fee_parameters_type& k)const { return 0; } - }; - - struct sidechain_address_update_operation : public base_operation - { - struct fee_parameters_type { uint64_t fee = 0; }; - - asset fee; - account_id_type payer; - - sidechain_address_id_type sidechain_address_id; - account_id_type sidechain_address_account; - sidechain_type sidechain; - optional deposit_public_key; - optional deposit_address; - optional deposit_address_data; - optional withdraw_public_key; - optional withdraw_address; - - account_id_type fee_payer()const { return payer; } - share_type calculate_fee(const fee_parameters_type& k)const { return 0; } - }; - - struct sidechain_address_delete_operation : public base_operation - { - struct fee_parameters_type { uint64_t fee = 0; }; - - asset fee; - account_id_type payer; - - sidechain_address_id_type sidechain_address_id; - account_id_type sidechain_address_account; - sidechain_type sidechain; - - account_id_type fee_payer()const { return payer; } - share_type calculate_fee(const fee_parameters_type& k)const { return 0; } - }; - -} } // namespace graphene::chain - -FC_REFLECT(graphene::chain::sidechain_address_add_operation::fee_parameters_type, (fee) ) -FC_REFLECT(graphene::chain::sidechain_address_add_operation, (fee)(payer) - (sidechain_address_account)(sidechain) - (deposit_public_key)(deposit_address)(deposit_address_data) - (withdraw_public_key)(withdraw_address) ) - -FC_REFLECT(graphene::chain::sidechain_address_update_operation::fee_parameters_type, (fee) ) -FC_REFLECT(graphene::chain::sidechain_address_update_operation, (fee)(payer) - (sidechain_address_id) - (sidechain_address_account)(sidechain) - (deposit_public_key)(deposit_address)(deposit_address_data) - (withdraw_public_key)(withdraw_address) ) - -FC_REFLECT(graphene::chain::sidechain_address_delete_operation::fee_parameters_type, (fee) ) -FC_REFLECT(graphene::chain::sidechain_address_delete_operation, (fee)(payer) - (sidechain_address_id) - (sidechain_address_account)(sidechain) ) diff --git a/libraries/app/include/graphene/app/sidechain_transaction.hpp b/libraries/app/include/graphene/app/sidechain_transaction.hpp deleted file mode 100644 index 01a4ce74..00000000 --- a/libraries/app/include/graphene/app/sidechain_transaction.hpp +++ /dev/null @@ -1,88 +0,0 @@ -#pragma once -#include -#include -#include -#include - -namespace graphene { namespace chain { - - struct sidechain_transaction_create_operation : public base_operation - { - struct fee_parameters_type { uint64_t fee = 0; }; - - asset fee; - account_id_type payer; - - sidechain_type sidechain; - object_id_type object_id; - std::string transaction; - std::vector signers; - - account_id_type fee_payer()const { return payer; } - share_type calculate_fee(const fee_parameters_type& k)const { return 0; } - }; - - struct sidechain_transaction_sign_operation : public base_operation - { - struct fee_parameters_type { uint64_t fee = 0; }; - - asset fee; - son_id_type signer; - account_id_type payer; - - sidechain_transaction_id_type sidechain_transaction_id; - std::string signature; - - account_id_type fee_payer()const { return payer; } - share_type calculate_fee( const fee_parameters_type& k )const { return 0; } - }; - - struct sidechain_transaction_send_operation : public base_operation - { - struct fee_parameters_type { uint64_t fee = 0; }; - - asset fee; - account_id_type payer; - - sidechain_transaction_id_type sidechain_transaction_id; - std::string sidechain_transaction; - - account_id_type fee_payer()const { return payer; } - share_type calculate_fee( const fee_parameters_type& k )const { return 0; } - }; - - struct sidechain_transaction_settle_operation : public base_operation - { - struct fee_parameters_type { uint64_t fee = 0; }; - - asset fee; - account_id_type payer; - - sidechain_transaction_id_type sidechain_transaction_id; - - account_id_type fee_payer()const { return payer; } - share_type calculate_fee( const fee_parameters_type& k )const { return 0; } - }; - -} } // graphene::chain - -FC_REFLECT( graphene::chain::sidechain_transaction_create_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::sidechain_transaction_create_operation, (fee)(payer) - (sidechain) - (object_id) - (transaction) - (signers) ) - -FC_REFLECT( graphene::chain::sidechain_transaction_sign_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::sidechain_transaction_sign_operation, (fee)(signer)(payer) - (sidechain_transaction_id) - (signature) ) - -FC_REFLECT( graphene::chain::sidechain_transaction_send_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::sidechain_transaction_send_operation, (fee)(payer) - (sidechain_transaction_id) - (sidechain_transaction) ) - -FC_REFLECT( graphene::chain::sidechain_transaction_settle_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::sidechain_transaction_settle_operation, (fee)(payer) - (sidechain_transaction_id) ) diff --git a/libraries/app/include/graphene/app/son.hpp b/libraries/app/include/graphene/app/son.hpp deleted file mode 100644 index 10a75412..00000000 --- a/libraries/app/include/graphene/app/son.hpp +++ /dev/null @@ -1,119 +0,0 @@ -#pragma once -#include -#include - -namespace graphene { namespace chain { - - struct son_create_operation : public base_operation - { - struct fee_parameters_type { uint64_t fee = 0; }; - - asset fee; - account_id_type owner_account; - std::string url; - vesting_balance_id_type deposit; - public_key_type signing_key; - flat_map sidechain_public_keys; - vesting_balance_id_type pay_vb; - - account_id_type fee_payer()const { return owner_account; } - share_type calculate_fee(const fee_parameters_type& k)const { return 0; } - }; - - struct son_update_operation : public base_operation - { - struct fee_parameters_type { uint64_t fee = 0; }; - - asset fee; - son_id_type son_id; - account_id_type owner_account; - optional new_url; - optional new_deposit; - optional new_signing_key; - optional> new_sidechain_public_keys; - optional new_pay_vb; - - account_id_type fee_payer()const { return owner_account; } - share_type calculate_fee(const fee_parameters_type& k)const { return 0; } - }; - - struct son_deregister_operation : public base_operation - { - struct fee_parameters_type { uint64_t fee = 0; }; - - asset fee; - son_id_type son_id; - account_id_type payer; - - account_id_type fee_payer()const { return payer; } - share_type calculate_fee(const fee_parameters_type& k)const { return 0; } - }; - - struct son_heartbeat_operation : public base_operation - { - struct fee_parameters_type { uint64_t fee = 0; }; - - asset fee; - son_id_type son_id; - account_id_type owner_account; - time_point_sec ts; - - account_id_type fee_payer()const { return owner_account; } - share_type calculate_fee(const fee_parameters_type& k)const { return 0; } - }; - - - struct son_report_down_operation : public base_operation - { - struct fee_parameters_type { uint64_t fee = 0; }; - - asset fee; - son_id_type son_id; - account_id_type payer; - time_point_sec down_ts; - - account_id_type fee_payer()const { return payer; } - share_type calculate_fee(const fee_parameters_type& k)const { return 0; } - }; - - enum class son_maintenance_request_type - { - request_maintenance, - cancel_request_maintenance - }; - - struct son_maintenance_operation : public base_operation - { - struct fee_parameters_type { uint64_t fee = 0; }; - - asset fee; - son_id_type son_id; - account_id_type owner_account; - son_maintenance_request_type request_type = son_maintenance_request_type::request_maintenance; - - account_id_type fee_payer()const { return owner_account; } - share_type calculate_fee(const fee_parameters_type& k)const { return 0; } - }; - -} } // namespace graphene::chain - -FC_REFLECT(graphene::chain::son_create_operation::fee_parameters_type, (fee) ) -FC_REFLECT(graphene::chain::son_create_operation, (fee)(owner_account)(url)(deposit)(signing_key)(sidechain_public_keys) - (pay_vb) ) - -FC_REFLECT(graphene::chain::son_update_operation::fee_parameters_type, (fee) ) -FC_REFLECT(graphene::chain::son_update_operation, (fee)(son_id)(owner_account)(new_url)(new_deposit) - (new_signing_key)(new_sidechain_public_keys)(new_pay_vb) ) - -FC_REFLECT(graphene::chain::son_deregister_operation::fee_parameters_type, (fee) ) -FC_REFLECT(graphene::chain::son_deregister_operation, (fee)(son_id)(payer) ) - -FC_REFLECT(graphene::chain::son_heartbeat_operation::fee_parameters_type, (fee) ) -FC_REFLECT(graphene::chain::son_heartbeat_operation, (fee)(son_id)(owner_account)(ts) ) - -FC_REFLECT(graphene::chain::son_report_down_operation::fee_parameters_type, (fee) ) -FC_REFLECT(graphene::chain::son_report_down_operation, (fee)(son_id)(payer)(down_ts) ) - -FC_REFLECT_ENUM( graphene::chain::son_maintenance_request_type, (request_maintenance)(cancel_request_maintenance) ) -FC_REFLECT(graphene::chain::son_maintenance_operation::fee_parameters_type, (fee) ) -FC_REFLECT(graphene::chain::son_maintenance_operation, (fee)(son_id)(owner_account)(request_type) ) diff --git a/libraries/app/include/graphene/app/son_wallet.hpp b/libraries/app/include/graphene/app/son_wallet.hpp deleted file mode 100644 index 5194bed2..00000000 --- a/libraries/app/include/graphene/app/son_wallet.hpp +++ /dev/null @@ -1,40 +0,0 @@ -#pragma once -#include -#include - -namespace graphene { namespace chain { - - struct son_wallet_recreate_operation : public base_operation - { - struct fee_parameters_type { uint64_t fee = 0; }; - - asset fee; - account_id_type payer; - - vector sons; - - account_id_type fee_payer()const { return payer; } - share_type calculate_fee(const fee_parameters_type& k)const { return 0; } - }; - - struct son_wallet_update_operation : public base_operation - { - struct fee_parameters_type { uint64_t fee = 0; }; - - asset fee; - account_id_type payer; - - son_wallet_id_type son_wallet_id; - sidechain_type sidechain; - string address; - - account_id_type fee_payer()const { return payer; } - share_type calculate_fee(const fee_parameters_type& k)const { return 0; } - }; - -} } // namespace graphene::chain - -FC_REFLECT(graphene::chain::son_wallet_recreate_operation::fee_parameters_type, (fee) ) -FC_REFLECT(graphene::chain::son_wallet_recreate_operation, (fee)(payer)(sons) ) -FC_REFLECT(graphene::chain::son_wallet_update_operation::fee_parameters_type, (fee) ) -FC_REFLECT(graphene::chain::son_wallet_update_operation, (fee)(payer)(son_wallet_id)(sidechain)(address) ) diff --git a/libraries/app/include/graphene/app/son_wallet_deposit.hpp b/libraries/app/include/graphene/app/son_wallet_deposit.hpp deleted file mode 100644 index 1b6a02c7..00000000 --- a/libraries/app/include/graphene/app/son_wallet_deposit.hpp +++ /dev/null @@ -1,57 +0,0 @@ -#pragma once -#include -#include - -#include - -namespace graphene { namespace chain { - - struct son_wallet_deposit_create_operation : public base_operation - { - struct fee_parameters_type { uint64_t fee = 0; }; - - asset fee; - account_id_type payer; - - son_id_type son_id; - fc::time_point_sec timestamp; - uint32_t block_num; - sidechain_type sidechain; - std::string sidechain_uid; - std::string sidechain_transaction_id; - std::string sidechain_from; - std::string sidechain_to; - std::string sidechain_currency; - fc::safe sidechain_amount; - chain::account_id_type peerplays_from; - chain::account_id_type peerplays_to; - chain::asset peerplays_asset; - - account_id_type fee_payer()const { return payer; } - share_type calculate_fee(const fee_parameters_type& k)const { return 0; } - }; - - struct son_wallet_deposit_process_operation : public base_operation - { - struct fee_parameters_type { uint64_t fee = 0; }; - - asset fee; - account_id_type payer; - - son_wallet_deposit_id_type son_wallet_deposit_id; - - account_id_type fee_payer()const { return payer; } - share_type calculate_fee(const fee_parameters_type& k)const { return 0; } - }; - -} } // namespace graphene::chain - -FC_REFLECT(graphene::chain::son_wallet_deposit_create_operation::fee_parameters_type, (fee) ) -FC_REFLECT(graphene::chain::son_wallet_deposit_create_operation, (fee)(payer) - (son_id) (timestamp) (block_num) (sidechain) - (sidechain_uid) (sidechain_transaction_id) (sidechain_from) (sidechain_to) (sidechain_currency) (sidechain_amount) - (peerplays_from) (peerplays_to) (peerplays_asset) ) - -FC_REFLECT(graphene::chain::son_wallet_deposit_process_operation::fee_parameters_type, (fee) ) -FC_REFLECT(graphene::chain::son_wallet_deposit_process_operation, (fee)(payer) - (son_wallet_deposit_id) ) diff --git a/libraries/app/include/graphene/app/son_wallet_withdraw.hpp b/libraries/app/include/graphene/app/son_wallet_withdraw.hpp deleted file mode 100644 index 0461d4b2..00000000 --- a/libraries/app/include/graphene/app/son_wallet_withdraw.hpp +++ /dev/null @@ -1,56 +0,0 @@ -#pragma once -#include -#include - -#include - -namespace graphene { namespace chain { - - struct son_wallet_withdraw_create_operation : public base_operation - { - struct fee_parameters_type { uint64_t fee = 0; }; - - asset fee; - account_id_type payer; - - son_id_type son_id; - fc::time_point_sec timestamp; - uint32_t block_num; - sidechain_type sidechain; - std::string peerplays_uid; - std::string peerplays_transaction_id; - chain::account_id_type peerplays_from; - chain::asset peerplays_asset; - sidechain_type withdraw_sidechain; - std::string withdraw_address; - std::string withdraw_currency; - safe withdraw_amount; - - account_id_type fee_payer()const { return payer; } - share_type calculate_fee(const fee_parameters_type& k)const { return 0; } - }; - - struct son_wallet_withdraw_process_operation : public base_operation - { - struct fee_parameters_type { uint64_t fee = 0; }; - - asset fee; - account_id_type payer; - - son_wallet_withdraw_id_type son_wallet_withdraw_id; - - account_id_type fee_payer()const { return payer; } - share_type calculate_fee(const fee_parameters_type& k)const { return 0; } - }; - -} } // namespace graphene::chain - -FC_REFLECT(graphene::chain::son_wallet_withdraw_create_operation::fee_parameters_type, (fee) ) -FC_REFLECT(graphene::chain::son_wallet_withdraw_create_operation, (fee)(payer) - (son_id) (timestamp) (block_num) (sidechain) - (peerplays_uid) (peerplays_transaction_id) (peerplays_from) (peerplays_asset) - (withdraw_sidechain) (withdraw_address) (withdraw_currency) (withdraw_amount) ) - -FC_REFLECT(graphene::chain::son_wallet_withdraw_process_operation::fee_parameters_type, (fee) ) -FC_REFLECT(graphene::chain::son_wallet_withdraw_process_operation, (fee)(payer) - (son_wallet_withdraw_id) ) diff --git a/libraries/chain/CMakeLists.txt b/libraries/chain/CMakeLists.txt index 0312c306..8d13885a 100755 --- a/libraries/chain/CMakeLists.txt +++ b/libraries/chain/CMakeLists.txt @@ -5,22 +5,13 @@ 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 HEADERS "include/graphene/chain/*.hpp" "${CMAKE_CURRENT_BINARY_DIR}/include/graphene/chain/hardfork.hpp") + +file(GLOB CPP_FILES "*.cpp") if( GRAPHENE_DISABLE_UNITY_BUILD ) - set( GRAPHENE_DB_FILES - db_balance.cpp - db_bet.cpp - db_block.cpp - db_debug.cpp - db_getter.cpp - db_init.cpp - db_maint.cpp - db_management.cpp - db_market.cpp - db_update.cpp - db_witness_schedule.cpp - ) + list(FILTER CPP_FILES EXCLUDE REGEX "[/]database[.]cpp$") + #message ("--- ${CPP_FILES}") message( STATUS "Graphene database unity build disabled" ) else( GRAPHENE_DISABLE_UNITY_BUILD ) set( GRAPHENE_DB_FILES @@ -30,79 +21,7 @@ endif( GRAPHENE_DISABLE_UNITY_BUILD ) ## SORT .cpp by most likely to change / break compile add_library( graphene_chain - - # As database takes the longest to compile, start it first - ${GRAPHENE_DB_FILES} - fork_database.cpp - - genesis_state.cpp - get_config.cpp - exceptions.cpp - - evaluator.cpp - balance_evaluator.cpp - account_evaluator.cpp - assert_evaluator.cpp - witness_evaluator.cpp - committee_member_evaluator.cpp - asset_evaluator.cpp - lottery_evaluator.cpp - transfer_evaluator.cpp - proposal_evaluator.cpp - market_evaluator.cpp - vesting_balance_evaluator.cpp - tournament_evaluator.cpp - tournament_object.cpp - match_object.cpp - game_object.cpp - withdraw_permission_evaluator.cpp - worker_evaluator.cpp - confidential_evaluator.cpp - special_authority_evaluation.cpp - buyback.cpp - - account_object.cpp - asset_object.cpp - fba_object.cpp - proposal_object.cpp - vesting_balance_object.cpp - small_objects.cpp - - block_database.cpp - - is_authorized_asset.cpp - - sport_evaluator.cpp - event_group_evaluator.cpp - event_group_object.cpp - event_evaluator.cpp - event_object.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 -### protocol/account_role.cpp - account_role_evaluator.cpp - - son_evaluator.cpp - son_object.cpp - - son_wallet_evaluator.cpp - son_wallet_deposit_evaluator.cpp - son_wallet_withdraw_evaluator.cpp - - sidechain_address_evaluator.cpp - sidechain_transaction_evaluator.cpp - + ${CPP_FILES} ${HEADERS} "${CMAKE_CURRENT_BINARY_DIR}/include/graphene/chain/hardfork.hpp" ) diff --git a/libraries/chain/db_maint.cpp b/libraries/chain/db_maint.cpp index 8a1a78bb..294626b1 100644 --- a/libraries/chain/db_maint.cpp +++ b/libraries/chain/db_maint.cpp @@ -22,10 +22,6 @@ * THE SOFTWARE. */ -#include - -#include - #include #include #include @@ -42,6 +38,8 @@ #include #include #include +#include +#include #include #include #include @@ -55,6 +53,8 @@ #include +#include + #define USE_VESTING_OBJECT_BY_ASSET_BALANCE_INDEX // vesting_balance_object by_asset_balance index needed namespace graphene { namespace chain { diff --git a/libraries/chain/db_notify.cpp b/libraries/chain/db_notify.cpp index 4ac34e3b..a14d7686 100644 --- a/libraries/chain/db_notify.cpp +++ b/libraries/chain/db_notify.cpp @@ -28,6 +28,7 @@ #include #include +#include #include #include #include @@ -47,7 +48,9 @@ #include #include #include - +#include +#include +#include using namespace fc; using namespace graphene::chain; @@ -597,6 +600,8 @@ void get_relevant_accounts( const object* obj, flat_set& accoun assert( aobj != nullptr ); accounts.insert( aobj->son_account ); break; + } case son_proposal_object_type:{ + break; } case son_wallet_object_type:{ break; } case son_wallet_deposit_object_type:{ @@ -641,7 +646,7 @@ void get_relevant_accounts( const object* obj, flat_set& accoun const auto& aobj = dynamic_cast(obj); FC_ASSERT( aobj != nullptr ); transaction_get_impacted_accounts( aobj->trx, accounts, - ignore_custom_operation_required_auths); + ignore_custom_operation_required_auths ); break; } case impl_blinded_balance_object_type:{ const auto& aobj = dynamic_cast(obj); @@ -698,6 +703,10 @@ void get_relevant_accounts( const object* obj, flat_set& accoun if (aobj->bidder.valid()) accounts.insert(*aobj->bidder); break; + } case impl_son_statistics_object_type: { + break; + } case impl_son_schedule_object_type: { + break; } } } diff --git a/libraries/chain/db_update.cpp b/libraries/chain/db_update.cpp index ccb3dd69..c75b0d53 100644 --- a/libraries/chain/db_update.cpp +++ b/libraries/chain/db_update.cpp @@ -30,12 +30,14 @@ #include #include #include +#include #include #include #include #include #include #include +#include #include diff --git a/libraries/chain/include/graphene/chain/betting_market_object.hpp b/libraries/chain/include/graphene/chain/betting_market_object.hpp index 9a3b3af1..55271ddf 100644 --- a/libraries/chain/include/graphene/chain/betting_market_object.hpp +++ b/libraries/chain/include/graphene/chain/betting_market_object.hpp @@ -732,3 +732,4 @@ FC_REFLECT_DERIVED( graphene::chain::betting_market_object, (graphene::db::objec FC_REFLECT_DERIVED( graphene::chain::bet_object, (graphene::db::object), (bettor_id)(betting_market_id)(amount_to_bet)(backer_multiplier)(back_or_lay)(end_of_delay) ) FC_REFLECT_DERIVED( graphene::chain::betting_market_position_object, (graphene::db::object), (bettor_id)(betting_market_id)(pay_if_payout_condition)(pay_if_not_payout_condition)(pay_if_canceled)(pay_if_not_canceled)(fees_collected) ) + diff --git a/libraries/chain/include/graphene/chain/block_database.hpp b/libraries/chain/include/graphene/chain/block_database.hpp index b3b040cc..2580e326 100644 --- a/libraries/chain/include/graphene/chain/block_database.hpp +++ b/libraries/chain/include/graphene/chain/block_database.hpp @@ -27,8 +27,6 @@ #include -#include - namespace graphene { namespace chain { struct index_entry; using namespace graphene::protocol; diff --git a/libraries/chain/include/graphene/chain/database.hpp b/libraries/chain/include/graphene/chain/database.hpp index b42604d2..f3c56ead 100644 --- a/libraries/chain/include/graphene/chain/database.hpp +++ b/libraries/chain/include/graphene/chain/database.hpp @@ -23,8 +23,6 @@ */ #pragma once -#include - #include #include #include @@ -34,19 +32,19 @@ #include #include #include -#include #include #include #include + +#include +#include +#include + #include #include -#include - -#include - #include #include @@ -64,6 +62,7 @@ namespace graphene { namespace chain { class force_settlement_object; class limit_order_object; class call_order_object; + class account_role_object; struct budget_record; diff --git a/libraries/chain/include/graphene/chain/event_object.hpp b/libraries/chain/include/graphene/chain/event_object.hpp index c00e3c6b..21b76a9f 100644 --- a/libraries/chain/include/graphene/chain/event_object.hpp +++ b/libraries/chain/include/graphene/chain/event_object.hpp @@ -164,4 +164,6 @@ typedef generic_index event_object_ MAP_OBJECT_ID_TO_TYPE(graphene::chain::event_object) -FC_REFLECT(graphene::chain::event_object, (name)(season)(start_time)(event_group_id)(at_least_one_betting_market_group_settled)(scores)) +FC_REFLECT_DERIVED(graphene::chain::event_object, (graphene::db::object), + (name)(season)(start_time)(event_group_id)(at_least_one_betting_market_group_settled)(scores)) + diff --git a/libraries/chain/include/graphene/chain/game_object.hpp b/libraries/chain/include/graphene/chain/game_object.hpp index 2a6f0b16..67a843bc 100644 --- a/libraries/chain/include/graphene/chain/game_object.hpp +++ b/libraries/chain/include/graphene/chain/game_object.hpp @@ -173,6 +173,6 @@ FC_REFLECT_ENUM(graphene::chain::game_state, (game_complete)) //FC_REFLECT_TYPENAME(graphene::chain::game_object) // manually serialized -FC_REFLECT(graphene::chain::game_object, (players)) +FC_REFLECT_DERIVED(graphene::chain::game_object, (graphene::db::object), (players)) diff --git a/libraries/chain/include/graphene/chain/get_config.hpp b/libraries/chain/include/graphene/chain/get_config.hpp index 4e49e688..adbdcee9 100644 --- a/libraries/chain/include/graphene/chain/get_config.hpp +++ b/libraries/chain/include/graphene/chain/get_config.hpp @@ -30,3 +30,4 @@ namespace graphene { namespace chain { fc::variant_object get_config(); } } // graphene::chain + diff --git a/libraries/chain/include/graphene/chain/global_property_object.hpp b/libraries/chain/include/graphene/chain/global_property_object.hpp index f203a964..a33e98dc 100644 --- a/libraries/chain/include/graphene/chain/global_property_object.hpp +++ b/libraries/chain/include/graphene/chain/global_property_object.hpp @@ -26,10 +26,12 @@ #include #include + #include -#include #include +#include + namespace graphene { namespace chain { /** diff --git a/libraries/chain/include/graphene/chain/match_object.hpp b/libraries/chain/include/graphene/chain/match_object.hpp index b7c73f59..07f5679e 100644 --- a/libraries/chain/include/graphene/chain/match_object.hpp +++ b/libraries/chain/include/graphene/chain/match_object.hpp @@ -172,5 +172,5 @@ FC_REFLECT_ENUM(graphene::chain::match_state, (match_complete)) //FC_REFLECT_TYPENAME(graphene::chain::match_object) // manually serialized -FC_REFLECT(graphene::chain::match_object, (players)) +FC_REFLECT_DERIVED(graphene::chain::match_object, (graphene::db::object), (players)) diff --git a/libraries/chain/include/graphene/chain/offer_evaluator.hpp b/libraries/chain/include/graphene/chain/offer_evaluator.hpp index 2ee42b17..5d779cd6 100644 --- a/libraries/chain/include/graphene/chain/offer_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/offer_evaluator.hpp @@ -3,7 +3,6 @@ #include - namespace graphene { namespace chain diff --git a/libraries/chain/include/graphene/chain/operation_history_object.hpp b/libraries/chain/include/graphene/chain/operation_history_object.hpp index 4fcb398d..b4538c60 100644 --- a/libraries/chain/include/graphene/chain/operation_history_object.hpp +++ b/libraries/chain/include/graphene/chain/operation_history_object.hpp @@ -100,7 +100,7 @@ class account_transaction_history_object : public abstract_object -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#define GRAPHENE_EXTERNAL_SERIALIZATION(ext, type) \ -namespace fc { \ - ext template void from_variant( const variant& v, type& vo, uint32_t max_depth ); \ - ext template void to_variant( const type& v, variant& vo, uint32_t max_depth ); \ -namespace raw { \ - ext template void pack< datastream, type >( datastream& s, const type& tx, uint32_t _max_depth=FC_PACK_MAX_DEPTH ); \ - ext template void pack< datastream, type >( datastream& s, const type& tx, uint32_t _max_depth=FC_PACK_MAX_DEPTH ); \ - ext template void unpack< datastream, type >( datastream& s, type& tx, uint32_t _max_depth=FC_PACK_MAX_DEPTH ); \ -} } // fc::raw - -#define FC_REFLECT_DERIVED_NO_TYPENAME( TYPE, INHERITS, MEMBERS ) \ -namespace fc { \ -template<> struct reflector {\ - typedef TYPE type; \ - typedef fc::true_type is_defined; \ - typedef fc::false_type is_enum; \ - enum member_count_enum { \ - local_member_count = 0 BOOST_PP_SEQ_FOR_EACH( FC_REFLECT_MEMBER_COUNT, +, MEMBERS ),\ - total_member_count = local_member_count BOOST_PP_SEQ_FOR_EACH( FC_REFLECT_BASE_MEMBER_COUNT, +, INHERITS )\ - }; \ - FC_REFLECT_DERIVED_IMPL_INLINE( TYPE, INHERITS, MEMBERS ) \ -}; \ -} // fc - - -namespace graphene { namespace chain { - using namespace graphene::db; - - using std::map; - using std::vector; - using std::unordered_map; - using std::string; - using std::deque; - using std::shared_ptr; - using std::weak_ptr; - using std::unique_ptr; - using std::set; - using std::pair; - using std::enable_shared_from_this; - using std::tie; - using std::make_pair; - - using fc::smart_ref; - using fc::variant_object; - using fc::variant; - using fc::enum_type; - using fc::optional; - using fc::unsigned_int; - using fc::signed_int; - using fc::time_point_sec; - using fc::time_point; - using fc::safe; - using fc::flat_map; - using fc::flat_set; - using fc::static_variant; - using fc::ecc::range_proof_type; - using fc::ecc::range_proof_info; - using fc::ecc::commitment_type; - struct void_t{}; - - typedef fc::ecc::private_key private_key_type; - typedef fc::sha256 chain_id_type; - - enum asset_issuer_permission_flags - { - charge_market_fee = 0x01, /**< an issuer-specified percentage of all market trades in this asset is paid to the issuer */ - white_list = 0x02, /**< accounts must be whitelisted in order to hold this asset */ - override_authority = 0x04, /**< issuer may transfer asset back to himself */ - transfer_restricted = 0x08, /**< require the issuer to be one party to every transfer */ - disable_force_settle = 0x10, /**< disable force settling */ - global_settle = 0x20, /**< allow the bitasset issuer to force a global settling -- this may be set in permissions, but not flags */ - disable_confidential = 0x40, /**< allow the asset to be used with confidential transactions */ - witness_fed_asset = 0x80, /**< allow the asset to be fed by witnesses */ - committee_fed_asset = 0x100 /**< allow the asset to be fed by the committee */ - }; - const static uint32_t ASSET_ISSUER_PERMISSION_MASK = charge_market_fee|white_list|override_authority|transfer_restricted|disable_force_settle|global_settle|disable_confidential - |witness_fed_asset|committee_fed_asset; - const static uint32_t UIA_ASSET_ISSUER_PERMISSION_MASK = charge_market_fee|white_list|override_authority|transfer_restricted|disable_confidential; - - enum reserved_spaces - { - relative_protocol_ids = 0, - protocol_ids = 1, - implementation_ids = 2 - }; - - inline bool is_relative( object_id_type o ){ return o.space() == 0; } - - /** - * List all object types from all namespaces here so they can - * be easily reflected and displayed in debug output. If a 3rd party - * wants to extend the core code then they will have to change the - * packed_object::type field from enum_type to uint16 to avoid - * warnings when converting packed_objects to/from json. - */ - enum object_type - { - null_object_type, - base_object_type, - account_object_type, - asset_object_type, - force_settlement_object_type, - committee_member_object_type, - witness_object_type, - limit_order_object_type, - call_order_object_type, - custom_object_type, - proposal_object_type, - operation_history_object_type, - withdraw_permission_object_type, - vesting_balance_object_type, - worker_object_type, - balance_object_type, - tournament_object_type, - tournament_details_object_type, - match_object_type, - game_object_type, - sport_object_type, - event_group_object_type, - event_object_type, - betting_market_rules_object_type, - betting_market_group_object_type, - betting_market_object_type, - bet_object_type, - custom_permission_object_type, - custom_account_authority_object_type, - offer_object_type, - nft_metadata_type, - nft_object_type, - account_role_type, - son_object_type, - son_proposal_object_type, - son_wallet_object_type, - son_wallet_deposit_object_type, - son_wallet_withdraw_object_type, - sidechain_address_object_type, - sidechain_transaction_object_type, - OBJECT_TYPE_COUNT ///< Sentry value which contains the number of different object types - }; - - enum impl_object_type - { - impl_global_property_object_type, - impl_dynamic_global_property_object_type, - impl_reserved0_object_type, // formerly index_meta_object_type, TODO: delete me - impl_asset_dynamic_data_type, - impl_asset_bitasset_data_type, - impl_account_balance_object_type, - impl_account_statistics_object_type, - impl_transaction_object_type, - impl_block_summary_object_type, - impl_account_transaction_history_object_type, - impl_blinded_balance_object_type, - impl_chain_property_object_type, - impl_witness_schedule_object_type, - impl_budget_record_object_type, - impl_special_authority_object_type, - impl_buyback_object_type, - impl_fba_accumulator_object_type, - impl_asset_dividend_data_type, - impl_pending_dividend_payout_balance_for_holder_object_type, - impl_distributed_dividend_balance_data_type, - impl_betting_market_position_object_type, - impl_global_betting_statistics_object_type, - impl_lottery_balance_object_type, - impl_sweeps_vesting_balance_object_type, - impl_offer_history_object_type, - impl_son_statistics_object_type, - impl_son_schedule_object_type - }; - - //typedef fc::unsigned_int object_id_type; - //typedef uint64_t object_id_type; - class account_object; - class committee_member_object; - class witness_object; - class asset_object; - class force_settlement_object; - class limit_order_object; - class call_order_object; - class custom_object; - class proposal_object; - class operation_history_object; - class withdraw_permission_object; - class vesting_balance_object; - class worker_object; - class balance_object; - class blinded_balance_object; - class tournament_object; - class tournament_details_object; - class match_object; - class game_object; - class sport_object; - class event_group_object; - class event_object; - class betting_market_rules_object; - class betting_market_group_object; - class betting_market_object; - class bet_object; - class custom_permission_object; - class custom_account_authority_object; - class offer_object; - class nft_metadata_object; - class nft_object; - class account_role_object; - class son_object; - class son_proposal_object; - class son_wallet_object; - class son_wallet_deposit_object; - class son_wallet_withdraw_object; - class sidechain_address_object; - class sidechain_transaction_object; - - typedef object_id< protocol_ids, account_object_type, account_object> account_id_type; - typedef object_id< protocol_ids, asset_object_type, asset_object> asset_id_type; - typedef object_id< protocol_ids, force_settlement_object_type, force_settlement_object> force_settlement_id_type; - typedef object_id< protocol_ids, committee_member_object_type, committee_member_object> committee_member_id_type; - typedef object_id< protocol_ids, witness_object_type, witness_object> witness_id_type; - typedef object_id< protocol_ids, limit_order_object_type, limit_order_object> limit_order_id_type; - typedef object_id< protocol_ids, call_order_object_type, call_order_object> call_order_id_type; - typedef object_id< protocol_ids, custom_object_type, custom_object> custom_id_type; - typedef object_id< protocol_ids, proposal_object_type, proposal_object> proposal_id_type; - typedef object_id< protocol_ids, operation_history_object_type, operation_history_object> operation_history_id_type; - typedef object_id< protocol_ids, withdraw_permission_object_type,withdraw_permission_object> withdraw_permission_id_type; - typedef object_id< protocol_ids, vesting_balance_object_type, vesting_balance_object> vesting_balance_id_type; - typedef object_id< protocol_ids, worker_object_type, worker_object> worker_id_type; - typedef object_id< protocol_ids, balance_object_type, balance_object> balance_id_type; - typedef object_id< protocol_ids, tournament_object_type, tournament_object> tournament_id_type; - typedef object_id< protocol_ids, tournament_details_object_type, tournament_details_object> tournament_details_id_type; - typedef object_id< protocol_ids, match_object_type, match_object> match_id_type; - typedef object_id< protocol_ids, game_object_type, game_object> game_id_type; - typedef object_id< protocol_ids, sport_object_type, sport_object> sport_id_type; - typedef object_id< protocol_ids, event_group_object_type, event_group_object> event_group_id_type; - typedef object_id< protocol_ids, event_object_type, event_object> event_id_type; - typedef object_id< protocol_ids, betting_market_rules_object_type, betting_market_rules_object> betting_market_rules_id_type; - typedef object_id< protocol_ids, betting_market_group_object_type, betting_market_group_object> betting_market_group_id_type; - typedef object_id< protocol_ids, betting_market_object_type, betting_market_object> betting_market_id_type; - typedef object_id< protocol_ids, bet_object_type, bet_object> bet_id_type; - typedef object_id< protocol_ids, custom_permission_object_type, custom_permission_object> custom_permission_id_type; - typedef object_id< protocol_ids, custom_account_authority_object_type, custom_account_authority_object> custom_account_authority_id_type; - typedef object_id< protocol_ids, offer_object_type, offer_object> offer_id_type; - typedef object_id< protocol_ids, nft_metadata_type, nft_metadata_object> nft_metadata_id_type; - typedef object_id< protocol_ids, nft_object_type, nft_object> nft_id_type; - typedef object_id< protocol_ids, account_role_type, account_role_object> account_role_id_type; - typedef object_id< protocol_ids, son_object_type, son_object> son_id_type; - typedef object_id< protocol_ids, son_proposal_object_type, son_proposal_object> son_proposal_id_type; - typedef object_id< protocol_ids, son_wallet_object_type, son_wallet_object> son_wallet_id_type; - typedef object_id< protocol_ids, son_wallet_deposit_object_type, son_wallet_deposit_object> son_wallet_deposit_id_type; - typedef object_id< protocol_ids, son_wallet_withdraw_object_type, son_wallet_withdraw_object> son_wallet_withdraw_id_type; - typedef object_id< protocol_ids, sidechain_address_object_type, sidechain_address_object> sidechain_address_id_type; - typedef object_id< protocol_ids, sidechain_transaction_object_type,sidechain_transaction_object> sidechain_transaction_id_type; - - // implementation types - class global_property_object; - class dynamic_global_property_object; - class asset_dynamic_data_object; - class asset_bitasset_data_object; - class account_balance_object; - class account_statistics_object; - class transaction_object; - class block_summary_object; - class account_transaction_history_object; - class chain_property_object; - class witness_schedule_object; - class budget_record_object; - class special_authority_object; - class buyback_object; - class fba_accumulator_object; - class asset_dividend_data_object; - class pending_dividend_payout_balance_for_holder_object; - class betting_market_position_object; - class global_betting_statistics_object; - class lottery_balance_object; - class sweeps_vesting_balance_object; - class offer_history_object; - class son_statistics_object; - class son_schedule_object; - - typedef object_id< implementation_ids, impl_global_property_object_type, global_property_object> global_property_id_type; - typedef object_id< implementation_ids, impl_dynamic_global_property_object_type, dynamic_global_property_object> dynamic_global_property_id_type; - typedef object_id< implementation_ids, impl_asset_dynamic_data_type, asset_dynamic_data_object> asset_dynamic_data_id_type; - typedef object_id< implementation_ids, impl_asset_bitasset_data_type, asset_bitasset_data_object> asset_bitasset_data_id_type; - typedef object_id< implementation_ids, impl_asset_dividend_data_type, asset_dividend_data_object> asset_dividend_data_id_type; - typedef object_id< implementation_ids, - impl_pending_dividend_payout_balance_for_holder_object_type, - pending_dividend_payout_balance_for_holder_object> pending_dividend_payout_balance_for_holder_object_type; - typedef object_id< implementation_ids, impl_account_balance_object_type, account_balance_object> account_balance_id_type; - typedef object_id< implementation_ids, impl_account_statistics_object_type, account_statistics_object> account_statistics_id_type; - typedef object_id< implementation_ids, impl_transaction_object_type, transaction_object> transaction_obj_id_type; - typedef object_id< implementation_ids, impl_block_summary_object_type, block_summary_object> block_summary_id_type; - - typedef object_id< implementation_ids, - impl_account_transaction_history_object_type, - account_transaction_history_object> account_transaction_history_id_type; - typedef object_id< implementation_ids, impl_chain_property_object_type, chain_property_object> chain_property_id_type; - typedef object_id< implementation_ids, impl_witness_schedule_object_type, witness_schedule_object> witness_schedule_id_type; - typedef object_id< implementation_ids, impl_budget_record_object_type, budget_record_object > budget_record_id_type; - typedef object_id< implementation_ids, impl_blinded_balance_object_type, blinded_balance_object > blinded_balance_id_type; - typedef object_id< implementation_ids, impl_special_authority_object_type, special_authority_object > special_authority_id_type; - typedef object_id< implementation_ids, impl_buyback_object_type, buyback_object > buyback_id_type; - typedef object_id< implementation_ids, impl_fba_accumulator_object_type, fba_accumulator_object > fba_accumulator_id_type; - typedef object_id< implementation_ids, impl_betting_market_position_object_type, betting_market_position_object > betting_market_position_id_type; - typedef object_id< implementation_ids, impl_global_betting_statistics_object_type, global_betting_statistics_object > global_betting_statistics_id_type; - typedef object_id< implementation_ids, impl_lottery_balance_object_type, lottery_balance_object > lottery_balance_id_type; - typedef object_id< implementation_ids, impl_sweeps_vesting_balance_object_type, sweeps_vesting_balance_object> sweeps_vesting_balance_id_type; - typedef object_id< implementation_ids, impl_offer_history_object_type, offer_history_object> offer_history_id_type; - typedef object_id< implementation_ids, impl_son_statistics_object_type, son_statistics_object > son_statistics_id_type; - typedef object_id< implementation_ids, impl_son_schedule_object_type, son_schedule_object> son_schedule_id_type; - - typedef fc::array symbol_type; - typedef fc::ripemd160 block_id_type; - typedef fc::ripemd160 checksum_type; - typedef fc::ripemd160 transaction_id_type; - typedef fc::sha256 digest_type; - typedef fc::ecc::compact_signature signature_type; - typedef safe share_type; - typedef fc::ripemd160 secret_hash_type; - typedef uint16_t weight_type; - - struct public_key_type - { - struct binary_key - { - binary_key() {} - uint32_t check = 0; - fc::ecc::public_key_data data; - }; - fc::ecc::public_key_data key_data; - public_key_type(); - public_key_type( const fc::ecc::public_key_data& data ); - public_key_type( const fc::ecc::public_key& pubkey ); - explicit public_key_type( const std::string& base58str ); - operator fc::ecc::public_key_data() const; - operator fc::ecc::public_key() const; - explicit operator std::string() const; - friend bool operator == ( const public_key_type& p1, const fc::ecc::public_key& p2); - friend bool operator == ( const public_key_type& p1, const public_key_type& p2); - friend bool operator != ( const public_key_type& p1, const public_key_type& p2); - // TODO: This is temporary for testing - bool is_valid_v1( const std::string& base58str ); - bool is_valid_muse( const std::string& base58str ); - }; - - struct extended_public_key_type - { - struct binary_key - { - binary_key() {} - uint32_t check = 0; - fc::ecc::extended_key_data data; - }; - - fc::ecc::extended_key_data key_data; - - extended_public_key_type(); - extended_public_key_type( const fc::ecc::extended_key_data& data ); - extended_public_key_type( const fc::ecc::extended_public_key& extpubkey ); - explicit extended_public_key_type( const std::string& base58str ); - operator fc::ecc::extended_public_key() const; - explicit operator std::string() const; - friend bool operator == ( const extended_public_key_type& p1, const fc::ecc::extended_public_key& p2); - friend bool operator == ( const extended_public_key_type& p1, const extended_public_key_type& p2); - friend bool operator != ( const extended_public_key_type& p1, const extended_public_key_type& p2); - }; - - struct extended_private_key_type - { - struct binary_key - { - binary_key() {} - uint32_t check = 0; - fc::ecc::extended_key_data data; - }; - - fc::ecc::extended_key_data key_data; - - extended_private_key_type(); - extended_private_key_type( const fc::ecc::extended_key_data& data ); - extended_private_key_type( const fc::ecc::extended_private_key& extprivkey ); - explicit extended_private_key_type( const std::string& base58str ); - operator fc::ecc::extended_private_key() const; - explicit operator std::string() const; - friend bool operator == ( const extended_private_key_type& p1, const fc::ecc::extended_private_key& p2); - friend bool operator == ( const extended_private_key_type& p1, const extended_private_key_type& p2); - friend bool operator != ( const extended_private_key_type& p1, const extended_private_key_type& p2); - }; - - typedef flat_map internationalized_string_type; - - typedef uint32_t bet_multiplier_type; -} } // graphene::chain - -namespace fc -{ - void to_variant( const graphene::chain::public_key_type& var, fc::variant& vo, uint32_t max_depth = 2 ); - void from_variant( const fc::variant& var, graphene::chain::public_key_type& vo, uint32_t max_depth = 2 ); - void to_variant( const graphene::chain::extended_public_key_type& var, fc::variant& vo, uint32_t max_depth = 2 ); - void from_variant( const fc::variant& var, graphene::chain::extended_public_key_type& vo, uint32_t max_depth = 2 ); - void to_variant( const graphene::chain::extended_private_key_type& var, fc::variant& vo, uint32_t max_depth = 2 ); - void from_variant( const fc::variant& var, graphene::chain::extended_private_key_type& vo, uint32_t max_depth = 2 ); -} - -FC_REFLECT( graphene::chain::public_key_type, (key_data) ) -FC_REFLECT( graphene::chain::public_key_type::binary_key, (data)(check) ) -FC_REFLECT( graphene::chain::extended_public_key_type, (key_data) ) -FC_REFLECT( graphene::chain::extended_public_key_type::binary_key, (check)(data) ) -FC_REFLECT( graphene::chain::extended_private_key_type, (key_data) ) -FC_REFLECT( graphene::chain::extended_private_key_type::binary_key, (check)(data) ) - -FC_REFLECT_ENUM( graphene::chain::object_type, - (null_object_type) - (base_object_type) - (account_object_type) - (force_settlement_object_type) - (asset_object_type) - (committee_member_object_type) - (witness_object_type) - (limit_order_object_type) - (call_order_object_type) - (custom_object_type) - (proposal_object_type) - (operation_history_object_type) - (withdraw_permission_object_type) - (vesting_balance_object_type) - (worker_object_type) - (balance_object_type) - (tournament_object_type) - (tournament_details_object_type) - (match_object_type) - (game_object_type) - (sport_object_type) - (event_group_object_type) - (event_object_type) - (betting_market_rules_object_type) - (betting_market_group_object_type) - (betting_market_object_type) - (bet_object_type) - (custom_permission_object_type) - (custom_account_authority_object_type) - (offer_object_type) - (nft_metadata_type) - (nft_object_type) - (account_role_type) - (son_object_type) - (son_proposal_object_type) - (son_wallet_object_type) - (son_wallet_deposit_object_type) - (son_wallet_withdraw_object_type) - (sidechain_address_object_type) - (sidechain_transaction_object_type) - (OBJECT_TYPE_COUNT) - ) -FC_REFLECT_ENUM( graphene::chain::impl_object_type, - (impl_global_property_object_type) - (impl_dynamic_global_property_object_type) - (impl_reserved0_object_type) - (impl_asset_dynamic_data_type) - (impl_asset_bitasset_data_type) - (impl_account_balance_object_type) - (impl_account_statistics_object_type) - (impl_transaction_object_type) - (impl_block_summary_object_type) - (impl_account_transaction_history_object_type) - (impl_blinded_balance_object_type) - (impl_chain_property_object_type) - (impl_witness_schedule_object_type) - (impl_budget_record_object_type) - (impl_special_authority_object_type) - (impl_buyback_object_type) - (impl_fba_accumulator_object_type) - (impl_asset_dividend_data_type) - (impl_pending_dividend_payout_balance_for_holder_object_type) - (impl_distributed_dividend_balance_data_type) - (impl_betting_market_position_object_type) - (impl_global_betting_statistics_object_type) - (impl_lottery_balance_object_type) - (impl_sweeps_vesting_balance_object_type) - (impl_offer_history_object_type) - (impl_son_statistics_object_type) - (impl_son_schedule_object_type) - ) - -FC_REFLECT_TYPENAME( graphene::chain::share_type ) - -FC_REFLECT_TYPENAME( graphene::chain::account_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::asset_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::force_settlement_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::committee_member_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::witness_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::limit_order_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::call_order_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::custom_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::proposal_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::operation_history_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::withdraw_permission_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::vesting_balance_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::worker_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::balance_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::sport_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::event_group_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::event_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::betting_market_rules_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::betting_market_group_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::betting_market_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::bet_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::tournament_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::offer_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::global_property_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::dynamic_global_property_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::asset_dynamic_data_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::asset_bitasset_data_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::account_balance_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::account_statistics_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::transaction_obj_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::block_summary_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::account_transaction_history_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::budget_record_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::special_authority_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::buyback_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::fba_accumulator_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::betting_market_position_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::global_betting_statistics_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::tournament_details_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::custom_permission_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::custom_account_authority_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::offer_history_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::nft_metadata_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::nft_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::account_role_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::son_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::son_proposal_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::son_wallet_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::son_wallet_deposit_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::son_wallet_withdraw_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::sidechain_address_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::sidechain_transaction_id_type ) - - -FC_REFLECT( graphene::chain::void_t, ) - -FC_REFLECT_ENUM( graphene::chain::asset_issuer_permission_flags, - (charge_market_fee) - (white_list) - (transfer_restricted) - (override_authority) - (disable_force_settle) - (global_settle) - (disable_confidential) - (witness_fed_asset) - (committee_fed_asset) - ) diff --git a/libraries/chain/include/graphene/chain/sidechain_address_evaluator.hpp b/libraries/chain/include/graphene/chain/sidechain_address_evaluator.hpp index 5da9d44a..1ff564b6 100644 --- a/libraries/chain/include/graphene/chain/sidechain_address_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/sidechain_address_evaluator.hpp @@ -1,5 +1,6 @@ #pragma once #include + #include namespace graphene { namespace chain { diff --git a/libraries/chain/include/graphene/chain/sidechain_address_object.hpp b/libraries/chain/include/graphene/chain/sidechain_address_object.hpp index b9646c52..6e58c8c6 100644 --- a/libraries/chain/include/graphene/chain/sidechain_address_object.hpp +++ b/libraries/chain/include/graphene/chain/sidechain_address_object.hpp @@ -1,9 +1,10 @@ #pragma once -#include #include #include +#include #include + #include namespace graphene { namespace chain { diff --git a/libraries/chain/include/graphene/chain/sidechain_defs.hpp b/libraries/chain/include/graphene/chain/sidechain_defs.hpp deleted file mode 100644 index 6bbc8b5c..00000000 --- a/libraries/chain/include/graphene/chain/sidechain_defs.hpp +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once - -#include - -namespace graphene { namespace chain { - -enum class sidechain_type { - unknown, - bitcoin, - ethereum, - eos, - peerplays -}; - -} } - -FC_REFLECT_ENUM(graphene::chain::sidechain_type, - (unknown) - (bitcoin) - (ethereum) - (eos) - (peerplays) ) diff --git a/libraries/chain/include/graphene/chain/sidechain_transaction_evaluator.hpp b/libraries/chain/include/graphene/chain/sidechain_transaction_evaluator.hpp index dabd2b94..66b817e9 100644 --- a/libraries/chain/include/graphene/chain/sidechain_transaction_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/sidechain_transaction_evaluator.hpp @@ -1,5 +1,6 @@ #pragma once #include + #include namespace graphene { namespace chain { diff --git a/libraries/chain/include/graphene/chain/sidechain_transaction_object.hpp b/libraries/chain/include/graphene/chain/sidechain_transaction_object.hpp index 0f01e689..9a0837bc 100644 --- a/libraries/chain/include/graphene/chain/sidechain_transaction_object.hpp +++ b/libraries/chain/include/graphene/chain/sidechain_transaction_object.hpp @@ -1,9 +1,10 @@ #pragma once -#include #include #include #include +#include + namespace graphene { namespace chain { using namespace graphene::db; using namespace graphene::protocol; @@ -70,6 +71,8 @@ FC_REFLECT_ENUM( graphene::chain::sidechain_transaction_status, (sent) (settled) ) +MAP_OBJECT_ID_TO_TYPE(graphene::chain::sidechain_transaction_object) + FC_REFLECT_DERIVED( graphene::chain::sidechain_transaction_object, (graphene::db::object ), (sidechain) (object_id) diff --git a/libraries/chain/include/graphene/chain/son_evaluator.hpp b/libraries/chain/include/graphene/chain/son_evaluator.hpp index 1e5c239f..9ac66e49 100644 --- a/libraries/chain/include/graphene/chain/son_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/son_evaluator.hpp @@ -1,7 +1,8 @@ #pragma once -#include #include +#include + namespace graphene { namespace chain { class create_son_evaluator : public evaluator diff --git a/libraries/chain/include/graphene/chain/son_info.hpp b/libraries/chain/include/graphene/chain/son_info.hpp deleted file mode 100644 index 2bfecac4..00000000 --- a/libraries/chain/include/graphene/chain/son_info.hpp +++ /dev/null @@ -1,47 +0,0 @@ -#pragma once -#include -#include - -namespace graphene { namespace chain { - using namespace graphene::db; - - /** - * @class son_info - * @brief tracks information about a SON info required to re/create primary wallet - * @ingroup object - */ - struct son_info { - son_id_type son_id; - weight_type weight = 0; - public_key_type signing_key; - flat_map sidechain_public_keys; - - bool operator==(const son_info& rhs) { - bool son_sets_equal = - (son_id == rhs.son_id) && - (weight == rhs.weight) && - (signing_key == rhs.signing_key) && - (sidechain_public_keys.size() == rhs.sidechain_public_keys.size()); - - if (son_sets_equal) { - bool sidechain_public_keys_equal = true; - for (size_t i = 0; i < sidechain_public_keys.size(); i++) { - const auto lhs_scpk = sidechain_public_keys.nth(i); - const auto rhs_scpk = rhs.sidechain_public_keys.nth(i); - sidechain_public_keys_equal = sidechain_public_keys_equal && - (lhs_scpk->first == rhs_scpk->first) && - (lhs_scpk->second == rhs_scpk->second); - } - son_sets_equal = son_sets_equal && sidechain_public_keys_equal; - } - return son_sets_equal; - } - }; - -} } - -FC_REFLECT( graphene::chain::son_info, - (son_id) - (weight) - (signing_key) - (sidechain_public_keys) ) diff --git a/libraries/chain/include/graphene/chain/son_object.hpp b/libraries/chain/include/graphene/chain/son_object.hpp index c3dc39be..bc69eb28 100644 --- a/libraries/chain/include/graphene/chain/son_object.hpp +++ b/libraries/chain/include/graphene/chain/son_object.hpp @@ -1,7 +1,8 @@ #pragma once -#include #include #include + +#include #include namespace graphene { namespace chain { @@ -112,8 +113,8 @@ namespace graphene { namespace chain { } } // graphene::chain -MAP_OBJECT_ID_TO_TYPE(graphene::chain::son_statistics_object) MAP_OBJECT_ID_TO_TYPE(graphene::chain::son_object) +MAP_OBJECT_ID_TO_TYPE(graphene::chain::son_statistics_object) FC_REFLECT_ENUM(graphene::chain::son_status, (inactive)(active)(request_maintenance)(in_maintenance)(deregistered) ) diff --git a/libraries/chain/include/graphene/chain/son_proposal_object.hpp b/libraries/chain/include/graphene/chain/son_proposal_object.hpp index 529f2e2f..92ecf4a5 100644 --- a/libraries/chain/include/graphene/chain/son_proposal_object.hpp +++ b/libraries/chain/include/graphene/chain/son_proposal_object.hpp @@ -1,9 +1,10 @@ #pragma once -#include #include #include +#include + namespace graphene { namespace chain { enum class son_proposal_type @@ -37,6 +38,8 @@ using son_proposal_index = generic_index; } } // graphene::chain +MAP_OBJECT_ID_TO_TYPE(graphene::chain::son_wallet_object) + FC_REFLECT_DERIVED( graphene::chain::son_wallet_object, (graphene::db::object), (valid_from) (expires) (addresses) (sons) ) diff --git a/libraries/chain/include/graphene/chain/tournament_object.hpp b/libraries/chain/include/graphene/chain/tournament_object.hpp index b6ef883e..9f2e5860 100644 --- a/libraries/chain/include/graphene/chain/tournament_object.hpp +++ b/libraries/chain/include/graphene/chain/tournament_object.hpp @@ -251,7 +251,7 @@ FC_REFLECT_DERIVED(graphene::chain::tournament_details_object, (graphene::db::ob (players_payers) (matches)) //FC_REFLECT_TYPENAME(graphene::chain::tournament_object) // manually serialized -FC_REFLECT(graphene::chain::tournament_object, (creator)) +FC_REFLECT_DERIVED(graphene::chain::tournament_object, (graphene::db::object), (creator)) FC_REFLECT_ENUM(graphene::chain::tournament_state, (accepting_registrations) (awaiting_start) diff --git a/libraries/chain/include/graphene/chain/transaction_evaluation_state.hpp b/libraries/chain/include/graphene/chain/transaction_evaluation_state.hpp index c53c3733..c6daeaa4 100644 --- a/libraries/chain/include/graphene/chain/transaction_evaluation_state.hpp +++ b/libraries/chain/include/graphene/chain/transaction_evaluation_state.hpp @@ -22,6 +22,8 @@ * THE SOFTWARE. */ #pragma once +#include + #include namespace graphene { diff --git a/libraries/chain/include/graphene/chain/vesting_balance_object.hpp b/libraries/chain/include/graphene/chain/vesting_balance_object.hpp index f831f05e..c60439b0 100644 --- a/libraries/chain/include/graphene/chain/vesting_balance_object.hpp +++ b/libraries/chain/include/graphene/chain/vesting_balance_object.hpp @@ -26,7 +26,6 @@ #include #include - #include #include diff --git a/libraries/chain/include/graphene/chain/witness_schedule_object.hpp b/libraries/chain/include/graphene/chain/witness_schedule_object.hpp index 20c57c7b..3e6616ba 100644 --- a/libraries/chain/include/graphene/chain/witness_schedule_object.hpp +++ b/libraries/chain/include/graphene/chain/witness_schedule_object.hpp @@ -33,6 +33,13 @@ #include +#include + +#include +#include + +#include + namespace graphene { namespace chain { typedef hash_ctr_rng< @@ -103,7 +110,7 @@ class son_schedule_object : public graphene::db::abstract_object rng_seed; + std::array< char, sizeof(secret_hash_type) > rng_seed = {}; /** * Not necessary for consensus, but used for figuring out the participation rate. diff --git a/libraries/chain/index.cpp b/libraries/chain/index.cpp deleted file mode 100644 index 41a469b2..00000000 --- a/libraries/chain/index.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2015 Cryptonomex, Inc., and contributors. - * - * The MIT License - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#include -#include -#include - -namespace graphene { namespace chain { - void base_primary_index::save_undo( const object& obj ) - { _db.save_undo( obj ); } - - void base_primary_index::on_add( const object& obj ) - { - _db.save_undo_add( obj ); - for( auto ob : _observers ) ob->on_add( obj ); - } - - void base_primary_index::on_remove( const object& obj ) - { _db.save_undo_remove( obj ); for( auto ob : _observers ) ob->on_remove( obj ); } - - void base_primary_index::on_modify( const object& obj ) - {for( auto ob : _observers ) ob->on_modify( obj ); } -} } // graphene::chain diff --git a/libraries/chain/nft_evaluator.cpp b/libraries/chain/nft_evaluator.cpp index 81fc2d95..81166e16 100644 --- a/libraries/chain/nft_evaluator.cpp +++ b/libraries/chain/nft_evaluator.cpp @@ -6,6 +6,8 @@ #include #include +#include + namespace graphene { namespace chain { void_result nft_metadata_create_evaluator::do_evaluate( const nft_metadata_create_operation& op ) diff --git a/libraries/chain/offer_evaluator.cpp b/libraries/chain/offer_evaluator.cpp index 01e05639..e4720611 100644 --- a/libraries/chain/offer_evaluator.cpp +++ b/libraries/chain/offer_evaluator.cpp @@ -2,11 +2,13 @@ #include #include #include -#include #include #include #include #include + +#include + #include namespace graphene @@ -94,7 +96,6 @@ namespace graphene auto now = d.head_block_time(); FC_ASSERT(now >= HARDFORK_NFT_TIME, "Not allowed until NFT HF"); const auto &offer = op.offer_id(d); - op.bidder(d); for (const auto &item : offer.item_ids) { const auto &nft_obj = item(d); diff --git a/libraries/chain/protocol/types.cpp b/libraries/chain/protocol/types.cpp deleted file mode 100644 index b7cac207..00000000 --- a/libraries/chain/protocol/types.cpp +++ /dev/null @@ -1,280 +0,0 @@ -/* - * Copyright (c) 2015 Cryptonomex, Inc., and contributors. - * - * The MIT License - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#include -#include - -#include -#include -#include -#include - -namespace graphene { namespace chain { - - public_key_type::public_key_type():key_data(){}; - - public_key_type::public_key_type( const fc::ecc::public_key_data& data ) - :key_data( data ) {}; - - public_key_type::public_key_type( const fc::ecc::public_key& pubkey ) - :key_data( pubkey ) {}; - - public_key_type::public_key_type( const std::string& base58str ) - { - // TODO: Refactor syntactic checks into static is_valid() - // to make public_key_type API more similar to address API - std::string prefix( GRAPHENE_ADDRESS_PREFIX ); - - // TODO: This is temporary for testing - try - { - if( is_valid_v1( base58str ) ) - prefix = std::string( "BTS" ); - } - catch( ... ) - { - } - - try - { - if( is_valid_muse( base58str ) ) - prefix = std::string( "MUSE" ); - } - catch( ... ) - { - } - - const size_t prefix_len = prefix.size(); - FC_ASSERT( base58str.size() > prefix_len ); - FC_ASSERT( base58str.substr( 0, prefix_len ) == prefix , "", ("base58str", base58str) ); - auto bin = fc::from_base58( base58str.substr( prefix_len ) ); - auto bin_key = fc::raw::unpack(bin); - key_data = bin_key.data; - FC_ASSERT( fc::ripemd160::hash( key_data.data, key_data.size() )._hash[0] == bin_key.check ); - }; - - bool public_key_type::is_valid_muse( const std::string& base58str ) - { - std::string prefix( "MUSE" ); - - const size_t prefix_len = prefix.size(); - FC_ASSERT( base58str.size() > prefix_len ); - FC_ASSERT( base58str.substr( 0, prefix_len ) == prefix , "", ("base58str", base58str) ); - auto bin = fc::from_base58( base58str.substr( prefix_len ) ); - auto bin_key = fc::raw::unpack(bin); - key_data = bin_key.data; - FC_ASSERT( fc::ripemd160::hash( key_data.data, key_data.size() )._hash[0] == bin_key.check ); - return true; - } - - // TODO: This is temporary for testing - bool public_key_type::is_valid_v1( const std::string& base58str ) - { - std::string prefix( "BTS" ); - const size_t prefix_len = prefix.size(); - FC_ASSERT( base58str.size() > prefix_len ); - FC_ASSERT( base58str.substr( 0, prefix_len ) == prefix , "", ("base58str", base58str) ); - auto bin = fc::from_base58( base58str.substr( prefix_len ) ); - auto bin_key = fc::raw::unpack(bin); - fc::ecc::public_key_data key_data = bin_key.data; - FC_ASSERT( fc::ripemd160::hash( key_data.data, key_data.size() )._hash[0] == bin_key.check ); - return true; - } - - public_key_type::operator fc::ecc::public_key_data() const - { - return key_data; - }; - - public_key_type::operator fc::ecc::public_key() const - { - return fc::ecc::public_key( key_data ); - }; - - public_key_type::operator std::string() const - { - binary_key k; - k.data = key_data; - k.check = fc::ripemd160::hash( k.data.data, k.data.size() )._hash[0]; - auto data = fc::raw::pack( k ); - return GRAPHENE_ADDRESS_PREFIX + fc::to_base58( data.data(), data.size() ); - } - - bool operator == ( const public_key_type& p1, const fc::ecc::public_key& p2) - { - return p1.key_data == p2.serialize(); - } - - bool operator == ( const public_key_type& p1, const public_key_type& p2) - { - return p1.key_data == p2.key_data; - } - - bool operator != ( const public_key_type& p1, const public_key_type& p2) - { - return p1.key_data != p2.key_data; - } - - // extended_public_key_type - - extended_public_key_type::extended_public_key_type():key_data(){}; - - extended_public_key_type::extended_public_key_type( const fc::ecc::extended_key_data& data ) - :key_data( data ){}; - - extended_public_key_type::extended_public_key_type( const fc::ecc::extended_public_key& extpubkey ) - { - key_data = extpubkey.serialize_extended(); - }; - - extended_public_key_type::extended_public_key_type( const std::string& base58str ) - { - std::string prefix( GRAPHENE_ADDRESS_PREFIX ); - - const size_t prefix_len = prefix.size(); - FC_ASSERT( base58str.size() > prefix_len ); - FC_ASSERT( base58str.substr( 0, prefix_len ) == prefix , "", ("base58str", base58str) ); - auto bin = fc::from_base58( base58str.substr( prefix_len ) ); - auto bin_key = fc::raw::unpack(bin); - FC_ASSERT( fc::ripemd160::hash( bin_key.data.data, bin_key.data.size() )._hash[0] == bin_key.check ); - key_data = bin_key.data; - } - - extended_public_key_type::operator fc::ecc::extended_public_key() const - { - return fc::ecc::extended_public_key::deserialize( key_data ); - } - - extended_public_key_type::operator std::string() const - { - binary_key k; - k.data = key_data; - k.check = fc::ripemd160::hash( k.data.data, k.data.size() )._hash[0]; - auto data = fc::raw::pack( k ); - return GRAPHENE_ADDRESS_PREFIX + fc::to_base58( data.data(), data.size() ); - } - - bool operator == ( const extended_public_key_type& p1, const fc::ecc::extended_public_key& p2) - { - return p1.key_data == p2.serialize_extended(); - } - - bool operator == ( const extended_public_key_type& p1, const extended_public_key_type& p2) - { - return p1.key_data == p2.key_data; - } - - bool operator != ( const extended_public_key_type& p1, const extended_public_key_type& p2) - { - return p1.key_data != p2.key_data; - } - - // extended_private_key_type - - extended_private_key_type::extended_private_key_type():key_data(){}; - - extended_private_key_type::extended_private_key_type( const fc::ecc::extended_key_data& data ) - :key_data( data ){}; - - extended_private_key_type::extended_private_key_type( const fc::ecc::extended_private_key& extprivkey ) - { - key_data = extprivkey.serialize_extended(); - }; - - extended_private_key_type::extended_private_key_type( const std::string& base58str ) - { - std::string prefix( GRAPHENE_ADDRESS_PREFIX ); - - const size_t prefix_len = prefix.size(); - FC_ASSERT( base58str.size() > prefix_len ); - FC_ASSERT( base58str.substr( 0, prefix_len ) == prefix , "", ("base58str", base58str) ); - auto bin = fc::from_base58( base58str.substr( prefix_len ) ); - auto bin_key = fc::raw::unpack(bin); - FC_ASSERT( fc::ripemd160::hash( bin_key.data.data, bin_key.data.size() )._hash[0] == bin_key.check ); - key_data = bin_key.data; - } - - extended_private_key_type::operator fc::ecc::extended_private_key() const - { - return fc::ecc::extended_private_key::deserialize( key_data ); - } - - extended_private_key_type::operator std::string() const - { - binary_key k; - k.data = key_data; - k.check = fc::ripemd160::hash( k.data.data, k.data.size() )._hash[0]; - auto data = fc::raw::pack( k ); - return GRAPHENE_ADDRESS_PREFIX + fc::to_base58( data.data(), data.size() ); - } - - bool operator == ( const extended_private_key_type& p1, const fc::ecc::extended_public_key& p2) - { - return p1.key_data == p2.serialize_extended(); - } - - bool operator == ( const extended_private_key_type& p1, const extended_private_key_type& p2) - { - return p1.key_data == p2.key_data; - } - - bool operator != ( const extended_private_key_type& p1, const extended_private_key_type& p2) - { - return p1.key_data != p2.key_data; - } - -} } // graphene::chain - -namespace fc -{ - using namespace std; - void to_variant( const graphene::chain::public_key_type& var, fc::variant& vo, uint32_t max_depth ) - { - vo = std::string( var ); - } - - void from_variant( const fc::variant& var, graphene::chain::public_key_type& vo, uint32_t max_depth ) - { - vo = graphene::chain::public_key_type( var.as_string() ); - } - - void to_variant( const graphene::chain::extended_public_key_type& var, fc::variant& vo, uint32_t max_depth ) - { - vo = std::string( var ); - } - - void from_variant( const fc::variant& var, graphene::chain::extended_public_key_type& vo, uint32_t max_depth ) - { - vo = graphene::chain::extended_public_key_type( var.as_string() ); - } - - void to_variant( const graphene::chain::extended_private_key_type& var, fc::variant& vo, uint32_t max_depth ) - { - vo = std::string( var ); - } - - void from_variant( const fc::variant& var, graphene::chain::extended_private_key_type& vo, uint32_t max_depth ) - { - vo = graphene::chain::extended_private_key_type( var.as_string() ); - } -} // fc diff --git a/libraries/db/include/graphene/db/object.hpp b/libraries/db/include/graphene/db/object.hpp index 3b8be32b..2c0f2adc 100644 --- a/libraries/db/include/graphene/db/object.hpp +++ b/libraries/db/include/graphene/db/object.hpp @@ -29,8 +29,6 @@ #define MAX_NESTING (200) -#define MAX_NESTING (200) - namespace graphene { namespace db { /** diff --git a/libraries/db/include/graphene/db/object_database.hpp b/libraries/db/include/graphene/db/object_database.hpp index 3a4315c1..d51249e1 100644 --- a/libraries/db/include/graphene/db/object_database.hpp +++ b/libraries/db/include/graphene/db/object_database.hpp @@ -143,6 +143,12 @@ namespace graphene { namespace db { return static_cast(_index[ObjectType::space_id][ObjectType::type_id].get()); } + template + SecondaryIndexType* add_secondary_index() + { + return get_mutable_index_type().template add_secondary_index(); + } + void pop_undo(); fc::path get_data_dir()const { return _data_dir; } diff --git a/libraries/egenesis/CMakeLists.txt b/libraries/egenesis/CMakeLists.txt index 68de4b00..225850d8 100644 --- a/libraries/egenesis/CMakeLists.txt +++ b/libraries/egenesis/CMakeLists.txt @@ -57,3 +57,5 @@ INSTALL( TARGETS LIBRARY DESTINATION lib ARCHIVE DESTINATION lib ) +file(GLOB HEADERS "include/graphene/egenesis/*.hpp") +INSTALL( FILES ${HEADERS} DESTINATION "include/graphene/egenesis" ) diff --git a/libraries/fc b/libraries/fc index 69ebbf4b..21418ec4 160000 --- a/libraries/fc +++ b/libraries/fc @@ -1 +1 @@ -Subproject commit 69ebbf4ba490482956de0e331b22f1018747d789 +Subproject commit 21418ec46e7e9bb40f77b2312761976d909722ec diff --git a/libraries/net/CMakeLists.txt b/libraries/net/CMakeLists.txt index 202a792d..806864af 100644 --- a/libraries/net/CMakeLists.txt +++ b/libraries/net/CMakeLists.txt @@ -11,9 +11,9 @@ set(SOURCES node.cpp add_library( graphene_net ${SOURCES} ${HEADERS} ) -target_link_libraries( graphene_net +target_link_libraries( graphene_net PUBLIC fc graphene_db graphene_protocol ) -target_include_directories( graphene_net +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/account_role.cpp b/libraries/net/account_role.cpp deleted file mode 100644 index 1d71d6cc..00000000 --- a/libraries/net/account_role.cpp +++ /dev/null @@ -1,61 +0,0 @@ -#include -#include - -namespace graphene -{ - namespace chain - { - - void account_role_create_operation::validate() const - { - FC_ASSERT(fee.amount >= 0, "Fee must not be negative"); - FC_ASSERT(allowed_operations.size() > 0, "Allowed operations should be positive"); - FC_ASSERT(whitelisted_accounts.size() > 0, "Whitelisted accounts should be positive"); - } - - void account_role_update_operation::validate() const - { - FC_ASSERT(fee.amount >= 0, "Fee must not be negative"); - for (auto aop : allowed_operations_to_add) - { - FC_ASSERT(aop >= 0 && aop < operation::count(), "operation_type is not valid"); - FC_ASSERT(allowed_operations_to_remove.find(aop) == allowed_operations_to_remove.end(), - "Cannot add and remove allowed operation at the same time."); - } - for (auto aop : allowed_operations_to_remove) - { - FC_ASSERT(aop >= 0 && aop < operation::count(), "operation_type is not valid"); - FC_ASSERT(allowed_operations_to_add.find(aop) == allowed_operations_to_add.end(), - "Cannot add and remove allowed operation at the same time."); - } - - for (auto acc : accounts_to_add) - { - FC_ASSERT(accounts_to_remove.find(acc) == accounts_to_remove.end(), - "Cannot add and remove accounts at the same time."); - } - - for (auto acc : accounts_to_remove) - { - FC_ASSERT(accounts_to_add.find(acc) == accounts_to_add.end(), - "Cannot add and remove accounts at the same time."); - } - } - - void account_role_delete_operation::validate() const - { - FC_ASSERT(fee.amount >= 0, "Fee must not be negative"); - } - - share_type account_role_create_operation::calculate_fee(const fee_parameters_type &k) const - { - return k.fee + calculate_data_fee(fc::raw::pack_size(*this), k.price_per_kbyte); - } - - share_type account_role_update_operation::calculate_fee(const fee_parameters_type &k) const - { - return k.fee + calculate_data_fee(fc::raw::pack_size(*this), k.price_per_kbyte); - } - - } // namespace chain -} // namespace graphene diff --git a/libraries/net/chain_parameters.cpp b/libraries/net/chain_parameters.cpp deleted file mode 100644 index a904b0e3..00000000 --- a/libraries/net/chain_parameters.cpp +++ /dev/null @@ -1,92 +0,0 @@ -#include -#include - -namespace graphene { namespace chain { - chain_parameters::chain_parameters() { - current_fees = std::make_shared(); - } - - // copy constructor - chain_parameters::chain_parameters(const chain_parameters& other) - { - current_fees = std::make_shared(*other.current_fees); - safe_copy(*this, other); - } - - // copy assignment - chain_parameters& chain_parameters::operator=(const chain_parameters& other) - { - if (&other != this) - { - current_fees = std::make_shared(*other.current_fees); - safe_copy(*this, other); - } - return *this; - } - - // copies the easy stuff - void chain_parameters::safe_copy(chain_parameters& to, const chain_parameters& from) - { - to.block_interval = from.block_interval; - to.maintenance_interval = from.maintenance_interval; - to.maintenance_skip_slots = from.maintenance_skip_slots; - to.committee_proposal_review_period = from.committee_proposal_review_period; - to.maximum_transaction_size = from.maximum_transaction_size; - to.maximum_block_size = from.maximum_block_size; - to.maximum_time_until_expiration = from.maximum_time_until_expiration; - to.maximum_proposal_lifetime = from.maximum_proposal_lifetime; - to.maximum_asset_whitelist_authorities = from.maximum_asset_whitelist_authorities; - to.maximum_asset_feed_publishers = from.maximum_asset_feed_publishers; - to.maximum_witness_count = from.maximum_witness_count; - to.maximum_committee_count = from.maximum_committee_count; - to.maximum_authority_membership = from.maximum_authority_membership; - to.reserve_percent_of_fee = from.reserve_percent_of_fee; - to.network_percent_of_fee = from.network_percent_of_fee; - to.lifetime_referrer_percent_of_fee = from.lifetime_referrer_percent_of_fee; - to.cashback_vesting_period_seconds = from.cashback_vesting_period_seconds; - to.cashback_vesting_threshold = from.cashback_vesting_threshold; - to.count_non_member_votes = from.count_non_member_votes; - to.allow_non_member_whitelists = from.allow_non_member_whitelists; - to.witness_pay_per_block = from.witness_pay_per_block; - to.witness_pay_vesting_seconds = from.witness_pay_vesting_seconds; - to.worker_budget_per_day = from.worker_budget_per_day; - to.max_predicate_opcode = from.max_predicate_opcode; - to.fee_liquidation_threshold = from.fee_liquidation_threshold; - to.accounts_per_fee_scale = from.accounts_per_fee_scale; - to.account_fee_scale_bitshifts = from.account_fee_scale_bitshifts; - to.max_authority_depth = from.max_authority_depth; - to.witness_schedule_algorithm= from.witness_schedule_algorithm; - to.min_round_delay = from.min_round_delay; - to.max_round_delay = from.max_round_delay; - to.min_time_per_commit_move = from.min_time_per_commit_move; - to.max_time_per_commit_move = from.max_time_per_commit_move; - to.min_time_per_reveal_move = from.min_time_per_reveal_move; - to.max_time_per_reveal_move = from.max_time_per_reveal_move; - to.rake_fee_percentage = from.rake_fee_percentage; - to.maximum_registration_deadline = from.maximum_registration_deadline; - to.maximum_players_in_tournament = from.maximum_players_in_tournament; - to.maximum_tournament_whitelist_length = from.maximum_tournament_whitelist_length; - to.maximum_tournament_start_time_in_future= from.maximum_tournament_start_time_in_future; - to.maximum_tournament_start_delay = from.maximum_tournament_start_delay; - to.maximum_tournament_number_of_wins = from.maximum_tournament_number_of_wins; - to.extensions = from.extensions; - } - - // move constructor - chain_parameters::chain_parameters(chain_parameters&& other) - { - current_fees = std::move(other.current_fees); - safe_copy(*this, other); - } - - // move assignment - chain_parameters& chain_parameters::operator=(chain_parameters&& other) - { - if (&other != this) - { - current_fees = std::move(other.current_fees); - safe_copy(*this, other); - } - return *this; - } -}} diff --git a/libraries/net/custom_account_authority.cpp b/libraries/net/custom_account_authority.cpp deleted file mode 100644 index a74234d7..00000000 --- a/libraries/net/custom_account_authority.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include -#include - -namespace graphene -{ -namespace chain -{ - -void custom_account_authority_create_operation::validate() const -{ - FC_ASSERT(fee.amount >= 0, "Fee must not be negative"); - FC_ASSERT(owner_account != GRAPHENE_TEMP_ACCOUNT && owner_account != GRAPHENE_COMMITTEE_ACCOUNT && owner_account != GRAPHENE_WITNESS_ACCOUNT && owner_account != GRAPHENE_RELAXED_COMMITTEE_ACCOUNT, - "Custom permissions and account auths cannot be created for special accounts"); - FC_ASSERT(valid_from < valid_to, "valid_from should be earlier than valid_to"); - FC_ASSERT(operation_type >= 0 && operation_type < operation::count(), "operation_type is not valid"); -} - -void custom_account_authority_update_operation::validate() const -{ - FC_ASSERT(fee.amount >= 0, "Fee must not be negative"); - FC_ASSERT(owner_account != GRAPHENE_TEMP_ACCOUNT && owner_account != GRAPHENE_COMMITTEE_ACCOUNT && owner_account != GRAPHENE_WITNESS_ACCOUNT && owner_account != GRAPHENE_RELAXED_COMMITTEE_ACCOUNT, - "Custom permissions and account auths cannot be created for special accounts"); - FC_ASSERT(new_valid_from.valid() || new_valid_to.valid(), "Something must be updated"); - if (new_valid_from && new_valid_to) - { - FC_ASSERT(*new_valid_from < *new_valid_to, "valid_from should be earlier than valid_to"); - } -} - -void custom_account_authority_delete_operation::validate() const -{ - FC_ASSERT(fee.amount >= 0, "Fee must not be negative"); - FC_ASSERT(owner_account != GRAPHENE_TEMP_ACCOUNT && owner_account != GRAPHENE_COMMITTEE_ACCOUNT && owner_account != GRAPHENE_WITNESS_ACCOUNT && owner_account != GRAPHENE_RELAXED_COMMITTEE_ACCOUNT, - "Custom permissions and account auths cannot be created for special accounts"); -} - -share_type custom_account_authority_create_operation::calculate_fee(const fee_parameters_type &k) const -{ - return k.fee + calculate_data_fee( fc::raw::pack_size(*this), k.price_per_kbyte ); -} - -} // namespace chain -} // namespace graphene diff --git a/libraries/net/custom_permission.cpp b/libraries/net/custom_permission.cpp deleted file mode 100644 index c0919cbd..00000000 --- a/libraries/net/custom_permission.cpp +++ /dev/null @@ -1,85 +0,0 @@ -#include -#include - -namespace graphene -{ -namespace chain -{ - -bool is_valid_permission_name(const string &name) -{ - try - { - const size_t len = name.size(); - // RBAC_MIN_PERMISSION_NAME_LENGTH <= len minimum length check - if (len < RBAC_MIN_PERMISSION_NAME_LENGTH) - { - return false; - } - // len <= RBAC_MAX_PERMISSION_NAME_LENGTH max length check - if (len > RBAC_MAX_PERMISSION_NAME_LENGTH) - { - return false; - } - // First character should be a letter between a-z - if (!(name[0] >= 'a' && name[0] <= 'z')) - { - return false; - } - // Any character of a permission name should either be a small case letter a-z or a digit 0-9 - for (const auto &ch : name) - { - if (!((ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9'))) - { - return false; - } - } - // Don't accept active and owner permissions as we already have them by default - // This is for removing ambiguity for users, accepting them doesn't create any problems - if (name == "active" || name == "owner") - { - return false; - } - - return true; - } - FC_CAPTURE_AND_RETHROW((name)) -} - -void custom_permission_create_operation::validate() const -{ - FC_ASSERT(fee.amount >= 0, "Fee must not be negative"); - FC_ASSERT(is_valid_permission_name(permission_name), "Invalid permission name provided"); - FC_ASSERT(owner_account != GRAPHENE_TEMP_ACCOUNT && owner_account != GRAPHENE_COMMITTEE_ACCOUNT && owner_account != GRAPHENE_WITNESS_ACCOUNT && owner_account != GRAPHENE_RELAXED_COMMITTEE_ACCOUNT, - "Custom permissions and account auths cannot be created for special accounts"); - FC_ASSERT(!auth.is_impossible(), "Impossible authority threshold auth provided"); - FC_ASSERT(auth.address_auths.size() == 0, "Only account and key auths supported"); -} - -void custom_permission_update_operation::validate() const -{ - FC_ASSERT(fee.amount >= 0, "Fee must not be negative"); - FC_ASSERT(owner_account != GRAPHENE_TEMP_ACCOUNT && owner_account != GRAPHENE_COMMITTEE_ACCOUNT && owner_account != GRAPHENE_WITNESS_ACCOUNT && owner_account != GRAPHENE_RELAXED_COMMITTEE_ACCOUNT, - "Custom permissions and account auths cannot be created for special accounts"); - FC_ASSERT(new_auth.valid(), "Something must be updated"); - if (new_auth) - { - FC_ASSERT(!new_auth->is_impossible(), "Impossible authority threshold auth provided"); - FC_ASSERT(new_auth->address_auths.size() == 0, "Only account and key auths supported"); - } -} - -void custom_permission_delete_operation::validate() const -{ - FC_ASSERT(fee.amount >= 0, "Fee must not be negative"); - FC_ASSERT(owner_account != GRAPHENE_TEMP_ACCOUNT && owner_account != GRAPHENE_COMMITTEE_ACCOUNT && owner_account != GRAPHENE_WITNESS_ACCOUNT && owner_account != GRAPHENE_RELAXED_COMMITTEE_ACCOUNT, - "Custom permissions and account auths cannot be created for special accounts"); -} - -share_type custom_permission_create_operation::calculate_fee(const fee_parameters_type &k) const -{ - return k.fee + calculate_data_fee( fc::raw::pack_size(*this), k.price_per_kbyte ); -} - -} // namespace chain -} // namespace graphene diff --git a/libraries/net/nft.cpp b/libraries/net/nft.cpp deleted file mode 100644 index 4a66f330..00000000 --- a/libraries/net/nft.cpp +++ /dev/null @@ -1,95 +0,0 @@ -#include -#include - -namespace graphene -{ -namespace chain -{ - -bool is_valid_nft_token_name(const string &name) -{ - try - { - const size_t len = name.size(); - // NFT_TOKEN_MIN_LENGTH <= len minimum length check - if (len < NFT_TOKEN_MIN_LENGTH) - { - return false; - } - // len <= NFT_TOKEN_MAX_LENGTH max length check - if (len > NFT_TOKEN_MAX_LENGTH) - { - return false; - } - // First character should be a letter between a-z/A-Z - if (!((name[0] >= 'a' && name[0] <= 'z') || (name[0] >= 'A' && name[0] <= 'Z'))) - { - return false; - } - // Any character should either be a small case letter a-z or a digit 0-9 - for (const auto &ch : name) - { - if (!((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9') || (ch == ' '))) - { - return false; - } - } - - return true; - } - FC_CAPTURE_AND_RETHROW((name)) -} - -void nft_metadata_create_operation::validate() const -{ - FC_ASSERT(fee.amount >= 0, "Fee must not be negative"); - FC_ASSERT(is_valid_nft_token_name(name), "Invalid NFT name provided"); - FC_ASSERT(is_valid_nft_token_name(symbol), "Invalid NFT symbol provided"); -} - -void nft_metadata_update_operation::validate() const -{ - FC_ASSERT(fee.amount >= 0, "Fee must not be negative"); - if(name) - FC_ASSERT(is_valid_nft_token_name(*name), "Invalid NFT name provided"); - if(symbol) - FC_ASSERT(is_valid_nft_token_name(*symbol), "Invalid NFT symbol provided"); -} - -void nft_mint_operation::validate() const -{ - FC_ASSERT(fee.amount >= 0, "Fee must not be negative"); -} - -share_type nft_metadata_create_operation::calculate_fee(const fee_parameters_type &k) const -{ - return k.fee + calculate_data_fee( fc::raw::pack_size(*this), k.price_per_kbyte ); -} - -share_type nft_metadata_update_operation::calculate_fee(const fee_parameters_type &k) const -{ - return k.fee + calculate_data_fee( fc::raw::pack_size(*this), k.price_per_kbyte ); -} - -share_type nft_mint_operation::calculate_fee(const fee_parameters_type &k) const -{ - return k.fee + calculate_data_fee( fc::raw::pack_size(*this), k.price_per_kbyte ); -} - -share_type nft_safe_transfer_from_operation::calculate_fee(const fee_parameters_type &k) const -{ - return k.fee + calculate_data_fee( fc::raw::pack_size(*this), k.price_per_kbyte ); -} - -share_type nft_approve_operation::calculate_fee(const fee_parameters_type &k) const -{ - return k.fee; -} - -share_type nft_set_approval_for_all_operation::calculate_fee(const fee_parameters_type &k) const -{ - return k.fee; -} - -} // namespace chain -} // namespace graphene diff --git a/libraries/net/node.cpp b/libraries/net/node.cpp index c7177251..28adc627 100644 --- a/libraries/net/node.cpp +++ b/libraries/net/node.cpp @@ -1340,7 +1340,7 @@ namespace graphene { namespace net { namespace detail { uint32_t handshaking_timeout = _peer_inactivity_timeout; fc::time_point handshaking_disconnect_threshold = fc::time_point::now() - fc::seconds(handshaking_timeout); - for( const peer_connection_ptr handshaking_peer : _handshaking_connections ) + for( const peer_connection_ptr& handshaking_peer : _handshaking_connections ) if( handshaking_peer->connection_initiation_time < handshaking_disconnect_threshold && handshaking_peer->get_last_message_received_time() < handshaking_disconnect_threshold && handshaking_peer->get_last_message_sent_time() < handshaking_disconnect_threshold ) @@ -1705,13 +1705,13 @@ namespace graphene { namespace net { namespace detail { dlog("is_already_connected_to_id returning true because the peer is us"); return true; } - for (const peer_connection_ptr active_peer : _active_connections) + for (const peer_connection_ptr& active_peer : _active_connections) if (node_id == active_peer->node_id) { dlog("is_already_connected_to_id returning true because the peer is already in our active list"); return true; } - for (const peer_connection_ptr handshaking_peer : _handshaking_connections) + for (const peer_connection_ptr& handshaking_peer : _handshaking_connections) if (node_id == handshaking_peer->node_id) { dlog("is_already_connected_to_id returning true because the peer is already in our handshaking list"); @@ -2878,7 +2878,7 @@ namespace graphene { namespace net { namespace detail { item_id advertised_item_id(item_ids_inventory_message_received.item_type, item_hash); bool we_advertised_this_item_to_a_peer = false; bool we_requested_this_item_from_a_peer = false; - for (const peer_connection_ptr peer : _active_connections) + for (const peer_connection_ptr& peer : _active_connections) { if (peer->inventory_advertised_to_peer.find(advertised_item_id) != peer->inventory_advertised_to_peer.end()) { diff --git a/libraries/net/offer.cpp b/libraries/net/offer.cpp deleted file mode 100644 index e83af3f8..00000000 --- a/libraries/net/offer.cpp +++ /dev/null @@ -1,57 +0,0 @@ -#include -#include - -namespace graphene -{ - namespace chain - { - share_type offer_operation::calculate_fee(const fee_parameters_type &schedule) const - { - return schedule.fee + calculate_data_fee( fc::raw::pack_size(*this), schedule.price_per_kbyte ); - } - - void offer_operation::validate() const - { - FC_ASSERT(item_ids.size() > 0); - FC_ASSERT(fee.amount >= 0); - FC_ASSERT(minimum_price.asset_id == maximum_price.asset_id); - FC_ASSERT(minimum_price.amount >= 0 && maximum_price.amount > 0); - FC_ASSERT(maximum_price >= minimum_price); - } - - share_type bid_operation::calculate_fee(const fee_parameters_type &schedule) const - { - share_type core_fee_required = schedule.fee; - return core_fee_required; - } - - void bid_operation::validate() const - { - FC_ASSERT(fee.amount.value >= 0); - FC_ASSERT(bid_price.amount.value >= 0); - } - - void cancel_offer_operation::validate() const - { - FC_ASSERT(fee.amount.value >= 0); - } - - share_type cancel_offer_operation::calculate_fee(const fee_parameters_type &schedule) const - { - share_type core_fee_required = schedule.fee; - return core_fee_required; - } - - void finalize_offer_operation::validate() const - { - FC_ASSERT(fee.amount.value >= 0); - } - - share_type finalize_offer_operation::calculate_fee(const fee_parameters_type &schedule) const - { - share_type core_fee_required = schedule.fee; - return core_fee_required; - } - - } // namespace chain -} // namespace graphene \ No newline at end of file diff --git a/libraries/net/peer_connection.cpp b/libraries/net/peer_connection.cpp index e5099e79..44a803d1 100644 --- a/libraries/net/peer_connection.cpp +++ b/libraries/net/peer_connection.cpp @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include diff --git a/libraries/net/small_ops.cpp b/libraries/net/small_ops.cpp deleted file mode 100644 index cba4b1b7..00000000 --- a/libraries/net/small_ops.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2019 BitShares Blockchain Foundation, and contributors. - * - * The MIT License - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#include -#include -#include -#include -#include -#include - -#include - -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::balance_claim_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::buyback_account_options ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::fba_distribute_operation ) - -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::vesting_balance_create_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::vesting_balance_withdraw_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::vesting_balance_create_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::vesting_balance_withdraw_operation ) - -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::chain_parameters ) diff --git a/libraries/plugins/bookie/bookie_plugin.cpp b/libraries/plugins/bookie/bookie_plugin.cpp index 3dd17d1b..a8c06a0d 100644 --- a/libraries/plugins/bookie/bookie_plugin.cpp +++ b/libraries/plugins/bookie/bookie_plugin.cpp @@ -64,6 +64,8 @@ class persistent_bet_object_helper : public secondary_index public: virtual ~persistent_bet_object_helper() {} + using watched_index = primary_index; + virtual void object_inserted(const object& obj) override; //virtual void object_removed( const object& obj ) override; //virtual void about_to_modify( const object& before ) override; @@ -99,6 +101,8 @@ class persistent_betting_market_object_helper : public secondary_index public: virtual ~persistent_betting_market_object_helper() {} + using watched_index = primary_index; + virtual void object_inserted(const object& obj) override; //virtual void object_removed( const object& obj ) override; //virtual void about_to_modify( const object& before ) override; @@ -134,6 +138,8 @@ class persistent_betting_market_group_object_helper : public secondary_index public: virtual ~persistent_betting_market_group_object_helper() {} + using watched_index = primary_index; + virtual void object_inserted(const object& obj) override; //virtual void object_removed( const object& obj ) override; //virtual void about_to_modify( const object& before ) override; @@ -169,6 +175,8 @@ class persistent_event_object_helper : public secondary_index public: virtual ~persistent_event_object_helper() {} + using watched_index = primary_index; + virtual void object_inserted(const object& obj) override; //virtual void object_removed( const object& obj ) override; //virtual void about_to_modify( const object& before ) override; @@ -465,45 +473,31 @@ void bookie_plugin::plugin_set_program_options(boost::program_options::options_d void bookie_plugin::plugin_initialize(const boost::program_options::variables_map& options) { - ilog("bookie plugin: plugin_startup() begin"); + ilog("bookie plugin: plugin_initialize() begin"); database().force_slow_replays(); database().applied_block.connect( [&]( const signed_block& b){ my->on_block_applied(b); } ); database().changed_objects.connect([&](const vector& changed_object_ids, const fc::flat_set& impacted_accounts){ my->on_objects_changed(changed_object_ids); }); database().new_objects.connect([this](const vector& ids, const flat_set& impacted_accounts) { my->on_objects_new(ids); }); database().removed_objects.connect([this](const vector& ids, const vector& objs, const flat_set& impacted_accounts) { my->on_objects_removed(ids); }); - //auto event_index = database().add_index >(); database().add_index >(); database().add_index >(); database().add_index >(); - const primary_index& bet_object_idx = database().get_index_type >(); - primary_index& nonconst_bet_object_idx = const_cast&>(bet_object_idx); - detail::persistent_bet_object_helper* persistent_bet_object_helper_index = nonconst_bet_object_idx.add_secondary_index(); - persistent_bet_object_helper_index->set_plugin_instance(this); - - const primary_index& betting_market_object_idx = database().get_index_type >(); - primary_index& nonconst_betting_market_object_idx = const_cast&>(betting_market_object_idx); - detail::persistent_betting_market_object_helper* persistent_betting_market_object_helper_index = nonconst_betting_market_object_idx.add_secondary_index(); - persistent_betting_market_object_helper_index->set_plugin_instance(this); - - const primary_index& betting_market_group_object_idx = database().get_index_type >(); - primary_index& nonconst_betting_market_group_object_idx = const_cast&>(betting_market_group_object_idx); - detail::persistent_betting_market_group_object_helper* persistent_betting_market_group_object_helper_index = nonconst_betting_market_group_object_idx.add_secondary_index(); - persistent_betting_market_group_object_helper_index->set_plugin_instance(this); - - const primary_index& event_object_idx = database().get_index_type >(); - primary_index& nonconst_event_object_idx = const_cast&>(event_object_idx); - detail::persistent_event_object_helper* persistent_event_object_helper_index = nonconst_event_object_idx.add_secondary_index(); - persistent_event_object_helper_index->set_plugin_instance(this); - - ilog("bookie plugin: plugin_startup() end"); + ilog("bookie plugin: plugin_initialize() end"); } void bookie_plugin::plugin_startup() { ilog("bookie plugin: plugin_startup()"); + + // Register secondary indexes + database().add_secondary_index()->set_plugin_instance(this); + database().add_secondary_index()->set_plugin_instance(this); + database().add_secondary_index()->set_plugin_instance(this); + database().add_secondary_index()->set_plugin_instance(this); + my->fill_localized_event_strings(); } diff --git a/libraries/plugins/peerplays_sidechain/bitcoin/bitcoin_transaction.cpp b/libraries/plugins/peerplays_sidechain/bitcoin/bitcoin_transaction.cpp index 1ad3643b..4b1053e0 100644 --- a/libraries/plugins/peerplays_sidechain/bitcoin/bitcoin_transaction.cpp +++ b/libraries/plugins/peerplays_sidechain/bitcoin/bitcoin_transaction.cpp @@ -180,7 +180,7 @@ void bitcoin_transaction_builder::add_out(payment_type type, int64_t amount, con const auto pubkey_bytes = bytes(pubkey.begin(), pubkey.begin() + pubkey.size()); add_out(type, amount, pubkey_bytes, front); } else { - const auto hash256 = fc::sha256::hash((char*)pubkey.begin(), pubkey.size()); + const auto hash256 = fc::sha256::hash((const char*)pubkey.begin(), pubkey.size()); const auto hash160 = fc::ripemd160::hash(hash256.data(), hash256.data_size()); add_out(type, amount, bytes(hash160.data(), hash160.data() + hash160.data_size()), front); } diff --git a/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/bitcoin_address.hpp b/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/bitcoin_address.hpp index 9ccdc781..4e6f251c 100644 --- a/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/bitcoin_address.hpp +++ b/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/bitcoin_address.hpp @@ -3,6 +3,7 @@ #include #include +using namespace graphene::protocol; namespace graphene { namespace peerplays_sidechain { namespace bitcoin { @@ -216,6 +217,7 @@ public: private: void create_redeem_script(const fc::ecc::public_key &user_key_data, const std::vector> &keys_data); +public: uint32_t latency_; }; diff --git a/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/serialize.hpp b/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/serialize.hpp index 2f1dfffe..b234f8a4 100644 --- a/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/serialize.hpp +++ b/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/serialize.hpp @@ -186,7 +186,7 @@ inline void pack(Stream &s, const bitcoin_transaction &tx, bool with_witness = t pack(s, out); if (flags & 1) { - for (const auto in : tx.vin) { + for (const auto& in : tx.vin) { pack_compact_size(s, in.scriptWitness.size()); for (const auto &sc : in.scriptWitness) pack(s, sc); @@ -294,13 +294,13 @@ inline void pack_tx_witness_signature(Stream &s, const std::vector &script { fc::datastream ps; - for (const auto in : tx.vin) + for (const auto& in : tx.vin) pack(ps, in.prevout); std::vector vec(ps.tellp()); if (vec.size()) { fc::datastream ds(vec.data(), size_t(vec.size())); - for (const auto in : tx.vin) + for (const auto& in : tx.vin) pack(ds, in.prevout); } @@ -309,13 +309,13 @@ inline void pack_tx_witness_signature(Stream &s, const std::vector &script { fc::datastream ps; - for (const auto in : tx.vin) + for (const auto& in : tx.vin) pack(ps, in.nSequence); std::vector vec(ps.tellp()); if (vec.size()) { fc::datastream ds(vec.data(), size_t(vec.size())); - for (const auto in : tx.vin) + for (const auto& in : tx.vin) pack(ds, in.nSequence); } @@ -324,13 +324,13 @@ inline void pack_tx_witness_signature(Stream &s, const std::vector &script { fc::datastream ps; - for (const auto out : tx.vout) + for (const auto& out : tx.vout) pack(ps, out); std::vector vec(ps.tellp()); if (vec.size()) { fc::datastream ds(vec.data(), size_t(vec.size())); - for (const auto out : tx.vout) + for (const auto& out : tx.vout) pack(ds, out); } diff --git a/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/sign_bitcoin_transaction.hpp b/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/sign_bitcoin_transaction.hpp index 41808562..365cbe4d 100644 --- a/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/sign_bitcoin_transaction.hpp +++ b/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/sign_bitcoin_transaction.hpp @@ -6,7 +6,7 @@ namespace graphene { namespace peerplays_sidechain { namespace bitcoin { -class bitcoin_transaction; +struct bitcoin_transaction; const secp256k1_context_t *btc_context(); diff --git a/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/types.hpp b/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/types.hpp index 36f8f0a6..659a568f 100644 --- a/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/types.hpp +++ b/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/types.hpp @@ -9,7 +9,7 @@ namespace graphene { namespace peerplays_sidechain { namespace bitcoin { -class bitcoin_transaction; +struct bitcoin_transaction; using bytes = std::vector; using accounts_keys = std::map; diff --git a/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/sidechain_net_handler_bitcoin.hpp b/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/sidechain_net_handler_bitcoin.hpp index 7284b88a..c641d49f 100644 --- a/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/sidechain_net_handler_bitcoin.hpp +++ b/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/sidechain_net_handler_bitcoin.hpp @@ -1,6 +1,7 @@ #pragma once #include + #include #include diff --git a/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/sidechain_net_manager.hpp b/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/sidechain_net_manager.hpp index 940db7d0..64518dd9 100644 --- a/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/sidechain_net_manager.hpp +++ b/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/sidechain_net_manager.hpp @@ -1,6 +1,7 @@ #pragma once #include + #include #include diff --git a/libraries/plugins/peerplays_sidechain/peerplays_sidechain_plugin.cpp b/libraries/plugins/peerplays_sidechain/peerplays_sidechain_plugin.cpp index 17eddef2..a3dc989c 100644 --- a/libraries/plugins/peerplays_sidechain/peerplays_sidechain_plugin.cpp +++ b/libraries/plugins/peerplays_sidechain/peerplays_sidechain_plugin.cpp @@ -5,11 +5,12 @@ #include #include + #include -#include #include #include #include +#include #include #include diff --git a/libraries/plugins/peerplays_sidechain/sidechain_net_handler_bitcoin.cpp b/libraries/plugins/peerplays_sidechain/sidechain_net_handler_bitcoin.cpp index d4040e7e..b47cecc5 100644 --- a/libraries/plugins/peerplays_sidechain/sidechain_net_handler_bitcoin.cpp +++ b/libraries/plugins/peerplays_sidechain/sidechain_net_handler_bitcoin.cpp @@ -13,9 +13,10 @@ #include #include -#include #include #include +#include +#include #include #include #include diff --git a/libraries/plugins/peerplays_sidechain/sidechain_net_handler_peerplays.cpp b/libraries/plugins/peerplays_sidechain/sidechain_net_handler_peerplays.cpp index 73363666..c30b6454 100644 --- a/libraries/plugins/peerplays_sidechain/sidechain_net_handler_peerplays.cpp +++ b/libraries/plugins/peerplays_sidechain/sidechain_net_handler_peerplays.cpp @@ -17,6 +17,8 @@ #include #include #include +#include +#include #include namespace graphene { namespace peerplays_sidechain { diff --git a/libraries/protocol/authority.cpp b/libraries/protocol/authority.cpp index 137568eb..47fc29b4 100644 --- a/libraries/protocol/authority.cpp +++ b/libraries/protocol/authority.cpp @@ -23,6 +23,7 @@ */ #include + #include namespace graphene { namespace protocol { diff --git a/libraries/protocol/custom_permission.cpp b/libraries/protocol/custom_permission.cpp index ac9b3daf..5084bf0b 100644 --- a/libraries/protocol/custom_permission.cpp +++ b/libraries/protocol/custom_permission.cpp @@ -81,5 +81,5 @@ share_type custom_permission_create_operation::calculate_fee(const fee_parameter return k.fee + calculate_data_fee( fc::raw::pack_size(*this), k.price_per_kbyte ); } -} // namespace chain +} // namespace protocol } // namespace graphene diff --git a/libraries/protocol/include/graphene/protocol/account.hpp b/libraries/protocol/include/graphene/protocol/account.hpp index 36b18b7e..f5b1f976 100644 --- a/libraries/protocol/include/graphene/protocol/account.hpp +++ b/libraries/protocol/include/graphene/protocol/account.hpp @@ -298,7 +298,7 @@ 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::protocol::account_create_operation::ext, (null_ext)(owner_special_authority)(active_special_authority)(buyback_options) ) +FC_REFLECT(graphene::protocol::account_create_operation::ext, (null_ext)(owner_special_authority)(active_special_authority)(buyback_options)(affiliate_distributions) ) FC_REFLECT_TYPENAME(graphene::protocol::extension) FC_REFLECT( graphene::protocol::account_create_operation, (fee)(registrar) diff --git a/libraries/protocol/include/graphene/protocol/chain_parameters.hpp b/libraries/protocol/include/graphene/protocol/chain_parameters.hpp index 8e767ac1..7dcf5fe5 100644 --- a/libraries/protocol/include/graphene/protocol/chain_parameters.hpp +++ b/libraries/protocol/include/graphene/protocol/chain_parameters.hpp @@ -22,11 +22,9 @@ * THE SOFTWARE. */ #pragma once -#include -#include + #include -#include -#include +#include #include @@ -76,7 +74,7 @@ namespace graphene { namespace protocol { chain_parameters(chain_parameters&& other); chain_parameters& operator=(const chain_parameters& other); chain_parameters& operator=(chain_parameters&& other); - /** using a smart ref breaks the circular dependency created between operations and the fee schedule */ + /** using a shared_ptr breaks the circular dependency created between operations and the fee schedule */ std::shared_ptr current_fees; ///< current schedule of fees uint8_t block_interval = GRAPHENE_DEFAULT_BLOCK_INTERVAL; ///< interval in seconds between blocks uint32_t maintenance_interval = GRAPHENE_DEFAULT_MAINTENANCE_INTERVAL; ///< interval in sections between blockchain maintenance events diff --git a/libraries/protocol/include/graphene/protocol/nft_ops.hpp b/libraries/protocol/include/graphene/protocol/nft_ops.hpp index 4805d5fb..d5ebb983 100644 --- a/libraries/protocol/include/graphene/protocol/nft_ops.hpp +++ b/libraries/protocol/include/graphene/protocol/nft_ops.hpp @@ -131,7 +131,7 @@ namespace graphene { namespace protocol { share_type calculate_fee(const fee_parameters_type &k) const; }; -} } // graphene::chain +} } // graphene::protocol FC_REFLECT( graphene::protocol::nft_metadata_create_operation::fee_parameters_type, (fee) (price_per_kbyte) ) FC_REFLECT( graphene::protocol::nft_metadata_update_operation::fee_parameters_type, (fee) ) @@ -146,3 +146,4 @@ FC_REFLECT( graphene::protocol::nft_mint_operation, (fee) (payer) (nft_metadata_ FC_REFLECT( graphene::protocol::nft_safe_transfer_from_operation, (fee) (operator_) (from) (to) (token_id) (data) (extensions) ) FC_REFLECT( graphene::protocol::nft_approve_operation, (fee) (operator_) (approved) (token_id) (extensions) ) FC_REFLECT( graphene::protocol::nft_set_approval_for_all_operation, (fee) (owner) (operator_) (approved) (extensions) ) + diff --git a/libraries/protocol/include/graphene/protocol/pts_address.hpp b/libraries/protocol/include/graphene/protocol/pts_address.hpp index e588f093..7c596b98 100644 --- a/libraries/protocol/include/graphene/protocol/pts_address.hpp +++ b/libraries/protocol/include/graphene/protocol/pts_address.hpp @@ -30,6 +30,10 @@ #include #include +#include +#include +#include + namespace fc { namespace ecc { class public_key; } } namespace graphene { namespace protocol { diff --git a/libraries/protocol/include/graphene/protocol/transaction.hpp b/libraries/protocol/include/graphene/protocol/transaction.hpp index b41d375d..aac83c95 100644 --- a/libraries/protocol/include/graphene/protocol/transaction.hpp +++ b/libraries/protocol/include/graphene/protocol/transaction.hpp @@ -239,7 +239,6 @@ FC_REFLECT_DERIVED( graphene::protocol::signed_transaction, (graphene::protocol: FC_REFLECT_DERIVED( graphene::protocol::processed_transaction, (graphene::protocol::signed_transaction), (operation_results) ) - 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/protocol/include/graphene/protocol/vesting.hpp b/libraries/protocol/include/graphene/protocol/vesting.hpp index da2bfec9..35f34bf1 100644 --- a/libraries/protocol/include/graphene/protocol/vesting.hpp +++ b/libraries/protocol/include/graphene/protocol/vesting.hpp @@ -135,7 +135,7 @@ FC_REFLECT( graphene::protocol::vesting_balance_withdraw_operation, (fee)(vestin 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::dormant_vesting_policy_initializer ) +FC_REFLECT(graphene::protocol::dormant_vesting_policy_initializer, ) FC_REFLECT_TYPENAME( graphene::protocol::vesting_policy_initializer ) FC_REFLECT_ENUM( graphene::protocol::vesting_balance_type, (normal)(gpos)(son) ) diff --git a/libraries/protocol/include/graphene/protocol/witness.hpp b/libraries/protocol/include/graphene/protocol/witness.hpp index afa2fc5c..466295c7 100644 --- a/libraries/protocol/include/graphene/protocol/witness.hpp +++ b/libraries/protocol/include/graphene/protocol/witness.hpp @@ -81,7 +81,7 @@ namespace graphene { namespace protocol { } } // graphene::protocol 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::protocol::witness_create_operation, (fee)(witness_account)(url)(block_signing_key)(initial_secret) ) FC_REFLECT( graphene::protocol::witness_update_operation::fee_parameters_type, (fee) ) FC_REFLECT( graphene::protocol::witness_update_operation, (fee)(witness)(witness_account)(new_url)(new_signing_key)(new_initial_secret) ) diff --git a/libraries/protocol/proposal.cpp b/libraries/protocol/proposal.cpp index aa2edd05..a1a40187 100644 --- a/libraries/protocol/proposal.cpp +++ b/libraries/protocol/proposal.cpp @@ -113,4 +113,3 @@ GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::proposal_de GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::proposal_create_operation ) GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::proposal_update_operation ) GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::proposal_delete_operation ) - diff --git a/libraries/protocol/small_ops.cpp b/libraries/protocol/small_ops.cpp index df234205..b870960a 100644 --- a/libraries/protocol/small_ops.cpp +++ b/libraries/protocol/small_ops.cpp @@ -65,3 +65,4 @@ FC_IMPLEMENT_DERIVED_EXCEPTION( invalid_committee_approval, transaction_exceptio FC_IMPLEMENT_DERIVED_EXCEPTION( insufficient_fee, transaction_exception, 4010007, "insufficient fee" ) } } // graphene::protocol + diff --git a/libraries/protocol/transaction.cpp b/libraries/protocol/transaction.cpp index c656a53a..491a340c 100644 --- a/libraries/protocol/transaction.cpp +++ b/libraries/protocol/transaction.cpp @@ -265,8 +265,9 @@ void verify_authority( const vector& ops, const flat_set required_active; flat_set required_owner; vector other; + flat_set available_keys; - sign_state s(sigs,get_active); + sign_state s(sigs,get_active, available_keys); s.max_recursion = max_recursion_depth; for( auto& id : active_aprovals ) s.approved_by.insert( id ); @@ -450,10 +451,11 @@ void signed_transaction::verify_authority( bool ignore_custom_operation_required_auths, uint32_t max_recursion )const { try { - graphene::protocol::verify_authority( operations, get_signature_keys( chain_id ), get_active, get_owner, get_custom, ignore_custom_operation_required_auths, max_recursion ); + graphene::protocol::verify_authority( operations, get_signature_keys( chain_id ), get_active, get_owner, + get_custom, ignore_custom_operation_required_auths, max_recursion ); } FC_CAPTURE_AND_RETHROW( (*this) ) } -} } // graphene::chain +} } // graphene::protocol GRAPHENE_EXTERNAL_SERIALIZATION(/*not extern*/, graphene::protocol::transaction) GRAPHENE_EXTERNAL_SERIALIZATION(/*not extern*/, graphene::protocol::signed_transaction) diff --git a/programs/build_helpers/check_reflect.py b/programs/build_helpers/check_reflect.py index 0f41f355..58b2851c 100755 --- a/programs/build_helpers/check_reflect.py +++ b/programs/build_helpers/check_reflect.py @@ -108,8 +108,8 @@ def validate_members(name2members_ref, name2members_test): error_items.append(name) print("") print("error in", name) - print("doxygen:", name2members_ref[name]) - print("fc :", name2members_test[name]) + print("doxygen:", sorted(name2members_ref[name])) + print("fc :", sorted(name2members_test[name])) else: ok_items.append(name) return diff --git a/programs/cli_wallet/main.cpp b/programs/cli_wallet/main.cpp index bb48cd0e..bc8e8b10 100644 --- a/programs/cli_wallet/main.cpp +++ b/programs/cli_wallet/main.cpp @@ -242,10 +242,9 @@ int main( int argc, char** argv ) if( options.count( "rpc-tls-certificate" ) ) cert_pem = options.at("rpc-tls-certificate").as(); - std::shared_ptr _websocket_tls_server; + auto _websocket_tls_server = std::make_shared(cert_pem, ""); if( options.count("rpc-tls-endpoint") ) { - _websocket_tls_server = std::make_shared(cert_pem, ""); _websocket_tls_server->on_connection([&]( const fc::http::websocket_connection_ptr& c ){ auto wsc = std::make_shared(c, GRAPHENE_MAX_NESTED_OBJECTS); wsc->register_api(wapi); diff --git a/tests/betting/betting_tests.cpp b/tests/betting/betting_tests.cpp index b257d7db..5ac3d8c8 100644 --- a/tests/betting/betting_tests.cpp +++ b/tests/betting/betting_tests.cpp @@ -132,115 +132,6 @@ using namespace graphene::chain::keywords; // 1.58 50:29 | 2.34 50:67 | 4.6 5:18 | 25 1:24 | 430 1:429 | // 1.59 100:59 | 2.36 25:34 | 4.7 10:37 -template object_id to_id(const O& o) { return o.id; } - -#define CREATE_ICE_HOCKEY_BETTING_MARKET(never_in_play, delay_before_settling) \ - create_sport({{"en", "Ice Hockey"}, {"zh_Hans", "冰球"}, {"ja", "アイスホッケー"}}); \ - generate_blocks(1); \ - const auto ice_hockey_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - create_event_group({{"en", "NHL"}, {"zh_Hans", "國家冰球聯盟"}, {"ja", "ナショナルホッケーリーグ"}}, ice_hockey_id); \ - generate_blocks(1); \ - const auto nhl_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - create_event({{"en", "Washington Capitals/Chicago Blackhawks"}, {"zh_Hans", "華盛頓首都隊/芝加哥黑鷹"}, {"ja", "ワシントン・キャピタルズ/シカゴ・ブラックホークス"}}, {{"en", "2016-17"}}, nhl_id); \ - generate_blocks(1); \ - const auto capitals_vs_blackhawks_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - create_betting_market_rules({{"en", "NHL Rules v1.0"}}, {{"en", "The winner will be the team with the most points at the end of the game. The team with fewer points will not be the winner."}}); \ - generate_blocks(1); \ - const auto betting_market_rules_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - create_betting_market_group({{"en", "Moneyline"}}, capitals_vs_blackhawks_id, betting_market_rules_id, asset_id_type(), never_in_play, delay_before_settling); \ - generate_blocks(1); \ - const auto moneyline_betting_markets_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - create_betting_market(moneyline_betting_markets_id, {{"en", "Washington Capitals win"}}); \ - generate_blocks(1); \ - const auto capitals_win_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - create_betting_market(moneyline_betting_markets_id, {{"en", "Chicago Blackhawks win"}}); \ - generate_blocks(1); \ - const auto blackhawks_win_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - (void)capitals_win_market_id; (void)blackhawks_win_market_id; - -// create the basic betting market, plus groups for the first, second, and third period results -#define CREATE_EXTENDED_ICE_HOCKEY_BETTING_MARKET(never_in_play, delay_before_settling) \ - CREATE_ICE_HOCKEY_BETTING_MARKET(never_in_play, delay_before_settling) \ - create_betting_market_group({{"en", "First Period Result"}}, capitals_vs_blackhawks_id, betting_market_rules_id, asset_id_type(), never_in_play, delay_before_settling); \ - generate_blocks(1); \ - const auto first_period_result_betting_markets_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - create_betting_market(first_period_result_betting_markets_id, {{"en", "Washington Capitals win"}}); \ - generate_blocks(1); \ - const auto first_period_capitals_win_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - create_betting_market(first_period_result_betting_markets_id, {{"en", "Chicago Blackhawks win"}}); \ - generate_blocks(1); \ - const auto first_period_blackhawks_win_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - (void)first_period_capitals_win_market_id; (void)first_period_blackhawks_win_market_id; \ - \ - create_betting_market_group({{"en", "Second Period Result"}}, capitals_vs_blackhawks_id, betting_market_rules_id, asset_id_type(), never_in_play, delay_before_settling); \ - generate_blocks(1); \ - const auto second_period_result_betting_markets_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - create_betting_market(second_period_result_betting_markets_id, {{"en", "Washington Capitals win"}}); \ - generate_blocks(1); \ - const auto second_period_capitals_win_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - create_betting_market(second_period_result_betting_markets_id, {{"en", "Chicago Blackhawks win"}}); \ - generate_blocks(1); \ - const auto second_period_blackhawks_win_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - (void)second_period_capitals_win_market_id; (void)second_period_blackhawks_win_market_id; \ - \ - create_betting_market_group({{"en", "Third Period Result"}}, capitals_vs_blackhawks_id, betting_market_rules_id, asset_id_type(), never_in_play, delay_before_settling); \ - generate_blocks(1); \ - const auto third_period_result_betting_markets_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - create_betting_market(third_period_result_betting_markets_id, {{"en", "Washington Capitals win"}}); \ - generate_blocks(1); \ - const auto third_period_capitals_win_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - create_betting_market(third_period_result_betting_markets_id, {{"en", "Chicago Blackhawks win"}}); \ - generate_blocks(1); \ - const auto third_period_blackhawks_win_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - (void)third_period_capitals_win_market_id; (void)third_period_blackhawks_win_market_id; - -#define CREATE_TENNIS_BETTING_MARKET() \ - create_betting_market_rules({{"en", "Tennis Rules v1.0"}}, {{"en", "The winner is the player who wins the last ball in the match."}}); \ - generate_blocks(1); \ - const auto tennis_rules_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - create_sport({{"en", "Tennis"}}); \ - generate_blocks(1); \ - const auto tennis_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - create_event_group({{"en", "Wimbledon"}}, tennis_id); \ - generate_blocks(1); \ - const auto wimbledon_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - create_event({{"en", "R. Federer/T. Berdych"}}, {{"en", "2017"}}, wimbledon_id); \ - generate_blocks(1); \ - const auto berdych_vs_federer_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - create_event({{"en", "M. Cilic/S. Querrye"}}, {{"en", "2017"}}, wimbledon_id); \ - generate_blocks(1); \ - const auto cilic_vs_querrey_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - create_betting_market_group({{"en", "Moneyline 1st sf"}}, berdych_vs_federer_id, tennis_rules_id, asset_id_type(), false, 0); \ - generate_blocks(1); \ - const auto moneyline_berdych_vs_federer_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - create_betting_market_group({{"en", "Moneyline 2nd sf"}}, cilic_vs_querrey_id, tennis_rules_id, asset_id_type(), false, 0); \ - generate_blocks(1); \ - const auto moneyline_cilic_vs_querrey_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - create_betting_market(moneyline_berdych_vs_federer_id, {{"en", "T. Berdych defeats R. Federer"}}); \ - generate_blocks(1); \ - const auto berdych_wins_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - create_betting_market(moneyline_berdych_vs_federer_id, {{"en", "R. Federer defeats T. Berdych"}}); \ - generate_blocks(1); \ - const auto federer_wins_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - create_betting_market(moneyline_cilic_vs_querrey_id, {{"en", "M. Cilic defeats S. Querrey"}}); \ - generate_blocks(1); \ - const auto cilic_wins_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - create_betting_market(moneyline_cilic_vs_querrey_id, {{"en", "S. Querrey defeats M. Cilic"}});\ - generate_blocks(1); \ - const auto querrey_wins_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - create_event({{"en", "R. Federer/M. Cilic"}}, {{"en", "2017"}}, wimbledon_id); \ - generate_blocks(1); \ - const auto cilic_vs_federer_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - create_betting_market_group({{"en", "Moneyline final"}}, cilic_vs_federer_id, tennis_rules_id, asset_id_type(), false, 0); \ - generate_blocks(1); \ - const auto moneyline_cilic_vs_federer_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - create_betting_market(moneyline_cilic_vs_federer_id, {{"en", "R. Federer defeats M. Cilic"}}); \ - generate_blocks(1); \ - const auto federer_wins_final_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - create_betting_market(moneyline_cilic_vs_federer_id, {{"en", "M. Cilic defeats R. Federer"}}); \ - generate_blocks(1); \ - const auto cilic_wins_final_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - (void)federer_wins_market_id;(void)cilic_wins_market_id;(void)federer_wins_final_market_id; (void)cilic_wins_final_market_id; (void)berdych_wins_market_id; (void)querrey_wins_market_id; BOOST_FIXTURE_TEST_SUITE( betting_tests, database_fixture ) @@ -2513,6 +2404,7 @@ BOOST_AUTO_TEST_CASE(event_driven_progression_errors_2) // as soon as a block is generated, the betting market group will settle, and the market // and group will cease to exist. The event should transition to "settled", then removed fc::variants objects_from_bookie = bookie_api.get_objects({capitals_vs_blackhawks_id}); + wdump((objects_from_bookie)(capitals_vs_blackhawks_id(db))); BOOST_CHECK_EQUAL(objects_from_bookie[0]["status"].as(1), "settled"); // we can't go back to upcoming, in_progress, frozen, or finished once we're canceled. diff --git a/tests/common/betting_test_markets.hpp b/tests/common/betting_test_markets.hpp index f67dc067..94c5b1c8 100644 --- a/tests/common/betting_test_markets.hpp +++ b/tests/common/betting_test_markets.hpp @@ -30,113 +30,115 @@ using namespace graphene::chain; +template object_id to_id(const O& o) { return o.id; } + #define CREATE_ICE_HOCKEY_BETTING_MARKET(never_in_play, delay_before_settling) \ create_sport({{"en", "Ice Hockey"}, {"zh_Hans", "冰球"}, {"ja", "アイスホッケー"}}); \ generate_blocks(1); \ - const sport_object& ice_hockey = *db.get_index_type().indices().get().rbegin(); \ - create_event_group({{"en", "NHL"}, {"zh_Hans", "國家冰球聯盟"}, {"ja", "ナショナルホッケーリーグ"}}, ice_hockey.id); \ + const auto ice_hockey_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_event_group({{"en", "NHL"}, {"zh_Hans", "國家冰球聯盟"}, {"ja", "ナショナルホッケーリーグ"}}, ice_hockey_id); \ generate_blocks(1); \ - const event_group_object& nhl = *db.get_index_type().indices().get().rbegin(); \ - create_event({{"en", "Washington Capitals/Chicago Blackhawks"}, {"zh_Hans", "華盛頓首都隊/芝加哥黑鷹"}, {"ja", "ワシントン・キャピタルズ/シカゴ・ブラックホークス"}}, {{"en", "2016-17"}}, nhl.id); \ + const auto nhl_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_event({{"en", "Washington Capitals/Chicago Blackhawks"}, {"zh_Hans", "華盛頓首都隊/芝加哥黑鷹"}, {"ja", "ワシントン・キャピタルズ/シカゴ・ブラックホークス"}}, {{"en", "2016-17"}}, nhl_id); \ generate_blocks(1); \ - const event_object& capitals_vs_blackhawks = *db.get_index_type().indices().get().rbegin(); \ + const auto capitals_vs_blackhawks_id = to_id(*db.get_index_type().indices().get().rbegin()); \ create_betting_market_rules({{"en", "NHL Rules v1.0"}}, {{"en", "The winner will be the team with the most points at the end of the game. The team with fewer points will not be the winner."}}); \ generate_blocks(1); \ - const betting_market_rules_object& betting_market_rules = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market_group({{"en", "Moneyline"}}, capitals_vs_blackhawks.id, betting_market_rules.id, asset_id_type(), never_in_play, delay_before_settling); \ + const auto betting_market_rules_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market_group({{"en", "Moneyline"}}, capitals_vs_blackhawks_id, betting_market_rules_id, asset_id_type(), never_in_play, delay_before_settling); \ generate_blocks(1); \ - const betting_market_group_object& moneyline_betting_markets = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(moneyline_betting_markets.id, {{"en", "Washington Capitals win"}}); \ + const auto moneyline_betting_markets_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(moneyline_betting_markets_id, {{"en", "Washington Capitals win"}}); \ generate_blocks(1); \ - const betting_market_object& capitals_win_market = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(moneyline_betting_markets.id, {{"en", "Chicago Blackhawks win"}}); \ + const auto capitals_win_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(moneyline_betting_markets_id, {{"en", "Chicago Blackhawks win"}}); \ generate_blocks(1); \ - const betting_market_object& blackhawks_win_market = *db.get_index_type().indices().get().rbegin(); \ - (void)capitals_win_market; (void)blackhawks_win_market; + const auto blackhawks_win_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + (void)capitals_win_market_id; (void)blackhawks_win_market_id; // create the basic betting market, plus groups for the first, second, and third period results #define CREATE_EXTENDED_ICE_HOCKEY_BETTING_MARKET(never_in_play, delay_before_settling) \ CREATE_ICE_HOCKEY_BETTING_MARKET(never_in_play, delay_before_settling) \ - create_betting_market_group({{"en", "First Period Result"}}, capitals_vs_blackhawks.id, betting_market_rules.id, asset_id_type(), never_in_play, delay_before_settling); \ + create_betting_market_group({{"en", "First Period Result"}}, capitals_vs_blackhawks_id, betting_market_rules_id, asset_id_type(), never_in_play, delay_before_settling); \ generate_blocks(1); \ - const betting_market_group_object& first_period_result_betting_markets = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(first_period_result_betting_markets.id, {{"en", "Washington Capitals win"}}); \ + const auto first_period_result_betting_markets_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(first_period_result_betting_markets_id, {{"en", "Washington Capitals win"}}); \ generate_blocks(1); \ - const betting_market_object& first_period_capitals_win_market = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(first_period_result_betting_markets.id, {{"en", "Chicago Blackhawks win"}}); \ + const auto first_period_capitals_win_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(first_period_result_betting_markets_id, {{"en", "Chicago Blackhawks win"}}); \ generate_blocks(1); \ - const betting_market_object& first_period_blackhawks_win_market = *db.get_index_type().indices().get().rbegin(); \ - (void)first_period_capitals_win_market; (void)first_period_blackhawks_win_market; \ + const auto first_period_blackhawks_win_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + (void)first_period_capitals_win_market_id; (void)first_period_blackhawks_win_market_id; \ \ - create_betting_market_group({{"en", "Second Period Result"}}, capitals_vs_blackhawks.id, betting_market_rules.id, asset_id_type(), never_in_play, delay_before_settling); \ + create_betting_market_group({{"en", "Second Period Result"}}, capitals_vs_blackhawks_id, betting_market_rules_id, asset_id_type(), never_in_play, delay_before_settling); \ generate_blocks(1); \ - const betting_market_group_object& second_period_result_betting_markets = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(second_period_result_betting_markets.id, {{"en", "Washington Capitals win"}}); \ + const auto second_period_result_betting_markets_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(second_period_result_betting_markets_id, {{"en", "Washington Capitals win"}}); \ generate_blocks(1); \ - const betting_market_object& second_period_capitals_win_market = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(second_period_result_betting_markets.id, {{"en", "Chicago Blackhawks win"}}); \ + const auto second_period_capitals_win_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(second_period_result_betting_markets_id, {{"en", "Chicago Blackhawks win"}}); \ generate_blocks(1); \ - const betting_market_object& second_period_blackhawks_win_market = *db.get_index_type().indices().get().rbegin(); \ - (void)second_period_capitals_win_market; (void)second_period_blackhawks_win_market; \ + const auto second_period_blackhawks_win_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + (void)second_period_capitals_win_market_id; (void)second_period_blackhawks_win_market_id; \ \ - create_betting_market_group({{"en", "Third Period Result"}}, capitals_vs_blackhawks.id, betting_market_rules.id, asset_id_type(), never_in_play, delay_before_settling); \ + create_betting_market_group({{"en", "Third Period Result"}}, capitals_vs_blackhawks_id, betting_market_rules_id, asset_id_type(), never_in_play, delay_before_settling); \ generate_blocks(1); \ - const betting_market_group_object& third_period_result_betting_markets = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(third_period_result_betting_markets.id, {{"en", "Washington Capitals win"}}); \ + const auto third_period_result_betting_markets_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(third_period_result_betting_markets_id, {{"en", "Washington Capitals win"}}); \ generate_blocks(1); \ - const betting_market_object& third_period_capitals_win_market = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(third_period_result_betting_markets.id, {{"en", "Chicago Blackhawks win"}}); \ + const auto third_period_capitals_win_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(third_period_result_betting_markets_id, {{"en", "Chicago Blackhawks win"}}); \ generate_blocks(1); \ - const betting_market_object& third_period_blackhawks_win_market = *db.get_index_type().indices().get().rbegin(); \ - (void)third_period_capitals_win_market; (void)third_period_blackhawks_win_market; + const auto third_period_blackhawks_win_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + (void)third_period_capitals_win_market_id; (void)third_period_blackhawks_win_market_id; #define CREATE_TENNIS_BETTING_MARKET() \ create_betting_market_rules({{"en", "Tennis Rules v1.0"}}, {{"en", "The winner is the player who wins the last ball in the match."}}); \ generate_blocks(1); \ - const betting_market_rules_object& tennis_rules = *db.get_index_type().indices().get().rbegin(); \ + const auto tennis_rules_id = to_id(*db.get_index_type().indices().get().rbegin()); \ create_sport({{"en", "Tennis"}}); \ generate_blocks(1); \ - const sport_object& tennis = *db.get_index_type().indices().get().rbegin(); \ - create_event_group({{"en", "Wimbledon"}}, tennis.id); \ + const auto tennis_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_event_group({{"en", "Wimbledon"}}, tennis_id); \ generate_blocks(1); \ - const event_group_object& wimbledon = *db.get_index_type().indices().get().rbegin(); \ - create_event({{"en", "R. Federer/T. Berdych"}}, {{"en", "2017"}}, wimbledon.id); \ + const auto wimbledon_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_event({{"en", "R. Federer/T. Berdych"}}, {{"en", "2017"}}, wimbledon_id); \ generate_blocks(1); \ - const event_object& berdych_vs_federer = *db.get_index_type().indices().get().rbegin(); \ - create_event({{"en", "M. Cilic/S. Querrye"}}, {{"en", "2017"}}, wimbledon.id); \ + const auto berdych_vs_federer_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_event({{"en", "M. Cilic/S. Querrye"}}, {{"en", "2017"}}, wimbledon_id); \ generate_blocks(1); \ - const event_object& cilic_vs_querrey = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market_group({{"en", "Moneyline 1st sf"}}, berdych_vs_federer.id, tennis_rules.id, asset_id_type(), false, 0); \ + const auto cilic_vs_querrey_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market_group({{"en", "Moneyline 1st sf"}}, berdych_vs_federer_id, tennis_rules_id, asset_id_type(), false, 0); \ generate_blocks(1); \ - const betting_market_group_object& moneyline_berdych_vs_federer = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market_group({{"en", "Moneyline 2nd sf"}}, cilic_vs_querrey.id, tennis_rules.id, asset_id_type(), false, 0); \ + const auto moneyline_berdych_vs_federer_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market_group({{"en", "Moneyline 2nd sf"}}, cilic_vs_querrey_id, tennis_rules_id, asset_id_type(), false, 0); \ generate_blocks(1); \ - const betting_market_group_object& moneyline_cilic_vs_querrey = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(moneyline_berdych_vs_federer.id, {{"en", "T. Berdych defeats R. Federer"}}); \ + const auto moneyline_cilic_vs_querrey_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(moneyline_berdych_vs_federer_id, {{"en", "T. Berdych defeats R. Federer"}}); \ generate_blocks(1); \ - const betting_market_object& berdych_wins_market = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(moneyline_berdych_vs_federer.id, {{"en", "R. Federer defeats T. Berdych"}}); \ + const auto berdych_wins_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(moneyline_berdych_vs_federer_id, {{"en", "R. Federer defeats T. Berdych"}}); \ generate_blocks(1); \ - const betting_market_object& federer_wins_market = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(moneyline_cilic_vs_querrey.id, {{"en", "M. Cilic defeats S. Querrey"}}); \ + const auto federer_wins_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(moneyline_cilic_vs_querrey_id, {{"en", "M. Cilic defeats S. Querrey"}}); \ generate_blocks(1); \ - const betting_market_object& cilic_wins_market = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(moneyline_cilic_vs_querrey.id, {{"en", "S. Querrey defeats M. Cilic"}});\ + const auto cilic_wins_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(moneyline_cilic_vs_querrey_id, {{"en", "S. Querrey defeats M. Cilic"}});\ generate_blocks(1); \ - const betting_market_object& querrey_wins_market = *db.get_index_type().indices().get().rbegin(); \ - create_event({{"en", "R. Federer/M. Cilic"}}, {{"en", "2017"}}, wimbledon.id); \ + const auto querrey_wins_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_event({{"en", "R. Federer/M. Cilic"}}, {{"en", "2017"}}, wimbledon_id); \ generate_blocks(1); \ - const event_object& cilic_vs_federer = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market_group({{"en", "Moneyline final"}}, cilic_vs_federer.id, tennis_rules.id, asset_id_type(), false, 0); \ + const auto cilic_vs_federer_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market_group({{"en", "Moneyline final"}}, cilic_vs_federer_id, tennis_rules_id, asset_id_type(), false, 0); \ generate_blocks(1); \ - const betting_market_group_object& moneyline_cilic_vs_federer = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(moneyline_cilic_vs_federer.id, {{"en", "R. Federer defeats M. Cilic"}}); \ + const auto moneyline_cilic_vs_federer_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(moneyline_cilic_vs_federer_id, {{"en", "R. Federer defeats M. Cilic"}}); \ generate_blocks(1); \ - const betting_market_object& federer_wins_final_market = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(moneyline_cilic_vs_federer.id, {{"en", "M. Cilic defeats R. Federer"}}); \ + const auto federer_wins_final_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(moneyline_cilic_vs_federer_id, {{"en", "M. Cilic defeats R. Federer"}}); \ generate_blocks(1); \ - const betting_market_object& cilic_wins_final_market = *db.get_index_type().indices().get().rbegin(); \ - (void)federer_wins_market;(void)cilic_wins_market;(void)federer_wins_final_market; (void)cilic_wins_final_market; (void)berdych_wins_market; (void)querrey_wins_market; + const auto cilic_wins_final_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + (void)federer_wins_market_id;(void)cilic_wins_market_id;(void)federer_wins_final_market_id; (void)cilic_wins_final_market_id; (void)berdych_wins_market_id; (void)querrey_wins_market_id; // set up a fixture that places a series of two matched bets, we'll use this fixture to verify // the result in all three possible outcomes @@ -149,25 +151,23 @@ struct simple_bet_test_fixture : database_fixture { { ACTORS( (alice)(bob) ); CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0); + capitals_win_betting_market_id = capitals_win_market_id; + blackhawks_win_betting_market_id = blackhawks_win_market_id; // give alice and bob 10k each transfer(account_id_type(), alice_id, asset(10000)); transfer(account_id_type(), bob_id, asset(10000)); // place bets at 10:1 - place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(100, asset_id_type()), 11 * GRAPHENE_BETTING_ODDS_PRECISION); - place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(1000, asset_id_type()), 11 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(100, asset_id_type()), 11 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(bob_id, capitals_win_market_id, bet_type::lay, asset(1000, asset_id_type()), 11 * GRAPHENE_BETTING_ODDS_PRECISION); // reverse positions at 1:1 - place_bet(alice_id, capitals_win_market.id, bet_type::lay, asset(1100, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); - place_bet(bob_id, capitals_win_market.id, bet_type::back, asset(1100, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); - - capitals_win_betting_market_id = capitals_win_market.id; - blackhawks_win_betting_market_id = blackhawks_win_market.id; - moneyline_betting_markets_id = moneyline_betting_markets.id; + place_bet(alice_id, capitals_win_market_id, bet_type::lay, asset(1100, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(bob_id, capitals_win_market_id, bet_type::back, asset(1100, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); // close betting to prepare for the next operation which will be grading or cancel - update_betting_market_group(moneyline_betting_markets.id, graphene::chain::keywords::_status = betting_market_group_status::closed); + update_betting_market_group(moneyline_betting_markets_id, graphene::chain::keywords::_status = betting_market_group_status::closed); generate_blocks(1); } }; diff --git a/tests/common/database_fixture.cpp b/tests/common/database_fixture.cpp index d7895f52..459f02f1 100644 --- a/tests/common/database_fixture.cpp +++ b/tests/common/database_fixture.cpp @@ -1615,6 +1615,7 @@ void database_fixture::resolve_betting_market_group(betting_market_group_id_type betting_market_group_resolve_operation betting_market_group_resolve_op; betting_market_group_resolve_op.betting_market_group_id = betting_market_group_id; betting_market_group_resolve_op.resolutions = resolutions; + wdump((resolutions)(betting_market_group_resolve_op)); process_operation_by_witnesses(betting_market_group_resolve_op); } FC_CAPTURE_AND_RETHROW( (betting_market_group_id)(resolutions) ) } diff --git a/tests/peerplays_sidechain/bitcoin_sign_tests.cpp b/tests/peerplays_sidechain/bitcoin_sign_tests.cpp index 501b9d44..87244fd5 100644 --- a/tests/peerplays_sidechain/bitcoin_sign_tests.cpp +++ b/tests/peerplays_sidechain/bitcoin_sign_tests.cpp @@ -193,7 +193,8 @@ BOOST_AUTO_TEST_CASE(weighted_multisig_spend_test) { int32_t hash_type = 1; // implement SIGHASH_ALL scheme for (auto &key : priv_keys) { - bytes key_data(key.get_secret().data(), key.get_secret().data() + key.get_secret().data_size()); + auto secret = key.get_secret(); + bytes key_data(secret.data(), secret.data() + secret.data_size()); std::vector sigs = sign_witness_transaction_part(tx, {redeem_script}, {amount}, key_data, btc_context(), hash_type); // insert signatures in reverse order tx.vin[0].scriptWitness.insert(tx.vin[0].scriptWitness.begin(), sigs[0]); @@ -335,7 +336,8 @@ BOOST_AUTO_TEST_CASE(user_sig_one_or_weighted_multisig_spend_test) { uint64_t amount = 10000; int32_t hash_type = 1; // implement SIGHASH_ALL scheme - bytes key_data(user_key.get_secret().data(), user_key.get_secret().data() + user_key.get_secret().data_size()); + auto secret = user_key.get_secret(); + bytes key_data(secret.data(), secret.data() + secret.data_size()); std::vector sigs = sign_witness_transaction_part(tx, {redeem_script}, {amount}, key_data, btc_context(), hash_type); tx.vin[0].scriptWitness.push_back(sigs[0]); sign_witness_transaction_finalize(tx, {redeem_script}, false); @@ -369,7 +371,8 @@ BOOST_AUTO_TEST_CASE(user_sig_one_or_weighted_multisig_spend_test) { int32_t hash_type = 1; // implement SIGHASH_ALL scheme for (auto &key : priv_keys) { - bytes key_data(key.get_secret().data(), key.get_secret().data() + key.get_secret().data_size()); + auto secret = key.get_secret(); + bytes key_data(secret.data(), secret.data() + secret.data_size()); std::vector sigs = sign_witness_transaction_part(tx, {redeem_script}, {amount}, key_data, btc_context(), hash_type); // insert signatures in reverse order tx.vin[0].scriptWitness.insert(tx.vin[0].scriptWitness.begin(), sigs[0]); @@ -435,7 +438,8 @@ BOOST_AUTO_TEST_CASE(user_sig_timelocked_one_or_weighted_multisig_spend_test) { uint64_t amount = 10000; int32_t hash_type = 1; // implement SIGHASH_ALL scheme - bytes key_data(user_key.get_secret().data(), user_key.get_secret().data() + user_key.get_secret().data_size()); + auto secret = user_key.get_secret(); + bytes key_data(secret.data(), secret.data() + secret.data_size()); std::vector sigs = sign_witness_transaction_part(tx, {redeem_script}, {amount}, key_data, btc_context(), hash_type); tx.vin[0].scriptWitness.push_back(sigs[0]); sign_witness_transaction_finalize(tx, {redeem_script}, false); diff --git a/tests/tests/account_role_tests.cpp b/tests/tests/account_role_tests.cpp index 17142154..b85ec96d 100644 --- a/tests/tests/account_role_tests.cpp +++ b/tests/tests/account_role_tests.cpp @@ -16,6 +16,9 @@ #include #include +#include +#include + #include #include diff --git a/tests/tests/affiliate_tests.cpp b/tests/tests/affiliate_tests.cpp index 804d9e8a..ad34b384 100644 --- a/tests/tests/affiliate_tests.cpp +++ b/tests/tests/affiliate_tests.cpp @@ -524,17 +524,17 @@ BOOST_AUTO_TEST_CASE( bookie_payout_test ) CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0); // place bets at 10:1 - place_bet(ath.paula_id, capitals_win_market.id, bet_type::back, asset(10000, asset_id_type()), 11 * GRAPHENE_BETTING_ODDS_PRECISION); - place_bet(ath.penny_id, capitals_win_market.id, bet_type::lay, asset(100000, asset_id_type()), 11 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(ath.paula_id, capitals_win_market_id, bet_type::back, asset(10000, asset_id_type()), 11 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(ath.penny_id, capitals_win_market_id, bet_type::lay, asset(100000, asset_id_type()), 11 * GRAPHENE_BETTING_ODDS_PRECISION); // reverse positions at 1:1 - place_bet(ath.paula_id, capitals_win_market.id, bet_type::lay, asset(110000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); - place_bet(ath.penny_id, capitals_win_market.id, bet_type::back, asset(110000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(ath.paula_id, capitals_win_market_id, bet_type::lay, asset(110000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(ath.penny_id, capitals_win_market_id, bet_type::back, asset(110000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); - update_betting_market_group(moneyline_betting_markets.id, graphene::chain::keywords::_status = betting_market_group_status::closed); - resolve_betting_market_group(moneyline_betting_markets.id, - {{capitals_win_market.id, betting_market_resolution_type::win}, - {blackhawks_win_market.id, betting_market_resolution_type::not_win}}); + update_betting_market_group(moneyline_betting_markets_id, graphene::chain::keywords::_status = betting_market_group_status::closed); + resolve_betting_market_group(moneyline_betting_markets_id, + {{capitals_win_market_id, betting_market_resolution_type::win}, + {blackhawks_win_market_id, betting_market_resolution_type::not_win}}); generate_block(); uint16_t rake_fee_percentage = db.get_global_properties().parameters.betting_rake_fee_percentage(); @@ -559,10 +559,10 @@ BOOST_AUTO_TEST_CASE( bookie_payout_test ) issue_uia( ath.paula_id, asset( 1000000, btc_id ) ); issue_uia( ath.petra_id, asset( 1000000, btc_id ) ); - create_event({{"en", "Washington Capitals/Chicago Blackhawks"}, {"zh_Hans", "華盛頓首都隊/芝加哥黑鷹"}, {"ja", "ワシントン・キャピタルズ/シカゴ・ブラックホークス"}}, {{"en", "2016-17"}}, nhl.id); \ + create_event({{"en", "Washington Capitals/Chicago Blackhawks"}, {"zh_Hans", "華盛頓首都隊/芝加哥黑鷹"}, {"ja", "ワシントン・キャピタルズ/シカゴ・ブラックホークス"}}, {{"en", "2016-17"}}, nhl_id); \ generate_blocks(1); \ const event_object& capitals_vs_blackhawks2 = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market_group({{"en", "Moneyline"}}, capitals_vs_blackhawks2.id, betting_market_rules.id, btc_id, false, 0); + create_betting_market_group({{"en", "Moneyline"}}, capitals_vs_blackhawks2.id, betting_market_rules_id, btc_id, false, 0); generate_blocks(1); const betting_market_group_object& moneyline_betting_markets2 = *db.get_index_type().indices().get().rbegin(); create_betting_market(moneyline_betting_markets2.id, {{"en", "Washington Capitals win"}}); diff --git a/tests/tests/custom_permission_tests.cpp b/tests/tests/custom_permission_tests.cpp index eb6694bb..b8a111f6 100644 --- a/tests/tests/custom_permission_tests.cpp +++ b/tests/tests/custom_permission_tests.cpp @@ -1,4 +1,3 @@ -#include #include #include #include diff --git a/tests/tests/sidechain_addresses_test.cpp b/tests/tests/sidechain_addresses_test.cpp index a58c051a..99d28d4b 100644 --- a/tests/tests/sidechain_addresses_test.cpp +++ b/tests/tests/sidechain_addresses_test.cpp @@ -5,6 +5,7 @@ #include #include #include + #include using namespace graphene::chain; diff --git a/tests/tests/son_wallet_tests.cpp b/tests/tests/son_wallet_tests.cpp index c6508268..dcde84c8 100644 --- a/tests/tests/son_wallet_tests.cpp +++ b/tests/tests/son_wallet_tests.cpp @@ -4,6 +4,7 @@ #include #include + #include using namespace graphene;