Browse Source

added anonset rpc call to scripts and code

pull/1/head
dan_s 2 years ago
parent
commit
60809bff4a
  1. 2
      update.sh
  2. 7
      var/www/explorer.dragonx.is/bin/update.pl
  3. 9
      var/www/explorer.dragonx.is/bin/update_blocks_redis.pl
  4. 2
      var/www/explorer.dragonx.is/template.html
  5. 2
      var/www/explorer.dragonx.is/update.sh
  6. 4
      var/www/explorer.dragonx.is/update_api.sh

2
update.sh

@ -7,7 +7,7 @@ cd $DIR && ./update_explorer_data.sh
cd $DIR && ./update_api.sh
# Anonset
cd $DIR && 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
# cd $DIR && 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 > $DIR/index-1.html

7
var/www/explorer.dragonx.is/bin/update.pl

@ -2,6 +2,10 @@
use strict;
use warnings;
use 5.014;
use redis;
my $r = Redis->new;
my $anonset = $r->get("anonset");
my $STATS = {};
$|=1;
@ -36,7 +40,8 @@ my @symbols = qw/
# derived stat
my $zpct = sprintf "%.3f", ($STATS->{SUPPLY} || 0) > 0 ? 100*($STATS->{ZFUNDS}/$STATS->{SUPPLY}) : "0.000";
$template =~ s/#ZFUNDS_PERCENT#/$zpct/ge;
$template =~ s/#ANONSET#/$anonset/ge;
say $template;
#}

9
var/www/explorer.dragonx.is/bin/update_blocks_redis.pl

@ -215,7 +215,7 @@ DATA
$valueBalance = ($o->{vout}->[0]->{value} || 0) + ($o->{vout}->[1]->{value} || 0);
$valueBalance ||= "?";
$from ||= "";
$txtype = "Mining";
if($zins+$zouts>0) {
$txtype = "Shielded";
@ -330,7 +330,12 @@ sub get_raw {
$json =~ s/"address":\w+"([a-z0-9]+)"(.+)"address":\w+"\g1"(.+)/"address": "$1"$2/mg;
warn "decoding tx=$tx"; # with json=$json";
my $j = JSON::Any->new;
my $o = $j->decode($json);
my $o ="";
eval {
$o = $j->decode($json);
};
return $o;
}

2
var/www/explorer.dragonx.is/template.html

@ -73,7 +73,7 @@
<div class="explorer-content-bar"><h3>Last Update: </h3><span>#TIPTIME#</span></div>
<div class="explorer-content-bar"><h3>Block Height : </h3><span>#BLOCKS#</span></div>
<div class="explorer-content-bar"><h3>Hashrate: </h3><span>#NETWORKSOLPS#</span></div>
<div class="explorer-content-bar"><h3 >Anonymity Set: </h3><span class="anonset">2410752</span></div>
<div class="explorer-content-bar"><h3 >Anonymity Set: </h3><span>#ANONSET#</span></div>
<div class="explorer-content-bar"><h3>Total Transactions: </h3><span>#TXCOUNT#</span></div>
<div class="explorer-content-bar"><h3>Price: </h3><span class='price'>0.00000273 BTC</span></div>
<div class="explorer-content-bar"><h3>Transaction Rate: </h3><span>#TXRATE#</span></div>

2
var/www/explorer.dragonx.is/update.sh

@ -5,7 +5,7 @@ set -e
DOMAIN=${SIONA_DOMAIN}
DIR="/var/www/$DOMAIN"
echo $$ >> $DOMAIN/PID
echo $$ >> $DIR/PID
# make a backup so we can diff them
cp $DIR/{index,index-prev}.html

4
var/www/explorer.dragonx.is/update_api.sh

@ -6,6 +6,7 @@ CLI=${SIONA_CLI}
# this is optional and not used yet here
ACNAME=${SIONA_ACNAME}
DIR=/var/www/$DOMAIN/api
HIGHESTBLOCK=$(curl -s "$DIR/api/getblockchain.json" | jq -r '.blocks')
# TODO: remove IP info from getpeerinfo
#$CLI getpeerinfo > $DIR/getpeerinfo.json
@ -16,4 +17,5 @@ $CLI -ac_name=$ACNAME getchaintxstats &> $DIR/getchaintxstats.json
$CLI -ac_name=$ACNAME gettxoutsetinfo &> $DIR/gettxoutsetinfo.json
$CLI -ac_name=$ACNAME coinsupply &> $DIR/coinsupply.json
$CLI -ac_name=$ACNAME getchaintips &> $DIR/getchaintips.json
$CLI -ac_name=$ACNAME getchaintxstats &> $DIR/getchaintxstats.json
$CLI -ac_name=$ACNAME getchaintxstats &> $DIR/getchaintxstats.json
redis-cli set anonset $($CLI -ac_name=$ACNAME z_anonsetblockdelta 1 $HIGHESTBLOCK)

Loading…
Cancel
Save