Difficulty and timestamp in beta

This is a perl script that will parse your debug.log file to get hash IDs as inputs for zcash-cli to get difficulty for your own block explorer. If log2_work in debug.log has some conversion factor to difficulty, it could get by with just the debug file and be a lot faster. Debug.log will include canceled blocks, showing something block explorer doesn’t. It’s an ugly method, but I didn’t know how else to get blocknum, time, and difficulty. Save as a file in the folder above zcash and run with perl filename.

open (F,"<.zcash/testnet3/debug.log"); @a=<F>; close F;

foreach $a (@a) {
   if ($a=~/.+best=([^ ]+).+height=(\d+).+date=\d\d\d\d-\d\d-(\d\d) (\d\d):(\d\d):(\d\d).+/) {
  $block=$2;
  $secs=$3*24*3600+$4*3600+$5*60+$6;
  $info=`./zcash/src/zcash-cli getblock $1`; # 1 is hash
  $info=~m/"difficulty" : (\d+)/sg;  
  $diff=$1;
  $sum=$thissecs;
  $thissecs=$secs-$lastsecs;
  $sum+=$thissecs;
  if ($sum/300 < .22 or $sum/500 > 2.3) { $anomoly=" ***"; }
  $blocks[$block]="$block\t$secs\t$thissecs\t$diff\t$anomoly\n";
  $anomoly="";
  $lastsecs=$secs;
  $check = 'yes';
  }
}
open (F,">difficulty.txt"); print F @blocks; close F;
exit; 

To check if the reported timestamps from above are realistic, run the following bash program 24 hr to record when blocks come into your node. https://forum.zcashcommunity.com/t/somebody-already-has-a-gpu-rig/1410/13

Use my code at your own risk.