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

Function newDataForScript

bidengine/shellscript.go:193–230  ·  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 resources := r.GSpec.Resources
204 if len(r.AllocatedResources) > 0 {
205 resources = r.AllocatedResources
206 }
207
208 // iterate over everything & sum it up
209 for i, group := range resources {
210 groupCount := group.Count
211
212 cpuQuantity := parseCPU(group.CPU)
213 gpuQuantity := parseGPU(group.GPU)
214 memoryQuantity := parseMemory(group.Memory)
215 storageQuantity := parseStorage(group.Storage)
216 endpointQuantity := len(group.Endpoints)
217
218 d.Resources[i] = dataForScriptElement{
219 CPU: cpuQuantity,
220 GPU: gpuQuantity,
221 Memory: memoryQuantity,
222 Storage: storageQuantity,
223 Count: groupCount,
224 EndpointQuantity: endpointQuantity,
225 IPLeaseQuantity: util.GetEndpointQuantityOfResourceUnits(group.Resources, rtypes.Endpoint_LEASED_IP),
226 }
227 }
228
229 return d
230}

Callers 2

CalculatePriceMethod · 0.85

Calls 5

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

Tested by 1