Add logging to order cancellation

This commit is contained in:
raymoo 2016-02-26 10:49:09 -08:00
parent 58b21b2851
commit 7713075aef

View File

@ -289,6 +289,7 @@ function exports.open_exchange(path)
red_inbox_stmt = assert(db:prepare(red_inbox_query)), red_inbox_stmt = assert(db:prepare(red_inbox_query)),
del_inbox_stmt = assert(db:prepare(del_inbox_query)), del_inbox_stmt = assert(db:prepare(del_inbox_query)),
summary_stmt = assert(db:prepare(summary_query)), summary_stmt = assert(db:prepare(summary_query)),
transaction_log_stmt = assert(db:prepare(transaction_log_query)),
} }
@ -647,6 +648,19 @@ function ex_methods.cancel_order(self, p_name, id, order_type, item_name, amount
return false, canc_err return false, canc_err
end end
local message = "Cancelled an order to " ..
order_type .. " " .. amount .. " " .. item_name .. "."
if order_type == "buy" then
message = message .. " (+" .. amount * rate .. ")"
end
local succ, err = self:log(message, p_name)
if not succ then
db:exec("ROLLBACK")
return false, err
end
db:exec("COMMIT;") db:exec("COMMIT;")
return true return true