Skip to content

Commit

Permalink
chore: optimize logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Candinya committed Jul 1, 2024
1 parent 0c897fa commit 120ca5a
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions internal/service/indexer/l2/indexer_staking.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,13 @@ func (s *server) indexStakingDistributeRewardsLog(ctx context.Context, header *t
// Step 1: collect all data
bigZero := big.NewInt(0)
for i, nodeAddr := range stakingDistributeRewardsEvent.NodeAddrs {
if stakingDistributeRewardsEvent.RequestCounts[i].Cmp(bigZero) == 0 {
if stakingDistributeRewardsEvent.RequestCounts[i].Cmp(bigZero) != 1 {
// No contribution in this epoch, skip
zap.L().Debug("node has no contribution in this epoch, skip",
zap.Uint64("epoch", stakingDistributeRewardsEvent.Epoch.Uint64()),
zap.String("nodeAddr", nodeAddr.String()),
)

continue
}

Expand All @@ -54,7 +59,12 @@ func (s *server) indexStakingDistributeRewardsLog(ctx context.Context, header *t
})
if err != nil {
// Error, but no need to abort
zap.L().Error("save node request count", zap.Any("index", i), zap.Any("event", stakingDistributeRewardsEvent), zap.Error(err))
zap.L().Error("save node request count",
zap.Uint64("epoch", stakingDistributeRewardsEvent.Epoch.Uint64()),
zap.String("nodeAddr", nodeAddr.Hex()),
zap.Int64("requestCount", stakingDistributeRewardsEvent.RequestCounts[i].Int64()),
zap.Error(err),
)
}
}

Expand Down

0 comments on commit 120ca5a

Please sign in to comment.