Skip to content

Commit 2903e6a

Browse files
authored
Merge pull request #80 from mimi89999/uint64
Use uint64 for cert index
2 parents ff3b0f6 + ab59e7f commit 2903e6a

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
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: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ func (w *Watcher) CreateIndexFile(filePath string) error {
286286
continue
287287
}
288288

289-
metrics.index[transparencyLog.URL] = int64(sth.TreeSize)
289+
metrics.index[transparencyLog.URL] = sth.TreeSize
290290
}
291291
}
292292
w.cancelFunc()
@@ -304,7 +304,7 @@ type worker struct {
304304
operatorName string
305305
ctURL string
306306
entryChan chan models.Entry
307-
ctIndex int64
307+
ctIndex uint64
308308
mu sync.Mutex
309309
running bool
310310
cancel context.CancelFunc
@@ -394,14 +394,14 @@ func (w *worker) runWorker(ctx context.Context) error {
394394
return errFetchingSTHFailed
395395
}
396396
// Start at the latest STH to skip all the past certificates
397-
w.ctIndex = int64(sth.TreeSize)
397+
w.ctIndex = sth.TreeSize
398398
}
399399

400400
certScanner := scanner.NewScanner(jsonClient, scanner.ScannerOptions{
401401
FetcherOptions: scanner.FetcherOptions{
402402
BatchSize: 100,
403403
ParallelFetch: 1,
404-
StartIndex: w.ctIndex,
404+
StartIndex: int64(w.ctIndex),
405405
Continuous: true,
406406
},
407407
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)