From b79a330690ce9cba1fff3aff43d27a358d0f8410 Mon Sep 17 00:00:00 2001 From: WorldDogs Date: Fri, 29 Nov 2024 14:54:35 +0800 Subject: [PATCH] refactor(tx-submitter): rename SetFailedStatus to TrySetFailedBatchIndex - Updated function name to better reflect its purpose and behavior - Changed the function name in multiple files to maintain consistency - This change is part of a larger effort to improve code clarity and maintainability --- tx-submitter/services/pendingtx.go | 2 +- tx-submitter/services/pendingtx_test.go | 6 +++--- tx-submitter/services/rollup.go | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tx-submitter/services/pendingtx.go b/tx-submitter/services/pendingtx.go index 03f23821..53276fb7 100644 --- a/tx-submitter/services/pendingtx.go +++ b/tx-submitter/services/pendingtx.go @@ -169,7 +169,7 @@ func (pt *PendingTxs) IncQueryTimes(txHash common.Hash) { pt.txinfos[txHash] = TxInfo{tx: pt.txinfos[txHash].tx, queryTimes: pt.txinfos[txHash].queryTimes + 1, sendTime: pt.txinfos[txHash].sendTime} } -func (pt *PendingTxs) SetFailedStatus(index uint64) { +func (pt *PendingTxs) TrySetFailedBatchIndex(index uint64) { pt.mu.Lock() defer pt.mu.Unlock() diff --git a/tx-submitter/services/pendingtx_test.go b/tx-submitter/services/pendingtx_test.go index 11d78c5e..71cb9ab7 100644 --- a/tx-submitter/services/pendingtx_test.go +++ b/tx-submitter/services/pendingtx_test.go @@ -11,7 +11,7 @@ func TestSetFailedStatus(t *testing.T) { pt := NewPendingTxs(nil, nil, nil) pt.SetPindex(2) require.Nil(t, pt.failedIndex) - pt.SetFailedStatus(2) + pt.TrySetFailedBatchIndex(2) require.NotNil(t, pt.failedIndex) require.EqualValues(t, 2, *pt.failedIndex) @@ -21,11 +21,11 @@ func TestSetFailedStatus(t *testing.T) { pt = NewPendingTxs(nil, nil, nil) failedIndex := uint64(2) pt.failedIndex = &failedIndex - pt.SetFailedStatus(3) + pt.TrySetFailedBatchIndex(3) require.EqualValues(t, 2, *pt.failedIndex) // set failed index without pindex -> failed pt = NewPendingTxs(nil, nil, nil) - pt.SetFailedStatus(2) + pt.TrySetFailedBatchIndex(2) require.Nil(t, pt.failedIndex) } diff --git a/tx-submitter/services/rollup.go b/tx-submitter/services/rollup.go index fe9cde5c..6042fe65 100644 --- a/tx-submitter/services/rollup.go +++ b/tx-submitter/services/rollup.go @@ -332,7 +332,7 @@ func (r *Rollup) ProcessTx() error { // happening between RemoveRollupRestriction // and SetPindex in the rollup function r.rollupFinalizeMu.Lock() - r.pendingTxs.SetFailedStatus(index) + r.pendingTxs.TrySetFailedBatchIndex(index) r.rollupFinalizeMu.Unlock() } @@ -713,7 +713,7 @@ func (r *Rollup) rollup() error { "err", err, "try_update_pooled_pending_index", cindex+1, ) - r.pendingTxs.SetFailedStatus(cindex + 1) + r.pendingTxs.TrySetFailedBatchIndex(cindex + 1) return nil }