Skip to content

Commit ab59e7f

Browse files
committed
Use uint64 for cert index
1 parent 5c68219 commit ab59e7f

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

internal/certificatetransparency/ct-parser.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func parseData(entry *ct.RawLogEntry, operatorName, logName, ctURL string) (mode
2727

2828
// Create main data structure
2929
data := models.Data{
30-
CertIndex: entry.Index,
30+
CertIndex: uint64(entry.Index),
3131
CertLink: certLink,
3232
Seen: float64(time.Now().UnixMilli()) / 1_000,
3333
Source: models.Source{

internal/certificatetransparency/ct-watcher.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ func (w *Watcher) CreateIndexFile(filePath string) error {
250250
continue
251251
}
252252

253-
metrics.index[transparencyLog.URL] = int64(sth.TreeSize)
253+
metrics.index[transparencyLog.URL] = sth.TreeSize
254254
}
255255
}
256256
w.cancelFunc()
@@ -268,7 +268,7 @@ type worker struct {
268268
operatorName string
269269
ctURL string
270270
entryChan chan models.Entry
271-
ctIndex int64
271+
ctIndex uint64
272272
mu sync.Mutex
273273
running bool
274274
cancel context.CancelFunc
@@ -353,19 +353,19 @@ func (w *worker) runWorker(ctx context.Context) error {
353353
if !validSavedCTIndexExists {
354354
sth, getSTHerr := jsonClient.GetSTH(ctx)
355355
if getSTHerr != nil {
356-
// TODO this can happen due to a 429 error. We should retry the request
356+
// TODO this can happen due to a 429 error. We should retry the request
357357
log.Printf("Could not get STH for '%s': %s\n", w.ctURL, getSTHerr)
358358
return errFetchingSTHFailed
359359
}
360360
// Start at the latest STH to skip all the past certificates
361-
w.ctIndex = int64(sth.TreeSize)
361+
w.ctIndex = sth.TreeSize
362362
}
363363

364364
certScanner := scanner.NewScanner(jsonClient, scanner.ScannerOptions{
365365
FetcherOptions: scanner.FetcherOptions{
366366
BatchSize: 100,
367367
ParallelFetch: 1,
368-
StartIndex: w.ctIndex,
368+
StartIndex: int64(w.ctIndex),
369369
Continuous: true,
370370
},
371371
Matcher: scanner.MatchAll{},

internal/certificatetransparency/logmetrics.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type (
1717
// CTMetrics is a map of operator names to a map of CT log urls to the number of certs processed by said log.
1818
CTMetrics map[string]OperatorMetric
1919
// CTCertIndex is a map of CT log urls to the last processed certficate index on the said log
20-
CTCertIndex map[string]int64
20+
CTCertIndex map[string]uint64
2121
)
2222

2323
var (
@@ -119,7 +119,7 @@ func (m *LogMetrics) Set(operator, url string, value int64) {
119119
}
120120

121121
// Inc the metric for a given operator and ct url.
122-
func (m *LogMetrics) Inc(operator, url string, index int64) {
122+
func (m *LogMetrics) Inc(operator, url string, index uint64) {
123123
m.mutex.Lock()
124124
defer m.mutex.Unlock()
125125

@@ -138,15 +138,15 @@ func (m *LogMetrics) GetAllCTIndexes() CTCertIndex {
138138

139139
// make a copy of the index and return it
140140
// since map is a refrence type
141-
copyOfIndex := make(map[string]int64)
141+
copyOfIndex := make(map[string]uint64)
142142
for k, v := range m.index {
143143
copyOfIndex[k] = v
144144
}
145145

146146
return copyOfIndex
147147
}
148148

149-
func (m *LogMetrics) GetCTIndex(url string) int64 {
149+
func (m *LogMetrics) GetCTIndex(url string) uint64 {
150150
m.mutex.RLock()
151151
defer m.mutex.RUnlock()
152152

internal/models/certstream.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func (e *Entry) entryToJSONBytes() []byte {
8787
}
8888

8989
type Data struct {
90-
CertIndex int64 `json:"cert_index"`
90+
CertIndex uint64 `json:"cert_index"`
9191
CertLink string `json:"cert_link"`
9292
Chain []LeafCert `json:"chain,omitempty"`
9393
LeafCert LeafCert `json:"leaf_cert"`

0 commit comments

Comments
 (0)