add comments in the DI bundle loader
This commit is contained in:
parent
30d339842e
commit
68b280b695
@ -30,27 +30,36 @@ func LoadBuiltinActors(lc fx.Lifecycle, mctx helpers.MetricsCtx, r repo.LockedRe
|
||||
}
|
||||
|
||||
for av, rel := range build.BuiltinActorReleases {
|
||||
// first check to see if we know this release
|
||||
key := dstore.NewKey(fmt.Sprintf("/builtin-actors/v%d/%s", av, rel))
|
||||
|
||||
data, err := ds.Get(ctx, key)
|
||||
switch err {
|
||||
case nil:
|
||||
// ok, we do, this should be the manifest cid
|
||||
mfCid, err := cid.Cast(data)
|
||||
if err != nil {
|
||||
return result, xerrors.Errorf("error parsing cid for %s: %w", key, err)
|
||||
}
|
||||
|
||||
// check the blockstore for existence of the manifest
|
||||
has, err := bs.Has(ctx, mfCid)
|
||||
if err != nil {
|
||||
return result, xerrors.Errorf("error checking blockstore for manifest cid %s: %w", mfCid, err)
|
||||
}
|
||||
|
||||
if has {
|
||||
// it's there, no need to reload the bundle to the blockstore; just add it to the manifest list.
|
||||
actors.AddManifest(av, mfCid)
|
||||
continue
|
||||
}
|
||||
|
||||
// we have a release key but don't have the manifest in the blockstore; maybe the user
|
||||
// nuked his blockstore to restart from a snapshot. So fallthrough to refetch (if necessary)
|
||||
// and reload the bundle.
|
||||
|
||||
case dstore.ErrNotFound:
|
||||
// we don't have a release key, we need to load the bundle
|
||||
|
||||
default:
|
||||
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
|
||||
return result, err
|
||||
}
|
||||
|
||||
// add the release key with the manifest to avoid reloading it in next restart.
|
||||
if err := ds.Put(ctx, key, mfCid.Bytes()); err != nil {
|
||||
return result, xerrors.Errorf("error storing manifest CID for builtin-actors vrsion %d to the datastore: %w", av, err)
|
||||
}
|
||||
}
|
||||
|
||||
// we've loaded all the bundles, now load the manifests to get actor code CIDs.
|
||||
cborStore := cbor.NewCborStore(bs)
|
||||
if err := actors.LoadManifests(ctx, cborStore); err != nil {
|
||||
return result, xerrors.Errorf("error loading actor manifests: %w", err)
|
||||
|
Loading…
Reference in New Issue
Block a user