From 2f3cbb03256e44b019bee7ab598213b57d3dfbed Mon Sep 17 00:00:00 2001 From: RunOnFlux Date: Tue, 26 Nov 2024 14:54:54 +0000 Subject: [PATCH] Update from https://github.com/RunOnFlux/flux/commit/6be86ad7f8136d80fae02b89a0b741be3e92cc60 --- services/appsService.js | 46 ++++++++++++++--------------------------- 1 file changed, 16 insertions(+), 30 deletions(-) diff --git a/services/appsService.js b/services/appsService.js index fc587315..f3299a45 100644 --- a/services/appsService.js +++ b/services/appsService.js @@ -4207,7 +4207,7 @@ async function softRegisterAppLocally(appSpecs, componentSpecs, res) { * @param {number} height Block height. * @returns {number} App price. */ -async function appPricePerMonth(dataForAppRegistration, height, suppliedPrices, callByFiatAndFluxPriceFunction) { +async function appPricePerMonth(dataForAppRegistration, height, suppliedPrices) { if (!dataForAppRegistration) { return new Error('Application specification not provided'); } @@ -4253,12 +4253,6 @@ async function appPricePerMonth(dataForAppRegistration, height, suppliedPrices, const additionalPrice = (appPrice * instancesAdditional) / 3; appPrice = (Math.ceil(additionalPrice * 100) + Math.ceil(appPrice * 100)) / 100; } - if (callByFiatAndFluxPriceFunction) { - const gSyncthingApp = dataForAppRegistration.containerData.includes('g:'); - if (gSyncthingApp) { - appPrice *= 0.8; - } - } if (appPrice < priceSpecifications.minPrice) { appPrice = priceSpecifications.minPrice; } @@ -4286,17 +4280,6 @@ async function appPricePerMonth(dataForAppRegistration, height, suppliedPrices, const additionalPrice = (appPrice * instancesAdditional) / 3; appPrice = (Math.ceil(additionalPrice * 100) + Math.ceil(appPrice * 100)) / 100; } - if (callByFiatAndFluxPriceFunction) { - if (cpuTotal <= 3 && ramTotal <= 6000 && hddTotal <= 150) { - appPrice *= 0.8; - } else if (cpuTotal <= 7 && ramTotal <= 29000 && hddTotal <= 370) { - appPrice *= 0.9; - } - const gSyncthingApp = dataForAppRegistration.containerData.includes('g:'); - if (gSyncthingApp) { - appPrice *= 0.8; - } - } if (appPrice < priceSpecifications.minPrice) { appPrice = priceSpecifications.minPrice; } @@ -4343,18 +4326,6 @@ async function appPricePerMonth(dataForAppRegistration, height, suppliedPrices, appPrice = (Math.ceil(additionalPrice * 100) + Math.ceil(appPrice * 100)) / 100; } - if (callByFiatAndFluxPriceFunction) { - if (cpuTotalCount <= 3 && ramTotalCount <= 6000 && hddTotalCount <= 150) { - appPrice *= 0.8; - } else if (cpuTotalCount <= 7 && ramTotalCount <= 29000 && hddTotalCount <= 370) { - appPrice *= 0.9; - } - const gSyncthingApp = dataForAppRegistration.compose.find((comp) => comp.containerData.includes('g:')); - if (gSyncthingApp) { - appPrice *= 0.8; - } - } - if (appPrice < priceSpecifications.minPrice) { appPrice = priceSpecifications.minPrice; } @@ -10428,6 +10399,21 @@ async function getAppFiatAndFluxPrice(req, res) { actualPriceToPay -= (perc * previousSpecsPrice); } } + const appHWrequirements = totalAppHWRequirements(appSpecFormatted, 'bamf'); + if (appHWrequirements.cpu < 3 && appHWrequirements.ram < 6000 && appHWrequirements.hdd < 150) { + actualPriceToPay *= 0.8; + } else if (appHWrequirements.cpu < 7 && appHWrequirements.ram < 29000 && appHWrequirements.hdd < 370) { + actualPriceToPay *= 0.9; + } + let gSyncthgApp = false; + if (appSpecFormatted.version <= 3) { + gSyncthgApp = appSpecFormatted.containerData.includes('g:'); + } else { + gSyncthgApp = appSpecFormatted.compose.find((comp) => comp.containerData.includes('g:')); + } + if (gSyncthgApp) { + actualPriceToPay *= 0.8; + } const marketplaceResponse = await axios.get('https://stats.runonflux.io/marketplace/listapps').catch((error) => log.error(error)); let marketPlaceApps = []; if (marketplaceResponse && marketplaceResponse.data && marketplaceResponse.data.status === 'success') {