Finalize sell only mode
This commit is contained in:
parent
3a4b59de07
commit
739b71f9e8
|
@ -20,6 +20,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
|||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.List;
|
||||
|
@ -145,15 +146,16 @@ public class GunbotProxyController {
|
|||
HttpServletResponse response,
|
||||
@RequestParam String currencyPair,
|
||||
@RequestParam BigDecimal rate,
|
||||
@RequestParam BigDecimal amount) {
|
||||
@RequestParam BigDecimal amount) throws IOException {
|
||||
|
||||
boolean globalSellOnlyMode = Boolean.parseBoolean(util.getConfigurationProperty("sellOnlyMode"));
|
||||
boolean pairSellOnlyMode = Boolean.parseBoolean(util.getConfigurationProperty(String.format("%s_sellOnlyMode", currencyPair)));
|
||||
if (globalSellOnlyMode || pairSellOnlyMode) {
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
String message = String.format("You are not allowed to buy. Sell Only mode is active for %s", currencyPair);
|
||||
logger.info(message);
|
||||
response.setStatus(403);
|
||||
return message;
|
||||
jsonObject.addProperty("error", message);
|
||||
logger.info(jsonObject.toString());
|
||||
return jsonObject.toString();
|
||||
}
|
||||
|
||||
String key = request.getHeader("key");
|
||||
|
|
|
@ -83,7 +83,6 @@ public class GunbotProxyService {
|
|||
|
||||
retryPolicy = new RetryPolicy()
|
||||
.retryOn(failure -> failure instanceof Exception)
|
||||
.abortOn(failure -> failure.getMessage().startsWith("error:"))
|
||||
.withDelay(500, TimeUnit.MILLISECONDS)
|
||||
.withMaxRetries(maxRetries);
|
||||
}
|
||||
|
@ -343,7 +342,7 @@ public class GunbotProxyService {
|
|||
throw new ProxyHandledException("No value was returned");
|
||||
} else if (result.contains("Nonce")) {
|
||||
throw new ProxyHandledException("nonce error: " + result);
|
||||
} else if (result.contains("error:")) {
|
||||
} else if (result.contains("Connection timed out")) {
|
||||
throw new RuntimeException(result);
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -9,7 +9,6 @@ import org.springframework.util.StringUtils;
|
|||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* Created by Elroy on 10-7-2017.
|
||||
|
@ -32,9 +31,9 @@ public class Util {
|
|||
try (InputStream input = new FileInputStream("configuration.properties")) {
|
||||
prop.load(input);
|
||||
value = prop.getProperty(key);
|
||||
logger.debug(String.format("reading property key %s -- value %s"), key, value);
|
||||
logger.debug(String.format("reading property key %s -- value %s", key, value));
|
||||
} catch (Exception e) {
|
||||
logger.error("Error reading configuration file", e.getMessage());
|
||||
logger.error("Error reading configuration file", e);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue