jahway603
3 years ago
3 changed files with 109 additions and 1 deletions
@ -0,0 +1,21 @@ |
|||
MIT License |
|||
|
|||
Copyright (c) 2021 ChileBob |
|||
|
|||
Permission is hereby granted, free of charge, to any person obtaining a copy |
|||
of this software and associated documentation files (the "Software"), to deal |
|||
in the Software without restriction, including without limitation the rights |
|||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|||
copies of the Software, and to permit persons to whom the Software is |
|||
furnished to do so, subject to the following conditions: |
|||
|
|||
The above copyright notice and this permission notice shall be included in all |
|||
copies or substantial portions of the Software. |
|||
|
|||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|||
SOFTWARE. |
@ -1,3 +1,17 @@ |
|||
# ShieldedOutputs |
|||
|
|||
Counts shielded outputs in hush v3 blocks |
|||
Counts shielded outputs in hush v3 blocks |
|||
|
|||
Forked from [ChileBob](https://github.com/ChileBob/ShieldedOutputs) who works on ycash |
|||
|
|||
## How to use |
|||
|
|||
1. Make sure your hush daemon (hushd) is running. |
|||
1. Open getstats in a text editor. |
|||
1. change "my $block_height = 699000" to what block number you want to begin at. |
|||
1. Run this with `perl getstats` and watch how many shielded outputs occured in each block in sequence. |
|||
|
|||
## License |
|||
|
|||
GPLv3 |
|||
|
|||
|
@ -0,0 +1,73 @@ |
|||
#!/usr/bin/perl |
|||
# |
|||
# Copright (c) 2021 Jahway603 & The Hush Developers under GPLv3 License |
|||
# |
|||
# forked from https://github.com/ChileBob/ShieldedOutputs |
|||
# Copyright (c) 2021 ChileBob under MIT License |
|||
# |
|||
|
|||
package common; |
|||
|
|||
use Data::Dumper; |
|||
use JSON; |
|||
|
|||
my $node_client = 'hush-cli'; # hush-cli client |
|||
|
|||
#my $block_height = 570000; # start block |
|||
my $block_height = 699000; # changed start block |
|||
|
|||
my $blockchaininfo = node_cli('getblockchaininfo'); |
|||
|
|||
print "Block\tEpoch\tShieldedOutputs\n"; |
|||
|
|||
while ( $block_height < $blockchaininfo->{'blocks'} ) { |
|||
|
|||
my $block = node_cli("getblock $block_height 2"); |
|||
|
|||
my $shielded_outputs = 0; |
|||
|
|||
foreach my $txn ( @{ $block->{'tx'} } ) { |
|||
|
|||
if ($txn->{'vShieldedOutput'}) { # shielded outputs |
|||
$shielded_outputs += scalar @{$txn->{'vShieldedOutput'}}; |
|||
} |
|||
} |
|||
|
|||
print "$block_height\t$block->{'time'}\t$shielded_outputs\n"; |
|||
|
|||
$block_height++; |
|||
} |
|||
|
|||
####################################################################################################################################### |
|||
# |
|||
# Safely parse JSON string |
|||
# |
|||
sub read_json { |
|||
|
|||
my ($raw) = @_; |
|||
|
|||
eval { decode_json($raw) }; # eval first, bad JSON kills puppies |
|||
|
|||
if (!$@) { |
|||
return(decode_json($raw)); |
|||
} |
|||
} |
|||
|
|||
|
|||
############################################################################################################################################################################# |
|||
# |
|||
# query node client, return JSON |
|||
# |
|||
sub node_cli { |
|||
|
|||
my ($command, $data) = @_; |
|||
|
|||
my $response = `$node_client $command $data 2>/dev/null`; # every time you use backticks a puppy dies :-( |
|||
|
|||
my $json = read_json($response); # bad JSON kills puppies too |
|||
|
|||
if ($json) { |
|||
return($json); |
|||
} |
|||
} |
|||
|
Loading…
Reference in new issue