diff --git a/genesis.json b/genesis.json index 1f990543..aedf53bf 100644 --- a/genesis.json +++ b/genesis.json @@ -234,7 +234,9 @@ "fee": 100000 } ],[ - 55,{} + 55,{ + "fee": 100000 + } ],[ 56,{ "fee": 100000 @@ -244,17 +246,17 @@ "fee": 100000 } ],[ - 58,{} - ],[ - 59,{ + 58,{ "fee": 100000 } + ],[ + 59,{} ] ], "scale": 10000 }, "block_interval": 5, - "maintenance_interval": 6000, + "maintenance_interval": 600, "maintenance_skip_slots": 3, "committee_proposal_review_period": 900, "maximum_transaction_size": 2048, diff --git a/libraries/app/impacted.cpp b/libraries/app/impacted.cpp index be4440fe..353810e4 100644 --- a/libraries/app/impacted.cpp +++ b/libraries/app/impacted.cpp @@ -222,7 +222,6 @@ struct get_impacted_account_visitor void operator()( const betting_market_create_operation& op ) {} void operator()( const betting_market_update_operation& op ) {} void operator()( const betting_market_group_resolve_operation& op ) {} - void operator()( const betting_market_group_freeze_operation& op ) {} void operator()( const betting_market_group_cancel_unmatched_bets_operation& op ) {} void operator()( const bet_place_operation& op ) diff --git a/libraries/chain/betting_market_evaluator.cpp b/libraries/chain/betting_market_evaluator.cpp index 70be3317..1cf73d8a 100644 --- a/libraries/chain/betting_market_evaluator.cpp +++ b/libraries/chain/betting_market_evaluator.cpp @@ -119,7 +119,7 @@ object_id_type betting_market_group_create_evaluator::do_apply(const betting_mar void_result betting_market_group_update_evaluator::do_evaluate(const betting_market_group_update_operation& op) { try { FC_ASSERT(trx_state->_is_proposed_trx); - FC_ASSERT(op.new_event_id.valid() || op.new_description || op.new_rules_id, "nothing to change"); + FC_ASSERT(op.new_event_id.valid() || op.new_description.valid() || op.new_rules_id.valid() || op.freeze.valid(), "nothing to change"); // the event_id in the operation can be a relative id. If it is, // resolve it and verify that it is truly an event @@ -151,6 +151,12 @@ void_result betting_market_group_update_evaluator::do_evaluate(const betting_mar FC_ASSERT( db().find_object(rules_id), "invalid rules specified" ); } + if (op.freeze.valid()) + { + const auto& _betting_market_group = &op.betting_market_group_id(db()); + FC_ASSERT(_betting_market_group->frozen != *op.freeze, "Freeze operation would not change the state of the betting market group"); + } + return void_result(); } FC_CAPTURE_AND_RETHROW( (op) ) } @@ -167,6 +173,8 @@ void_result betting_market_group_update_evaluator::do_apply(const betting_market bmgo.event_id = event_id; if( op.new_rules_id.valid() ) bmgo.rules_id = rules_id; + if( op.freeze.valid() ) + bmgo.frozen = *op.freeze; }); return void_result(); } FC_CAPTURE_AND_RETHROW( (op) ) } @@ -356,23 +364,6 @@ void_result betting_market_group_resolve_evaluator::do_apply(const betting_marke return void_result(); } FC_CAPTURE_AND_RETHROW( (op) ) } -void_result betting_market_group_freeze_evaluator::do_evaluate(const betting_market_group_freeze_operation& op) -{ try { - const database& d = db(); - _betting_market_group = &op.betting_market_group_id(d); - FC_ASSERT(_betting_market_group->frozen != op.freeze, "Freeze operation would not change the state of the betting market group"); - return void_result(); -} FC_CAPTURE_AND_RETHROW( (op) ) } - -void_result betting_market_group_freeze_evaluator::do_apply(const betting_market_group_freeze_operation& op) -{ try { - db().modify(*_betting_market_group, [&]( betting_market_group_object& betting_market_group_obj ) { - betting_market_group_obj.frozen = op.freeze; - }); - - return void_result(); -} FC_CAPTURE_AND_RETHROW( (op) ) } - void_result betting_market_group_cancel_unmatched_bets_evaluator::do_evaluate(const betting_market_group_cancel_unmatched_bets_operation& op) { try { const database& d = db(); diff --git a/libraries/chain/db_notify.cpp b/libraries/chain/db_notify.cpp index bcaf4a80..34810391 100644 --- a/libraries/chain/db_notify.cpp +++ b/libraries/chain/db_notify.cpp @@ -205,7 +205,6 @@ struct get_impacted_account_visitor void operator()(const betting_market_update_operation&){} void operator()(const bet_place_operation&){} void operator()(const betting_market_group_resolve_operation&){} - void operator()(const betting_market_group_freeze_operation&){} void operator()(const betting_market_group_resolved_operation &){} void operator()(const betting_market_group_cancel_unmatched_bets_operation&){} void operator()(const bet_matched_operation &){} diff --git a/libraries/chain/include/graphene/chain/betting_market_evaluator.hpp b/libraries/chain/include/graphene/chain/betting_market_evaluator.hpp index a1a1128f..84937acf 100644 --- a/libraries/chain/include/graphene/chain/betting_market_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/betting_market_evaluator.hpp @@ -129,18 +129,6 @@ namespace graphene { namespace chain { const betting_market_group_object* _betting_market_group; }; - class betting_market_group_freeze_evaluator : public evaluator - { - public: - typedef betting_market_group_freeze_operation operation_type; - - void_result do_evaluate( const betting_market_group_freeze_operation& o ); - void_result do_apply( const betting_market_group_freeze_operation& o ); - private: - const betting_market_group_object* _betting_market_group; - }; - - class betting_market_group_cancel_unmatched_bets_evaluator : public evaluator { public: diff --git a/libraries/chain/include/graphene/chain/protocol/betting_market.hpp b/libraries/chain/include/graphene/chain/protocol/betting_market.hpp index bd47b3db..4f8828f6 100644 --- a/libraries/chain/include/graphene/chain/protocol/betting_market.hpp +++ b/libraries/chain/include/graphene/chain/protocol/betting_market.hpp @@ -116,6 +116,8 @@ struct betting_market_group_update_operation : public base_operation optional new_rules_id; + optional freeze; + extensions_type extensions; account_id_type fee_payer()const { return GRAPHENE_WITNESS_ACCOUNT; } @@ -217,20 +219,6 @@ struct betting_market_group_resolved_operation : public base_operation share_type calculate_fee(const fee_parameters_type& k)const { return 0; } }; -struct betting_market_group_freeze_operation : public base_operation -{ - struct fee_parameters_type { uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; }; - asset fee; - - betting_market_group_id_type betting_market_group_id; - bool freeze; // the new state of the betting market - - extensions_type extensions; - - account_id_type fee_payer()const { return GRAPHENE_WITNESS_ACCOUNT; } - void validate()const; -}; - struct betting_market_group_cancel_unmatched_bets_operation : public base_operation { struct fee_parameters_type { uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; }; @@ -381,7 +369,7 @@ FC_REFLECT( graphene::chain::betting_market_group_create_operation, FC_REFLECT( graphene::chain::betting_market_group_update_operation::fee_parameters_type, (fee) ) FC_REFLECT( graphene::chain::betting_market_group_update_operation, - (fee)(betting_market_group_id)(new_description)(new_event_id)(new_rules_id)(extensions) ) + (fee)(betting_market_group_id)(new_description)(new_event_id)(new_rules_id)(freeze)(extensions) ) FC_REFLECT( graphene::chain::betting_market_create_operation::fee_parameters_type, (fee) ) FC_REFLECT( graphene::chain::betting_market_create_operation, @@ -401,10 +389,6 @@ FC_REFLECT( graphene::chain::betting_market_group_resolved_operation::fee_parame FC_REFLECT( graphene::chain::betting_market_group_resolved_operation, (bettor_id)(betting_market_group_id)(resolutions)(winnings)(fees_paid)(fee) ) -FC_REFLECT( graphene::chain::betting_market_group_freeze_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::betting_market_group_freeze_operation, - (fee)(betting_market_group_id)(freeze)(extensions) ) - FC_REFLECT( graphene::chain::betting_market_group_cancel_unmatched_bets_operation::fee_parameters_type, (fee) ) FC_REFLECT( graphene::chain::betting_market_group_cancel_unmatched_bets_operation, (fee)(betting_market_group_id)(extensions) ) diff --git a/libraries/chain/include/graphene/chain/protocol/operations.hpp b/libraries/chain/include/graphene/chain/protocol/operations.hpp index 8f6d50ae..38c05eae 100644 --- a/libraries/chain/include/graphene/chain/protocol/operations.hpp +++ b/libraries/chain/include/graphene/chain/protocol/operations.hpp @@ -112,7 +112,6 @@ namespace graphene { namespace chain { bet_place_operation, betting_market_group_resolve_operation, betting_market_group_resolved_operation, // VIRTUAL - betting_market_group_freeze_operation, betting_market_group_cancel_unmatched_bets_operation, bet_matched_operation, // VIRTUAL bet_cancel_operation, diff --git a/libraries/chain/protocol/betting_market.cpp b/libraries/chain/protocol/betting_market.cpp index baec1545..7517c098 100644 --- a/libraries/chain/protocol/betting_market.cpp +++ b/libraries/chain/protocol/betting_market.cpp @@ -60,11 +60,6 @@ void betting_market_group_resolve_operation::validate() const FC_ASSERT( fee.amount >= 0 ); } -void betting_market_group_freeze_operation::validate() const -{ - FC_ASSERT( fee.amount >= 0 ); -} - void betting_market_group_cancel_unmatched_bets_operation::validate() const { FC_ASSERT( fee.amount >= 0 ); diff --git a/libraries/wallet/include/graphene/wallet/wallet.hpp b/libraries/wallet/include/graphene/wallet/wallet.hpp index 88e4422b..fec081cb 100644 --- a/libraries/wallet/include/graphene/wallet/wallet.hpp +++ b/libraries/wallet/include/graphene/wallet/wallet.hpp @@ -1659,6 +1659,7 @@ class wallet_api fc::optional description, fc::optional event_id, fc::optional rules_id, + fc::optional freeze, bool broadcast = false); signed_transaction propose_create_betting_market( diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index e4f508d4..08459abc 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -5308,6 +5308,7 @@ signed_transaction wallet_api::propose_update_betting_market_group( fc::optional description, fc::optional event_id, fc::optional rules_id, + fc::optional freeze, bool broadcast /*= false*/) { FC_ASSERT( !is_locked() ); @@ -5318,7 +5319,7 @@ signed_transaction wallet_api::propose_update_betting_market_group( betting_market_group_update_op.new_description = description; betting_market_group_update_op.new_event_id = event_id; betting_market_group_update_op.new_rules_id = rules_id; - //betting_market_group_create_op.asset_id = asset_id; + betting_market_group_update_op.freeze = freeze; proposal_create_operation prop_op; prop_op.expiration_time = expiration_time; diff --git a/tests/betting/betting_tests.cpp b/tests/betting/betting_tests.cpp index f5b3a8e1..49053ceb 100644 --- a/tests/betting/betting_tests.cpp +++ b/tests/betting/betting_tests.cpp @@ -693,11 +693,12 @@ BOOST_AUTO_TEST_CASE(betting_market_group_update_test) const betting_market_rules_object& new_betting_market_rules = create_betting_market_rules({{"en", "NHL Rules v2.0"}}, {{"en", "The winner will be the team with the most points at the end of the game. The team with fewer points will not be the winner."}}); fc::optional new_rule = new_betting_market_rules.id; + fc::optional freeze; - update_betting_market_group(moneyline_betting_markets.id, new_desc, empty_object_id, empty_object_id); - update_betting_market_group(moneyline_betting_markets.id, dempty, new_event, empty_object_id); - update_betting_market_group(moneyline_betting_markets.id, dempty, empty_object_id, new_rule); - update_betting_market_group(moneyline_betting_markets.id, new_desc, new_event, new_rule); + update_betting_market_group(moneyline_betting_markets.id, new_desc, empty_object_id, empty_object_id, freeze); + update_betting_market_group(moneyline_betting_markets.id, dempty, new_event, empty_object_id, freeze); + update_betting_market_group(moneyline_betting_markets.id, dempty, empty_object_id, new_rule, freeze); + update_betting_market_group(moneyline_betting_markets.id, new_desc, new_event, new_rule, freeze); transfer(account_id_type(), bob_id, asset(10000000)); place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION, 1000000 / 50 /* chain defaults to 2% fees */); diff --git a/tests/common/database_fixture.cpp b/tests/common/database_fixture.cpp index 477256e0..f6881f36 100644 --- a/tests/common/database_fixture.cpp +++ b/tests/common/database_fixture.cpp @@ -1357,13 +1357,15 @@ const betting_market_group_object& database_fixture::create_betting_market_group void database_fixture::update_betting_market_group(betting_market_group_id_type betting_market_group_id, fc::optional description, fc::optional event_id, - fc::optional rules_id) + fc::optional rules_id, + fc::optional freeze) { try { betting_market_group_update_operation betting_market_group_update_op; betting_market_group_update_op.betting_market_group_id = betting_market_group_id; betting_market_group_update_op.new_description = description; betting_market_group_update_op.new_event_id = event_id; betting_market_group_update_op.new_rules_id = rules_id; + betting_market_group_update_op.freeze = freeze; process_operation_by_witnesses(betting_market_group_update_op); } FC_CAPTURE_AND_RETHROW( (betting_market_group_id)(description)(event_id)(rules_id)) } diff --git a/tests/common/database_fixture.hpp b/tests/common/database_fixture.hpp index 95b0d285..a8241a96 100644 --- a/tests/common/database_fixture.hpp +++ b/tests/common/database_fixture.hpp @@ -309,7 +309,8 @@ struct database_fixture { void update_betting_market_group(betting_market_group_id_type betting_market_group_id, fc::optional description, fc::optional event_id, - fc::optional rules_id); + fc::optional rules_id, + fc::optional freeze); const betting_market_object& create_betting_market(betting_market_group_id_type group_id, internationalized_string_type payout_condition); void update_betting_market(betting_market_id_type betting_market_id,