Skip to content

Commit

Permalink
Throttle between batches
Browse files Browse the repository at this point in the history
  • Loading branch information
ThibautBremand committed Aug 10, 2023
1 parent 2413cd7 commit 58277b3
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,11 @@ export const SubmitTransactionsBulk: FC = () => {

const totalTransactions = Object.values(params.transactionsMapParam || {}).length;
setProgressPercentage(Math.floor((results.length / totalTransactions) * 100));

if (parallelize && i < transactions.length) {
// Throttle requests
await new Promise((resolve) => setTimeout(resolve, 10000));
}
} catch (e) {
throw e;
}
Expand All @@ -233,7 +238,7 @@ export const SubmitTransactionsBulk: FC = () => {
const message = createMessage({ txResults: null, error: e });
chrome.runtime.sendMessage<ReceiveSubmitTransactionsBulkBackgroundMessage>(message);
});
}, [params.transactionsMapParam, onError, submitTransactionsBulk, createMessage]);
}, [params.transactionsMapParam, onError, submitTransactionsBulk, parallelize, createMessage]);
const { transactionsMapParam } = params;

const allTransactions = transactionsMapParam || {};
Expand Down

0 comments on commit 58277b3

Please sign in to comment.