wallet-core: clamp claim retry properly
This commit is contained in:
parent
611a57ca0a
commit
b2931fbac6
@ -91,19 +91,24 @@ export namespace Duration {
|
||||
}
|
||||
return { d_ms: deadline.t_ms - now.t_ms };
|
||||
}
|
||||
|
||||
export function toIntegerYears(d: Duration): number {
|
||||
if (typeof d.d_ms !== "number") {
|
||||
throw Error("infinite duration");
|
||||
}
|
||||
return Math.ceil(d.d_ms / 1000 / 60 / 60 / 24 / 365);
|
||||
}
|
||||
|
||||
export const fromSpec = durationFromSpec;
|
||||
|
||||
export function getForever(): Duration {
|
||||
return { d_ms: "forever" };
|
||||
}
|
||||
|
||||
export function getZero(): Duration {
|
||||
return { d_ms: 0 };
|
||||
}
|
||||
|
||||
export function fromTalerProtocolDuration(
|
||||
d: TalerProtocolDuration,
|
||||
): Duration {
|
||||
@ -116,6 +121,7 @@ export namespace Duration {
|
||||
d_ms: d.d_us / 1000,
|
||||
};
|
||||
}
|
||||
|
||||
export function toTalerProtocolDuration(d: Duration): TalerProtocolDuration {
|
||||
if (d.d_ms === "forever") {
|
||||
return {
|
||||
@ -126,6 +132,14 @@ export namespace Duration {
|
||||
d_us: d.d_ms * 1000,
|
||||
};
|
||||
}
|
||||
|
||||
export function clamp(args: {
|
||||
lower: Duration;
|
||||
upper: Duration;
|
||||
value: Duration;
|
||||
}): Duration {
|
||||
return durationMax(durationMin(args.value, args.upper), args.lower);
|
||||
}
|
||||
}
|
||||
|
||||
export namespace AbsoluteTime {
|
||||
|
@ -1659,7 +1659,7 @@ export class MerchantService implements MerchantServiceInterface {
|
||||
await exec(`taler-merchant-dbinit -c "${this.configFilename}"`);
|
||||
|
||||
this.proc = this.globalState.spawnService(
|
||||
"valgrind",
|
||||
"taler-merchant-httpd",
|
||||
[
|
||||
"taler-merchant-httpd",
|
||||
"-LDEBUG",
|
||||
|
@ -26,7 +26,6 @@
|
||||
*/
|
||||
import {
|
||||
AbsoluteTime,
|
||||
AgeRestriction,
|
||||
AmountJson,
|
||||
Amounts,
|
||||
codecForContractTerms,
|
||||
@ -606,10 +605,11 @@ async function failProposalPermanently(
|
||||
}
|
||||
|
||||
function getProposalRequestTimeout(proposal: ProposalRecord): Duration {
|
||||
return durationMax(
|
||||
{ d_ms: 60000 },
|
||||
durationMin({ d_ms: 5000 }, RetryInfo.getDuration(proposal.retryInfo)),
|
||||
);
|
||||
return Duration.clamp({
|
||||
lower: Duration.fromSpec({ seconds: 1}),
|
||||
upper: Duration.fromSpec({seconds: 60}),
|
||||
value: getRetryDuration(proposal.retryInfo),
|
||||
});
|
||||
}
|
||||
|
||||
function getPayRequestTimeout(purchase: PurchaseRecord): Duration {
|
||||
|
Loading…
Reference in New Issue
Block a user