diff --git a/bin/sealerwatch.pl b/bin/sealerwatch.pl index d9d38901e5250d635f3a44d9af6fc6abee1f0d44..c3c77eafaa17d768a223eb5d29b0fa8b7e5670ab 100755 --- a/bin/sealerwatch.pl +++ b/bin/sealerwatch.pl @@ -382,21 +382,28 @@ sub colour_split $col . substr( $name, 1 ) . ansi::normal(); } +my $maxy = 2; sub presentation_top { my $block = shift; return if not defined $block; # my $warning = ''; - $warning = ' ' . ansi::red() . " **NOT RECENT** " . ansi::normal() - if $block->timestamp + 1800 < time(); + if ( $block->timestamp + 1800 < time() ) + { + $warning = ' ' . ansi::red() . " **NOT RECENT** " . ansi::normal() + } + elsif ( $block->timestamp + 30 < time() ) + { + $warning = ' ' . ansi::bgyellow() . ansi::black() . " **NOT RECENT** " . ansi::normal() + } print ansi::CUP(), ansi::normal(), tools::gmt($block->timestamp), $warning, ansi::EL(0), - ansi::CUP(scalar(keys %signers) + 2, 1); + ansi::CUP($maxy, 1); } while ( defined $block || sleep 1 ) @@ -414,7 +421,7 @@ while ( defined $block || sleep 1 ) $number = $block->number; if ( exists $cache{ $number - 1 }{'block'} ) { - $parent = $cache{ $number - 1}{'block'}; + $parent = $cache{ $number - 1 }{'block'}; # If we do have any information about previous blocks, # see if the hash matches. If we were in a side branch # we would eventually get wrong hashes, because we @@ -422,8 +429,15 @@ while ( defined $block || sleep 1 ) # This is a good way to determine if we're side tracked. if ( $parent->hash ne $block->parentHash ) { + # First delete the signer of the to-be-forgotten block + # from the list of 'recent signs'. This will create a + # red 'n/a' to appear in the list. This is more desirable + # than finding the proper previous block of this signer, + # as it makes it more visual that a fork had happened. + my $prevsigner = $cache{ $number - 1 }{'signer'}; + delete $signers{$prevsigner}; # If we are side tracked, we'll read backwards - # until we find a match (or nothing cached) + # until we find a match (or until we have nothing cached) delete $cache{$number}; $number --; next; @@ -470,7 +484,8 @@ while ( defined $block || sleep 1 ) defined $alias ? $alias : '', ansi::EL(0); } - print ansi::ED(0); + $maxy = scalar( keys %{ $result->{'signers'} }) + 2; + print ansi::ED(0), ansi::CUP($maxy, 1); # $number = $block->number + 1; select( undef, undef,undef, 0.2 );