Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion contracts/market.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,13 @@ const updateTradesHistory = async (type, buyer, seller, symbol, quantity, price,
let nbTradesToDelete = tradesToDelete.length;

while (nbTradesToDelete > 0) {
let volumeToDelete = api.BigNumber(0);
for (let index = 0; index < nbTradesToDelete; index += 1) {
const trade = tradesToDelete[index];
await updateVolumeMetric(trade.symbol, trade.volume, false);
volumeToDelete = volumeToDelete.plus(trade.volume);
await api.db.remove('tradesHistory', trade);
}
await updateVolumeMetric(symbol, volumeToDelete, false);
tradesToDelete = await api.db.find(
'tradesHistory',
{
Expand Down Expand Up @@ -340,6 +342,7 @@ actions.createSSC = async () => {
await removeBadOrders();
await removeBlacklistedOrders('buy', 'waitingforlove');
await removeBlacklistedOrders('sell', 'waitingforlove');
await api.db.addIndexes('tradesHistory', [{ name: 'timestamp', index: { timestamp: 1 } }]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you gate this new index addition behind a params.updateIndex check in the same way as the mining contract?

}
};

Expand Down