From 71f802ef35102c1b4e20d33d8a40b70ed9a7b7d1 Mon Sep 17 00:00:00 2001 From: CalDescent Date: Mon, 4 Oct 2021 09:25:23 +0100 Subject: [PATCH] Exponentially backoff when bootstrapping fails, to reduce bandwidth The retry interval starts at 5 minutes and doubles with each failure. --- src/main/java/org/qortal/repository/Bootstrap.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/qortal/repository/Bootstrap.java b/src/main/java/org/qortal/repository/Bootstrap.java index e72d253e..99de6d60 100644 --- a/src/main/java/org/qortal/repository/Bootstrap.java +++ b/src/main/java/org/qortal/repository/Bootstrap.java @@ -32,6 +32,8 @@ public class Bootstrap { private Repository repository; + private int retryMinutes = 5; + private static final Logger LOGGER = LogManager.getLogger(Bootstrap.class); /** The maximum number of untrimmed blocks allowed to be included in a bootstrap, beyond the trim threshold */ @@ -312,8 +314,9 @@ public class Bootstrap { } catch (DataException e) { LOGGER.info("Bootstrap import failed: {}", e.getMessage()); - this.updateStatus("Bootstrapping failed. Retrying in 5 minutes"); - Thread.sleep(5 * 60 * 1000L); + this.updateStatus(String.format("Bootstrapping failed. Retrying in %d minutes...", retryMinutes)); + Thread.sleep(retryMinutes * 60 * 1000L); + retryMinutes *= 2; } } }