added last block

This commit is contained in:
rdavidek 2021-05-26 15:03:48 +02:00
parent 1b44489b20
commit 2810fb8b24

View File

@ -1,6 +1,10 @@
package cz.kamma.mining.bean;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
@ -43,7 +47,7 @@ public class MiningBean {
if (currency.equals("usd"))
curSym = "$";
else if (currency.equals("eur"))
curSym = "";
curSym = "";
workers.clear();
prices.clear();
@ -289,6 +293,8 @@ public class MiningBean {
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();
@ -301,6 +307,19 @@ public class MiningBean {
wi.setValue("Unknown");
workers.add(wi);
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");
SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
wi.setValue("" + sdf.format(new Date(time*1000)) + " - "+finder + " - "+amount);
} else
wi.setValue("Unknown");
network.add(wi);
wi = new KeyValue();
wi.setKey("Difficulty");
if (net.getDouble("difficulty") > 0)