Skip to content

Commit

Permalink
feat(xgon): change pending tx metric logic to singe file
Browse files Browse the repository at this point in the history
  • Loading branch information
zibuyu28 committed Oct 31, 2023
1 parent b9c8901 commit 9562ced
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
22 changes: 22 additions & 0 deletions sequencer/db_metric.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package sequencer

import (
"github.com/0xPolygonHermez/zkevm-node/log"
"github.com/0xPolygonHermez/zkevm-node/sequencer/metrics"
"time"
)

func (d *dbManager) countPendingTx() {
ticker := time.NewTicker(time.Second * 10)
for {
select {
case <-ticker.C:
transactions, err := d.txPool.CountPendingTransactions(d.ctx)
if err != nil {
log.Errorf("load pending tx from pool: %v", err)
continue
}
metrics.PendingTxCount(int(transactions))
}
}
}
16 changes: 0 additions & 16 deletions sequencer/dbmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package sequencer

import (
"context"
"github.com/0xPolygonHermez/zkevm-node/sequencer/metrics"
"math/big"
"time"

Expand Down Expand Up @@ -117,21 +116,6 @@ func (d *dbManager) checkIfReorg() {
}
}

func (d *dbManager) countPendingTx() {
ticker := time.NewTicker(time.Second * 10)
for {
select {
case <-ticker.C:
transactions, err := d.txPool.CountPendingTransactions(d.ctx)
if err != nil {
log.Errorf("load pending tx from pool: %v", err)
continue
}
metrics.PendingTxCount(int(transactions))
}
}
}

// loadFromPool keeps loading transactions from the pool
func (d *dbManager) loadFromPool() {
for {
Expand Down

0 comments on commit 9562ced

Please sign in to comment.