in go/storage/certdatabase.go [89:115]
func (db *CertDatabase) EnsureCacheIsConsistent() error {
storageEpoch, err := db.getStorageEpoch()
if err != nil {
return err
}
cacheEpoch, err := db.cache.GetEpoch()
if err != nil {
return err
}
if cacheEpoch == storageEpoch+1 || (cacheEpoch == 0 && storageEpoch == 0) {
return nil
}
// The epochs are inconsistent, so we'll reset the cached log states
// based on what's in storage. This ensures that the ct-fetch process
// downloads a portion of each log that is contiguous with what's
// already in storage.
logStates, err := db.GetCTLogsFromStorage()
if err != nil {
return err
}
return db.cache.Restore(storageEpoch+1, logStates)
}