Merge pull request #8941 from filecoin-project/gstuart/actors-cids-older-versions

Feat: api: Api call to get actor cids works for versions < 16
This commit is contained in:
Geoff Stuart
2022-06-29 15:31:50 -04:00
committed by GitHub
17 changed files with 386 additions and 635 deletions
+4 -17
View File
@@ -1526,27 +1526,14 @@ func (m *StateModule) StateNetworkVersion(ctx context.Context, tsk types.TipSetK
func (a *StateAPI) StateActorCodeCIDs(ctx context.Context, nv network.Version) (map[string]cid.Cid, error) {
actorVersion, err := actors.VersionForNetwork(nv)
if err != nil {
return nil, xerrors.Errorf("invalid network version")
return nil, xerrors.Errorf("invalid network version %d: %w", nv, err)
}
cids := make(map[string]cid.Cid)
manifestCid, ok := actors.GetManifest(actorVersion)
if !ok {
return nil, xerrors.Errorf("cannot get manifest CID")
cids, err := actors.GetActorCodeIDs(actorVersion)
if err != nil {
return nil, xerrors.Errorf("could not find cids for network version %d, actors version %d: %w", nv, actorVersion, err)
}
cids["_manifest"] = manifestCid
var actorKeys = actors.GetBuiltinActorsKeys()
for _, name := range actorKeys {
actorCID, ok := actors.GetActorCodeID(actorVersion, name)
if !ok {
return nil, xerrors.Errorf("didn't find actor %v code id for actor version %d", name,
actorVersion)
}
cids[name] = actorCID
}
return cids, nil
}