Deployments Keeper Processing for Store/Chain Population
Source code reference location
The Create
method takes in Deployment details as an argument and writes the new Deployment to the blockchain.
func (k Keeper) Create(ctx sdk.Context, deployment types.Deployment, groups []types.Group) error {
store := ctx.KVStore(k.skey)
key := deploymentKey(deployment.ID())
if store.Has(key) {
return types.ErrDeploymentExists
}
store.Set(key, k.cdc.MustMarshal(&deployment))
for idx := range groups {
group := groups[idx]
if !group.ID().DeploymentID().Equals(deployment.ID()) {
return types.ErrInvalidGroupID
}
gkey := groupKey(group.ID())
store.Set(gkey, k.cdc.MustMarshal(&group))
}
ctx.EventManager().EmitEvent(
types.NewEventDeploymentCreated(deployment.ID(), deployment.Version).
ToSDKEvent(),
)
telemetry.IncrCounter(1.0, "akash.deployment_created")
return nil
}