Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
RunOnFluxBot committed Nov 26, 2024
1 parent 705d60f commit 2f3cbb0
Showing 1 changed file with 16 additions and 30 deletions.
46 changes: 16 additions & 30 deletions services/appsService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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') {
Expand Down

0 comments on commit 2f3cbb0

Please sign in to comment.