Skip to content

Commit

Permalink
Merge pull request #1062 from golemfactory/bugfix/demand-min-expiration
Browse files Browse the repository at this point in the history
fix(demand): defined minimum expiration value for demand
  • Loading branch information
grisha87 authored Sep 3, 2024
2 parents 28d634e + 1c48145 commit 186ac6b
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/market/market.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,24 @@ export class MarketModuleImpl implements MarketModule {
? await this.applyLocalGVMIServeSupport(demandOptions.workload)
: demandOptions.workload;

const expirationSec = orderOptions.rentHours * 60 * 60;

/**
* 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_WARN = 5 * 60;

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,
expirationSec: orderOptions.rentHours * 60 * 60, // hours to seconds
expirationSec,
});
const workloadDirector = new WorkloadDemandDirector(workloadConfig);
await workloadDirector.apply(builder);
Expand Down

0 comments on commit 186ac6b

Please sign in to comment.