threaded load

This commit is contained in:
rdavidek 2021-06-06 14:39:22 +02:00
parent d5b06ee3ca
commit 18a584f6d8
3 changed files with 368 additions and 311 deletions

View File

@ -4,6 +4,6 @@ public interface Constants {
public static final String APP_VERSION = "v0.8";
public static final String COPYRIGHT = "2021";
public static final int DEFAULT_HTTP_TIMEOUT = 2000;
public static final int RELOAD_TIME = 20000;
public static final int DEFAULT_HTTP_TIMEOUT = 10000;
public static final int RELOAD_TIME = DEFAULT_HTTP_TIMEOUT;
}

View File

@ -18,7 +18,17 @@ import cz.kamma.mining.vo.KeyValue;
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");
java.lang.System.setProperty("https.protocols", "TLSv1,TLSv1.1,TLSv1.2");
List<KeyValue> prices = new ArrayList<>();
@ -29,32 +39,22 @@ public class MiningBean {
String[] cryptoCur = new String[] { "btc", "ltc", "xrp", "eth" };
double[] lastPrices = new double[] { 0, 0, 0, 0 };
String ltcapikey = request.getParameter("ltcapikey");
String dogapikey = request.getParameter("dogapikey");
String ltcWallet = request.getParameter("ltc");
String xrpWallet = request.getParameter("xrp");
String ethWallet = request.getParameter("eth");
String currency = request.getParameter("cur");
ltcapikey = request.getParameter("ltcapikey");
dogapikey = request.getParameter("dogapikey");
ltcWallet = request.getParameter("ltc");
xrpWallet = request.getParameter("xrp");
ethWallet = request.getParameter("eth");
currency = request.getParameter("cur");
if (currency == null || currency.equals("null") || currency.length() == 0)
currency = "usd";
else
currency = currency.toLowerCase();
String curSym = "$";
if (currency.equals("usd"))
curSym = "$";
else if (currency.equals("eur"))
curSym = "";
workers.clear();
prices.clear();
network.clear();
pool.clear();
String resultStr;
String restRequest;
curSym = "\u20ac";
for (int i = 0; i < cryptoCur.length; i++) {
String ccur = cryptoCur[i];
@ -75,318 +75,374 @@ public class MiningBean {
}
}
if (ltcWallet != null && !"null".equals(ltcWallet) && ltcWallet.length() > 0) {
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");
new Thread(new Runnable() {
double res = Double.parseDouble(confirmedBalance);
if (res > 0d) {
resultStr = res + " LTC " + curSym + String.format("%.2f", (res * lastPrices[1]));
} else
resultStr = "Unknown";
KeyValue wi = new KeyValue();
wi.setKey("My Balance LTC");
wi.setValue(resultStr);
prices.add(wi);
}
}
@Override
public void run() {
if (ltcWallet != null && !"null".equals(ltcWallet) && ltcWallet.length() > 0) {
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");
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);
}
}
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);
double res = Double.parseDouble(confirmedBalance);
if (res > 0d) {
resultStr = res + " LTC " + curSym + String.format("%.2f", (res * lastPrices[1]));
} else
resultStr = "Unknown";
KeyValue wi = new KeyValue();
wi.setKey("My Balance LTC");
wi.setValue(resultStr);
prices.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) {
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();) {
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);
new Thread(new Runnable() {
@Override
public void run() {
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<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
.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();
new Thread(new Runnable() {
wi = new KeyValue();
wi.setKey("Next Payout");
if (estimates.getDouble("payout") > 0)
wi.setValue(estimates.getDouble("payout") + " DOG");
else
wi.setValue("Unknown");
workers.add(wi);
@Override
public void run() {
String miningJson = HttpHelper
.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();
wi.setKey("Last Block");
if (blocks != null && blocks.get(0) != null) {
JSONObject block = (JSONObject)blocks.get(0);
long time = block.getLong("time");
String finder = block.getString("finder");
//double amount = block.getDouble("amount");
wi.setValue("" + sdf.format(new Date(time*1000)) + " "+finder);
} else
wi.setValue("Unknown");
network.add(wi);
wi = new KeyValue();
wi.setKey("Next Payout");
if (estimates.getDouble("payout") > 0)
wi.setValue(estimates.getDouble("payout") + " DOG");
else
wi.setValue("Unknown");
workers.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("Last Block Time");
if (blocks != null && blocks.get(0) != null) {
JSONObject block = (JSONObject) blocks.get(0);
long time = block.getLong("time");
wi.setValue("" + sdf.format(new Date(time * 1000)));
} else
wi.setValue("Unknown");
network.add(wi);
wi = new KeyValue();
wi.setKey("Next Difficulty");
if (net.getDouble("nextdifficulty") > 0)
wi.setValue("" + net.getDouble("nextdifficulty"));
else
wi.setValue("Unknown");
network.add(wi);
wi = new KeyValue();
wi.setKey("Last Block Finder");
if (blocks != null && blocks.get(0) != null) {
JSONObject block = (JSONObject) blocks.get(0);
String finder = block.getString("finder");
if (block.isNull("group_name"))
wi.setValue(finder);
else
wi.setValue(finder + " (SOLO)");
} else
wi.setValue("Unknown");
network.add(wi);
wi = new KeyValue();
wi.setKey("Pool Hashrate");
if (raw.getJSONObject("pool").getDouble("hashrate") > 0)
wi.setValue((raw.getJSONObject("pool").getDouble("hashrate") / 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("Network Hashrate");
if (raw.getJSONObject("network").getDouble("hashrate") > 0)
wi.setValue((raw.getJSONObject("network").getDouble("hashrate") / 1000000) + " GH/s");
else
wi.setValue("Unknown");
network.add(wi);
}
wi = new KeyValue();
wi.setKey("Next Difficulty");
if (net.getDouble("nextdifficulty") > 0)
wi.setValue("" + net.getDouble("nextdifficulty"));
else
wi.setValue("Unknown");
network.add(wi);
miningJson = HttpHelper
.getStringResponse("https://aikapool.com/doge/index.php?page=api&action=getuserbalance&api_key="
+ dogapikey + "&id=282608&_=1621333944761", 5000);
if (miningJson != null && miningJson.length() > 0) {
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("Pool Hashrate");
if (raw.getJSONObject("pool").getDouble("hashrate") > 0)
wi.setValue((raw.getJSONObject("pool").getDouble("hashrate") / 1000000) + " GH/s");
else
wi.setValue("Unknown");
network.add(wi);
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("Network Hashrate");
if (raw.getJSONObject("network").getDouble("hashrate") > 0)
wi.setValue((raw.getJSONObject("network").getDouble("hashrate") / 1000000) + " GH/s");
else
wi.setValue("Unknown");
network.add(wi);
}
}
}).start();
wi = new KeyValue();
wi.setKey("Confirmed");
if (data.getDouble("confirmed") >= 0)
wi.setValue(data.getDouble("confirmed") + " DOG");
else
wi.setValue("Unknown");
workers.add(wi);
new Thread(new Runnable() {
wi = new KeyValue();
wi.setKey("Unconfirmed");
if (data.getDouble("unconfirmed") >= 0)
wi.setValue(data.getDouble("unconfirmed") + " DOG");
else
wi.setValue("Unknown");
workers.add(wi);
@Override
public void run() {
String miningJson = HttpHelper
.getStringResponse("https://aikapool.com/doge/index.php?page=api&action=getuserbalance&api_key="
+ dogapikey + "&id=282608&_=1621333944761", 5000);
if (miningJson != null && miningJson.length() > 0) {
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();
wi.setKey("Last Update");
wi.setValue("" + sdf.format(new Date(System.currentTimeMillis())));

View File

@ -3,7 +3,8 @@
<%@ page language="java" contentType="text/html; charset=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.setHeader("Cache-Control", "no-cache");