Skip to content

Commit

Permalink
fix tx counter
Browse files Browse the repository at this point in the history
  • Loading branch information
giskook committed Apr 26, 2024
1 parent 1a82d86 commit 70be6d0
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 11 deletions.
6 changes: 0 additions & 6 deletions sequencer/addrqueue.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,6 @@ func (a *addrQueue) updateCurrentNonceBalance(nonce *uint64, balance *big.Int) (
if (a.readyTx.Nonce != a.currentNonce) || (a.currentBalance.Cmp(a.readyTx.Cost) < 0) {
oldReadyTx = a.readyTx
a.readyTx = nil

getPoolReadyTxCounter().delete(oldReadyTx.FromStr)
}
}

Expand All @@ -205,8 +203,6 @@ func (a *addrQueue) updateCurrentNonceBalance(nonce *uint64, balance *big.Int) (
a.readyTx = nrTx
log.Infof("set notReadyTx %s as readyTx for addrQueue %s", nrTx.HashStr, a.fromStr)
delete(a.notReadyTxs, a.currentNonce)

getPoolReadyTxCounter().set(a.fromStr, a.GetTxCount())
}
}
}
Expand All @@ -215,8 +211,6 @@ func (a *addrQueue) updateCurrentNonceBalance(nonce *uint64, balance *big.Int) (
if oldReadyTx != nil && oldReadyTx.Nonce > a.currentNonce {
log.Infof("set readyTx %s as notReadyTx from addrQueue %s", oldReadyTx.HashStr, a.fromStr)
a.notReadyTxs[oldReadyTx.Nonce] = oldReadyTx

getPoolReadyTxCounter().delete(oldReadyTx.FromStr)
}

return a.readyTx, oldReadyTx, txsToDelete
Expand Down
8 changes: 5 additions & 3 deletions sequencer/addrqueue_xlayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ func (a *addrQueue) GetTxCount() int64 {
if a == nil {
return 0
}
var readyTxCount, notReadyTxCount int64
var readyTxCount int64
if a.readyTx != nil {
readyTxCount = 1
}
notReadyTxCount = int64(len(a.notReadyTxs))
notReadyTxCount := int64(len(a.notReadyTxs))
forcedTxCount := int64(len(a.forcedTxs))
pendingTxsToStoreCount := int64(len(a.pendingTxsToStore))

return readyTxCount + notReadyTxCount
return readyTxCount + notReadyTxCount + forcedTxCount + pendingTxsToStoreCount
}
File renamed without changes.
1 change: 1 addition & 0 deletions sequencer/txsorted_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func (e *txSortedList) add(tx *TxTracker) bool {
func (e *txSortedList) delete(tx *TxTracker) bool {
e.mutex.Lock()
defer e.mutex.Unlock()
getPoolReadyTxCounter().delete(tx.FromStr)

if tx, found := e.list[tx.HashStr]; found {
sLen := len(e.sorted)
Expand Down
2 changes: 0 additions & 2 deletions sequencer/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,6 @@ func (w *Worker) DeleteTx(txHash common.Hash, addr common.Address) {
if deletedReadyTx != nil {
log.Debugf("tx %s deleted from TxSortedList", deletedReadyTx.Hash.String())
w.txSortedList.delete(deletedReadyTx)

getPoolReadyTxCounter().set(addrQueue.fromStr, addrQueue.GetTxCount())
}
} else {
log.Warnf("addrQueue %s not found", addr.String())
Expand Down

0 comments on commit 70be6d0

Please sign in to comment.