From c7277187c5d104c8332ca37336f7ccd466a292e2 Mon Sep 17 00:00:00 2001 From: woodser Date: Sun, 10 Dec 2023 07:46:18 -0500 Subject: [PATCH] fix cycling through price providers --- .../haveno/core/provider/ProvidersRepository.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/haveno/core/provider/ProvidersRepository.java b/core/src/main/java/haveno/core/provider/ProvidersRepository.java index 99d7ed767a..c57c082cb0 100644 --- a/core/src/main/java/haveno/core/provider/ProvidersRepository.java +++ b/core/src/main/java/haveno/core/provider/ProvidersRepository.java @@ -47,7 +47,7 @@ public class ProvidersRepository { @Getter @Nullable private List bannedNodes; - private int index = 0; + private int index = -1; /////////////////////////////////////////////////////////////////////////////////////////// @@ -80,16 +80,21 @@ public class ProvidersRepository { } // returns true if provider selection loops to beginning - public boolean selectNextProviderBaseUrl() { + public synchronized boolean selectNextProviderBaseUrl() { boolean looped = false; if (!providerList.isEmpty()) { + + // increment index + index++; + + // loop to beginning if (index >= providerList.size()) { index = 0; looped = true; } + // update base url baseUrl = providerList.get(index); - index++; if (providerList.size() == 1 && config.baseCurrencyNetwork.isMainnet()) log.warn("We only have one provider");