Browse Source

merging master into this branch

pull/11/head
jahway603 2 months ago
parent
commit
5eaadde848
  1. 64
      README.md
  2. 0
      address/template.html
  3. 0
      addresses/template.html
  4. 0
      api/anonset.json
  5. 0
      api/coinsupply.json
  6. 0
      api/getblockchain.json
  7. 0
      api/getchaintips.json
  8. 0
      api/getchaintxstats.json
  9. 0
      api/getinfo.json
  10. 0
      api/getmininginfo.json
  11. 0
      api/gettxoutsetinfo.json
  12. 0
      api/index.html
  13. 0
      api/snapshots/snapshot-old.json
  14. 0
      api/snapshots/snapshot.json
  15. 0
      bin/HOWTO
  16. 0
      bin/Makefile
  17. 0
      bin/backup/update_blocks_redis.pl
  18. 0
      bin/balances.pl
  19. 0
      bin/block-340k.json
  20. 95
      bin/blocks_update.pl
  21. 0
      bin/example.html
  22. 8
      bin/home_update.pl
  23. 0
      bin/nope/README
  24. 0
      bin/nope/update_addresses.pl
  25. 0
      block/template.html
  26. 1
      blocks/template.html
  27. 0
      crons/README
  28. BIN
      favicon.ico
  29. BIN
      fonts/UbuntuMono.ttf
  30. 1
      git/explorer.hush.land/yep
  31. 1
      git/hush3/yep
  32. 0
      index-1.html
  33. 0
      index-new.html
  34. 0
      index-prev.html
  35. 0
      index.html
  36. 29
      run_siona.sh
  37. 0
      template.html
  38. 0
      tx/template.html
  39. 15
      update.sh
  40. 0
      var/www/explorer.hush.land/PID
  41. 19
      var/www/explorer.hush.land/update_api.sh
  42. 17
      var/www/explorer.hush.land/update_explorer_data.sh
  43. 12
      var/www/explorer.hush.land/var/www/explorer.hush.land/PID
  44. 15
      var/www/explorer.hush.land/var/www/explorer.hush.land/update.sh

64
README.md

@ -1,36 +1,66 @@
# Siona
This is Siona, a maximum privacy block explorer designed for chains which support zaddrs
and which runs <a href="https://explorer.hush.is">explorer.hush.is</a> and <a href="https://explorer.hush.land">explorer.hush.land</a>.
It is written in Perl 5 and generates static HTML with no Javascript and basic inline CSS for styling. It requires a Redis server
This is Siona, a maximum privacy block explorer designed for chains which support zaddrs. It is written in Perl 5 and generates static HTML with no Javascript and basic inline CSS for styling. It requires a Redis server
running on localhost, which is for caching and reduces disk i/o.
# Installing dependencies
Siona runs on the following private blockchains:
- <a href="https://explorer.hush.is">explorer.hush.is</a>
- <a href="https://explorer.hush.land">explorer.hush.land</a>
- <a href="https://explorer.dragonx.is">explorer.dragonx.is</a>
# Install dependencies on Debian/Ubuntu
Install redis-server and cpan:
```
sudo apt-get install redis-server
sudo apt-get install libpath-tiny-perl
```
Install JSON::Any.pm and Redis.pm Perl modules:
```
sudo cpan install JSON::Any.pm
sudo cpan install Redis.pm
```
# Git clone
Move to the root directory of the Explorer, it must be empty.
```
cd /var/www/dragonx.hush.land
git clone https://git.hush.is/hush/siona.git .
```
Requires JSON::Any and Redis Perl modules and redis-server an Debian package.
# First time run and update
On Debian 11, install by running `sudo apt install redis libjson-perl libredis-perl`
```
CLI=/root/hush3/src/hush-cli DIR=/var/www/dragonx.hush.land/api DOMAIN=dragonx.hush.land ARRAKIS=DRAGONX ./run_siona.sh
```
Please contribute back package names for other Linux distros.
### Need support?
# Instructions
* Matrix: <a href="https://hush.is/matrix">https://hush.is/matrix</a>
* Telegram: <a href="https://hush.is/tg">https://hush.is/tg</a>
Assume you put `update.sh` in /home/$USER and your Hush source code in ~/git/hush3 , add this to your $USER crontab with `crontab -e` :
# Update Explorer every 5 minutes with cron
```
# set env vars that Siona will use
SIONA_DOMAIN=explorer.some.poop
SIONA_ACNAME=GAZOOTZ
SIONA_CLI=~/git/hush3/src/hush-cli -ac_NAME=${SIONA_ACNAME}
ARRAKIS=DRAGONX
DOMAIN=dragonx.hush.land
CLI=/root/hush3/src/hush-cli
DIR=/var/www/dragonx.hush.land/api
# update explorer data every 5 minutes
*/5 * * * * ~/update.sh
*/5 * * * * cd /var/www/$DOMAIN && ./run_siona.sh
```
# Copyright
2016-2022 The Hush Developers
2016-2024 The Hush Developers
# License

