threaded load
This commit is contained in:
parent
d5b06ee3ca
commit
18a584f6d8
@ -4,6 +4,6 @@ public interface Constants {
|
|||||||
|
|
||||||
public static final String APP_VERSION = "v0.8";
|
public static final String APP_VERSION = "v0.8";
|
||||||
public static final String COPYRIGHT = "2021";
|
public static final String COPYRIGHT = "2021";
|
||||||
public static final int DEFAULT_HTTP_TIMEOUT = 2000;
|
public static final int DEFAULT_HTTP_TIMEOUT = 10000;
|
||||||
public static final int RELOAD_TIME = 20000;
|
public static final int RELOAD_TIME = DEFAULT_HTTP_TIMEOUT;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,7 +18,17 @@ import cz.kamma.mining.vo.KeyValue;
|
|||||||
|
|
||||||
public class MiningBean {
|
public class MiningBean {
|
||||||
|
|
||||||
public static String updateAll(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
String curSym = "$";
|
||||||
|
String ltcapikey;
|
||||||
|
String dogapikey;
|
||||||
|
String ltcWallet;
|
||||||
|
String xrpWallet;
|
||||||
|
String ethWallet;
|
||||||
|
String currency;
|
||||||
|
String resultStr;
|
||||||
|
String restRequest;
|
||||||
|
|
||||||
|
public String updateAll(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
|
SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
|
||||||
java.lang.System.setProperty("https.protocols", "TLSv1,TLSv1.1,TLSv1.2");
|
java.lang.System.setProperty("https.protocols", "TLSv1,TLSv1.1,TLSv1.2");
|
||||||
List<KeyValue> prices = new ArrayList<>();
|
List<KeyValue> prices = new ArrayList<>();
|
||||||
@ -29,32 +39,22 @@ public class MiningBean {
|
|||||||
String[] cryptoCur = new String[] { "btc", "ltc", "xrp", "eth" };
|
String[] cryptoCur = new String[] { "btc", "ltc", "xrp", "eth" };
|
||||||
double[] lastPrices = new double[] { 0, 0, 0, 0 };
|
double[] lastPrices = new double[] { 0, 0, 0, 0 };
|
||||||
|
|
||||||
String ltcapikey = request.getParameter("ltcapikey");
|
ltcapikey = request.getParameter("ltcapikey");
|
||||||
String dogapikey = request.getParameter("dogapikey");
|
dogapikey = request.getParameter("dogapikey");
|
||||||
String ltcWallet = request.getParameter("ltc");
|
ltcWallet = request.getParameter("ltc");
|
||||||
String xrpWallet = request.getParameter("xrp");
|
xrpWallet = request.getParameter("xrp");
|
||||||
String ethWallet = request.getParameter("eth");
|
ethWallet = request.getParameter("eth");
|
||||||
String currency = request.getParameter("cur");
|
currency = request.getParameter("cur");
|
||||||
|
|
||||||
if (currency == null || currency.equals("null") || currency.length() == 0)
|
if (currency == null || currency.equals("null") || currency.length() == 0)
|
||||||
currency = "usd";
|
currency = "usd";
|
||||||
else
|
else
|
||||||
currency = currency.toLowerCase();
|
currency = currency.toLowerCase();
|
||||||
|
|
||||||
String curSym = "$";
|
|
||||||
|
|
||||||
if (currency.equals("usd"))
|
if (currency.equals("usd"))
|
||||||
curSym = "$";
|
curSym = "$";
|
||||||
else if (currency.equals("eur"))
|
else if (currency.equals("eur"))
|
||||||
curSym = "";
|
curSym = "\u20ac";
|
||||||
|
|
||||||
workers.clear();
|
|
||||||
prices.clear();
|
|
||||||
network.clear();
|
|
||||||
pool.clear();
|
|
||||||
|
|
||||||
String resultStr;
|
|
||||||
String restRequest;
|
|
||||||
|
|
||||||
for (int i = 0; i < cryptoCur.length; i++) {
|
for (int i = 0; i < cryptoCur.length; i++) {
|
||||||
String ccur = cryptoCur[i];
|
String ccur = cryptoCur[i];
|
||||||
@ -75,318 +75,374 @@ public class MiningBean {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ltcWallet != null && !"null".equals(ltcWallet) && ltcWallet.length() > 0) {
|
new Thread(new Runnable() {
|
||||||
restRequest = HttpHelper
|
|
||||||
.getStringResponse("https://chain.so/api/v2/get_address_balance/LTC/".concat(ltcWallet));
|
|
||||||
if (restRequest != null && restRequest.length() > 0) {
|
|
||||||
JSONObject full = new JSONObject(restRequest);
|
|
||||||
JSONObject data = (JSONObject) full.get("data");
|
|
||||||
String confirmedBalance = (String) data.get("confirmed_balance");
|
|
||||||
|
|
||||||
double res = Double.parseDouble(confirmedBalance);
|
@Override
|
||||||
if (res > 0d) {
|
public void run() {
|
||||||
resultStr = res + " LTC " + curSym + String.format("%.2f", (res * lastPrices[1]));
|
if (ltcWallet != null && !"null".equals(ltcWallet) && ltcWallet.length() > 0) {
|
||||||
} else
|
restRequest = HttpHelper
|
||||||
resultStr = "Unknown";
|
.getStringResponse("https://chain.so/api/v2/get_address_balance/LTC/".concat(ltcWallet));
|
||||||
KeyValue wi = new KeyValue();
|
if (restRequest != null && restRequest.length() > 0) {
|
||||||
wi.setKey("My Balance LTC");
|
JSONObject full = new JSONObject(restRequest);
|
||||||
wi.setValue(resultStr);
|
JSONObject data = (JSONObject) full.get("data");
|
||||||
prices.add(wi);
|
String confirmedBalance = (String) data.get("confirmed_balance");
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (xrpWallet != null && !"null".equals(xrpWallet) && xrpWallet.length() > 0) {
|
double res = Double.parseDouble(confirmedBalance);
|
||||||
restRequest = HttpHelper
|
if (res > 0d) {
|
||||||
.getStringResponse("https://data.ripple.com/v2/accounts/".concat(xrpWallet).concat("/balances"));
|
resultStr = res + " LTC " + curSym + String.format("%.2f", (res * lastPrices[1]));
|
||||||
if (restRequest != null && restRequest.length() > 0) {
|
} else
|
||||||
JSONObject full = new JSONObject(restRequest);
|
resultStr = "Unknown";
|
||||||
JSONArray balances = (JSONArray) full.get("balances");
|
KeyValue wi = new KeyValue();
|
||||||
double res = balances.getJSONObject(0).getDouble("value");
|
wi.setKey("My Balance LTC");
|
||||||
if (res > 0d) {
|
wi.setValue(resultStr);
|
||||||
resultStr = res + " XRP " + curSym + String.format("%.2f", (res * lastPrices[2]));
|
prices.add(wi);
|
||||||
} else
|
}
|
||||||
resultStr = "Unknown";
|
|
||||||
KeyValue wi = new KeyValue();
|
|
||||||
wi.setKey("My Balance XRP");
|
|
||||||
wi.setValue(resultStr);
|
|
||||||
prices.add(wi);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ethWallet != null && !"null".equals(ethWallet) && ethWallet.length() > 0) {
|
|
||||||
restRequest = HttpHelper
|
|
||||||
.getStringResponse("https://api.etherscan.io/api?module=account&action=balance&address=" + ethWallet
|
|
||||||
+ "&tag=latest&apikey=N54NVXSVSISMQ4QIM2JVKJW56KHCKMU5T4");
|
|
||||||
if (restRequest != null && restRequest.length() > 0) {
|
|
||||||
JSONObject full = new JSONObject(restRequest);
|
|
||||||
String confirmedBalance = (String) full.get("result");
|
|
||||||
|
|
||||||
double res = Double.parseDouble(confirmedBalance);
|
|
||||||
res = res * 0.000000000000000001;
|
|
||||||
if (res > 0d) {
|
|
||||||
resultStr = res + " ETH " + curSym + String.format("%.2f", (res * lastPrices[3]));
|
|
||||||
} else
|
|
||||||
resultStr = "Unknown";
|
|
||||||
KeyValue wi = new KeyValue();
|
|
||||||
wi.setKey("My Balance ETH");
|
|
||||||
wi.setValue(resultStr);
|
|
||||||
prices.add(wi);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ltcapikey != null && !"null".equals(ltcapikey) && ltcapikey.length() > 0) {
|
|
||||||
String miningJson = HttpHelper
|
|
||||||
.getStringResponse("https://www.litecoinpool.org/api?api_key=".concat(ltcapikey));
|
|
||||||
if (miningJson != null && miningJson.length() > 0) {
|
|
||||||
JSONObject full = new JSONObject(miningJson);
|
|
||||||
JSONObject user = (JSONObject) full.get("user");
|
|
||||||
KeyValue wi = new KeyValue();
|
|
||||||
wi.setKey("HashRate");
|
|
||||||
if (user.getInt("hash_rate") > 0)
|
|
||||||
wi.setValue((user.getInt("hash_rate") / 1000) + " MH/s");
|
|
||||||
else
|
|
||||||
wi.setValue("Unknown");
|
|
||||||
workers.add(wi);
|
|
||||||
|
|
||||||
JSONObject workersJson = (JSONObject) full.get("workers");
|
|
||||||
for (Iterator<String> keys = workersJson.keys(); keys.hasNext();) {
|
|
||||||
String key = keys.next();
|
|
||||||
JSONObject worker = (JSONObject) workersJson.get(key);
|
|
||||||
wi = new KeyValue();
|
|
||||||
wi.setKey("HashRate " + key);
|
|
||||||
wi.setValue((worker.getInt("hash_rate") / 1000) + " MH/s");
|
|
||||||
workers.add(wi);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wi = new KeyValue();
|
|
||||||
wi.setKey("Paid");
|
|
||||||
if (user.getDouble("paid_rewards") > 0)
|
|
||||||
wi.setValue(user.getDouble("paid_rewards") + " LTC " + curSym
|
|
||||||
+ String.format("%.2f", (user.getDouble("paid_rewards") * lastPrices[1])));
|
|
||||||
else
|
|
||||||
wi.setValue("Unknown");
|
|
||||||
workers.add(wi);
|
|
||||||
|
|
||||||
wi = new KeyValue();
|
|
||||||
wi.setKey("Unpaid");
|
|
||||||
if (user.getDouble("unpaid_rewards") > 0)
|
|
||||||
wi.setValue(user.getDouble("unpaid_rewards") + " LTC " + curSym
|
|
||||||
+ String.format("%.2f", (user.getDouble("unpaid_rewards") * lastPrices[1])));
|
|
||||||
else
|
|
||||||
wi.setValue("Unknown");
|
|
||||||
workers.add(wi);
|
|
||||||
|
|
||||||
wi = new KeyValue();
|
|
||||||
wi.setKey("Total");
|
|
||||||
if (user.getDouble("total_rewards") > 0)
|
|
||||||
wi.setValue(user.getDouble("total_rewards") + " LTC " + curSym
|
|
||||||
+ String.format("%.2f", (user.getDouble("total_rewards") * lastPrices[1])));
|
|
||||||
else
|
|
||||||
wi.setValue("Unknown");
|
|
||||||
workers.add(wi);
|
|
||||||
|
|
||||||
wi = new KeyValue();
|
|
||||||
wi.setKey("Expected 24h");
|
|
||||||
if (user.getDouble("expected_24h_rewards") > 0)
|
|
||||||
wi.setValue(user.getDouble("expected_24h_rewards") + " LTC " + curSym
|
|
||||||
+ String.format("%.2f", (user.getDouble("expected_24h_rewards") * lastPrices[1])));
|
|
||||||
else
|
|
||||||
wi.setValue("Unknown");
|
|
||||||
workers.add(wi);
|
|
||||||
|
|
||||||
wi = new KeyValue();
|
|
||||||
wi.setKey("Past 24h");
|
|
||||||
if (user.getDouble("past_24h_rewards") > 0)
|
|
||||||
wi.setValue(user.getDouble("past_24h_rewards") + " LTC " + curSym
|
|
||||||
+ String.format("%.2f", (user.getDouble("past_24h_rewards") * lastPrices[1])));
|
|
||||||
else
|
|
||||||
wi.setValue("Unknown");
|
|
||||||
workers.add(wi);
|
|
||||||
|
|
||||||
JSONObject net = (JSONObject) full.get("network");
|
|
||||||
wi = new KeyValue();
|
|
||||||
wi.setKey("Network HashRate");
|
|
||||||
if (net.getLong("hash_rate") > 0)
|
|
||||||
wi.setValue((net.getLong("hash_rate") / 1000000) + " GH/s");
|
|
||||||
else
|
|
||||||
wi.setValue("Unknown");
|
|
||||||
network.add(wi);
|
|
||||||
|
|
||||||
wi = new KeyValue();
|
|
||||||
wi.setKey("Difficulty");
|
|
||||||
if (net.getDouble("difficulty") > 0)
|
|
||||||
wi.setValue("" + net.getDouble("difficulty"));
|
|
||||||
else
|
|
||||||
wi.setValue("Unknown");
|
|
||||||
network.add(wi);
|
|
||||||
|
|
||||||
wi = new KeyValue();
|
|
||||||
wi.setKey("Next Difficulty");
|
|
||||||
if (net.getDouble("next_difficulty") > 0)
|
|
||||||
wi.setValue("" + net.getDouble("next_difficulty"));
|
|
||||||
else
|
|
||||||
wi.setValue("Unknown");
|
|
||||||
network.add(wi);
|
|
||||||
|
|
||||||
wi = new KeyValue();
|
|
||||||
wi.setKey("Retarget time");
|
|
||||||
if (net.getDouble("retarget_time") > 0)
|
|
||||||
wi.setValue(splitToComponentTimes(net.getInt("retarget_time")));
|
|
||||||
else
|
|
||||||
wi.setValue("Unknown");
|
|
||||||
network.add(wi);
|
|
||||||
|
|
||||||
JSONObject poolJson = (JSONObject) full.get("pool");
|
|
||||||
wi = new KeyValue();
|
|
||||||
wi.setKey("Pool HashRate");
|
|
||||||
if (poolJson.getLong("hash_rate") > 0)
|
|
||||||
wi.setValue((poolJson.getLong("hash_rate") / 1000000) + " GH/s");
|
|
||||||
else
|
|
||||||
wi.setValue("Unknown");
|
|
||||||
pool.add(wi);
|
|
||||||
|
|
||||||
wi = new KeyValue();
|
|
||||||
wi.setKey("Active users");
|
|
||||||
if (poolJson.getInt("active_users") > 0)
|
|
||||||
wi.setValue("" + poolJson.getInt("active_users"));
|
|
||||||
else
|
|
||||||
wi.setValue("Unknown");
|
|
||||||
pool.add(wi);
|
|
||||||
|
|
||||||
wi = new KeyValue();
|
|
||||||
wi.setKey("PPS Ratio");
|
|
||||||
if (poolJson.getDouble("pps_ratio") > 0)
|
|
||||||
wi.setValue("" + poolJson.getDouble("pps_ratio"));
|
|
||||||
else
|
|
||||||
wi.setValue("Unknown");
|
|
||||||
pool.add(wi);
|
|
||||||
}
|
}
|
||||||
}
|
}).start();
|
||||||
|
|
||||||
|
new Thread(new Runnable() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (xrpWallet != null && !"null".equals(xrpWallet) && xrpWallet.length() > 0) {
|
||||||
|
restRequest = HttpHelper.getStringResponse(
|
||||||
|
"https://data.ripple.com/v2/accounts/".concat(xrpWallet).concat("/balances"));
|
||||||
|
if (restRequest != null && restRequest.length() > 0) {
|
||||||
|
JSONObject full = new JSONObject(restRequest);
|
||||||
|
JSONArray balances = (JSONArray) full.get("balances");
|
||||||
|
double res = balances.getJSONObject(0).getDouble("value");
|
||||||
|
if (res > 0d) {
|
||||||
|
resultStr = res + " XRP " + curSym + String.format("%.2f", (res * lastPrices[2]));
|
||||||
|
} else
|
||||||
|
resultStr = "Unknown";
|
||||||
|
KeyValue wi = new KeyValue();
|
||||||
|
wi.setKey("My Balance XRP");
|
||||||
|
wi.setValue(resultStr);
|
||||||
|
prices.add(wi);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
|
||||||
|
new Thread(new Runnable() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (ethWallet != null && !"null".equals(ethWallet) && ethWallet.length() > 0) {
|
||||||
|
restRequest = HttpHelper
|
||||||
|
.getStringResponse("https://api.etherscan.io/api?module=account&action=balance&address="
|
||||||
|
+ ethWallet + "&tag=latest&apikey=N54NVXSVSISMQ4QIM2JVKJW56KHCKMU5T4");
|
||||||
|
if (restRequest != null && restRequest.length() > 0) {
|
||||||
|
JSONObject full = new JSONObject(restRequest);
|
||||||
|
String confirmedBalance = (String) full.get("result");
|
||||||
|
|
||||||
|
double res = Double.parseDouble(confirmedBalance);
|
||||||
|
res = res * 0.000000000000000001;
|
||||||
|
if (res > 0d) {
|
||||||
|
resultStr = res + " ETH " + curSym + String.format("%.2f", (res * lastPrices[3]));
|
||||||
|
} else
|
||||||
|
resultStr = "Unknown";
|
||||||
|
KeyValue wi = new KeyValue();
|
||||||
|
wi.setKey("My Balance ETH");
|
||||||
|
wi.setValue(resultStr);
|
||||||
|
prices.add(wi);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
|
||||||
|
new Thread(new Runnable() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (ltcapikey != null && !"null".equals(ltcapikey) && ltcapikey.length() > 0) {
|
||||||
|
String miningJson = HttpHelper
|
||||||
|
.getStringResponse("https://www.litecoinpool.org/api?api_key=".concat(ltcapikey));
|
||||||
|
if (miningJson != null && miningJson.length() > 0) {
|
||||||
|
JSONObject full = new JSONObject(miningJson);
|
||||||
|
JSONObject user = (JSONObject) full.get("user");
|
||||||
|
KeyValue wi = new KeyValue();
|
||||||
|
wi.setKey("HashRate");
|
||||||
|
if (user.getInt("hash_rate") > 0)
|
||||||
|
wi.setValue((user.getInt("hash_rate") / 1000) + " MH/s");
|
||||||
|
else
|
||||||
|
wi.setValue("Unknown");
|
||||||
|
workers.add(wi);
|
||||||
|
|
||||||
|
JSONObject workersJson = (JSONObject) full.get("workers");
|
||||||
|
for (Iterator<String> keys = workersJson.keys(); keys.hasNext();) {
|
||||||
|
String key = keys.next();
|
||||||
|
JSONObject worker = (JSONObject) workersJson.get(key);
|
||||||
|
wi = new KeyValue();
|
||||||
|
wi.setKey("HashRate " + key);
|
||||||
|
wi.setValue((worker.getInt("hash_rate") / 1000) + " MH/s");
|
||||||
|
workers.add(wi);
|
||||||
|
}
|
||||||
|
|
||||||
|
wi = new KeyValue();
|
||||||
|
wi.setKey("Paid");
|
||||||
|
if (user.getDouble("paid_rewards") > 0)
|
||||||
|
wi.setValue(user.getDouble("paid_rewards") + " LTC " + curSym
|
||||||
|
+ String.format("%.2f", (user.getDouble("paid_rewards") * lastPrices[1])));
|
||||||
|
else
|
||||||
|
wi.setValue("Unknown");
|
||||||
|
workers.add(wi);
|
||||||
|
|
||||||
|
wi = new KeyValue();
|
||||||
|
wi.setKey("Unpaid");
|
||||||
|
if (user.getDouble("unpaid_rewards") > 0)
|
||||||
|
wi.setValue(user.getDouble("unpaid_rewards") + " LTC " + curSym
|
||||||
|
+ String.format("%.2f", (user.getDouble("unpaid_rewards") * lastPrices[1])));
|
||||||
|
else
|
||||||
|
wi.setValue("Unknown");
|
||||||
|
workers.add(wi);
|
||||||
|
|
||||||
|
wi = new KeyValue();
|
||||||
|
wi.setKey("Total");
|
||||||
|
if (user.getDouble("total_rewards") > 0)
|
||||||
|
wi.setValue(user.getDouble("total_rewards") + " LTC " + curSym
|
||||||
|
+ String.format("%.2f", (user.getDouble("total_rewards") * lastPrices[1])));
|
||||||
|
else
|
||||||
|
wi.setValue("Unknown");
|
||||||
|
workers.add(wi);
|
||||||
|
|
||||||
|
wi = new KeyValue();
|
||||||
|
wi.setKey("Expected 24h");
|
||||||
|
if (user.getDouble("expected_24h_rewards") > 0)
|
||||||
|
wi.setValue(user.getDouble("expected_24h_rewards") + " LTC " + curSym
|
||||||
|
+ String.format("%.2f", (user.getDouble("expected_24h_rewards") * lastPrices[1])));
|
||||||
|
else
|
||||||
|
wi.setValue("Unknown");
|
||||||
|
workers.add(wi);
|
||||||
|
|
||||||
|
wi = new KeyValue();
|
||||||
|
wi.setKey("Past 24h");
|
||||||
|
if (user.getDouble("past_24h_rewards") > 0)
|
||||||
|
wi.setValue(user.getDouble("past_24h_rewards") + " LTC " + curSym
|
||||||
|
+ String.format("%.2f", (user.getDouble("past_24h_rewards") * lastPrices[1])));
|
||||||
|
else
|
||||||
|
wi.setValue("Unknown");
|
||||||
|
workers.add(wi);
|
||||||
|
|
||||||
|
JSONObject net = (JSONObject) full.get("network");
|
||||||
|
wi = new KeyValue();
|
||||||
|
wi.setKey("Network HashRate");
|
||||||
|
if (net.getLong("hash_rate") > 0)
|
||||||
|
wi.setValue((net.getLong("hash_rate") / 1000000) + " GH/s");
|
||||||
|
else
|
||||||
|
wi.setValue("Unknown");
|
||||||
|
network.add(wi);
|
||||||
|
|
||||||
|
wi = new KeyValue();
|
||||||
|
wi.setKey("Difficulty");
|
||||||
|
if (net.getDouble("difficulty") > 0)
|
||||||
|
wi.setValue("" + net.getDouble("difficulty"));
|
||||||
|
else
|
||||||
|
wi.setValue("Unknown");
|
||||||
|
network.add(wi);
|
||||||
|
|
||||||
|
wi = new KeyValue();
|
||||||
|
wi.setKey("Next Difficulty");
|
||||||
|
if (net.getDouble("next_difficulty") > 0)
|
||||||
|
wi.setValue("" + net.getDouble("next_difficulty"));
|
||||||
|
else
|
||||||
|
wi.setValue("Unknown");
|
||||||
|
network.add(wi);
|
||||||
|
|
||||||
|
wi = new KeyValue();
|
||||||
|
wi.setKey("Retarget time");
|
||||||
|
if (net.getDouble("retarget_time") > 0)
|
||||||
|
wi.setValue(splitToComponentTimes(net.getInt("retarget_time")));
|
||||||
|
else
|
||||||
|
wi.setValue("Unknown");
|
||||||
|
network.add(wi);
|
||||||
|
|
||||||
|
JSONObject poolJson = (JSONObject) full.get("pool");
|
||||||
|
wi = new KeyValue();
|
||||||
|
wi.setKey("Pool HashRate");
|
||||||
|
if (poolJson.getLong("hash_rate") > 0)
|
||||||
|
wi.setValue((poolJson.getLong("hash_rate") / 1000000) + " GH/s");
|
||||||
|
else
|
||||||
|
wi.setValue("Unknown");
|
||||||
|
pool.add(wi);
|
||||||
|
|
||||||
|
wi = new KeyValue();
|
||||||
|
wi.setKey("Active users");
|
||||||
|
if (poolJson.getInt("active_users") > 0)
|
||||||
|
wi.setValue("" + poolJson.getInt("active_users"));
|
||||||
|
else
|
||||||
|
wi.setValue("Unknown");
|
||||||
|
pool.add(wi);
|
||||||
|
|
||||||
|
wi = new KeyValue();
|
||||||
|
wi.setKey("PPS Ratio");
|
||||||
|
if (poolJson.getDouble("pps_ratio") > 0)
|
||||||
|
wi.setValue("" + poolJson.getDouble("pps_ratio"));
|
||||||
|
else
|
||||||
|
wi.setValue("Unknown");
|
||||||
|
pool.add(wi);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
|
||||||
if (dogapikey != null && !"null".equals(dogapikey) && dogapikey.length() > 0) {
|
if (dogapikey != null && !"null".equals(dogapikey) && dogapikey.length() > 0) {
|
||||||
String miningJson = HttpHelper
|
|
||||||
.getStringResponse("https://aikapool.com/doge/index.php?page=api&action=getuserworkers&api_key="
|
|
||||||
+ dogapikey + "&id=282608&_=1621333944761", 5000);
|
|
||||||
if (miningJson != null && miningJson.length() > 0) {
|
|
||||||
JSONObject full = new JSONObject(miningJson);
|
|
||||||
JSONObject user = (JSONObject) full.get("getuserworkers");
|
|
||||||
JSONArray data = (JSONArray) user.get("data");
|
|
||||||
KeyValue wi = new KeyValue();
|
|
||||||
|
|
||||||
for (Iterator it = data.iterator(); it.hasNext();) {
|
new Thread(new Runnable() {
|
||||||
JSONObject workersJson = (JSONObject) it.next();
|
|
||||||
wi = new KeyValue();
|
@Override
|
||||||
wi.setKey("HashRate " + workersJson.getString("username"));
|
public void run() {
|
||||||
double hr = workersJson.getDouble("hashrate");
|
String miningJson = HttpHelper
|
||||||
wi.setValue(String.format("%.2f", (hr / 1000)) + " MH/s");
|
.getStringResponse("https://aikapool.com/doge/index.php?page=api&action=getuserworkers&api_key="
|
||||||
workers.add(wi);
|
+ dogapikey + "&id=282608&_=1621333944761", 5000);
|
||||||
|
if (miningJson != null && miningJson.length() > 0) {
|
||||||
|
JSONObject full = new JSONObject(miningJson);
|
||||||
|
JSONObject user = (JSONObject) full.get("getuserworkers");
|
||||||
|
JSONArray data = (JSONArray) user.get("data");
|
||||||
|
KeyValue wi = new KeyValue();
|
||||||
|
|
||||||
|
for (Iterator<Object> it = data.iterator(); it.hasNext();) {
|
||||||
|
JSONObject workersJson = (JSONObject) it.next();
|
||||||
|
wi = new KeyValue();
|
||||||
|
wi.setKey("HashRate " + workersJson.getString("username"));
|
||||||
|
double hr = workersJson.getDouble("hashrate");
|
||||||
|
wi.setValue(String.format("%.2f", (hr / 1000)) + " MH/s");
|
||||||
|
workers.add(wi);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}).start();
|
||||||
|
|
||||||
miningJson = HttpHelper
|
new Thread(new Runnable() {
|
||||||
.getStringResponse("https://aikapool.com/doge/index.php?page=api&action=getdashboarddata&api_key="
|
|
||||||
+ dogapikey + "&id=282608&_=1621333944761", 5000);
|
|
||||||
if (miningJson != null && miningJson.length() > 0) {
|
|
||||||
JSONObject full = new JSONObject(miningJson);
|
|
||||||
JSONObject user = (JSONObject) full.get("getdashboarddata");
|
|
||||||
JSONObject data = (JSONObject) user.get("data");
|
|
||||||
JSONObject net = (JSONObject) data.get("network");
|
|
||||||
JSONObject pers = (JSONObject) data.get("personal");
|
|
||||||
JSONObject poolj = (JSONObject) data.get("pool");
|
|
||||||
JSONArray blocks = (JSONArray) poolj.get("blocks");
|
|
||||||
JSONObject estimates = (JSONObject) pers.get("estimates");
|
|
||||||
JSONObject raw = (JSONObject) data.get("raw");
|
|
||||||
KeyValue wi = new KeyValue();
|
|
||||||
|
|
||||||
wi = new KeyValue();
|
@Override
|
||||||
wi.setKey("Next Payout");
|
public void run() {
|
||||||
if (estimates.getDouble("payout") > 0)
|
String miningJson = HttpHelper
|
||||||
wi.setValue(estimates.getDouble("payout") + " DOG");
|
.getStringResponse("https://aikapool.com/doge/index.php?page=api&action=getdashboarddata&api_key="
|
||||||
else
|
+ dogapikey + "&id=282608&_=1621333944761", 5000);
|
||||||
wi.setValue("Unknown");
|
if (miningJson != null && miningJson.length() > 0) {
|
||||||
workers.add(wi);
|
JSONObject full = new JSONObject(miningJson);
|
||||||
|
JSONObject user = (JSONObject) full.get("getdashboarddata");
|
||||||
|
JSONObject data = (JSONObject) user.get("data");
|
||||||
|
JSONObject net = (JSONObject) data.get("network");
|
||||||
|
JSONObject pers = (JSONObject) data.get("personal");
|
||||||
|
JSONObject poolj = (JSONObject) data.get("pool");
|
||||||
|
JSONArray blocks = (JSONArray) poolj.get("blocks");
|
||||||
|
JSONObject estimates = (JSONObject) pers.get("estimates");
|
||||||
|
JSONObject raw = (JSONObject) data.get("raw");
|
||||||
|
KeyValue wi = new KeyValue();
|
||||||
|
|
||||||
wi = new KeyValue();
|
wi = new KeyValue();
|
||||||
wi.setKey("Last Block");
|
wi.setKey("Next Payout");
|
||||||
if (blocks != null && blocks.get(0) != null) {
|
if (estimates.getDouble("payout") > 0)
|
||||||
JSONObject block = (JSONObject)blocks.get(0);
|
wi.setValue(estimates.getDouble("payout") + " DOG");
|
||||||
long time = block.getLong("time");
|
else
|
||||||
String finder = block.getString("finder");
|
wi.setValue("Unknown");
|
||||||
//double amount = block.getDouble("amount");
|
workers.add(wi);
|
||||||
wi.setValue("" + sdf.format(new Date(time*1000)) + " "+finder);
|
|
||||||
} else
|
|
||||||
wi.setValue("Unknown");
|
|
||||||
network.add(wi);
|
|
||||||
|
|
||||||
wi = new KeyValue();
|
wi = new KeyValue();
|
||||||
wi.setKey("Difficulty");
|
wi.setKey("Last Block Time");
|
||||||
if (net.getDouble("difficulty") > 0)
|
if (blocks != null && blocks.get(0) != null) {
|
||||||
wi.setValue("" + net.getDouble("difficulty"));
|
JSONObject block = (JSONObject) blocks.get(0);
|
||||||
else
|
long time = block.getLong("time");
|
||||||
wi.setValue("Unknown");
|
wi.setValue("" + sdf.format(new Date(time * 1000)));
|
||||||
network.add(wi);
|
} else
|
||||||
|
wi.setValue("Unknown");
|
||||||
|
network.add(wi);
|
||||||
|
|
||||||
wi = new KeyValue();
|
wi = new KeyValue();
|
||||||
wi.setKey("Next Difficulty");
|
wi.setKey("Last Block Finder");
|
||||||
if (net.getDouble("nextdifficulty") > 0)
|
if (blocks != null && blocks.get(0) != null) {
|
||||||
wi.setValue("" + net.getDouble("nextdifficulty"));
|
JSONObject block = (JSONObject) blocks.get(0);
|
||||||
else
|
String finder = block.getString("finder");
|
||||||
wi.setValue("Unknown");
|
if (block.isNull("group_name"))
|
||||||
network.add(wi);
|
wi.setValue(finder);
|
||||||
|
else
|
||||||
|
wi.setValue(finder + " (SOLO)");
|
||||||
|
} else
|
||||||
|
wi.setValue("Unknown");
|
||||||
|
network.add(wi);
|
||||||
|
|
||||||
wi = new KeyValue();
|
wi = new KeyValue();
|
||||||
wi.setKey("Pool Hashrate");
|
wi.setKey("Difficulty");
|
||||||
if (raw.getJSONObject("pool").getDouble("hashrate") > 0)
|
if (net.getDouble("difficulty") > 0)
|
||||||
wi.setValue((raw.getJSONObject("pool").getDouble("hashrate") / 1000000) + " GH/s");
|
wi.setValue("" + net.getDouble("difficulty"));
|
||||||
else
|
else
|
||||||
wi.setValue("Unknown");
|
wi.setValue("Unknown");
|
||||||
network.add(wi);
|
network.add(wi);
|
||||||
|
|
||||||
wi = new KeyValue();
|
wi = new KeyValue();
|
||||||
wi.setKey("Network Hashrate");
|
wi.setKey("Next Difficulty");
|
||||||
if (raw.getJSONObject("network").getDouble("hashrate") > 0)
|
if (net.getDouble("nextdifficulty") > 0)
|
||||||
wi.setValue((raw.getJSONObject("network").getDouble("hashrate") / 1000000) + " GH/s");
|
wi.setValue("" + net.getDouble("nextdifficulty"));
|
||||||
else
|
else
|
||||||
wi.setValue("Unknown");
|
wi.setValue("Unknown");
|
||||||
network.add(wi);
|
network.add(wi);
|
||||||
}
|
|
||||||
|
|
||||||
miningJson = HttpHelper
|
wi = new KeyValue();
|
||||||
.getStringResponse("https://aikapool.com/doge/index.php?page=api&action=getuserbalance&api_key="
|
wi.setKey("Pool Hashrate");
|
||||||
+ dogapikey + "&id=282608&_=1621333944761", 5000);
|
if (raw.getJSONObject("pool").getDouble("hashrate") > 0)
|
||||||
if (miningJson != null && miningJson.length() > 0) {
|
wi.setValue((raw.getJSONObject("pool").getDouble("hashrate") / 1000000) + " GH/s");
|
||||||
JSONObject full = new JSONObject(miningJson);
|
else
|
||||||
JSONObject user = (JSONObject) full.get("getuserbalance");
|
wi.setValue("Unknown");
|
||||||
JSONObject data = (JSONObject) user.get("data");
|
network.add(wi);
|
||||||
KeyValue wi = new KeyValue();
|
|
||||||
|
|
||||||
wi = new KeyValue();
|
wi = new KeyValue();
|
||||||
wi.setKey("Paid");
|
wi.setKey("Network Hashrate");
|
||||||
if (data.getDouble("paid") >= 0)
|
if (raw.getJSONObject("network").getDouble("hashrate") > 0)
|
||||||
wi.setValue(data.getDouble("paid") + " DOG");
|
wi.setValue((raw.getJSONObject("network").getDouble("hashrate") / 1000000) + " GH/s");
|
||||||
else
|
else
|
||||||
wi.setValue("Unknown");
|
wi.setValue("Unknown");
|
||||||
workers.add(wi);
|
network.add(wi);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
|
||||||
wi = new KeyValue();
|
new Thread(new Runnable() {
|
||||||
wi.setKey("Confirmed");
|
|
||||||
if (data.getDouble("confirmed") >= 0)
|
|
||||||
wi.setValue(data.getDouble("confirmed") + " DOG");
|
|
||||||
else
|
|
||||||
wi.setValue("Unknown");
|
|
||||||
workers.add(wi);
|
|
||||||
|
|
||||||
wi = new KeyValue();
|
@Override
|
||||||
wi.setKey("Unconfirmed");
|
public void run() {
|
||||||
if (data.getDouble("unconfirmed") >= 0)
|
String miningJson = HttpHelper
|
||||||
wi.setValue(data.getDouble("unconfirmed") + " DOG");
|
.getStringResponse("https://aikapool.com/doge/index.php?page=api&action=getuserbalance&api_key="
|
||||||
else
|
+ dogapikey + "&id=282608&_=1621333944761", 5000);
|
||||||
wi.setValue("Unknown");
|
if (miningJson != null && miningJson.length() > 0) {
|
||||||
workers.add(wi);
|
JSONObject full = new JSONObject(miningJson);
|
||||||
|
JSONObject user = (JSONObject) full.get("getuserbalance");
|
||||||
|
JSONObject data = (JSONObject) user.get("data");
|
||||||
|
KeyValue wi = new KeyValue();
|
||||||
|
|
||||||
}
|
wi = new KeyValue();
|
||||||
|
wi.setKey("Paid");
|
||||||
|
if (data.getDouble("paid") >= 0)
|
||||||
|
wi.setValue(data.getDouble("paid") + " DOG");
|
||||||
|
else
|
||||||
|
wi.setValue("Unknown");
|
||||||
|
workers.add(wi);
|
||||||
|
|
||||||
|
wi = new KeyValue();
|
||||||
|
wi.setKey("Confirmed");
|
||||||
|
if (data.getDouble("confirmed") >= 0)
|
||||||
|
wi.setValue(data.getDouble("confirmed") + " DOG");
|
||||||
|
else
|
||||||
|
wi.setValue("Unknown");
|
||||||
|
workers.add(wi);
|
||||||
|
|
||||||
|
wi = new KeyValue();
|
||||||
|
wi.setKey("Unconfirmed");
|
||||||
|
if (data.getDouble("unconfirmed") >= 0)
|
||||||
|
wi.setValue(data.getDouble("unconfirmed") + " DOG");
|
||||||
|
else
|
||||||
|
wi.setValue("Unknown");
|
||||||
|
workers.add(wi);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Thread.sleep(Constants.DEFAULT_HTTP_TIMEOUT);
|
||||||
|
|
||||||
KeyValue wi = new KeyValue();
|
KeyValue wi = new KeyValue();
|
||||||
wi.setKey("Last Update");
|
wi.setKey("Last Update");
|
||||||
wi.setValue("" + sdf.format(new Date(System.currentTimeMillis())));
|
wi.setValue("" + sdf.format(new Date(System.currentTimeMillis())));
|
||||||
|
|||||||
@ -3,7 +3,8 @@
|
|||||||
<%@ page language="java" contentType="text/html; charset=UTF-8"
|
<%@ page language="java" contentType="text/html; charset=UTF-8"
|
||||||
pageEncoding="UTF-8"%>
|
pageEncoding="UTF-8"%>
|
||||||
<%
|
<%
|
||||||
String res = MiningBean.updateAll(request, response);
|
MiningBean mb = new MiningBean();
|
||||||
|
String res = mb.updateAll(request, response);
|
||||||
|
|
||||||
response.setContentType("text/xml; charset=UTF-8");
|
response.setContentType("text/xml; charset=UTF-8");
|
||||||
response.setHeader("Cache-Control", "no-cache");
|
response.setHeader("Cache-Control", "no-cache");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user