rpc: fix orders matchable field not considering already matched amount

This commit is contained in:
Crypto City 2020-11-26 18:01:16 +00:00
parent 1e73157f9d
commit ea43d90db1

View File

@ -4196,7 +4196,8 @@ namespace cryptonote
}
const uint64_t balance = it->second;
const uint64_t max_amount = balance / e.price;
e.matchable = (uint32_t)std::min<uint64_t>(max_amount, e.amount);
const uint32_t already_matched = db.get_cc_trade_used(e.nonce);
e.matchable = (uint32_t)std::min<uint64_t>(max_amount, e.amount - std::min(already_matched, e.amount));
it->second -= e.matchable * e.price;
}
@ -4244,7 +4245,8 @@ namespace cryptonote
it = running_item_balances.insert(std::make_pair(std::make_tuple(e.account, e.type, e.id), 0)).first;
}
const uint32_t item_balance = it->second;
e.matchable = (uint32_t)std::min<uint32_t>(item_balance, e.amount);
const uint32_t already_matched = db.get_cc_trade_used(e.nonce);
e.matchable = (uint32_t)std::min<uint32_t>(item_balance, e.amount - std::min(already_matched, e.amount));
it->second -= e.matchable;
}
}