use of duckutil.RateReporter in project snowblossom by snowblossomcoin.
the class ReportManager method record.
public synchronized void record(String address, long count) {
total.record(count);
if (!rate_map.containsKey(address)) {
rate_map.put(address, new RateReporter());
}
rate_map.get(address).record(count);
}
use of duckutil.RateReporter in project snowblossom by snowblossomcoin.
the class ReportManager method writeReport.
public synchronized void writeReport(String path) {
try {
PrintStream out = new PrintStream(new AtomicFileOutputStream(path));
DecimalFormat df = new DecimalFormat("0.0");
out.println("Total: " + total.getReportLong(df));
TreeSet<String> to_remove = new TreeSet<>();
for (Map.Entry<String, RateReporter> me : rate_map.entrySet()) {
if (me.getValue().isZero()) {
to_remove.add(me.getKey());
} else {
out.println(me.getKey() + " " + me.getValue().getReportLong(df));
}
}
for (String k : to_remove) {
rate_map.remove(k);
}
out.flush();
out.close();
} catch (Exception e) {
logger.log(Level.WARNING, "Error writing report: " + e.toString());
}
}
use of duckutil.RateReporter in project snowblossom by snowblossomcoin.
the class ReportManager method writeReportJson.
public synchronized void writeReportJson(JSONObject json) {
json.put("total", total.getRawRates());
JSONObject miners = new JSONObject();
TreeSet<String> to_remove = new TreeSet<>();
for (Map.Entry<String, RateReporter> me : rate_map.entrySet()) {
if (me.getValue().isZero()) {
to_remove.add(me.getKey());
} else {
miners.put(me.getKey(), me.getValue().getRawRates());
}
}
for (String k : to_remove) {
rate_map.remove(k);
}
json.put("miners", miners);
}
Aggregations