MCPcopy
hub / github.com/canopy-network/canopy / loadCheckpointsFile

Method loadCheckpointsFile

controller/controller.go:423–438  ·  view source on GitHub ↗

loadCheckpointsFile reads checkpoints.json (if present) into the controller cache.

()

Source from the content-addressed store, hash-verified

421
422// loadCheckpointsFile reads checkpoints.json (if present) into the controller cache.
423func (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.
441func (c *Controller) checkpointFromFile(height, chainId uint64) lib.HexBytes {

Callers 1

NewFunction · 0.80

Calls 2

WarnfMethod · 0.65
UnmarshalMethod · 0.65

Tested by

no test coverage detected