Skip to content

Commit

Permalink
refactor(tx-submitter): rename SetFailedStatus to TrySetFailedBatchIndex
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
WorldDogs committed Nov 29, 2024
1 parent c3aea64 commit b79a330
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion tx-submitter/services/pendingtx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
6 changes: 3 additions & 3 deletions tx-submitter/services/pendingtx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
}
4 changes: 2 additions & 2 deletions tx-submitter/services/rollup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

}
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit b79a330

Please sign in to comment.