From 6df6b9fdae54098f075846870735d0c4d5218dcb Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Thu, 5 Jul 2018 12:29:42 -0700 Subject: [PATCH] update maturity dates to also give amount, now requires JSON.pm --- bin/block_maturity_dates.pl | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/bin/block_maturity_dates.pl b/bin/block_maturity_dates.pl index d7d5e69..fdd962c 100755 --- a/bin/block_maturity_dates.pl +++ b/bin/block_maturity_dates.pl @@ -3,19 +3,31 @@ use strict; use warnings; use POSIX qw(strftime); - -my $output = qx{./fiat/verus listtransactions "" 1000 |grep blockstomaturity | cut -d: -f2 | sed 's/,//g' | sort -n}; -my @lines = split /\n/, $output; +use JSON; chomp(my $host = `hostname`); +my $num_blocks = int( shift || 1000 ); +my $output = qx{./fiat/verus listtransactions "" $num_blocks}; +#my $output = qx{./fiat/verus listtransactions "" $blocks}; # |grep blockstomaturity | cut -d: -f2 | sed 's/,//g' | sort -n}; +my $blocks = decode_json($output); print "$host:\n"; my $num = 0; -for my $line (@lines) { +my $total = 0; +for my $block (@$blocks) { + next unless $block->{category} eq 'immature'; $num++; - chomp $line; - # my $date = localtime(time + 60*$line); - my $date = strftime "%a %b %e %H:%M:00 %Y", localtime(time + 60*$line); - print "$num $date\n"; + my $amount = $block->{amount}; + my $blockstomaturity = $block->{blockstomaturity}; + my $date = strftime "%a %b %e %H:%M:00 %Y", localtime(time + 60*$blockstomaturity); + printf "%02d %s, %d\n", $num, $date, $amount; + $total += $amount; } -print "Total: $num immature blocks\n"; +#for my $line (@lines) { +# chomp $line; +# # my $date = localtime(time + 60*$line); +# my $date = strftime "%a %b %e %H:%M:00 %Y", localtime(time + 60*$line); +# print "$num $date\n"; +#} + +print "Total: $num immature blocks, $total VRSC\n";