diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
new file mode 100644
index 0000000000..681f41ae2a
--- /dev/null
+++ b/.idea/codeStyles/Project.xml
@@ -0,0 +1,116 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ xmlns:android
+
+ ^$
+
+
+
+
+
+
+
+
+ xmlns:.*
+
+ ^$
+
+
+ BY_NAME
+
+
+
+
+
+
+ .*:id
+
+ http://schemas.android.com/apk/res/android
+
+
+
+
+
+
+
+
+ .*:name
+
+ http://schemas.android.com/apk/res/android
+
+
+
+
+
+
+
+
+ name
+
+ ^$
+
+
+
+
+
+
+
+
+ style
+
+ ^$
+
+
+
+
+
+
+
+
+ .*
+
+ ^$
+
+
+ BY_NAME
+
+
+
+
+
+
+ .*
+
+ http://schemas.android.com/apk/res/android
+
+
+ ANDROID_ATTRIBUTE_ORDER
+
+
+
+
+
+
+ .*
+
+ .*
+
+
+ BY_NAME
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/com/tangem/data/network/ServerApiRipple.java b/app/src/main/java/com/tangem/data/network/ServerApiRipple.java
index ddbe82e090..efec1cfd0b 100644
--- a/app/src/main/java/com/tangem/data/network/ServerApiRipple.java
+++ b/app/src/main/java/com/tangem/data/network/ServerApiRipple.java
@@ -25,7 +25,14 @@ public class ServerApiRipple {
private int requestsCount = 0;
- public static String lastNode;
+ private final String rippleURL1 = "https://s1.ripple.com:51234"; //TODO: make random selection, add more?, move
+ private final String rippleURL2 = "https://s2.ripple.com:51234";
+
+ private String currentURL = rippleURL1;
+
+ public String getCurrentURL() {
+ return currentURL;
+ }
public boolean isRequestsSequenceCompleted() {
Log.i(TAG, String.format("isRequestsSequenceCompleted: %s (%d requests left)", String.valueOf(requestsCount <= 0), requestsCount));
@@ -46,11 +53,9 @@ public class ServerApiRipple {
public void requestData(String method, String wallet, String tx) {
requestsCount++;
- String rippleURL = "https://s1.ripple.com:51234"; //TODO: make random selection
- lastNode = rippleURL; //TODO: show node instead of URL
Retrofit retrofitRipple = new Retrofit.Builder()
- .baseUrl(rippleURL)
+ .baseUrl(currentURL)
.addConverterFactory(GsonConverterFactory.create())
.build();
@@ -93,6 +98,38 @@ public class ServerApiRipple {
rippleBody = new RippleBody();
}
+ Call call = rippleApi.ripple(rippleBody);
+ call.enqueue(new Callback() {
+ @Override
+ public void onResponse(@NonNull Call call, @NonNull Response response) {
+ if (response.code() == 200) {
+ requestsCount--;
+ responseListener.onSuccess(method, response.body());
+ Log.i(TAG, "requestData " + method + " onResponse " + response.code());
+ } else {
+ retryRequest(method, rippleBody);
+ Log.e(TAG, "requestData " + method + " onResponse " + response.code());
+ }
+ }
+
+ @Override
+ public void onFailure(@NonNull Call call, @NonNull Throwable t) {
+ retryRequest(method, rippleBody);
+ Log.e(TAG, "requestData " + method + " onFailure " + t.getMessage());
+ }
+ });
+ }
+
+ private void retryRequest(String method, RippleBody rippleBody) {
+ currentURL = rippleURL2;
+
+ Retrofit retrofitRipple = new Retrofit.Builder()
+ .baseUrl(currentURL)
+ .addConverterFactory(GsonConverterFactory.create())
+ .build();
+
+ RippleApi rippleApi = retrofitRipple.create(RippleApi.class);
+
Call call = rippleApi.ripple(rippleBody);
call.enqueue(new Callback() {
@Override
diff --git a/app/src/main/java/com/tangem/wallet/xrp/XrpEngine.java b/app/src/main/java/com/tangem/wallet/xrp/XrpEngine.java
index 9a7bb12594..a449ef560c 100644
--- a/app/src/main/java/com/tangem/wallet/xrp/XrpEngine.java
+++ b/app/src/main/java/com/tangem/wallet/xrp/XrpEngine.java
@@ -455,7 +455,7 @@ public class XrpEngine extends CoinEngine {
coinData.setBalanceReceived(true);
coinData.setBalanceUnconfirmed(Long.parseLong(rippleResponse.getResult().getAccount_data().getBalance()));
coinData.setSequence(rippleResponse.getResult().getAccount_data().getSequence());
- coinData.setValidationNodeDescription(ServerApiRipple.lastNode);
+ coinData.setValidationNodeDescription(serverApiRipple.getCurrentURL());
// //check pending
// if (App.pendingTransactionsStorage.hasTransactions(ctx.getCard())) {