Skip to content

Commit

Permalink
ARCO-205: fix PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
pawellewandowski98 committed Sep 30, 2024
1 parent 5236173 commit 7aa4925
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions internal/metamorph/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,6 @@ func (p *Processor) StartProcessStatusUpdatesInStorage() {
go func() {
defer p.waitGroup.Done()

//statusUpdatesMap := map[chainhash.Hash]store.UpdateStatus{}

for {
select {
case <-p.ctx.Done():
Expand All @@ -417,11 +415,6 @@ func (p *Processor) StartProcessStatusUpdatesInStorage() {
if len(actualUpdateStatusMap) >= p.processStatusUpdatesBatchSize {
p.checkAndUpdate(actualUpdateStatusMap)

err = p.cacheStore.Del(CacheStatusUpdateKey)
if err != nil {
p.logger.Error("failed to reset status update map", slog.String("err", err.Error()))
}

// 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)
Expand All @@ -431,11 +424,6 @@ func (p *Processor) StartProcessStatusUpdatesInStorage() {
if len(statusUpdatesMap) > 0 {
p.checkAndUpdate(statusUpdatesMap)

err := p.cacheStore.Del(CacheStatusUpdateKey)
if err != nil {
p.logger.Error("failed to reset status update map", slog.String("err", err.Error()))
}

// 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)
Expand Down Expand Up @@ -465,6 +453,11 @@ func (p *Processor) checkAndUpdate(statusUpdatesMap map[chainhash.Hash]store.Upd
if err != nil {
p.logger.Error("failed to bulk update statuses", slog.String("err", err.Error()))
}

err = p.cacheStore.Del(CacheStatusUpdateKey)
if err != nil {
p.logger.Error("failed to reset status update map", slog.String("err", err.Error()))
}
}

func (p *Processor) statusUpdateWithCallback(statusUpdates, doubleSpendUpdates []store.UpdateStatus) error {
Expand Down

0 comments on commit 7aa4925

Please sign in to comment.