Browse Source

Merge pull request 'sync' (#3) from onryo/siona:master into master

Reviewed-on: #3
pull/6/head
Duke Leto 2 years ago
parent
commit
d2a93f42a6
  1. 41
      var/www/explorer.hush.land/bin/update_blocks_redis.pl

41
var/www/explorer.hush.land/bin/update_blocks_redis.pl

@ -15,12 +15,16 @@ my $j = JSON::Any->new;
#sleep 10;
# While Siona swims, we pave with bricks on the road she will run on...
my $dir = shift || '/var/www/explorer.hush.land/var/www/explorer.hush.land/api';
my $cli = "/home/hush/git/hush3/src/hush-cli";
my $acname = $ENV{SIONA_ACNAME} || 'HUSH';
my $domain = $ENV{SIONA_DOMAIN} || 'explorer.hush.land';
my $root = "/var/www/$domain";
my $basedir = "/var/www/$domain/var/www/$domain";
my $dir = shift || "$basedir/api";
my $cli = $ENV{SIONA_CLI} || "/home/hush/git/hush3/src/hush-cli";
my $getinfo = readfile("$dir/getinfo.json");
my $mining = readfile("$dir/getmininginfo.json");
my $template = readfile("/var/www/explorer.hush.land/var/www/explorer.hush.land/blocks/template.html");
my $blocksdir = "/var/www/explorer.hush.land/var/www/explorer.hush.land/blocks/";
my $blocksdir = "$basedir/blocks";
my $template = readfile("$blocksdir/template.html");
if($getinfo =~ m/"blocks": (\d+)/){ $STATS->{BLOCKS} ||= $1; }
if($getinfo =~ m/"tls_connections": (\d+)/){ $STATS->{TLS_CONNECTIONS} ||= $1; }
if($getinfo =~ m/"connections": (\d+)/){ $STATS->{CONNECTIONS} ||= $1; }
@ -39,8 +43,9 @@ for my $h ($height-80 .. $height) {
#for my $h (910265 .. 910270) {
#last if($h < 0);
my $thisminer = "";
# TODO: fix this garbage
my $reward = $h > 340000 ? "3.125 HUSH" : "12.5 HUSH";
# TODO: actually look at the block reward for this height via
# the tx data from the very first txid in this block
my $reward = $h > 340000 ? "3.125 $acname" : "12.5 $acname";
my $block = get_block($h);
#die Dumper $block;
my $time = $block->{time};
@ -51,11 +56,10 @@ for my $h ($height-80 .. $height) {
my $hash = qx!$cli getblockhash $h!;
chomp $hash;
my $root = "/var/www/explorer.hush.land";
my $blockdir = "$root/var/www/explorer.hush.land/block/$hash";
my $blockdir = "$root/var/www/$domain/block/$hash";
if (!-e "$root/block/$h") {
# make /block/HEIGHT work
my $cmd = "ln -s $blockdir $root/var/www/explorer.hush.land/block/$h";
my $cmd = "ln -s $blockdir $root/var/www/$domain/block/$h";
qx{$cmd};
warn $cmd;
}
@ -64,8 +68,8 @@ for my $h ($height-80 .. $height) {
my $cmd = "mkdir -p $blockdir";
qx{$cmd};
warn $cmd;
my $block_template_file = "/var/www/explorer.hush.land/var/www/explorer.hush.land/block/template.html";
my $new_block_file = "/var/www/explorer.hush.land/var/www/explorer.hush.land/block/$hash/index.html";
my $block_template_file = "$basedir/block/template.html";
my $new_block_file = "$blockdir/index.html";
# TODO: process template with block details
my $block_template = readfile($block_template_file);
$block_template =~ s/#BLOCKS#/$h/g;
@ -79,8 +83,9 @@ for my $h ($height-80 .. $height) {
$block_template =~ s/#CHAINWORK#/$block->{chainwork}/ge;
$block_template =~ s/#MERKLEROOT#/$block->{merkleroot}/ge;
$block_template =~ s/#FINALSAPLINGROOT#/$block->{finalsaplingroot}/ge;
# TODO
$block_template =~ s/#BLOCKREWARD#/3.125 HUSH/g;
# TODO: fix block reward
my $blockreward = "3.125 $acname";
$block_template =~ s/#BLOCKREWARD#/$blockreward/g;
$block_template =~ s/#BLOCKNONCE#/$block->{nonce}/ge;
$block_template =~ s/#DIFFICULTY#/$block->{difficulty}/ge;
$block_template =~ s/#NUM_TXS#/$numtx/g;
@ -116,9 +121,9 @@ HTML
next if $@;
$TX->{$tx} = $o;
my $tx_dir = "$root/var/www/explorer.hush.land/tx/$tx";
my $tx_file = "$root/var/www/explorer.hush.land/tx/$tx/index.html";
my $tx_template_file = "$root/var/www/explorer.hush.land/tx/template.html";
my $tx_dir = "$root/var/www/$domain/tx/$tx";
my $tx_file = "$root/var/www/$domain/tx/$tx/index.html";
my $tx_template_file = "$root/var/www/$domain/tx/template.html";
my $tx_template = readfile($tx_template_file);
my $txtime = localtime($o->{time});
#my $txsize = $o->{size} . " bytes";
@ -236,7 +241,7 @@ STUFF
} elsif ($txtype eq "Shielding") {
$stuff =<<STUFF;
$from ($valueBalanceThird HUSH) => zs1??? (shielding)
$from ($valueBalanceThird $acname) => zs1??? (shielding)
STUFF
} elsif ($txtype eq "Notary") {
@ -273,7 +278,7 @@ STUFF
<tr>
<td style="font-size: 14px">$stuff</td>
<td style="font-size: 14px">$txtime</td>
<td style="font-size: 14px">$valueBalance HUSH</td>
<td style="font-size: 14px">$valueBalance $acname</td>
</tr>
</table>
HTML

Loading…
Cancel
Save