Skip to content

Commit

Permalink
Refactor: Rename ProvidersRepository to PriceFeedNodeAddressProvider
Browse files Browse the repository at this point in the history
Signed-off-by: HenrikJannsen <[email protected]>
  • Loading branch information
HenrikJannsen committed Jul 26, 2024
1 parent 11ac408 commit f1796e5
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 30 deletions.
4 changes: 2 additions & 2 deletions core/src/main/java/bisq/core/btc/BitcoinModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import bisq.core.btc.wallet.BtcWalletService;
import bisq.core.btc.wallet.NonBsqCoinSelector;
import bisq.core.btc.wallet.TradeWalletService;
import bisq.core.provider.ProvidersRepository;
import bisq.core.provider.PriceFeedNodeAddressProvider;
import bisq.core.provider.fee.FeeService;
import bisq.core.provider.price.PriceFeedService;

Expand Down Expand Up @@ -93,7 +93,7 @@ protected void configure() {
bind(BtcNodes.class).in(Singleton.class);
bind(Balances.class).in(Singleton.class);

bind(ProvidersRepository.class).in(Singleton.class);
bind(PriceFeedNodeAddressProvider.class).in(Singleton.class);
bind(PriceFeedService.class).in(Singleton.class);
bind(FeeService.class).in(Singleton.class);
bind(TxFeeEstimationService.class).in(Singleton.class);
Expand Down
14 changes: 7 additions & 7 deletions core/src/main/java/bisq/core/filter/FilterManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import bisq.core.offer.Offer;
import bisq.core.payment.payload.PaymentAccountPayload;
import bisq.core.payment.payload.PaymentMethod;
import bisq.core.provider.ProvidersRepository;
import bisq.core.provider.PriceFeedNodeAddressProvider;
import bisq.core.user.Preferences;
import bisq.core.user.User;

Expand Down Expand Up @@ -101,7 +101,7 @@ public interface Listener {
private final User user;
private final Preferences preferences;
private final ConfigFileEditor configFileEditor;
private final ProvidersRepository providersRepository;
private final PriceFeedNodeAddressProvider priceFeedNodeAddressProvider;
private final boolean ignoreDevMsg;
private final ObjectProperty<Filter> filterProperty = new SimpleObjectProperty<>();
private final List<Listener> listeners = new CopyOnWriteArrayList<>();
Expand All @@ -121,7 +121,7 @@ public FilterManager(P2PService p2PService,
User user,
Preferences preferences,
Config config,
ProvidersRepository providersRepository,
PriceFeedNodeAddressProvider priceFeedNodeAddressProvider,
BanFilter banFilter,
@Named(Config.IGNORE_DEV_MSG) boolean ignoreDevMsg,
@Named(Config.USE_DEV_PRIVILEGE_KEYS) boolean useDevPrivilegeKeys) {
Expand All @@ -130,7 +130,7 @@ public FilterManager(P2PService p2PService,
this.user = user;
this.preferences = preferences;
this.configFileEditor = new ConfigFileEditor(config.getConfigFile());
this.providersRepository = providersRepository;
this.priceFeedNodeAddressProvider = priceFeedNodeAddressProvider;
this.ignoreDevMsg = ignoreDevMsg;

publicKeys = useDevPrivilegeKeys ?
Expand Down Expand Up @@ -583,7 +583,7 @@ private void onFilterAddedFromNetwork(Filter filterFromNetwork) {
saveBannedNodes(BANNED_PRICE_RELAY_NODES, priceRelayNodes);

//TODO should be moved to client with listening on onFilterAdded
providersRepository.applyBannedNodes(priceRelayNodes);
priceFeedNodeAddressProvider.applyBannedNodes(priceRelayNodes);

//TODO should be moved to client with listening on onFilterAdded
if (filterFromNetwork.isPreventPublicBtcNetwork() &&
Expand Down Expand Up @@ -626,8 +626,8 @@ private void clearBannedNodes() {
saveBannedNodes(FILTER_PROVIDED_SEED_NODES, null);
saveBannedNodes(BANNED_PRICE_RELAY_NODES, null);

if (providersRepository.getBannedNodes() != null) {
providersRepository.applyBannedNodes(null);
if (priceFeedNodeAddressProvider.getBannedNodes() != null) {
priceFeedNodeAddressProvider.applyBannedNodes(null);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import javax.annotation.Nullable;

@Slf4j
public class ProvidersRepository {
public class PriceFeedNodeAddressProvider {
public static final List<String> DEFAULT_NODES = Arrays.asList(
"http://ro7nv73awqs3ga2qtqeqawrjpbxwarsazznszvr6whv7tes5ehffopid.onion/", // @alexej996
"http://runbtcpn7gmbj5rgqeyfyvepqokrijem6rbw7o5wgqbguimuoxrmcdyd.onion" // @runbtc
Expand All @@ -58,9 +58,9 @@ public class ProvidersRepository {
///////////////////////////////////////////////////////////////////////////////////////////

@Inject
public ProvidersRepository(Config config,
@Named(Config.PROVIDERS) List<String> providers,
@Named(Config.USE_LOCALHOST_FOR_P2P) boolean useLocalhostForP2P) {
public PriceFeedNodeAddressProvider(Config config,
@Named(Config.PROVIDERS) List<String> providers,
@Named(Config.USE_LOCALHOST_FOR_P2P) boolean useLocalhostForP2P) {

this.config = config;
this.providersFromProgramArgs = providers;
Expand Down
20 changes: 10 additions & 10 deletions core/src/main/java/bisq/core/provider/price/PriceFeedService.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import bisq.core.locale.TradeCurrency;
import bisq.core.monetary.Altcoin;
import bisq.core.monetary.Price;
import bisq.core.provider.PriceFeedNodeAddressProvider;
import bisq.core.provider.PriceHttpClient;
import bisq.core.provider.ProvidersRepository;
import bisq.core.provider.fee.FeeService;
import bisq.core.user.Preferences;

Expand Down Expand Up @@ -66,7 +66,7 @@
@Slf4j
public class PriceFeedService {
private final HttpClient httpClient;
private final ProvidersRepository providersRepository;
private final PriceFeedNodeAddressProvider priceFeedNodeAddressProvider;
private final Preferences preferences;
private final FeeService feeService;

Expand Down Expand Up @@ -101,15 +101,15 @@ public class PriceFeedService {
@Inject
public PriceFeedService(PriceHttpClient httpClient,
FeeService feeService,
@SuppressWarnings("SameParameterValue") ProvidersRepository providersRepository,
@SuppressWarnings("SameParameterValue") PriceFeedNodeAddressProvider priceFeedNodeAddressProvider,
@SuppressWarnings("SameParameterValue") Preferences preferences) {
this.httpClient = httpClient;
this.providersRepository = providersRepository;
this.priceFeedNodeAddressProvider = priceFeedNodeAddressProvider;
this.preferences = preferences;
this.feeService = feeService;

// Do not use Guice for PriceProvider as we might create multiple instances
this.priceProvider = new PriceProvider(httpClient, providersRepository.getBaseUrl());
this.priceProvider = new PriceProvider(httpClient, priceFeedNodeAddressProvider.getBaseUrl());
}


Expand Down Expand Up @@ -161,10 +161,10 @@ public String getProviderNodeAddress() {
private void request(boolean repeatRequests) {
if (requestTs == 0)
log.debug("request from provider {}",
providersRepository.getBaseUrl());
priceFeedNodeAddressProvider.getBaseUrl());
else
log.debug("request from provider {} {} sec. after last request",
providersRepository.getBaseUrl(),
priceFeedNodeAddressProvider.getBaseUrl(),
(System.currentTimeMillis() - requestTs) / 1000d);

requestTs = System.currentTimeMillis();
Expand Down Expand Up @@ -256,9 +256,9 @@ private void retryWithNewProvider() {
}

private void setNewPriceProvider() {
providersRepository.selectNextProviderBaseUrl();
if (!providersRepository.getBaseUrl().isEmpty())
priceProvider = new PriceProvider(httpClient, providersRepository.getBaseUrl());
priceFeedNodeAddressProvider.selectNextProviderBaseUrl();
if (!priceFeedNodeAddressProvider.getBaseUrl().isEmpty())
priceProvider = new PriceProvider(httpClient, priceFeedNodeAddressProvider.getBaseUrl());
else
log.warn("We cannot create a new priceProvider because new base url is empty.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package bisq.core.filter;

import bisq.core.provider.ProvidersRepository;
import bisq.core.provider.PriceFeedNodeAddressProvider;
import bisq.core.user.Preferences;
import bisq.core.user.User;

Expand Down Expand Up @@ -106,7 +106,7 @@ void beforeEach(@TempDir Path tmpDir, @Mock P2PService p2PService, @Mock P2PData
mock(User.class),
mock(Preferences.class),
config,
mock(ProvidersRepository.class),
mock(PriceFeedNodeAddressProvider.class),
mock(BanFilter.class),
false,
true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package bisq.core.filter;

import bisq.core.locale.Res;
import bisq.core.provider.ProvidersRepository;
import bisq.core.provider.PriceFeedNodeAddressProvider;
import bisq.core.user.Preferences;
import bisq.core.user.User;

Expand Down Expand Up @@ -61,7 +61,7 @@ void onAllServicesInitializedNoFilterMainnet() {
mock(User.class),
mock(Preferences.class),
mock(Config.class),
mock(ProvidersRepository.class),
mock(PriceFeedNodeAddressProvider.class),
mock(BanFilter.class),
false,
true
Expand Down Expand Up @@ -99,7 +99,7 @@ void onAllServicesInitializedNoFilterMainnetIgnoreDevMsg() {
mock(User.class),
mock(Preferences.class),
mock(Config.class),
mock(ProvidersRepository.class),
mock(PriceFeedNodeAddressProvider.class),
mock(BanFilter.class),
true,
true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package bisq.core.filter;

import bisq.core.provider.ProvidersRepository;
import bisq.core.provider.PriceFeedNodeAddressProvider;
import bisq.core.user.Preferences;
import bisq.core.user.User;

Expand Down Expand Up @@ -109,7 +109,7 @@ void testBannedPrivilegedDevKey(@TempDir Path tmpDir,
mock(User.class),
mock(Preferences.class),
config,
mock(ProvidersRepository.class),
mock(PriceFeedNodeAddressProvider.class),
mock(BanFilter.class),
false,
true
Expand Down

0 comments on commit f1796e5

Please sign in to comment.