Skip to content

Commit

Permalink
fix: fix logic
Browse files Browse the repository at this point in the history
  • Loading branch information
nick-bisonai committed Aug 2, 2024
1 parent c8a25d2 commit 7285fb7
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions node/pkg/dal/collector/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,24 +156,16 @@ func (c *Collector) receiveEach(ctx context.Context, configId int32) error {
}

func (c *Collector) compareAndSwapLatestTimestamp(data aggregator.SubmissionData) bool {
c.mu.RLock()
c.mu.Lock()
defer c.mu.Unlock()

old, ok := c.LatestTimestamps[data.GlobalAggregate.ConfigID]
c.mu.RUnlock()
if !ok {
c.mu.Lock()
if !ok || !old.After(data.GlobalAggregate.Timestamp) {
c.LatestTimestamps[data.GlobalAggregate.ConfigID] = data.GlobalAggregate.Timestamp
c.mu.Unlock()
return true
}

if old.After(data.GlobalAggregate.Timestamp) {
return false
}

c.mu.Lock()
c.LatestTimestamps[data.GlobalAggregate.ConfigID] = data.GlobalAggregate.Timestamp
c.mu.Unlock()
return true
return false
}

func (c *Collector) processIncomingData(ctx context.Context, data aggregator.SubmissionData) {
Expand Down

0 comments on commit 7285fb7

Please sign in to comment.