mirror of
https://github.com/haveno-dex/haveno.git
synced 2026-01-08 02:55:35 -05:00
Merge ca68efd8c9 into 3400665e94
This commit is contained in:
commit
d22da092c0
4 changed files with 41 additions and 3 deletions
|
|
@ -78,6 +78,10 @@ public final class XmrConnectionService {
|
|||
private static final int MAX_CONSECUTIVE_ERRORS = 3; // max errors before switching connections
|
||||
private static int numConsecutiveErrors = 0;
|
||||
|
||||
private int getMaxConsecutiveErrors() {
|
||||
return isProxyApplied(getConnection()) ? 1 : MAX_CONSECUTIVE_ERRORS;
|
||||
}
|
||||
|
||||
public enum XmrConnectionFallbackType {
|
||||
LOCAL,
|
||||
CUSTOM,
|
||||
|
|
@ -602,7 +606,8 @@ public final class XmrConnectionService {
|
|||
boolean isConnected = false;
|
||||
if (xmrLocalNode.isConnected()) {
|
||||
MoneroRpcConnection conn = connectionManager.getConnectionByUri(connection.getUri());
|
||||
conn.checkConnection(connectionManager.getTimeout());
|
||||
long timeout = isProxyApplied(conn) ? 60000 : connectionManager.getTimeout();
|
||||
conn.checkConnection(timeout);
|
||||
isConnected = Boolean.TRUE.equals(conn.isConnected());
|
||||
}
|
||||
|
||||
|
|
@ -736,6 +741,13 @@ public final class XmrConnectionService {
|
|||
connectionList.removeConnection(currentConnection.getUri());
|
||||
connectionList.addConnection(currentConnection);
|
||||
connectionList.setCurrentConnectionUri(currentConnection.getUri());
|
||||
|
||||
// set timeout based on connection type
|
||||
long timeout = isProxyApplied(currentConnection) ? 60000 : REFRESH_PERIOD_HTTP_MS;
|
||||
connectionManager.setTimeout(timeout);
|
||||
if (currentConnection instanceof MoneroRpcConnection) {
|
||||
currentConnection.setTimeout(timeout);
|
||||
}
|
||||
}
|
||||
|
||||
// set connection property on user thread
|
||||
|
|
@ -819,7 +831,7 @@ public final class XmrConnectionService {
|
|||
|
||||
// skip error handling up to max attempts
|
||||
numConsecutiveErrors++;
|
||||
if (numConsecutiveErrors <= MAX_CONSECUTIVE_ERRORS) {
|
||||
if (numConsecutiveErrors <= getMaxConsecutiveErrors()) {
|
||||
return;
|
||||
} else {
|
||||
numConsecutiveErrors = 0; // reset error count
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import lombok.Getter;
|
|||
import lombok.ToString;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import static haveno.core.util.PriceUtil.reformatMarketPrice;
|
||||
|
|
@ -80,6 +81,8 @@ public class OfferInfo implements Payload {
|
|||
private final boolean isPrivateOffer;
|
||||
private final String challenge;
|
||||
private final String extraInfo;
|
||||
private final List<String> acceptedCountryCodes;
|
||||
private final String city;
|
||||
|
||||
public OfferInfo(OfferInfoBuilder builder) {
|
||||
this.id = builder.getId();
|
||||
|
|
@ -116,6 +119,8 @@ public class OfferInfo implements Payload {
|
|||
this.isPrivateOffer = builder.isPrivateOffer();
|
||||
this.challenge = builder.getChallenge();
|
||||
this.extraInfo = builder.getExtraInfo();
|
||||
this.acceptedCountryCodes = builder.getAcceptedCountryCodes();
|
||||
this.city = builder.getCity();
|
||||
}
|
||||
|
||||
public static OfferInfo toOfferInfo(Offer offer) {
|
||||
|
|
@ -185,7 +190,9 @@ public class OfferInfo implements Payload {
|
|||
.withArbitratorSigner(offer.getOfferPayload().getArbitratorSigner() == null ? null : offer.getOfferPayload().getArbitratorSigner().getFullAddress())
|
||||
.withIsPrivateOffer(offer.isPrivateOffer())
|
||||
.withChallenge(offer.getChallenge())
|
||||
.withExtraInfo(offer.getCombinedExtraInfo());
|
||||
.withExtraInfo(offer.getCombinedExtraInfo())
|
||||
.withAcceptedCountryCodes(offer.getAcceptedCountryCodes())
|
||||
.withCity(offer.getF2FCity());
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -229,6 +236,8 @@ public class OfferInfo implements Payload {
|
|||
Optional.ofNullable(splitOutputTxHash).ifPresent(builder::setSplitOutputTxHash);
|
||||
Optional.ofNullable(challenge).ifPresent(builder::setChallenge);
|
||||
Optional.ofNullable(extraInfo).ifPresent(builder::setExtraInfo);
|
||||
Optional.ofNullable(acceptedCountryCodes).ifPresent(builder::addAllAcceptedCountryCodes);
|
||||
builder.setCity(city == null ? "" : city);
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
|
|
@ -269,6 +278,8 @@ public class OfferInfo implements Payload {
|
|||
.withIsPrivateOffer(proto.getIsPrivateOffer())
|
||||
.withChallenge(proto.getChallenge())
|
||||
.withExtraInfo(proto.getExtraInfo())
|
||||
.withAcceptedCountryCodes(proto.getAcceptedCountryCodesList())
|
||||
.withCity(proto.getCity())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
package haveno.core.api.model.builder;
|
||||
|
||||
import haveno.core.api.model.OfferInfo;
|
||||
import java.util.List;
|
||||
import lombok.Getter;
|
||||
|
||||
/*
|
||||
|
|
@ -66,6 +67,8 @@ public final class OfferInfoBuilder {
|
|||
private boolean isPrivateOffer;
|
||||
private String challenge;
|
||||
private String extraInfo;
|
||||
private List<String> acceptedCountryCodes;
|
||||
private String city;
|
||||
|
||||
public OfferInfoBuilder withId(String id) {
|
||||
this.id = id;
|
||||
|
|
@ -252,6 +255,16 @@ public final class OfferInfoBuilder {
|
|||
return this;
|
||||
}
|
||||
|
||||
public OfferInfoBuilder withAcceptedCountryCodes(List<String> acceptedCountryCodes) {
|
||||
this.acceptedCountryCodes = acceptedCountryCodes;
|
||||
return this;
|
||||
}
|
||||
|
||||
public OfferInfoBuilder withCity(String city) {
|
||||
this.city = city;
|
||||
return this;
|
||||
}
|
||||
|
||||
public OfferInfo build() {
|
||||
return new OfferInfo(this);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -612,6 +612,8 @@ message OfferInfo {
|
|||
bool is_private_offer = 32;
|
||||
string challenge = 33;
|
||||
string extra_info = 34;
|
||||
repeated string accepted_country_codes = 35;
|
||||
string city = 36;
|
||||
}
|
||||
|
||||
message AvailabilityResultWithDescription {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue