@@ -30,27 +30,36 @@ func LoadBuiltinActors(lc fx.Lifecycle, mctx helpers.MetricsCtx, r repo.LockedRe
3030 }
3131
3232 for av , rel := range build .BuiltinActorReleases {
33+ // first check to see if we know this release
3334 key := dstore .NewKey (fmt .Sprintf ("/builtin-actors/v%d/%s" , av , rel ))
3435
3536 data , err := ds .Get (ctx , key )
3637 switch err {
3738 case nil :
39+ // ok, we do, this should be the manifest cid
3840 mfCid , err := cid .Cast (data )
3941 if err != nil {
4042 return result , xerrors .Errorf ("error parsing cid for %s: %w" , key , err )
4143 }
4244
45+ // check the blockstore for existence of the manifest
4346 has , err := bs .Has (ctx , mfCid )
4447 if err != nil {
4548 return result , xerrors .Errorf ("error checking blockstore for manifest cid %s: %w" , mfCid , err )
4649 }
4750
4851 if has {
52+ // it's there, no need to reload the bundle to the blockstore; just add it to the manifest list.
4953 actors .AddManifest (av , mfCid )
5054 continue
5155 }
5256
57+ // we have a release key but don't have the manifest in the blockstore; maybe the user
58+ // nuked his blockstore to restart from a snapshot. So fallthrough to refetch (if necessary)
59+ // and reload the bundle.
60+
5361 case dstore .ErrNotFound :
62+ // we don't have a release key, we need to load the bundle
5463
5564 default :
5665 return result , xerrors .Errorf ("error loading %s from datastore: %w" , key , err )
@@ -62,11 +71,13 @@ func LoadBuiltinActors(lc fx.Lifecycle, mctx helpers.MetricsCtx, r repo.LockedRe
6271 return result , err
6372 }
6473
74+ // add the release key with the manifest to avoid reloading it in next restart.
6575 if err := ds .Put (ctx , key , mfCid .Bytes ()); err != nil {
6676 return result , xerrors .Errorf ("error storing manifest CID for builtin-actors vrsion %d to the datastore: %w" , av , err )
6777 }
6878 }
6979
80+ // we've loaded all the bundles, now load the manifests to get actor code CIDs.
7081 cborStore := cbor .NewCborStore (bs )
7182 if err := actors .LoadManifests (ctx , cborStore ); err != nil {
7283 return result , xerrors .Errorf ("error loading actor manifests: %w" , err )
0 commit comments