Skip to content

Commit

Permalink
Merge pull request #1172 from alvasw/move_pricenodes_to_config
Browse files Browse the repository at this point in the history
Set pricenodes in config files
  • Loading branch information
alvasw authored Sep 13, 2023
2 parents 56a8047 + b62cf7c commit 4107cd4
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,28 @@
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

import java.util.List;
import java.util.concurrent.CompletableFuture;

@Slf4j
@Getter
public class BondedRolesService implements Service {
@Getter
public static class Config {
private final com.typesafe.config.Config marketPrice;
private final List<? extends com.typesafe.config.Config> marketPriceServiceProviders;
private final com.typesafe.config.Config blockchainExplorer;
private final boolean ignoreSecurityManager;

public Config(com.typesafe.config.Config marketPrice,
public Config(List<? extends com.typesafe.config.Config> marketPriceServiceProviders,
com.typesafe.config.Config blockchainExplorer,
boolean ignoreSecurityManager) {
this.marketPrice = marketPrice;
this.marketPriceServiceProviders = marketPriceServiceProviders;
this.blockchainExplorer = blockchainExplorer;
this.ignoreSecurityManager = ignoreSecurityManager;
}

public static Config from(com.typesafe.config.Config config) {
return new Config(config.getConfig("marketPrice"),
return new Config(config.getConfigList("marketPriceServiceProviders"),
config.getConfig("blockchainExplorer"),
config.getBoolean("ignoreSecurityManager"));
}
Expand All @@ -65,7 +66,7 @@ public static Config from(com.typesafe.config.Config config) {
public BondedRolesService(Config config, Version version, NetworkService networkService) {
authorizedBondedRolesService = new AuthorizedBondedRolesService(networkService, config.isIgnoreSecurityManager());
bondedRoleRegistrationService = new BondedRoleRegistrationService(networkService, authorizedBondedRolesService);
marketPriceService = new MarketPriceService(MarketPriceService.Config.from(config.getMarketPrice()),
marketPriceService = new MarketPriceService(MarketPriceService.Config.from(config.getMarketPriceServiceProviders()),
networkService,
version);
explorerService = new ExplorerService(ExplorerService.Config.from(config.getBlockchainExplorer()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,26 @@ public class MarketPriceService {
@Getter
@ToString
public static final class Config {
public static Config from(com.typesafe.config.Config config) {
//todo move to conf
return new MarketPriceService.Config(Set.of(
new MarketPriceService.Provider("https://price.bisq.wiz.biz/", "wiz", Transport.Type.CLEAR),

// Sample I2P tunnel, see docs folder for instructions how to create one
// new MarketPriceService.Provider("http://txvrt45gy3d73vubwddvyqvv5ke5b6ycmcohlcypbmpmsjyg4ofa.b32.i2p/", "tunnel-to-wiz", Transport.Type.I2P),

new MarketPriceService.Provider("http://wizpriceje6q5tdrxkyiazsgu7irquiqjy2dptezqhrtu7l2qelqktid.onion/", "wiz", Transport.Type.TOR),
new MarketPriceService.Provider("http://emzypricpidesmyqg2hc6dkwitqzaxrqnpkdg3ae2wef5znncu2ambqd.onion/", "emzy", Transport.Type.TOR),
new MarketPriceService.Provider("http://aprcndeiwdrkbf4fq7iozxbd27dl72oeo76n7zmjwdi4z34agdrnheyd.onion/", "mrosseel", Transport.Type.TOR),
new MarketPriceService.Provider("http://devinpndvdwll4wiqcyq5e7itezmarg7rzicrvf6brzkwxdm374kmmyd.onion/", "devinbileck", Transport.Type.TOR),
new MarketPriceService.Provider("http://ro7nv73awqs3ga2qtqeqawrjpbxwarsazznszvr6whv7tes5ehffopid.onion/", "alexej996", Transport.Type.TOR)));
public static Config from(List<? extends com.typesafe.config.Config> marketPriceServiceProviders) {
Set<Provider> marketPriceProviders = marketPriceServiceProviders.stream()
.map(config -> {
String url = config.getString("url");
String operator = config.getString("operator");
Transport.Type transportType = getTransportTypeFromUrl(url);
return new Provider(url, operator, transportType);
}).collect(Collectors.toUnmodifiableSet());

return new MarketPriceService.Config(marketPriceProviders);
}

private static Transport.Type getTransportTypeFromUrl(String url) {
if (url.endsWith(".i2p/")) {
return Transport.Type.I2P;
} else if (url.endsWith(".onion/")) {
return Transport.Type.TOR;
} else {
return Transport.Type.CLEAR;
}
}

private final Set<Provider> providers;
Expand Down
30 changes: 28 additions & 2 deletions desktop_app/src/main/resources/desktop.conf
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,34 @@ application {

bondedRoles = {
ignoreSecurityManager = false
marketPrice = {
}

marketPriceServiceProviders = [
{
url = "https://price.bisq.wiz.biz/"
operator = "wiz",
},
{
url = "http://wizpriceje6q5tdrxkyiazsgu7irquiqjy2dptezqhrtu7l2qelqktid.onion/"
operator = "wiz",
},
{
url = "http://emzypricpidesmyqg2hc6dkwitqzaxrqnpkdg3ae2wef5znncu2ambqd.onion/"
operator = "emzy",
},
{
url = "http://aprcndeiwdrkbf4fq7iozxbd27dl72oeo76n7zmjwdi4z34agdrnheyd.onion/"
operator = "mrosseel",
},
{
url = "http://devinpndvdwll4wiqcyq5e7itezmarg7rzicrvf6brzkwxdm374kmmyd.onion/"
operator = "devinbileck",
},
{
url = "http://ro7nv73awqs3ga2qtqeqawrjpbxwarsazznszvr6whv7tes5ehffopid.onion/"
operator = "alexej996",
},
]

blockchainExplorer = {
}
}
Expand Down
30 changes: 28 additions & 2 deletions oracle_node_app/src/main/resources/oracle_node.conf
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,34 @@ application {

bondedRoles = {
ignoreSecurityManager = true
marketPrice = {
}

marketPriceServiceProviders = [
{
url = "https://price.bisq.wiz.biz/"
operator = "wiz",
},
{
url = "http://wizpriceje6q5tdrxkyiazsgu7irquiqjy2dptezqhrtu7l2qelqktid.onion/"
operator = "wiz",
},
{
url = "http://emzypricpidesmyqg2hc6dkwitqzaxrqnpkdg3ae2wef5znncu2ambqd.onion/"
operator = "emzy",
},
{
url = "http://aprcndeiwdrkbf4fq7iozxbd27dl72oeo76n7zmjwdi4z34agdrnheyd.onion/"
operator = "mrosseel",
},
{
url = "http://devinpndvdwll4wiqcyq5e7itezmarg7rzicrvf6brzkwxdm374kmmyd.onion/"
operator = "devinbileck",
},
{
url = "http://ro7nv73awqs3ga2qtqeqawrjpbxwarsazznszvr6whv7tes5ehffopid.onion/"
operator = "alexej996",
},
]

blockchainExplorer = {
}
}
Expand Down
30 changes: 28 additions & 2 deletions rest_api_app/src/main/resources/rest_api.conf
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,34 @@ application {

bondedRoles = {
ignoreSecurityManager = false
marketPrice = {
}

marketPriceServiceProviders = [
{
url = "https://price.bisq.wiz.biz/"
operator = "wiz",
},
{
url = "http://wizpriceje6q5tdrxkyiazsgu7irquiqjy2dptezqhrtu7l2qelqktid.onion/"
operator = "wiz",
},
{
url = "http://emzypricpidesmyqg2hc6dkwitqzaxrqnpkdg3ae2wef5znncu2ambqd.onion/"
operator = "emzy",
},
{
url = "http://aprcndeiwdrkbf4fq7iozxbd27dl72oeo76n7zmjwdi4z34agdrnheyd.onion/"
operator = "mrosseel",
},
{
url = "http://devinpndvdwll4wiqcyq5e7itezmarg7rzicrvf6brzkwxdm374kmmyd.onion/"
operator = "devinbileck",
},
{
url = "http://ro7nv73awqs3ga2qtqeqawrjpbxwarsazznszvr6whv7tes5ehffopid.onion/"
operator = "alexej996",
},
]

blockchainExplorer = {
}
}
Expand Down
30 changes: 28 additions & 2 deletions seed_node_app/src/main/resources/seed_node.conf
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,34 @@ application {

bondedRoles = {
ignoreSecurityManager = false
marketPrice = {
}

marketPriceServiceProviders = [
{
url = "https://price.bisq.wiz.biz/"
operator = "wiz",
},
{
url = "http://wizpriceje6q5tdrxkyiazsgu7irquiqjy2dptezqhrtu7l2qelqktid.onion/"
operator = "wiz",
},
{
url = "http://emzypricpidesmyqg2hc6dkwitqzaxrqnpkdg3ae2wef5znncu2ambqd.onion/"
operator = "emzy",
},
{
url = "http://aprcndeiwdrkbf4fq7iozxbd27dl72oeo76n7zmjwdi4z34agdrnheyd.onion/"
operator = "mrosseel",
},
{
url = "http://devinpndvdwll4wiqcyq5e7itezmarg7rzicrvf6brzkwxdm374kmmyd.onion/"
operator = "devinbileck",
},
{
url = "http://ro7nv73awqs3ga2qtqeqawrjpbxwarsazznszvr6whv7tes5ehffopid.onion/"
operator = "alexej996",
},
]

blockchainExplorer = {
}
}
Expand Down

0 comments on commit 4107cd4

Please sign in to comment.