From 1c48145f7ffc731ba40b16bbb536f7a496cb79e9 Mon Sep 17 00:00:00 2001 From: Marcin Gordel Date: Tue, 3 Sep 2024 14:00:24 +0200 Subject: [PATCH] refactor(demand): added warning when rentHours is less than 5 min --- src/market/market.module.ts | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/market/market.module.ts b/src/market/market.module.ts index 0b803e09d..2a66a9d52 100644 --- a/src/market/market.module.ts +++ b/src/market/market.module.ts @@ -285,22 +285,20 @@ export class MarketModuleImpl implements MarketModule { ? await this.applyLocalGVMIServeSupport(demandOptions.workload) : demandOptions.workload; + const expirationSec = orderOptions.rentHours * 60 * 60; + /** - * We need to publish a demand with a minimum expiration time of no less than 5 minutes. - * - * When negotiating an offer and sending a counter proposal, providers (on default settings) - * reject offers with an expirationSec of less than 5 minutes. - * By default, the expirationSec in CounterProposal value is copied from the value defined in the demand. - * - * Additionally, we want to avoid a situation when the demand expires before finding and signing - * an agreement with the provider. Therefore, we assume a minimum time of 15 minutes, - * if the value calculated based on the user-defined rentHourse is less. + * Default value on providers for MIN_AGREEMENT_EXPIRATION = 5min. + * This means that if the user declares a rentHours time of less than 5 min, + * offers will be rejected during negotiations with these providers. */ - const MIN_EXPIRATION_SEC = 15 * 60; + const MIN_EXPIRATION_SEC_WARN = 5 * 60; - const expirationSecBasedOnRentTime = orderOptions.rentHours * 60 * 60; - const expirationSec = - expirationSecBasedOnRentTime < MIN_EXPIRATION_SEC ? MIN_EXPIRATION_SEC : expirationSecBasedOnRentTime; + if (expirationSec < MIN_EXPIRATION_SEC_WARN) { + this.logger.warn( + "The declared value of rentHours is less than 5 min. This may cause offers to be rejected during negotiations.", + ); + } const workloadConfig = new WorkloadDemandDirectorConfig({ ...workloadOptions,