From 13e83256d04519b751dc6cee4dafe77f03f5a52b Mon Sep 17 00:00:00 2001 From: Danh Date: Fri, 4 Aug 2023 22:32:04 +0700 Subject: [PATCH 1/2] rm txs pending too much --- src/state/transactions/updater.tsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/state/transactions/updater.tsx b/src/state/transactions/updater.tsx index df6923298b..c22c34e094 100644 --- a/src/state/transactions/updater.tsx +++ b/src/state/transactions/updater.tsx @@ -15,7 +15,7 @@ import { revokePermit } from 'state/user/actions' import { findTx } from 'utils' import { includes } from 'utils/array' -import { checkedTransaction, finalizeTransaction, replaceTx } from './actions' +import { checkedTransaction, finalizeTransaction, removeTx, replaceTx } from './actions' import { SerializableTransactionReceipt, TRANSACTION_TYPE, TransactionDetails } from './type' function shouldCheck( @@ -83,7 +83,12 @@ export default function Updater(): null { const transaction = findTx(transactions, hash) if (!transaction || !res) return // !res this mean tx was drop - const { sentAtBlock, from, to, nonce, data } = transaction + const { sentAtBlock, from, to, nonce, data, addedTime } = transaction + const checkRemoveTxs = () => { + // pending >2 days + if (Date.now() - addedTime > 2 * 86_400_000) dispatch(removeTx({ chainId, hash })) + } + if (sentAtBlock && from && to && nonce && data) findReplacementTx(readProvider, sentAtBlock, { from, @@ -103,10 +108,10 @@ export default function Updater(): null { } }) .catch(() => { - // dispatch(removeTx({ chainId, hash })) + checkRemoveTxs() }) else { - // dispatch(removeTx({ chainId, hash })) + checkRemoveTxs() } }) .catch(console.warn) From e90e1540fc644693867e2ea68c6eb5a815ea6510 Mon Sep 17 00:00:00 2001 From: Danh Date: Sat, 5 Aug 2023 12:09:08 +0700 Subject: [PATCH 2/2] reduce time --- src/state/transactions/updater.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/state/transactions/updater.tsx b/src/state/transactions/updater.tsx index c22c34e094..a5a22559eb 100644 --- a/src/state/transactions/updater.tsx +++ b/src/state/transactions/updater.tsx @@ -85,8 +85,8 @@ export default function Updater(): null { const { sentAtBlock, from, to, nonce, data, addedTime } = transaction const checkRemoveTxs = () => { - // pending >2 days - if (Date.now() - addedTime > 2 * 86_400_000) dispatch(removeTx({ chainId, hash })) + // pending >1 days + if (Date.now() - addedTime > 86_400_000) dispatch(removeTx({ chainId, hash })) } if (sentAtBlock && from && to && nonce && data)