Skip to content

Commit 26fcc18

Browse files
committed
fix: clamp MetricNumBatches to zero when batch ID is zero
1 parent e62e3e4 commit 26fcc18

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

bridges/ethKC/bridgeExecutor.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ func (executor *bridgeExecutor) MyTurnAsLeader() bool {
157157
func (executor *bridgeExecutor) GetBatchFromKC(ctx context.Context) (*bridgeCore.TransferBatch, error) {
158158
batch, err := executor.kcClient.GetPendingBatch(ctx)
159159
if err == nil {
160-
executor.statusHandler.SetIntMetric(bridgeCore.MetricNumBatches, safeUint64ToInt(batch.ID)-1)
160+
n := max(safeUint64ToInt(batch.ID)-1, 0)
161+
executor.statusHandler.SetIntMetric(bridgeCore.MetricNumBatches, n)
161162
if len(batch.Deposits) > 0 {
162163
lastDeposit := batch.Deposits[len(batch.Deposits)-1]
163164
executor.statusHandler.SetIntMetric(bridgeCore.MetricCurrentDepositNonce, safeUint64ToInt(lastDeposit.Nonce))

0 commit comments

Comments
 (0)