Search in sources :

Example 1 with TimeRecord

use of duckutil.TimeRecord in project snowblossom by snowblossomcoin.

the class Arktika method printStats.

public void printStats() {
    long now = System.currentTimeMillis();
    long count_long = op_count.sumAndReset();
    double count = count_long;
    rate_report.record(count_long);
    double time_ms = now - last_stats_time;
    double time_sec = time_ms / 1000.0;
    double rate = count / time_sec;
    DecimalFormat df = new DecimalFormat("0.000");
    String block_time_report = "";
    if (last_work_unit != null) {
        BigInteger target = BlockchainUtil.targetBytesToBigInteger(last_work_unit.getReportTarget());
        double diff = PowUtil.getDiffForTarget(target);
        double block_time_sec = Math.pow(2.0, diff) / rate;
        double min = block_time_sec / 60.0;
        block_time_report = String.format("- at this rate %s minutes per share (diff %s)", df.format(min), df.format(diff));
    }
    logger.info(String.format("15 Second mining rate: %s/sec %s", df.format(rate), block_time_report));
    logger.info(rate_report.getReportShort(df));
    last_stats_time = now;
    if (count == 0) {
        if (getWorkUnit() == null) {
            logger.info("Stalled.  No valid work unit, reconnecting to pool");
            try {
                pool_client.subscribe();
            } catch (Throwable t) {
                logger.info("Exception in subscribe: " + t);
            }
        } else {
            logger.info("No hashing, and we have a good work unit from the pool.  So probably something else wrong.");
        }
    }
    if (config.getBoolean("display_timerecord")) {
        TimeRecord old = time_record;
        time_record = new TimeRecord();
        TimeRecord.setSharedRecord(time_record);
        old.printReport(System.out);
    }
    StringBuilder queue_report = new StringBuilder();
    queue_report.append("Queues: {");
    for (Map.Entry<Integer, FaQueue> me : layer_to_queue_map.entrySet()) {
        queue_report.append(me.getValue().size());
        queue_report.append(",");
    }
    queue_report.append("}");
    for (int i = 0; i < layer_count; i++) {
        FieldSource fs = all_sources[i];
        logger.info(String.format("Layer %d: %s", i, fs.getRateString(time_sec)));
    }
    logger.info(String.format("RPC Server: %s", stubo.getRateString(time_sec)));
    logger.info(queue_report.toString());
    logger.info(String.format("Shares: %d (rejected %d) (blocks %d)", share_submit_count.get(), share_reject_count.get(), share_block_count.get()));
}
Also used : DecimalFormat(java.text.DecimalFormat) BigInteger(java.math.BigInteger) TimeRecord(duckutil.TimeRecord) BigInteger(java.math.BigInteger) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) TreeMap(java.util.TreeMap)

Example 2 with TimeRecord

use of duckutil.TimeRecord in project snowblossom by snowblossomcoin.

the class SurfMiner method printStats.

public void printStats() {
    long now = System.currentTimeMillis();
    long count_long = op_count.sumAndReset();
    double count = count_long;
    rate_report.record(count_long);
    double time_ms = now - last_stats_time;
    double time_sec = time_ms / 1000.0;
    double rate = count / time_sec;
    DecimalFormat df = new DecimalFormat("0.000");
    String block_time_report = "";
    if (last_work_unit != null) {
        BigInteger target = BlockchainUtil.targetBytesToBigInteger(last_work_unit.getReportTarget());
        double diff = PowUtil.getDiffForTarget(target);
        double block_time_sec = Math.pow(2.0, diff) / rate;
        double min = block_time_sec / 60.0;
        block_time_report = String.format("- at this rate %s minutes per share (diff %s)", df.format(min), df.format(diff));
    }
    logger.info(rate_report.getReportShort(df));
    last_stats_time = now;
    if (count == 0) {
        if (getWorkUnit() == null) {
            logger.info("Stalled.  No valid work unit, reconnecting to pool");
            try {
                pool_client.subscribe();
            } catch (Throwable t) {
                logger.info("Exception in subscribe: " + t);
            }
        } else {
            logger.info("No hashing, and we have a good work unit from the pool.  So probably something else wrong.");
        }
    }
    if (config.getBoolean("display_timerecord")) {
        TimeRecord old = time_record;
        time_record = new TimeRecord();
        TimeRecord.setSharedRecord(time_record);
        old.printReport(System.out);
    }
    logger.info(String.format("Shares: %d (rejected %d) (blocks %d)", share_submit_count.get(), share_reject_count.get(), share_block_count.get()));
}
Also used : TimeRecord(duckutil.TimeRecord) DecimalFormat(java.text.DecimalFormat) BigInteger(java.math.BigInteger) ByteString(com.google.protobuf.ByteString)

Example 3 with TimeRecord

use of duckutil.TimeRecord in project snowblossom by snowblossomcoin.

the class MrPlow method printStats.

