Skip to content

Commit

Permalink
Append as time series
Browse files Browse the repository at this point in the history
  • Loading branch information
ferglor committed Jul 18, 2024
1 parent fa76ced commit c6065d4
Showing 1 changed file with 18 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ type logBuffer struct {
queues map[string]*upkeepLogQueue
queueIDs []string
blockHashes map[int64]string
availableLogs map[string]map[int64]int
dequeuedLogs map[string]map[int64]int
availableLogs map[string]map[int64][]int
dequeuedLogs map[string]map[int64][]int

lock sync.RWMutex
}
Expand All @@ -87,8 +87,8 @@ func NewLogBuffer(lggr logger.Logger, lookback, blockRate, logLimit uint32) LogB
queueIDs: []string{},
blockHashes: map[int64]string{},
queues: make(map[string]*upkeepLogQueue),
availableLogs: map[string]map[int64]int{},
dequeuedLogs: map[string]map[int64]int{},
availableLogs: map[string]map[int64][]int{},
dequeuedLogs: map[string]map[int64][]int{},
}
}

Expand Down Expand Up @@ -208,14 +208,18 @@ func (b *logBuffer) dequeue(start int64, capacity int, minimumDequeue bool) ([]B

upkeepAvailableLogs, ok := b.availableLogs[qid]
if !ok {
upkeepAvailableLogs = map[int64]int{}
upkeepAvailableLogs = map[int64][]int{}
}

_, ok2 := upkeepAvailableLogs[start]
if !ok2 {
upkeepAvailableLogs[start] = logsInRange
series2, ok3 := upkeepAvailableLogs[start]
if !ok3 {
series2 = []int{logsInRange}
} else {
series2 = append(series2, logsInRange)
}

upkeepAvailableLogs[start] = series2

b.availableLogs[qid] = upkeepAvailableLogs

if capacity == 0 {
Expand Down Expand Up @@ -245,16 +249,18 @@ func (b *logBuffer) dequeue(start int64, capacity int, minimumDequeue bool) ([]B

dequeuedLogs, ok := b.dequeuedLogs[qid]
if !ok {
dequeuedLogs = map[int64]int{}
dequeuedLogs = map[int64][]int{}
}

_, ok3 := dequeuedLogs[start]
series, ok3 := dequeuedLogs[start]
if !ok3 {
dequeuedLogs[start] = len(logs)
series = []int{len(logs)}
} else {
dequeuedLogs[start] += len(logs)
series = append(series, len(logs))
}

dequeuedLogs[start] = series

b.dequeuedLogs[qid] = dequeuedLogs
}
b.lggr.Debugw("minimum commitment logs dequeued", "start", start, "end", end, "numUpkeeps", len(b.queues), "numUpkeepIDs", len(b.queueIDs), "minimumDequeueMet", minimumDequeueMet, "logLimit", logLimit, "queuesQueried", queuesQueried, "queuesInRange", queuesInRange, "queuesIterated", queuesIterated)
Expand Down

0 comments on commit c6065d4

Please sign in to comment.