0
var/www/explorer.hush.land/var/www/explorer.hush.land/address/template.html → address/template.html

0
var/www/explorer.hush.land/var/www/explorer.hush.land/addresses/template.html → addresses/template.html

0
var/www/explorer.hush.land/var/www/explorer.hush.land/api/anonset.json → api/anonset.json

0
var/www/explorer.hush.land/var/www/explorer.hush.land/api/coinsupply.json → api/coinsupply.json

0
var/www/explorer.hush.land/var/www/explorer.hush.land/api/getblockchain.json → api/getblockchain.json

0
var/www/explorer.hush.land/var/www/explorer.hush.land/api/getchaintips.json → api/getchaintips.json

0
var/www/explorer.hush.land/var/www/explorer.hush.land/api/getchaintxstats.json → api/getchaintxstats.json

0
var/www/explorer.hush.land/var/www/explorer.hush.land/api/getinfo.json → api/getinfo.json

0
var/www/explorer.hush.land/var/www/explorer.hush.land/api/getmininginfo.json → api/getmininginfo.json

0
var/www/explorer.hush.land/var/www/explorer.hush.land/api/gettxoutsetinfo.json → api/gettxoutsetinfo.json

0
var/www/explorer.hush.land/var/www/explorer.hush.land/api/index.html → api/index.html

0
var/www/explorer.hush.land/var/www/explorer.hush.land/api/snapshots/snapshot-old.json → api/snapshots/snapshot-old.json

0
var/www/explorer.hush.land/var/www/explorer.hush.land/api/snapshots/snapshot.json → api/snapshots/snapshot.json

0
var/www/explorer.hush.land/bin/HOWTO → bin/HOWTO

0
var/www/explorer.hush.land/bin/Makefile → bin/Makefile

0
var/www/explorer.hush.land/bin/backup/update_blocks_redis.pl → bin/backup/update_blocks_redis.pl

0
var/www/explorer.hush.land/bin/balances.pl → bin/balances.pl

0
var/www/explorer.hush.land/bin/block-340k.json → bin/block-340k.json

95
var/www/explorer.hush.land/bin/update_blocks_redis.pl → bin/blocks_update.pl

@ -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
@ -318,9 +314,48 @@ HTML
;
}
my $total_block_duration = 0;
for my $duration (@block_durations) {
if ($duration ne '--') {
$total_block_duration += $duration;
}
}
$avg_block_duration = $total_block_duration / $NUM_BLOCKS_TO_SHOW;
if ($avg_block_duration > 0) {
$avg_block_duration = sprintf "%.2f", $avg_block_duration;
my $blocktime = 75; # please Satoshi let this never change again
my $deviation = 100*($avg_block_duration / $blocktime);
my $word = ($avg_block_duration > $blocktime) ? "above" : "below";
if ($word eq 'above') { $deviation -= 100; }
if ($word eq 'below') { $deviation -= 100; }
$word .= "!" if ($deviation >= 20);
my $num_miners = keys %unique_miners;
my $longblock_multiplier = sprintf "%.2f", $longest_blocktime / $avg_block_duration;
$deviation = sprintf "%.2f", $deviation;
my $tx_per_block = sprintf("%.2f", $total_txs / $NUM_BLOCKS_TO_SHOW);
$STATS->{BLOCKS_STATS} =<<STATS;
<table border=1>
<tr><th colspan=2>Block Stats in the last $NUM_BLOCKS_TO_SHOW blocks</th></tr>
<tr><td>Average Blocktime</td><td align=center>$avg_block_duration sec</td></tr>
<tr><td>Blocktime Deviation</td><td align=center> $deviation% $word 75 sec</td></tr>
<tr><td>Longest Blocktime</td><td align=center> $longest_blocktime sec (${longblock_multiplier}X average)</td></tr>
<tr><td>Total Transactions</td><td align=center> $total_txs</td></tr>
<tr><td>Transactions Per Block</td><td align=center> $tx_per_block </td></tr>
<tr><td>Unique Miner Addresses</td><td align=center> $num_miners </td></tr>
</table>
<br/>
STATS
}
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 +418,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 +446,4 @@ sub readfile {
}
close($fh);
return $data;
}
}

