Implement virtual op for settlement cancel #250

This commit is contained in:
theoreticalbts 2015-09-17 15:12:08 -04:00
parent e008cbb70b
commit f0502ee2f1
4 changed files with 48 additions and 5 deletions

View file

@ -37,7 +37,10 @@ struct get_impacted_account_visitor
} }
void operator()( const limit_order_create_operation& op ) {} void operator()( const limit_order_create_operation& op ) {}
void operator()( const limit_order_cancel_operation& op ) {} void operator()( const limit_order_cancel_operation& op )
{
_impacted.insert( op.fee_paying_account );
}
void operator()( const call_order_update_operation& op ) {} void operator()( const call_order_update_operation& op ) {}
void operator()( const fill_order_operation& op ) void operator()( const fill_order_operation& op )
{ {
@ -182,6 +185,12 @@ struct get_impacted_account_visitor
for( const auto& in : op.inputs ) for( const auto& in : op.inputs )
add_authority_accounts( _impacted, in.owner ); add_authority_accounts( _impacted, in.owner );
} }
void operator()( const asset_settle_cancel_operation& op )
{
_impacted.insert( op.account );
}
}; };
void operation_get_impacted_accounts( const operation& op, flat_set<account_id_type>& result ) void operation_get_impacted_accounts( const operation& op, flat_set<account_id_type>& result )

View file

@ -93,7 +93,11 @@ void database::cancel_order(const force_settlement_object& order, bool create_vi
if( create_virtual_op ) if( create_virtual_op )
{ {
// TODO: create virtual op asset_settle_cancel_operation vop;
vop.settlement = order.id;
vop.account = order.owner;
vop.amount = order.balance;
push_applied_operation( vop );
} }
} }
@ -109,7 +113,10 @@ void database::cancel_order( const limit_order_object& order, bool create_virtua
if( create_virtual_op ) if( create_virtual_op )
{ {
// TODO: create a virtual cancel operation limit_order_cancel_operation vop;
vop.order = order.id;
vop.fee_paying_account = order.seller;
push_applied_operation( vop );
} }
remove(order); remove(order);

View file

@ -189,6 +189,29 @@ namespace graphene { namespace chain {
void validate()const; void validate()const;
}; };
/**
* Virtual op generated when force settlement is cancelled.
*/
struct asset_settle_cancel_operation : public base_operation
{
struct fee_parameters_type { };
asset fee;
force_settlement_id_type settlement;
/// Account requesting the force settlement. This account pays the fee
account_id_type account;
/// Amount of asset to force settle. This must be a market-issued asset
asset amount;
extensions_type extensions;
account_id_type fee_payer()const { return account; }
void validate()const {}
share_type calculate_fee(const fee_parameters_type& params)const
{ return 0; }
};
/** /**
* @ingroup operations * @ingroup operations
*/ */
@ -407,6 +430,7 @@ FC_REFLECT( graphene::chain::bitasset_options,
FC_REFLECT( graphene::chain::asset_create_operation::fee_parameters_type, (symbol3)(symbol4)(long_symbol)(price_per_kbyte) ) FC_REFLECT( graphene::chain::asset_create_operation::fee_parameters_type, (symbol3)(symbol4)(long_symbol)(price_per_kbyte) )
FC_REFLECT( graphene::chain::asset_global_settle_operation::fee_parameters_type, (fee) ) FC_REFLECT( graphene::chain::asset_global_settle_operation::fee_parameters_type, (fee) )
FC_REFLECT( graphene::chain::asset_settle_operation::fee_parameters_type, (fee) ) FC_REFLECT( graphene::chain::asset_settle_operation::fee_parameters_type, (fee) )
FC_REFLECT( graphene::chain::asset_settle_cancel_operation::fee_parameters_type, )
FC_REFLECT( graphene::chain::asset_fund_fee_pool_operation::fee_parameters_type, (fee) ) FC_REFLECT( graphene::chain::asset_fund_fee_pool_operation::fee_parameters_type, (fee) )
FC_REFLECT( graphene::chain::asset_update_operation::fee_parameters_type, (fee)(price_per_kbyte) ) FC_REFLECT( graphene::chain::asset_update_operation::fee_parameters_type, (fee)(price_per_kbyte) )
FC_REFLECT( graphene::chain::asset_update_bitasset_operation::fee_parameters_type, (fee) ) FC_REFLECT( graphene::chain::asset_update_bitasset_operation::fee_parameters_type, (fee) )
@ -447,6 +471,7 @@ FC_REFLECT( graphene::chain::asset_update_feed_producers_operation,
FC_REFLECT( graphene::chain::asset_publish_feed_operation, FC_REFLECT( graphene::chain::asset_publish_feed_operation,
(fee)(publisher)(asset_id)(feed)(extensions) ) (fee)(publisher)(asset_id)(feed)(extensions) )
FC_REFLECT( graphene::chain::asset_settle_operation, (fee)(account)(amount)(extensions) ) FC_REFLECT( graphene::chain::asset_settle_operation, (fee)(account)(amount)(extensions) )
FC_REFLECT( graphene::chain::asset_settle_cancel_operation, (fee)(settlement)(account)(amount)(extensions) )
FC_REFLECT( graphene::chain::asset_global_settle_operation, (fee)(issuer)(asset_to_settle)(settle_price)(extensions) ) FC_REFLECT( graphene::chain::asset_global_settle_operation, (fee)(issuer)(asset_to_settle)(settle_price)(extensions) )
FC_REFLECT( graphene::chain::asset_issue_operation, FC_REFLECT( graphene::chain::asset_issue_operation,
(fee)(issuer)(asset_to_issue)(issue_to_account)(memo)(extensions) ) (fee)(issuer)(asset_to_issue)(issue_to_account)(memo)(extensions) )

View file

@ -28,7 +28,7 @@ namespace graphene { namespace chain {
limit_order_create_operation, limit_order_create_operation,
limit_order_cancel_operation, limit_order_cancel_operation,
call_order_update_operation, call_order_update_operation,
fill_order_operation, fill_order_operation, // VIRTUAL
account_create_operation, account_create_operation,
account_update_operation, account_update_operation,
account_whitelist_operation, account_whitelist_operation,
@ -65,7 +65,9 @@ namespace graphene { namespace chain {
override_transfer_operation, override_transfer_operation,
transfer_to_blind_operation, transfer_to_blind_operation,
blind_transfer_operation, blind_transfer_operation,
transfer_from_blind_operation transfer_from_blind_operation,
asset_settle_cancel_operation // VIRTUAL
> operation; > operation;
/// @} // operations group /// @} // operations group