Skip to content

Commit

Permalink
Add estimate in hours to mining
Browse files Browse the repository at this point in the history
  • Loading branch information
fireduck64 committed May 24, 2018
1 parent aa97a87 commit a3defc3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
6 changes: 3 additions & 3 deletions src/client/SnowBlossomClient.java
Expand Up @@ -415,8 +415,8 @@ public void runLoadTest()
if (!br.spent) spendable.add(br);
}
Collections.shuffle(spendable);
long min_send = 500000L;
long max_send = 5000000L;
long min_send = 50000L;
long max_send = 500000L;
long send_delta = max_send - min_send;
SplittableRandom rnd = new SplittableRandom();
int output_count = 2;
Expand All @@ -426,7 +426,7 @@ public void runLoadTest()
//Collections.shuffle(spendable);

LinkedList<TransactionOutput> out_list = new LinkedList<>();
long fee = rnd.nextLong(5000);
long fee = rnd.nextLong(500);
long needed_value = fee;
for(int i=0; i< output_count; i++)
{
Expand Down
29 changes: 16 additions & 13 deletions src/miner/SnowBlossomMiner.java
Expand Up @@ -15,25 +15,15 @@
import snowblossom.proto.SubmitReply;
import snowblossom.proto.AddressSpec;
import snowblossom.proto.WalletDatabase;
import snowblossom.NetworkParams;
import snowblossom.NetworkParamsProd;
import snowblossom.NetworkParamsTestnet;
import snowblossom.AddressSpecHash;
import snowblossom.HexUtil;
import snowblossom.ChainHash;
import snowblossom.AddressUtil;
import snowblossom.*;


import java.util.logging.Logger;
import java.util.logging.Level;
import java.util.Random;
import snowblossom.PowUtil;
import snowblossom.Globals;
import snowblossom.SnowMerkleProof;
import snowblossom.trie.HashUtils;
import duckutil.Config;
import duckutil.ConfigFile;
import snowblossom.DigestUtil;
import com.google.protobuf.ByteString;
import java.security.Security;
import java.security.MessageDigest;
Expand All @@ -43,7 +33,7 @@
import java.util.LinkedList;
import java.util.concurrent.atomic.AtomicLong;
import java.text.DecimalFormat;
import snowblossom.LogSetup;
import java.math.BigInteger;

public class SnowBlossomMiner
{
Expand Down Expand Up @@ -197,7 +187,20 @@ public void printStats()

DecimalFormat df=new DecimalFormat("0.0");

logger.info(String.format("Mining rate: %s/sec", df.format(rate)));
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/sec %s", df.format(rate),block_time_report));

last_stats_time = now;

Expand Down

0 comments on commit a3defc3

Please sign in to comment.