diff --git a/.gitignore b/.gitignore index 0dc7b4b..5bef259 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ -/.vscode \ No newline at end of file +/.vscode +/explorer.dragonx.is/api/hashrate.json +/explorer.dragonx.is/api/hashrate100.json \ No newline at end of file diff --git a/explorer.dragonx.is/bin/update_blocks_redis.pl b/explorer.dragonx.is/bin/update_blocks_redis.pl index 7c7ff30..a99ff64 100644 --- a/explorer.dragonx.is/bin/update_blocks_redis.pl +++ b/explorer.dragonx.is/bin/update_blocks_redis.pl @@ -282,7 +282,7 @@ STUFF STUFF } else { $txBG = "rgba(0, 255, 8, 0.1)"; - $txOutline = "rgba(0, 255, 8, 0.5)"; + $txOutline = "rgba(0, 255, 8, 0.6)"; $stuff =< zs1??? (fully shielded) @@ -291,42 +291,53 @@ STUFF } my $tx_table = < -
- $txtype -
-
-

Transaction

-
${valueBalance} DRGX
- $txtime -
-

TX ID

- $tx -
-
-

Miner

- $to -
-
-
-
-
-

Zins

-

Zouts

-

$zins

-

$zouts

-
-
-
-
-

Vins

-

Vouts

-

$vins

-

$vouts

+
+

Transaction

+
+ $txtype +
+
${valueBalance} DRGX
+ $txtime +
+
+
+

TX ID

+ $tx +
+
+

Miner

+

$to

+
+
+
+
+
+

Vins

+

$vins

+
+
+

Vouts

+

$vouts

+
+
+
+
+

Zins

+

$zins

+
+
+

Zouts

+

$zouts

+
+
+
+
-
-
-
HTML $STATS->{TX_TABLE} .= $tx_table; @@ -397,14 +408,24 @@ for my $b (reverse @blocks) { $duration = "--" unless $duration; $STATS->{BLOCKS_TABLE} .= <<"FUCK"; -
- $height - ${duration}s - $hash - $miner + $reward - $time - Transactions: $txs -
+
+
+ $height +
+ $hash +

$miner + $reward

+
+
+
+
+

${duration}s

+
+
+

$time

+

Transactions: $txs

+
+
+
FUCK } diff --git a/explorer.dragonx.is/block/template.html b/explorer.dragonx.is/block/template.html index d2fb620..2434dc0 100644 --- a/explorer.dragonx.is/block/template.html +++ b/explorer.dragonx.is/block/template.html @@ -1,195 +1,160 @@ + + + + + + + + + Explorer | DragonX + - - - - - - - Explorer | DragonX - + +
+
+ +
+
+ Block List + Explorer +

Block Info

+
+
+
+

Block

+ #BLOCKS# +
+
+
+
+

Reward

+

#BLOCKREWARD#

+
+
+

Difficulty

+

#DIFFICULTY#

+
+
+

Block Size

+

#BLOCKSIZE#

+
+
+
+
+

Block Time

+

#BLOCKTIME#

+
+
+

Block Version

+

#VERSION#

+
+
+

Block Bits

+

#BITS#

+
+
+
+
+
+
+

Block Hash

+ #BLOCKHASH# +
+
+

Prev Hash

+ #PREVIOUSBLOCKHASH# +
+
+
+
+

Block Nonce

+

+ #BLOCKNONCE# +

+
+
+

Block Anchor

+

+ #ANCHOR# +

+
+
+

Chainwork

+

+ #CHAINWORK# +

+
+
+

Merkle Root

+

+ #MERKLEROOT# +

+
+
+

Final Sapling Root

+

+ #FINALSAPLINGROOT# +

+
+
+
#TX_TABLE#
+ +
+
+
+ + - -
- - - -
-
-
-
- - -
-
-
- DragonX Was built on the HUSH - Blockchain. -
- -
-
- - - -
-
-

Block

- #BLOCKS# -
-
-

Difficulty

- #DIFFICULTY# -
-
-

Block Size

- #BLOCKSIZE# -
-
-

Block Time

- #BLOCKTIME# -
-
-

Block Version

- #VERSION# -
-
-

Block Bits

- #BITS# -
-
-

Reward

- #BLOCKREWARD# -
-
-

Block Hash

- #BLOCKHASH# -
-
-

Prev Hash

- - #PREVIOUSBLOCKHASH# -
-
-

Block Nonce

- #BLOCKNONCE# -
-
-

Block Anchor

- #ANCHOR# -
-
-

Chainwork

- #CHAINWORK# -
-
-

Merkle Root

- #MERKLEROOT# -
-
-

Final Sapling Root

