Skip to content

Commit

Permalink
Report HS version to pricenode
Browse files Browse the repository at this point in the history
In order to evaluate progress on bisq-network/projects#23,
the Bisq app reports its hiddenservice version.

This change is going to be undone as soon as we do not need the
info anymore.
  • Loading branch information
freimair committed Mar 4, 2020
1 parent dbecc0a commit 5d38298
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import bisq.core.provider.HttpClientProvider;

import bisq.network.http.HttpClient;
import bisq.network.p2p.P2PService;

import bisq.common.app.Version;
import bisq.common.util.MathUtils;
Expand Down Expand Up @@ -47,8 +48,13 @@ public PriceProvider(HttpClient httpClient, String baseUrl) {

public Tuple2<Map<String, Long>, Map<String, MarketPrice>> getAll() throws IOException {
Map<String, MarketPrice> marketPriceMap = new HashMap<>();
String hsVersion = "";
if (P2PService.getMyNodeAddress() != null)
hsVersion = P2PService.getMyNodeAddress().getHostName().length() > 22 ? ", HSv3" : ", HSv2";

String json = httpClient.requestWithGET("getAllMarketPrices", "User-Agent", "bisq/"
+ Version.VERSION);
+ Version.VERSION + hsVersion);


LinkedTreeMap<?, ?> map = new Gson().fromJson(json, LinkedTreeMap.class);
Map<String, Long> tsMap = new HashMap<>();
Expand Down
8 changes: 7 additions & 1 deletion p2p/src/main/java/bisq/network/p2p/P2PService.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ public class P2PService implements SetupListener, MessageListener, ConnectionLis
private final KeepAliveManager keepAliveManager;
private final Socks5ProxyProvider socks5ProxyProvider;

@Getter
private static NodeAddress myNodeAddress;


///////////////////////////////////////////////////////////////////////////////////////////
// Constructor
Expand Down Expand Up @@ -195,11 +198,14 @@ public void start(@Nullable P2PServiceListener listener) {
public void onAllServicesInitialized() {
if (networkNode.getNodeAddress() != null) {
maybeProcessAllMailboxEntries();
myNodeAddress = networkNode.getNodeAddress();
} else {
// If our HS is still not published
networkNode.nodeAddressProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != null)
if (newValue != null) {
maybeProcessAllMailboxEntries();
myNodeAddress = networkNode.getNodeAddress();
}
});
}
}
Expand Down

0 comments on commit 5d38298

Please sign in to comment.