MCPcopy Create free account
hub / github.com/akash-network/provider / newDataForScript

Function newDataForScript

bidengine/shellscript.go:193–237  ·  view source on GitHub ↗
(r Request)

Source from the content-addressed store, hash-verified

191}
192
193func newDataForScript(r Request) dataForScript {
194 d := dataForScript{
195 Resources: make([]dataForScriptElement, len(r.GSpec.Resources)),
196 Price: r.GSpec.Price(),
197 }
198
199 if r.PricePrecision > 0 {
200 d.PricePrecision = &r.PricePrecision
201 }
202
203 for _, attr := range r.GSpec.Requirements.Attributes {
204 if attr.Key == "confidential-compute" && attr.Value == "true" {
205 d.ConfidentialCompute = true
206 break
207 }
208 }
209
210 resources := r.GSpec.Resources
211 if len(r.AllocatedResources) > 0 {
212 resources = r.AllocatedResources
213 }
214
215 // iterate over everything & sum it up
216 for i, group := range resources {
217 groupCount := group.Count
218
219 cpuQuantity := parseCPU(group.CPU)
220 gpuQuantity := parseGPU(group.GPU)
221 memoryQuantity := parseMemory(group.Memory)
222 storageQuantity := parseStorage(group.Storage)
223 endpointQuantity := len(group.Endpoints)
224
225 d.Resources[i] = dataForScriptElement{
226 CPU: cpuQuantity,
227 GPU: gpuQuantity,
228 Memory: memoryQuantity,
229 Storage: storageQuantity,
230 Count: groupCount,
231 EndpointQuantity: endpointQuantity,
232 IPLeaseQuantity: util.GetEndpointQuantityOfResourceUnits(group.Resources, rtypes.Endpoint_LEASED_IP),
233 }
234 }
235
236 return d
237}

Callers 2

CalculatePriceMethod · 0.85

Calls 5

parseCPUFunction · 0.85
parseGPUFunction · 0.85
parseMemoryFunction · 0.85
parseStorageFunction · 0.85

Tested by 1