Skip to content

Commit

Permalink
fix(demand): defined minimum expiration value for demand
Browse files Browse the repository at this point in the history
  • Loading branch information
mgordel committed Sep 2, 2024
1 parent 98c7259 commit c91b270
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/market/market.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,26 @@ export class MarketModuleImpl implements MarketModule {
? await this.applyLocalGVMIServeSupport(demandOptions.workload)
: demandOptions.workload;

/**
* 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.
*/
const MIN_EXPIRATION_SEC = 15;

const expirationSecBasedOnRentTime = orderOptions.rentHours * 3600;
const expirationSec =
expirationSecBasedOnRentTime < MIN_EXPIRATION_SEC ? MIN_EXPIRATION_SEC : expirationSecBasedOnRentTime;

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 c91b270

Please sign in to comment.