- #FINALSAPLINGROOT# -
-
- #TX_TABLE# - -
-
-
-
- -
- Explorer -
-
- Blocks -
-
-
-
-
-
- \ No newline at end of file diff --git a/explorer.dragonx.is/blocks/template.html b/explorer.dragonx.is/blocks/template.html index 3cde079..2e06e01 100644 --- a/explorer.dragonx.is/blocks/template.html +++ b/explorer.dragonx.is/blocks/template.html @@ -1,106 +1,48 @@ - - - - - - - - - Explorer | DragonX - + + + + + + + + + + Explorer | DragonX + -
- - - -
-
-
- - - +
+
+ + + + +
+
+ Back + + -
- - -
-
-
DragonX Was built on the HUSH Blockchain.
- -
-
- - - #BLOCKS_TABLE# - -
-
-
- - -
- - Back
-
-
-
-
+
diff --git a/explorer.dragonx.is/export_env.sh b/explorer.dragonx.is/export_env.sh index a5a6120..f287e4b 100644 --- a/explorer.dragonx.is/export_env.sh +++ b/explorer.dragonx.is/export_env.sh @@ -2,4 +2,5 @@ export SIONA_ROOT_DIR="siona-DragonX" export SIONA_DOMAIN="explorer.dragonx.is" -export SIONA_CLI="/home/admin/HUSH/hush3/src/dragonx-cli" \ No newline at end of file +export SIONA_CLI="/home/admin/HUSH/hush3/src/dragonx-cli" +export SIONA_ACNAME="DRAGONX" \ No newline at end of file diff --git a/explorer.dragonx.is/index.html b/explorer.dragonx.is/index.html index c1a8b44..5c69b3a 100644 --- a/explorer.dragonx.is/index.html +++ b/explorer.dragonx.is/index.html @@ -1,156 +1,168 @@ + + + + + + + + Explorer | DragonX + - - - - - - - Explorer | DragonX - + +
+ + +
+
+
+
+
+
+

DragonX Explorer

+
+

Price

+

#PRICE#

+
+
+
+
+
+
+

Hashrate

+

#HASHPS#

+
+
+

Difficulty

+

#DIFFICULTY#

+
+
+
+
+
+
+

Block Height:

+

#BLOCKS#

+
- -
- - - -
-
-
-
- - -
-
-
- DragonX Was built on the HUSH - Blockchain. -
- -
-
-
- This Explorer was forked from the  - HUSH Explorer. -
-
-

Last Update:

- #TIPTIME# -
-
-

Block Height :

- #BLOCKS# -
-
-

Hashrate:

- #HASHPS# -
-
-

Anonymity Set:

- #ANONSET# -
-
-

Total Transactions:

- #TXCOUNT# -
-
-

Price:

- 0.00000273 BTC -
-
-

Transaction Rate:

- #TXRATE# -
-
-

Difficulty:

- #DIFFICULTY# -
-
-

Total Volume:

- .0077033708 BTC -
-
-

Protocol Version:

- #PROTOCOLVERSION# -
-
-

Peers Connected:

- #CONNECTIONS# via TLS 1.3 -
-
-

Circulating Supply:

- #SUPPLY# -
-
-

Shielded Supply:

- #ZFUNDS# -
-
-

Percent Shielded:

- #ZFUNDS_PERCENT# -
- -
-
-
- - -
-
-
-
-
-
- +
+

Anonymity Set:

+

#ANONSET#

+
+ +
+

Total Transactions:

+

#TXCOUNT#

+
+ +
+

Transaction Rate:

+

#TXRATE#

+
+ +
+

Total Volume:

+

.0077033708 BTC

+
+ +
+
+
+

Circulating Supply:

+

#SUPPLY#

+
+
+

Shielded Supply:

+

#ZFUNDS#

+
+
+

Percent Shielded:

+

#ZFUNDS_PERCENT#

+
- \ No newline at end of file +
+
+ Blocklist +
+
+
+ +
+
+ + + + + diff --git a/explorer.dragonx.is/template.html b/explorer.dragonx.is/template.html index a69a800..0ba50cf 100644 --- a/explorer.dragonx.is/template.html +++ b/explorer.dragonx.is/template.html @@ -1,145 +1,168 @@ + + + + + + + + Explorer | DragonX + - - - - - - - Explorer | DragonX - + +
+ + +
+
+
+
+
+
+

DragonX Explorer

+
+

Price

+

#PRICE#

+
+
+
+
+
+
+

Hashrate

+

#HASHPS#

+
+
+

Difficulty

+

#DIFFICULTY#

+
+
+
+
+
+
+

Block Height:

+

#BLOCKS#

+
- -
- - - -
-
-
-
- - -
-
-
DragonX Was built on the HUSH Blockchain.
- -
-
-
This Explorer was forked from the  HUSH Explorer.
-
-

Last Update:

#TIPTIME# -
-
-

Block Height :

#BLOCKS# -
-
-

