From 3feea69a4c71a505e782825e4d33c75ffeda8857 Mon Sep 17 00:00:00 2001 From: Eric Frias Date: Wed, 22 Mar 2017 16:02:57 -0400 Subject: [PATCH] Stub out bet fill virtual op --- libraries/app/impacted.cpp | 4 ++ .../chain/protocol/betting_market.hpp | 38 +++++++++++++++++++ .../graphene/chain/protocol/operations.hpp | 1 + 3 files changed, 43 insertions(+) diff --git a/libraries/app/impacted.cpp b/libraries/app/impacted.cpp index 7cda823a..6a16c5e3 100644 --- a/libraries/app/impacted.cpp +++ b/libraries/app/impacted.cpp @@ -221,6 +221,10 @@ struct get_impacted_account_visitor { _impacted.insert( op.bettor_id ); } + void operator()( const bet_matched_operation& op ) + { + _impacted.insert( op.bettor_id ); + } }; diff --git a/libraries/chain/include/graphene/chain/protocol/betting_market.hpp b/libraries/chain/include/graphene/chain/protocol/betting_market.hpp index c2637942..c0fb9b35 100644 --- a/libraries/chain/include/graphene/chain/protocol/betting_market.hpp +++ b/libraries/chain/include/graphene/chain/protocol/betting_market.hpp @@ -148,6 +148,41 @@ struct bet_place_operation : public base_operation void validate()const; }; +/** + * virtual op generated when a bet is matched + */ +struct bet_matched_operation : public base_operation +{ + struct fee_parameters_type {}; + + bet_matched_operation(){} + bet_matched_operation(account_id_type bettor_id, bet_id_type bet_id, + asset amount_bet, share_type fees_paid, + bet_multiplier_type backer_multiplier, + share_type guaranteed_winnings_returned) : + bettor_id(bettor_id), + bet_id(bet_id), + amount_bet(amount_bet), + fees_paid(fees_paid), + backer_multiplier(backer_multiplier), + guaranteed_winnings_returned(guaranteed_winnings_returned) + {} + + account_id_type bettor_id; + bet_id_type bet_id; + asset amount_bet; + share_type fees_paid; // same asset type as amount_bet + bet_multiplier_type backer_multiplier; // the actual odds received + share_type guaranteed_winnings_returned; // same asset type as amount_bet + asset fee; // unimportant for a virtual op + + account_id_type fee_payer()const { return bettor_id; } + void validate()const { FC_ASSERT(false, "virtual operation"); } + + /// This is a virtual operation; there is no fee + share_type calculate_fee(const fee_parameters_type& k)const { return 0; } +}; + struct bet_cancel_operation : public base_operation { struct fee_parameters_type { uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; }; @@ -223,6 +258,9 @@ FC_REFLECT( graphene::chain::bet_place_operation::fee_parameters_type, (fee) ) FC_REFLECT( graphene::chain::bet_place_operation, (fee)(bettor_id)(betting_market_id)(amount_to_bet)(backer_multiplier)(amount_reserved_for_fees)(back_or_lay)(extensions) ) +FC_REFLECT( graphene::chain::bet_matched_operation::fee_parameters_type, ) +FC_REFLECT( graphene::chain::bet_matched_operation, (bettor_id)(bet_id)(amount_bet)(fees_paid)(backer_multiplier)(guaranteed_winnings_returned) ) + FC_REFLECT( graphene::chain::bet_cancel_operation::fee_parameters_type, (fee) ) FC_REFLECT( graphene::chain::bet_cancel_operation, (bettor_id) (bet_to_cancel) (extensions) ) diff --git a/libraries/chain/include/graphene/chain/protocol/operations.hpp b/libraries/chain/include/graphene/chain/protocol/operations.hpp index bc625531..caec546d 100644 --- a/libraries/chain/include/graphene/chain/protocol/operations.hpp +++ b/libraries/chain/include/graphene/chain/protocol/operations.hpp @@ -104,6 +104,7 @@ namespace graphene { namespace chain { betting_market_group_create_operation, betting_market_create_operation, bet_place_operation, + bet_matched_operation, // VIRTUAL bet_cancel_operation, bet_canceled_operation // VIRTUAL > operation;