public void printStats() {
    long now = System.currentTimeMillis();
    double count = op_count.getAndSet(0L);
    double time_ms = now - last_stats_time;
    double time_sec = time_ms / 1000.0;
    double rate = count / time_sec;
    DecimalFormat df = new DecimalFormat("0.000");
    String block_time_report = "";
    if (last_block_template != null) {
        BigInteger target = BlockchainUtil.targetBytesToBigInteger(last_block_template.getHeader().getTarget());
        double diff = PowUtil.getDiffForTarget(target);
        double block_time_sec = Math.pow(2.0, diff) / rate;
        double hours = block_time_sec / 3600.0;
        block_time_report = String.format("- at this rate %s hours per block", df.format(hours));
    }
    logger.info(String.format("Mining rate: %s", report_manager.getTotalRate().getReportLong(df)));
    logger.info(String.format("Mining rate: %s/sec %s", df.format(rate), block_time_report));
    last_stats_time = now;
    if (config.getBoolean("display_timerecord")) {
        TimeRecord old = time_record;
        time_record = new TimeRecord();
        TimeRecord.setSharedRecord(time_record);
        old.printReport(System.out);
    }
}
Also used : TimeRecord(duckutil.TimeRecord) DecimalFormat(java.text.DecimalFormat) BigInteger(java.math.BigInteger) ByteString(com.google.protobuf.ByteString)

Example 4 with TimeRecord

use of duckutil.TimeRecord in project snowblossom by snowblossomcoin.

the class PoolMiner method printStats.

public void printStats() {
    long now = System.currentTimeMillis();
    long count_long = op_count.sumAndReset();
    double count = count_long;
    rate_report.record(count_long);
    double time_ms = now - last_stats_time;
    double time_sec = time_ms / 1000.0;
    double rate = count / time_sec;
    DecimalFormat df = new DecimalFormat("0.000");
    String block_time_report = "";
    if (last_work_unit != null) {
        BigInteger target = BlockchainUtil.targetBytesToBigInteger(last_work_unit.getReportTarget());
        double diff = PowUtil.getDiffForTarget(target);
        double block_time_sec = Math.pow(2.0, diff) / rate;
        double min = block_time_sec / 60.0;
        block_time_report = String.format("- at this rate %s minutes per share (diff %s)", df.format(min), df.format(diff));
    }
    logger.info(String.format("15 Second mining rate: %s/sec %s", df.format(rate), block_time_report));
    logger.info(rate_report.getReportShort(df));
    last_stats_time = now;
    if (count == 0) {
        if (getWorkUnit() == null) {
            logger.info("Stalled.  No valid work unit, reconnecting to pool");
            try {
                pool_client.subscribe();
            } catch (Throwable t) {
                logger.info("Exception in subscribe: " + t);
            }
        } else {
            logger.info("No hashing, and we have a good work unit from the pool.  So probably something else wrong.");
        }
    }
    if (config.getBoolean("display_timerecord")) {
        TimeRecord old = time_record;
        time_record = new TimeRecord();
        TimeRecord.setSharedRecord(time_record);
        old.printReport(System.out);
    }
    logger.info(String.format("Shares: %d (rejected %d) (blocks %d)", share_submit_count.get(), share_reject_count.get(), share_block_count.get()));
}
Also used : TimeRecord(duckutil.TimeRecord) DecimalFormat(java.text.DecimalFormat) BigInteger(java.math.BigInteger) ByteString(com.google.protobuf.ByteString)

Example 5 with TimeRecord

use of duckutil.TimeRecord in project snowblossom by snowblossomcoin.

the class SnowBlossomMiner method printStats.

public void printStats() {
    long now = System.currentTimeMillis();
    double count = op_count.sumAndReset();
    double time_ms = now - last_stats_time;
    double time_sec = time_ms / 1000.0;
    double rate = count / time_sec;
    DecimalFormat df = new DecimalFormat("0.000");
    String block_time_report = "";
    if (last_block_template != null) {
        BigInteger target = BlockchainUtil.targetBytesToBigInteger(last_block_template.getHeader().getTarget());
        double diff = PowUtil.getDiffForTarget(target);
        double block_time_sec = Math.pow(2.0, diff) / rate;
        double hours = block_time_sec / 3600.0;
        double min = hours * 60.0;
        block_time_report = String.format("- at this rate %s hours or %s minutes per block", df.format(hours), df.format(min));
    }
    logger.info(String.format("Mining rate: %s/sec %s", df.format(rate), block_time_report));
    last_stats_time = now;
    if (count == 0) {
        logger.info("we seem to be stalled, reconnecting to node");
        try {
            subscribe();
        } catch (Throwable t) {
            logger.info("Exception in subscribe: " + t);
        }
    }
    if (config.getBoolean("display_timerecord")) {
        TimeRecord old = time_record;
        time_record = new TimeRecord();
        TimeRecord.setSharedRecord(time_record);
        old.printReport(System.out);
    }
}
Also used : TimeRecord(duckutil.TimeRecord) DecimalFormat(java.text.DecimalFormat) BigInteger(java.math.BigInteger) ByteString(com.google.protobuf.ByteString)

Aggregations

TimeRecord (duckutil.TimeRecord)6 BigInteger (java.math.BigInteger)5 DecimalFormat (java.text.DecimalFormat)5 ByteString (com.google.protobuf.ByteString)4 TreeMap (java.util.TreeMap)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 KeyPair (java.security.KeyPair)1 Map (java.util.Map)1 Random (java.util.Random)1 Test (org.junit.Test)1 HashedTrie (snowblossom.lib.trie.HashedTrie)1 MemPool (snowblossom.node.MemPool)1 Transaction (snowblossom.proto.Transaction)1 TransactionInput (snowblossom.proto.TransactionInput)1 TransactionOutput (snowblossom.proto.TransactionOutput)1