guard against UI setting cash and leverage factors for accounts I don't know about when span is off
This commit is contained in:
1 parent
6b3c3ded68
commit
58533bf16f
1 file changed
+21
-7
@@ -48,13 +48,6 @@ MarginServiceServer::MarginServiceServer(bts::api::ServiceContext& context, md::
|
||||
|
||||
LOG(Gen, Info, "MarginServiceServer: service started");
|
||||
|
||||
// _admin_service.get_admin_data(api::VoidMessage(),
|
||||
// [=] (const bts::api::Result<::bts::api::admin::AdminData> r)
|
||||
// {
|
||||
// if(r.value())
|
||||
// _admin_data = *r.value();
|
||||
// });
|
||||
|
||||
_admin_service.subscribe_admin_data() |
|
||||
rxcpp::operators::subscribe<api::admin::Admin_dataUpdate>(
|
||||
[this](auto const &update)
|
||||
@@ -203,6 +196,13 @@ void MarginServiceServer::incremental_update_report(const std::string& account,
|
||||
void MarginServiceServer::set_cash_factor(const ::bts::api::position::CashFactorUpdate& request,
|
||||
const api::Response<::bts::api::ResultMessage>& reply)
|
||||
{
|
||||
if(!config::get<bts::config::SpanMargin>().enabled())
|
||||
{
|
||||
api::ResultMessage resp; resp.set_success(true);
|
||||
reply(resp);
|
||||
return;
|
||||
}
|
||||
|
||||
std::scoped_lock<std::recursive_mutex> l(_lock);
|
||||
auto acct = AdminServiceUtils::find_account(_admin_data, request.account(), false);
|
||||
if(!acct)
|
||||
@@ -234,6 +234,13 @@ void MarginServiceServer::set_cash_factor(const ::bts::api::position::CashFactor
|
||||
void MarginServiceServer::set_cash_balance(const ::bts::api::position::CashBalanceUpdate& request,
|
||||
const api::Response<::bts::api::ResultMessage>& reply)
|
||||
{
|
||||
if(!config::get<bts::config::SpanMargin>().enabled())
|
||||
{
|
||||
api::ResultMessage resp; resp.set_success(true);
|
||||
reply(resp);
|
||||
return;
|
||||
}
|
||||
|
||||
std::scoped_lock<std::recursive_mutex> l(_lock);
|
||||
auto acct = AdminServiceUtils::find_account(_admin_data, request.account(), false);
|
||||
if(!acct)
|
||||
@@ -265,6 +272,13 @@ void MarginServiceServer::set_cash_balance(const ::bts::api::position::CashBalan
|
||||
void MarginServiceServer::set_should_enforce_margin(const ::bts::api::position::EnforceUpdate& request,
|
||||
const api::Response<::bts::api::ResultMessage>& reply)
|
||||
{
|
||||
if(!config::get<bts::config::SpanMargin>().enabled())
|
||||
{
|
||||
api::ResultMessage resp; resp.set_success(true);
|
||||
reply(resp);
|
||||
return;
|
||||
}
|
||||
|
||||
std::scoped_lock<std::recursive_mutex> l(_lock);
|
||||
auto acct = AdminServiceUtils::find_account(_admin_data, request.account(), false);
|
||||
if(!acct)
|
||||
|
||||
Reference in new issue
Block a user