Added api call to get actors cids

This commit is contained in:
Geoff Stuart
2022-06-23 14:07:23 -04:00
parent 824da5ea51
commit e684248f48
15 changed files with 134 additions and 17 deletions
+30 -1
View File
@@ -7,12 +7,14 @@ import (
"fmt"
"strconv"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/libp2p/go-libp2p-core/peer"
"github.com/filecoin-project/go-state-types/crypto"
"github.com/filecoin-project/go-state-types/cbor"
cid "github.com/ipfs/go-cid"
"github.com/ipfs/go-cid"
"go.uber.org/fx"
"golang.org/x/xerrors"
@@ -1460,6 +1462,33 @@ func (m *StateModule) StateNetworkVersion(ctx context.Context, tsk types.TipSetK
return m.StateManager.GetNetworkVersion(ctx, ts.Height()), nil
}
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")
}
cids := make(map[string]cid.Cid)
manifestCid, ok := actors.GetManifest(actorVersion)
if !ok {
return nil, xerrors.Errorf("cannot get manifest CID")
}
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
}
func (a *StateAPI) StateGetRandomnessFromTickets(ctx context.Context, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte, tsk types.TipSetKey) (abi.Randomness, error) {
return a.StateManager.GetRandomnessFromTickets(ctx, personalization, randEpoch, entropy, tsk)
}