|
|
@ -15,17 +15,14 @@ my $j = JSON::Any->new; |
|
|
|
#sleep 10; |
|
|
|
|
|
|
|
# While Siona swims, we pave with bricks on the road she will run on... |
|
|
|
my $acname = $ENV{SIONA_ACNAME} || 'HUSH'; |
|
|
|
my $ticker = $acname eq 'HUSH3' ? 'HUSH' : $acname; |
|
|
|
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 $domain = $ENV{DOMAIN}; |
|
|
|
my $cli = $ENV{CLI}; |
|
|
|
my $arrakis = $ENV{ARRAKIS}; |
|
|
|
my $dir = $ENV{DIR}; |
|
|
|
my $getinfo = readfile("$dir/getinfo.json"); |
|
|
|
my $mining = readfile("$dir/getmininginfo.json"); |
|
|
|
my $blocksdir = "$basedir/blocks"; |
|
|
|
my $template = readfile("$blocksdir/template.html"); |
|
|
|
my $template = readfile("/var/www/$domain/blocks/template.html"); |
|
|
|
my $blocksdir = "/var/www/$domain/blocks/"; |
|
|
|
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; } |
|
|
@ -40,13 +37,12 @@ $STATS->{BLOCKS_TABLE} = ""; |
|
|
|
$STATS->{TX_TABLE} = ""; |
|
|
|
|
|
|
|
my $mineraddress = ""; |
|
|
|
for my $h ($height-80 .. $height) { |
|
|
|
for my $h ($height-50 .. $height) { |
|
|
|
#for my $h (910265 .. 910270) { |
|
|
|
#last if($h < 0); |
|
|
|
my $thisminer = ""; |
|
|
|
# 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 $ticker" : "12.5 $ticker"; |
|
|
|
# TODO: fix this garbage |
|
|
|
my $reward = $h > 340000 ? "3.125 HUSH" : "12.5 HUSH"; |
|
|
|
my $block = get_block($h); |
|
|
|
#die Dumper $block; |
|
|
|
my $time = $block->{time}; |
|
|
@ -54,13 +50,14 @@ for my $h ($height-80 .. $height) { |
|
|
|
my @txs = @{ $block->{tx} }; |
|
|
|
my $numtx = @txs; |
|
|
|
# TODO: look on filesystem first? redis cache? |
|
|
|
my $hash = qx!$cli getblockhash $h!; |
|
|
|
my $hash = qx!$cli -ac_name=$arrakis getblockhash $h!; |
|
|
|
chomp $hash; |
|
|
|
|
|
|
|
my $blockdir = "$root/var/www/$domain/block/$hash"; |
|
|
|
my $root = "/var/www/$domain"; |
|
|
|
my $blockdir = "$root/block/$hash"; |
|
|
|
if (!-e "$root/block/$h") { |
|
|
|
# make /block/HEIGHT work |
|
|
|
my $cmd = "ln -s $blockdir $root/var/www/$domain/block/$h"; |
|
|
|
my $cmd = "ln -s $blockdir $root/block/$h"; |
|
|
|
qx{$cmd}; |
|
|
|
warn $cmd; |
|
|
|
} |
|
|
@ -69,8 +66,8 @@ for my $h ($height-80 .. $height) { |
|
|
|
my $cmd = "mkdir -p $blockdir"; |
|
|
|
qx{$cmd}; |
|
|
|
warn $cmd; |
|
|
|
my $block_template_file = "$basedir/block/template.html"; |
|
|
|
my $new_block_file = "$blockdir/index.html"; |
|
|
|
my $block_template_file = "/var/www/$domain/block/template.html"; |
|
|
|
my $new_block_file = "/var/www/$domain/block/$hash/index.html"; |
|
|
|
# TODO: process template with block details |
|
|
|
my $block_template = readfile($block_template_file); |
|
|
|
$block_template =~ s/#BLOCKS#/$h/g; |
|
|
@ -84,9 +81,8 @@ 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: fix block reward |
|
|
|
my $blockreward = "3.125 $ticker"; |
|
|
|
$block_template =~ s/#BLOCKREWARD#/$blockreward/g; |
|
|
|
# TODO |
|
|
|
$block_template =~ s/#BLOCKREWARD#/3.125 HUSH/g; |
|
|
|
$block_template =~ s/#BLOCKNONCE#/$block->{nonce}/ge; |
|
|
|
$block_template =~ s/#DIFFICULTY#/$block->{difficulty}/ge; |
|
|
|
$block_template =~ s/#NUM_TXS#/$numtx/g; |
|
|
@ -100,7 +96,7 @@ HTML |
|
|
|
|
|
|
|
my $txi = 0; |
|
|
|
for my $tx (@txs) { |
|
|
|
my $json = qx!$cli getrawtransaction $tx 1!; |
|
|
|
my $json = qx!$cli -ac_name=$arrakis getrawtransaction $tx 1!; |
|
|
|
# "vout": 0, |
|
|
|
# "address": "RBHHGTQoULWb8gPD6Nj4fix6ov46hzzQMj", |
|
|
|
# address is duplicated in the JSON of getrawtransaction !! fuck. |
|
|
@ -122,9 +118,9 @@ HTML |
|
|
|
next if $@; |
|
|
|
|
|
|
|
$TX->{$tx} = $o; |
|
|
|
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_dir = "$root/tx/$tx"; |
|
|
|
my $tx_file = "$root/tx/$tx/index.html"; |
|
|
|
my $tx_template_file = "$root/tx/template.html"; |
|
|
|
my $tx_template = readfile($tx_template_file); |
|
|
|
my $txtime = localtime($o->{time}); |
|
|
|
#my $txsize = $o->{size} . " bytes"; |
|
|
@ -242,7 +238,7 @@ STUFF |
|
|
|
} elsif ($txtype eq "Shielding") { |
|
|
|
$stuff =<<STUFF; |
|
|
|
|
|
|
|
$from ($valueBalanceThird $ticker) => zs1??? (shielding) |
|
|
|
$from ($valueBalanceThird HUSH) => zs1??? (shielding) |
|
|
|
|
|
|
|
STUFF |
|
|
|
} elsif ($txtype eq "Notary") { |
|
|
@ -279,7 +275,7 @@ STUFF |
|
|
|
<tr> |
|
|
|
<td style="font-size: 14px">$stuff</td> |
|
|
|
<td style="font-size: 14px">$txtime</td> |
|
|
|
<td style="font-size: 14px">$valueBalance $ticker</td> |
|
|
|
<td style="font-size: 14px">$valueBalance HUSH</td> |
|
|
|
</tr> |
|
|
|
</table> |
|
|
|
HTML |
|
|
@ -320,7 +316,7 @@ HTML |
|
|
|
|
|
|
|
sub get_raw { |
|
|
|
my $tx = shift; |
|
|
|
my $cmd = "$cli getrawtransaction $tx 1"; |
|
|
|
my $cmd = "$cli -ac_name=$arrakis getrawtransaction $tx 1"; |
|
|
|
warn $cmd; |
|
|
|
my $json = qx!$cmd!; |
|
|
|
# "vout": 0, |
|
|
@ -383,7 +379,7 @@ sub get_block { |
|
|
|
|
|
|
|
# create data if it's not there |
|
|
|
if( $block =~ m/^HASH/ || length($block) == 0 ) { |
|
|
|
my $cmd = "$cli getblock $height"; |
|
|
|
my $cmd = "$cli -ac_name=$arrakis getblock $height"; |
|
|
|
warn $cmd; |
|
|
|
$block = qx/$cmd/; |
|
|
|
} |
|
|
@ -411,4 +407,4 @@ sub readfile { |
|
|
|
} |
|
|
|
close($fh); |
|
|
|
return $data; |
|
|
|
} |
|
|
|
} |