Skip to content

Commit 1c7e0c4

Browse files
authored
processTx should block processing until nonce lock is acquired (#354)
* Block worker on lock acquisition * Update * Update
1 parent ce3af1a commit 1c7e0c4

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/worker/tasks/processTx.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,20 +135,22 @@ export const processTx = async () => {
135135
return;
136136
}
137137

138-
// - For each wallet address, check the nonce in database and the mempool
139-
const [walletBalance, mempoolNonceData, dbNonceData, gasOverrides] =
138+
// Important: We need to block this worker until the nonce lock is acquired
139+
const dbNonceData = await getWalletNonce({
140+
pgtx,
141+
chainId,
142+
address: walletAddress,
143+
});
144+
145+
// For each wallet address, check the nonce in database and the mempool
146+
const [walletBalance, mempoolNonceData, gasOverrides] =
140147
await Promise.all([
141148
sdk.wallet.balance(),
142149
sdk.wallet.getNonce("pending"),
143-
getWalletNonce({
144-
pgtx,
145-
chainId,
146-
address: walletAddress,
147-
}),
148150
getDefaultGasOverrides(provider),
149151
]);
150152

151-
// Wallet Balance Webhook
153+
// Wallet balance webhook
152154
if (
153155
BigNumber.from(walletBalance.value).lte(
154156
BigNumber.from(config.minWalletBalance),

0 commit comments

Comments
 (0)