0
var/www/explorer.hush.land/bin/example.html → bin/example.html

8
var/www/explorer.hush.land/bin/update.pl → bin/home_update.pl

@ -9,14 +9,14 @@ $|=1;
sleep 30;
# While Siona swims, we pave with bricks on the road she will run on...
# my $dir = shift || $ENV{HOME} . "/data";
my $dir = shift || '/var/www/explorer.hush.land/var/www/explorer.hush.land/api';
my $domain = $ENV{DOMAIN};
my $dir = $ENV{DIR};
my $getinfo = readfile("$dir/getinfo.json");
my $mining = readfile("$dir/getmininginfo.json");
my $txstats = readfile("$dir/getchaintxstats.json");
# run the slowest last so the RPC interface isn't juggling
my $coinsupply = readfile("$dir/coinsupply.json");
my $template = readfile("/var/www/explorer.hush.land/var/www/explorer.hush.land/template.html");
my $template = readfile("/var/www/$domain/template.html");
#say $template;
@ -71,4 +71,4 @@ sub readfile {
return $data;
}
# "connections": 48,
# "tls_connections": 28,
# "tls_connections": 28,

0
var/www/explorer.hush.land/bin/nope/README → bin/nope/README

0
var/www/explorer.hush.land/bin/nope/update_addresses.pl → bin/nope/update_addresses.pl

0
var/www/explorer.hush.land/var/www/explorer.hush.land/block/template.html → block/template.html

1
var/www/explorer.hush.land/var/www/explorer.hush.land/blocks/template.html → blocks/template.html