Hashrate:

#HASHPS# -
-
-

Anonymity Set:

#ANONSET# -
-
-

Total Transactions:

#TXCOUNT# -
-
-

Price:

- -
-
-

Transaction Rate:

#TXRATE# -
-
-

Difficulty:

#DIFFICULTY# -
-
-

Total Volume:

- -
-
-

Protocol Version:

#PROTOCOLVERSION# -
-
-

Peers Connected:

#CONNECTIONS# via TLS 1.3 -
-
-

Circulating Supply:

#SUPPLY# -
-
-

Shielded Supply:

#ZFUNDS# -
-
-

Percent Shielded:

#ZFUNDS_PERCENT# -
- -
-
-
+
+

Total Transactions:

+

#TXCOUNT#

+
- - -
-
-
-
-
-
- +
+

Total Volume:

+

.0077033708 BTC

+
- \ No newline at end of file +
+
+
+

Circulating Supply:

+

#SUPPLY#

+
+
+

Shielded Supply:

+

#ZFUNDS#

+
+
+

Percent Shielded:

+

#ZFUNDS_PERCENT#

+
+ +
+
+ Blocklist +
+
+
+ +
+
+ + + + + diff --git a/explorer.dragonx.is/update_api.sh b/explorer.dragonx.is/update_api.sh index a17a632..eea5458 100644 --- a/explorer.dragonx.is/update_api.sh +++ b/explorer.dragonx.is/update_api.sh @@ -1,6 +1,11 @@ #!/usr/bin/env bash # Copyright 2016-2022 The Hush Developers +SIONA_ROOT_DIR="siona-DragonX" +SIONA_DOMAIN="explorer.dragonx.is" +SIONA_CLI="/home/admin/HUSH/hush3/src/dragonx-cli" +SIONA_ACNAME="DRAGONX" + DOMAIN=${SIONA_DOMAIN} ROOT_DIR=${SIONA_ROOT_DIR} CLI=${SIONA_CLI} @@ -10,15 +15,19 @@ DIR=/var/www/$ROOT_DIR/$DOMAIN/api HIGHESTBLOCK=$(curl -s "https://$DOMAIN/api/getblockchain.json" | jq -r '.blocks') echo "highest block" $HIGHESTBLOCK + # 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 + + redis-cli set anonset $($CLI z_anonsetblockdelta 1 $HIGHESTBLOCK) redis-cli set hashps $($CLI getnetworkhashps -1) + diff --git a/explorer.dragonx.is/update_hashrate.sh b/explorer.dragonx.is/update_hashrate.sh new file mode 100644 index 0000000..0584059 --- /dev/null +++ b/explorer.dragonx.is/update_hashrate.sh @@ -0,0 +1,79 @@ +#!/usr/bin/env bash +# Copyright 2016-2022 The Hush Developers + +SIONA_ROOT_DIR="siona-DragonX" +SIONA_DOMAIN="explorer.dragonx.is" +SIONA_CLI="/home/admin/HUSH/hush3/src/dragonx-cli" +SIONA_ACNAME="DRAGONX" + +DOMAIN=${SIONA_DOMAIN} +ROOT_DIR=${SIONA_ROOT_DIR} +CLI=${SIONA_CLI} +# this is optional and not used yet here +ACNAME=${SIONA_ACNAME} +DIR=/var/www/$ROOT_DIR/$DOMAIN/api + +$CLI getblockchaininfo &> $DIR/getblockchain.json + +HIGHESTBLOCK=$(curl -s "https://$DOMAIN/api/getblockchain.json" | jq -r '.blocks') +CURBLOCKCOMPARE=$(curl -s "https://$DOMAIN/api/blockinfo.json" | jq -r '.height') + +#check if still on the same block so there's no duplicate data +if (( $HIGHESTBLOCK == $CURBLOCKCOMPARE)); then + + echo "getblockchain.json blocks" $HIGHESTBLOCK + echo "blockinfo.json height" $CURBLOCKCOMPARE + echo "no new block, skipping..." + +else + + echo "getblockchain.json blocks" $HIGHESTBLOCK + echo "blockinfo.json height" $CURBLOCKCOMPARE + echo "new block, adding data.." + + $CLI getnetworkhashps -1 &> $DIR/hashps.json + $CLI getblock $HIGHESTBLOCK 1 &> $DIR/blockinfo.json + + CURBLOCKHEIGHT=$(curl -s "https://$DOMAIN/api/blockinfo.json" | jq -r '.height') + echo "CURBLOCKHEIGHT" $CURBLOCKHEIGHT + CURBLOCKDIFF=$(curl -s "https://$DOMAIN/api/blockinfo.json" | jq -r '.difficulty') + echo "CURBLOCKDIFF" $CURBLOCKDIFF + CURBLOCKTIME=$(curl -s "https://$DOMAIN/api/blockinfo.json" | jq -r '.time') + echo "CURBLOCKTIME" $CURBLOCKTIME + CURHASHPS=$(curl -s "https://$DOMAIN/api/hashps.json") + echo "CURHASHPS" $CURHASHPS + + #recording every block for historical data purposes + jq --arg jq_block_height ${CURBLOCKHEIGHT} \ + --arg jq_block_diff ${CURBLOCKDIFF} \ + --arg jq_block_time ${CURBLOCKTIME} \ + --arg jq_block_hashps ${CURHASHPS} \ + '.blocks += [{ + "Block": $jq_block_height, + "Time": $jq_block_time, + "Diff": $jq_block_diff, + "Hashrate": $jq_block_hashps + }]' /var/www/siona-DragonX/explorer.dragonx.is/api/hashrate.json > /var/www/siona-DragonX/explorer.dragonx.is/api/hashrate.json.tmp + mv /var/www/siona-DragonX/explorer.dragonx.is/api/hashrate.json.tmp /var/www/siona-DragonX/explorer.dragonx.is/api/hashrate.json + + #only record every 100th block for rendering the graph so I don't have to loop through every entry to format for d3.js + if (($HIGHESTBLOCK % 100 == 0)); then + jq --arg jq_block_height ${CURBLOCKHEIGHT} \ + --arg jq_block_diff ${CURBLOCKDIFF} \ + --arg jq_block_time ${CURBLOCKTIME} \ + --arg jq_block_hashps ${CURHASHPS} \ + '.blocks += [{ + "Block": $jq_block_height, + "Time": $jq_block_time, + "Diff": $jq_block_diff, + "Hashrate": $jq_block_hashps + }]' /var/www/siona-DragonX/explorer.dragonx.is/api/hashrate.json > /var/www/siona-DragonX/explorer.dragonx.is/api/hashrate100.json.tmp + mv /var/www/siona-DragonX/explorer.dragonx.is/api/hashrate100.json.tmp /var/www/siona-DragonX/explorer.dragonx.is/api/hashrate100.json + + else + echo "not 100th block" + fi + +fi + + diff --git a/main.js b/main.js new file mode 100644 index 0000000..6fa6cae --- /dev/null +++ b/main.js @@ -0,0 +1,90 @@ + +// set the dimensions and margins of the graph +var margin = {top: 100, right: -10, bottom: 0, left: -10}, + width = 538 - margin.left - margin.right, + height = 350 - margin.top - margin.bottom; + +// parse the date / time +var parseTime = d3.timeParse("%Y"); + +// set the ranges +var x = d3.scaleTime().range([0, width]); +var y = d3.scaleLinear().range([height, 0]); + +// define the line +var valueline = d3.line() + .x(function(d) { return x(d.Time); }) + .y(function(d) { return y(d.Diff); }); +// define the line +var valueline2 = d3.line() + .x(function(d) { return x(d.Time); }) + .y(function(d) { return y(d.Hashrate); }); + +// append the svg obgect to the body of the page +// appends a 'group' element to 'svg' +// moves the 'group' element to the top left margin +var svg = d3.select("#graphContainer").append("svg") + .attr("width", width + margin.left + margin.right) + .attr("height", height + margin.top + margin.bottom) + .attr("class", "graph") + .append("g") + .attr("transform", + "translate(" + margin.left + "," + margin.top + ")"); + +function draw(data, blocks) { + + var data = data[blocks]; + + let graphHeight = 0; + + + // format the data + data.forEach(function(d) { + // d.Time = parseTime(d.Time); + console.log(d.Time); + d.Diff = +d.Diff; + d.Hashrate = +d.Hashrate; + graphHeight = d.Diff; + }); + + // sort years ascending + data.sort(function(a, b){ + return a["Block"]-b["Block"]; + }) + + // Scale the range of the data + x.domain(d3.extent(data, function(d) { return d.Time; })); + y.domain([0, d3.max(data, function(d) { + return Math.max(d.Diff, d.Hashrate); })]); + + // Add the valueline path. + svg.append("path") + .data([data]) + .attr("class", "line1") + .attr("d", valueline); + // Add the valueline path. + svg.append("path") + .data([data]) + .attr("class", "line2") + .attr("d", valueline2); + // Add the X Axis + svg.append("g") + .attr("transform", "translate(0," + (height - 20) + ")") + .call(d3.axisBottom(x)); + + // // Add the Y Axis + // svg.append("g") + // .call(d3.axisLeft(y)); + } +// Get the data +d3.json("./api/hashrate100.json", function(error, data) { + if (error) throw error; + + data.blocks.splice(0, data.blocks.length - 5 ); + // console.log(data); + + // trigger render + draw(data, "blocks"); +}); + +