Skip to content

Commit

Permalink
add more logs
Browse files Browse the repository at this point in the history
  • Loading branch information
gusin13 committed Jan 10, 2025
1 parent 72e1a7d commit e8f234d
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions internal/services/pollers.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ func (s *Service) processBTCSubscriber(ctx context.Context) *types.Error {
var (
lastProcessedID string
batchSize = s.cfg.Pollers.ExpiryChecker.BatchSize
totalProcessed = 0
totalFetched = 0
batchCount = 0
)

startTime := time.Now()
for {
batchCount++
result, err := s.db.GetBTCDelegationsByStatesInBatches(
ctx,
[]types.DelegationState{
Expand All @@ -37,6 +39,8 @@ func (s *Service) processBTCSubscriber(ctx context.Context) *types.Error {
break
}

totalFetched += len(result.Delegations)

// Process batch
for _, delegation := range result.Delegations {
if s.trackedSubs.IsSubscribed(delegation.StakingTxHashHex) {
Expand All @@ -57,8 +61,6 @@ func (s *Service) processBTCSubscriber(ctx context.Context) *types.Error {
}

s.trackedSubs.AddSubscription(delegation.StakingTxHashHex)
totalProcessed++

log.Debug().
Str("stakingTxHash", delegation.StakingTxHashHex).
Msg("Successfully registered BTC notification")
Expand All @@ -73,7 +75,9 @@ func (s *Service) processBTCSubscriber(ctx context.Context) *types.Error {
}

log.Info().
Int("total_processed", totalProcessed).
Int("total_delegations_fetched", totalFetched).
Int("total_batches", batchCount).
Int("batch_size", int(batchSize)).
Float64("duration_seconds", time.Since(startTime).Seconds()).
Msg("BTC subscription processing completed")

Expand Down

0 comments on commit e8f234d

Please sign in to comment.