Skip to content

Commit

Permalink
Check deck sizes on startup in case they were only partly built
Browse files Browse the repository at this point in the history
closes #31
  • Loading branch information
fireduck64 committed May 24, 2018
1 parent 65370dd commit c5cf34b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
6 changes: 6 additions & 0 deletions src/SnowMerkleProof.java
Expand Up @@ -116,6 +116,12 @@ public SnowMerkleProof(File path, String base)
RandomAccessFile deck_file = new RandomAccessFile(new File(path, base +".deck." + letter), "r");
FileChannel deck_channel = deck_file.getChannel();

long expected_len = snow_file.length() / h;
if (deck_file.length() != expected_len)
{
throw new java.io.IOException("Unexpected length on " + base +".deck." + letter);
}

deck_map.put(h, deck_channel);
}
deck_files = ImmutableMap.copyOf(deck_map);
Expand Down
10 changes: 4 additions & 6 deletions src/miner/FieldScan.java
Expand Up @@ -9,7 +9,7 @@
import java.io.File;

import java.util.logging.Logger;
import java.util.Random;
import java.util.SplittableRandom;

import java.util.Map;
import java.util.SortedMap;
Expand Down Expand Up @@ -87,13 +87,11 @@ public void scan(boolean report)
private void checkField(int field_number, SnowMerkleProof proof)
throws java.io.IOException
{
Random rnd = new Random();
SplittableRandom rnd = new SplittableRandom();

// If the field ends up with more than 32 bits of words, just check one from
// the first part. meh.
long max = Math.min((long)Integer.MAX_VALUE, proof.getTotalWords());
long max = proof.getTotalWords();

long check = rnd.nextInt((int)max);
long check = rnd.nextLong(max);
SnowPowProof p = proof.getProof(check);

SnowFieldInfo info = params.getSnowFieldInfo(field_number);
Expand Down

0 comments on commit c5cf34b

Please sign in to comment.