@ -66,6 +66,7 @@ a:hover { color: #b3b3b3 }
<td><a href="https://hush.land/team.html">Team</a></td>
</tr>
</table>
#BLOCKS_STATS#
#BLOCKS_TABLE#
<div class="links">
<a href="https://hush.is/matrix"><span style="color: #262626">[</span> matrix <span style="color: #262626">]</span></a>

0
var/www/explorer.hush.land/crons/README → crons/README

BIN
favicon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
fonts/UbuntuMono.ttf

Binary file not shown.

1
git/explorer.hush.land/yep

@ -1 +0,0 @@
yep

1
git/hush3/yep

@ -1 +0,0 @@
git clone https://git.hush.is/hush/hush3

0
var/www/explorer.hush.land/var/www/explorer.hush.land/index-1.html → index-1.html

0
var/www/explorer.hush.land/var/www/explorer.hush.land/index-new.html → index-new.html

0
var/www/explorer.hush.land/var/www/explorer.hush.land/index-prev.html → index-prev.html

0
var/www/explorer.hush.land/var/www/explorer.hush.land/index.html → index.html

29
run_siona.sh

@ -0,0 +1,29 @@
#!/usr/bin/env bash
# UPDATE EXPLORER DATA
NEWFILE=/var/www/$DOMAIN/blocks/index.new.html
INDEXFILE=/var/www/$DOMAIN/blocks/index.html
# reads data from api
/var/www/$DOMAIN/bin/blocks_update.pl > $NEWFILE
if [ -s $NEWFILE ]; then
cp $NEWFILE $INDEXFILE
fi
# UDPATE API
$CLI -ac_name=$ARRAKIS getinfo &> api/getinfo.json
$CLI -ac_name=$ARRAKIS getmininginfo &> api/getmininginfo.json
$CLI -ac_name=$ARRAKIS getblockchaininfo &> api/getblockchain.json
$CLI -ac_name=$ARRAKIS getchaintxstats &> api/getchaintxstats.json
$CLI -ac_name=$ARRAKIS gettxoutsetinfo &> api/gettxoutsetinfo.json
$CLI -ac_name=$ARRAKIS coinsupply &> api/coinsupply.json
$CLI -ac_name=$ARRAKIS getchaintips &> api/getchaintips.json
$CLI -ac_name=$ARRAKIS getchaintxstats &> api/getchaintxstats.json
# UPDATE INDEX.HTML
perl bin/home_update.pl > index-1.html
cat index-1.html > index.html

0
var/www/explorer.hush.land/var/www/explorer.hush.land/template.html → template.html

0
var/www/explorer.hush.land/var/www/explorer.hush.land/tx/template.html → tx/template.html

15
update.sh

@ -1,15 +0,0 @@
#!/usr/bin/env bash
DOMAIN=$(SIONA_DOMAIN)
DIR="/var/www/$DOMAIN"
DIRDIR="$DIR$DIR"
cd $DIR && ./update_explorer_data.sh
cd $DIR && ./update_api.sh
# Anonset
cd $DIRDIR && anonset=$(curl -s "https://$DOMAIN/api/getchaintxstats.json" | jq -r '.shielded_pool_size') && sed -i "s|<span class='anonset'>.*</span>|<span class='anonset'> $anonset </span>|g" template.html
perl $DIR/bin/update.pl > $DIRDIR/index-1.html
cd $DIRDIR && cat index-1.html > index.html

0
var/www/explorer.hush.land/PID

19
var/www/explorer.hush.land/update_api.sh

@ -1,19 +0,0 @@
#!/usr/bin/env bash
# Copyright 2016-2022 The Hush Developers
DOMAIN=${SIONA_DOMAIN}
CLI=${SIONA_CLI}
# this is optional and not used yet here
ACNAME=${SIONA_ACNAME}
DIR=/var/www/$DOMAIN/var/www/$DOMAIN/api
# TODO: remove IP info from getpeerinfo
#$CLI getpeerinfo > $DIR/getpeerinfo.json
$CLI getinfo &> $DIR/getinfo.json
$CLI getmininginfo &> $DIR/getmininginfo.json
$CLI getblockchaininfo &> $DIR/getblockchain.json
$CLI getchaintxstats &> $DIR/getchaintxstats.json
$CLI gettxoutsetinfo &> $DIR/gettxoutsetinfo.json
$CLI coinsupply &> $DIR/coinsupply.json
$CLI getchaintips &> $DIR/getchaintips.json
$CLI getchaintxstats &> $DIR/getchaintxstats.json

17
var/www/explorer.hush.land/update_explorer_data.sh

@ -1,17 +0,0 @@
#!/usr/bin/env bash
cli=$(SIONA_CLI)
# only ask for data if we don't have it
#if [ -s ~/data/blocks/block-$HEIGHT.json ]; then
# HEIGHT=$($cli getblockcount); $cli getblock $HEIGHT > ~/data/blocks/block-$HEIGHT.json
#fi
NEWFILE=/var/www/$domain/var/www/$domain/blocks/index.new.html
INDEXFILE=/var/www/$domain/var/www/$domain/blocks/index.html
# reads data from /var/www/$domain/api
/var/www/$domain/bin/update_blocks_redis.pl > $NEWFILE
if [ -s $NEWFILE ]; then
cp $NEWFILE $INDEXFILE
fi

12
var/www/explorer.hush.land/var/www/explorer.hush.land/PID

@ -1,12 +0,0 @@
226212
226355
226361
226664
227090
227309
227738
227933
228039
228062
228077
228090

15
var/www/explorer.hush.land/var/www/explorer.hush.land/update.sh

@ -1,15 +0,0 @@
#!/usr/bin/env bash
set -e
DOMAIN=explorer.hush.land/var/www/explorer.hush.land
DIR=/var/www
echo $$ >> $DIR/$DOMAIN/PID
# make a backup so we can diff them
cp $DIR/$DOMAIN/{index,index-prev}.html
# let index.html settle
sleep 2
perl /var/www/explorer.hush.land/bin/update.pl /var/www/explorer.hush.land/api &> $DIR/$DOMAIN/index-new.html
cp $DIR/$DOMAIN/index-new.html $DIR/$DOMAIN/index.html
Loading…
Cancel
Save