loadCheckpointsFile reads checkpoints.json (if present) into the controller cache.
()
| 421 | |
| 422 | // loadCheckpointsFile reads checkpoints.json (if present) into the controller cache. |
| 423 | func (c *Controller) loadCheckpointsFile() { |
| 424 | path := filepath.Join(c.Config.DataDirPath, checkpointsFileName) |
| 425 | fileBytes, err := os.ReadFile(path) |
| 426 | if err != nil { |
| 427 | if !errors.Is(err, os.ErrNotExist) { |
| 428 | c.log.Warnf("failed to read checkpoints file: %s", err) |
| 429 | } |
| 430 | return |
| 431 | } |
| 432 | checkpoints := make(map[uint64]map[uint64]lib.HexBytes) |
| 433 | if err = json.Unmarshal(fileBytes, &checkpoints); err != nil { |
| 434 | c.log.Warnf("failed to parse checkpoints file: %s", err) |
| 435 | return |
| 436 | } |
| 437 | c.checkpoints = checkpoints |
| 438 | } |
| 439 | |
| 440 | // checkpointFromFile returns a cached checkpoint for a given chain and height, or nil if not found. |
| 441 | func (c *Controller) checkpointFromFile(height, chainId uint64) lib.HexBytes { |