diff --git a/internal/poller/poller.go b/internal/poller/poller.go index f31e5c3..23dd632 100644 --- a/internal/poller/poller.go +++ b/internal/poller/poller.go @@ -48,9 +48,11 @@ func (p *Poller) Stop() { } func (p *Poller) poll(ctx context.Context) error { + log.Debug().Msg("Polling started") if err := p.service.ProcessExpiredDelegations(ctx); err != nil { log.Error().Err(err).Msg("Error processing expired delegations") return err } + log.Debug().Msg("Polling completed") return nil } diff --git a/internal/services/service.go b/internal/services/service.go index 627b4f3..cf7b3d9 100644 --- a/internal/services/service.go +++ b/internal/services/service.go @@ -7,6 +7,7 @@ import ( "github.com/babylonlabs-io/staking-expiry-checker/internal/db" "github.com/babylonlabs-io/staking-expiry-checker/internal/queue" queueclient "github.com/babylonlabs-io/staking-queue-client/client" + "github.com/rs/zerolog/log" ) type Service struct { @@ -27,12 +28,14 @@ func (s *Service) ProcessExpiredDelegations(ctx context.Context) error { // TODO: Use cache with ttl to store the tip height. btcTip, err := s.btc.GetBlockCount() if err != nil { + log.Error().Err(err).Msg("Error getting BTC tip height") return err } for { expiredDelegations, err := s.db.FindExpiredDelegations(ctx, uint64(btcTip)) if err != nil { + log.Error().Err(err).Msg("Error finding expired delegations") return err } if len(expiredDelegations) == 0 { @@ -42,14 +45,15 @@ func (s *Service) ProcessExpiredDelegations(ctx context.Context) error { for _, delegation := range expiredDelegations { ev := queueclient.NewExpiredStakingEvent(delegation.StakingTxHashHex, delegation.TxType) if err := s.queueManager.SendExpiredStakingEvent(ctx, ev); err != nil { + log.Error().Err(err).Msg("Error sending expired staking event") return err } // After successfully sending the event, delete the entry from the database. if err := s.db.DeleteExpiredDelegation(ctx, delegation.ID); err != nil { + log.Error().Err(err).Msg("Error deleting expired delegation") return err } } - } return nil