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