gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-wallet-core] 03/04: adding a max timeout since retry counter can


From: gnunet
Subject: [taler-wallet-core] 03/04: adding a max timeout since retry counter can be very high
Date: Thu, 13 Jan 2022 05:34:29 +0100

This is an automated email from the git hooks/post-receive script.

sebasjm pushed a commit to branch master
in repository wallet-core.

commit 4b289cde5d362c863bee84dc3aa8fbe06b747b41
Author: Sebastian <sebasjm@gmail.com>
AuthorDate: Thu Jan 13 01:33:03 2022 -0300

    adding a max timeout since retry counter can be very high
---
 packages/taler-wallet-core/src/util/retries.ts | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/packages/taler-wallet-core/src/util/retries.ts 
b/packages/taler-wallet-core/src/util/retries.ts
index cac7b1b5..8dec22be 100644
--- a/packages/taler-wallet-core/src/util/retries.ts
+++ b/packages/taler-wallet-core/src/util/retries.ts
@@ -32,11 +32,13 @@ export interface RetryInfo {
 export interface RetryPolicy {
   readonly backoffDelta: Duration;
   readonly backoffBase: number;
+  readonly maxTimeout: Duration;
 }
 
 const defaultRetryPolicy: RetryPolicy = {
   backoffBase: 1.5,
   backoffDelta: { d_ms: 200 },
+  maxTimeout: { d_ms: 6000 },
 };
 
 export function updateRetryInfoTimeout(
@@ -51,8 +53,11 @@ export function updateRetryInfoTimeout(
     r.nextRetry = { t_ms: "never" };
     return;
   }
+
+  const nextIncrement = p.backoffDelta.d_ms * Math.pow(p.backoffBase, 
r.retryCounter)
+
   const t =
-    now.t_ms + p.backoffDelta.d_ms * Math.pow(p.backoffBase, r.retryCounter);
+    now.t_ms + (p.maxTimeout.d_ms === "forever" ? nextIncrement : 
Math.min(p.maxTimeout.d_ms, nextIncrement));
   r.nextRetry = { t_ms: t };
 }
 
@@ -68,7 +73,7 @@ export function getRetryDuration(
     return { d_ms: "forever" };
   }
   const t = p.backoffDelta.d_ms * Math.pow(p.backoffBase, r.retryCounter);
-  return { d_ms: t };
+  return { d_ms: p.maxTimeout.d_ms === "forever" ? t : 
Math.min(p.maxTimeout.d_ms, t) };
 }
 
 export function initRetryInfo(

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]