diff --git a/internal/metamorph/processor.go b/internal/metamorph/processor.go index 5c2642b76..1da21c48b 100644 --- a/internal/metamorph/processor.go +++ b/internal/metamorph/processor.go @@ -415,9 +415,10 @@ func (p *Processor) StartProcessStatusUpdatesInStorage() { return case statusUpdate := <-p.storageStatusUpdateCh: // Ensure no duplicate statuses + p.logger.Info("Status update received", slog.String("hash", statusUpdate.Hash.String()), slog.String("status", statusUpdate.Status.String())) err := p.updateStatusMap(statusUpdate) if err != nil { - p.logger.Error("failed to update status", slog.String("err", err.Error())) + p.logger.Error("failed to update status", slog.String("err", err.Error()), slog.String("hash", statusUpdate.Hash.String())) return } @@ -428,6 +429,7 @@ func (p *Processor) StartProcessStatusUpdatesInStorage() { } if statusUpdateCount >= p.processStatusUpdatesBatchSize { + p.logger.Info("Status update count is greater than batch size", slog.Int("count", statusUpdateCount), slog.Int("batch_size", p.processStatusUpdatesBatchSize)) err := p.checkAndUpdate(ctx) if err != nil { p.logger.Error("failed to check and update statuses", slog.String("err", err.Error())) @@ -436,6 +438,8 @@ func (p *Processor) StartProcessStatusUpdatesInStorage() { // Reset ticker to delay the next tick, ensuring the interval starts after the batch is processed. // This prevents unnecessary immediate updates and maintains the intended time interval between batches. ticker.Reset(p.processStatusUpdatesInterval) + } else { + p.logger.Debug("Status update count is less than batch size", slog.Int("count", statusUpdateCount), slog.Int("batch_size", p.processStatusUpdatesBatchSize)) } case <-ticker.C: statusUpdateCount, err := p.getStatusUpdateCount() @@ -466,12 +470,15 @@ func (p *Processor) checkAndUpdate(ctx context.Context) error { tracing.EndTracing(span, err) }() + p.logger.Info("checkAndUpdate - Checking and updating statuses") + statusUpdatesMap, err := p.getAndDeleteAllTransactionStatuses() if err != nil { return err } if len(statusUpdatesMap) == 0 { + p.logger.Info("checkAndUpdate - No statuses to update") return nil } @@ -480,8 +487,10 @@ func (p *Processor) checkAndUpdate(ctx context.Context) error { for _, status := range statusUpdatesMap { if len(status.CompetingTxs) > 0 { + p.logger.Info("checkAndUpdate - Double spend detected", slog.String("hash", status.Hash.String())) doubleSpendUpdates = append(doubleSpendUpdates, status) } else { + p.logger.Info("checkAndUpdate - Status update", slog.String("hash", status.Hash.String()), slog.String("status", status.Status.String())) statusUpdates = append(statusUpdates, status) } } diff --git a/internal/metamorph/processor_helpers.go b/internal/metamorph/processor_helpers.go index 37217705b..bded400ef 100644 --- a/internal/metamorph/processor_helpers.go +++ b/internal/metamorph/processor_helpers.go @@ -28,6 +28,7 @@ func (p *Processor) updateStatusMap(statusUpdate store.UpdateStatus) error { currentStatusUpdate, err := p.getTransactionStatus(statusUpdate.Hash) if err != nil { if errors.Is(err, cache.ErrCacheNotFound) { + p.logger.Info("updateStatusMap - status record not found, creating new one", slog.String("hash", statusUpdate.Hash.String())) // if record doesn't exist, save new one return p.setTransactionStatus(statusUpdate) } @@ -35,10 +36,12 @@ func (p *Processor) updateStatusMap(statusUpdate store.UpdateStatus) error { } if shouldUpdateCompetingTxs(statusUpdate, *currentStatusUpdate) { + p.logger.Info("updateStatusMap - updating competing txs", slog.String("hash", statusUpdate.Hash.String())) currentStatusUpdate.CompetingTxs = mergeUnique(statusUpdate.CompetingTxs, currentStatusUpdate.CompetingTxs) } if shouldUpdateStatus(statusUpdate, *currentStatusUpdate) { + p.logger.Info("updateStatusMap - updating status", slog.String("hash", statusUpdate.Hash.String()), slog.String("old_status", currentStatusUpdate.Status.String()), slog.String("new_status", statusUpdate.Status.String())) currentStatusUpdate.Status = statusUpdate.Status statusUpdate.StatusHistory = append(currentStatusUpdate.StatusHistory, store.StatusWithTimestamp{ Status: statusUpdate.Status, @@ -46,6 +49,8 @@ func (p *Processor) updateStatusMap(statusUpdate store.UpdateStatus) error { }) } + p.logger.Info("updateStatusMap - updating status in cache", slog.String("hash", statusUpdate.Hash.String()), slog.String("status", statusUpdate.Status.String()), slog.Any("status_history", statusUpdate.StatusHistory)) + return p.setTransactionStatus(*currentStatusUpdate) }