Skip to content
Snippets Groups Projects
Commit b8d741f4 authored by Robert Martin-Legene's avatar Robert Martin-Legene
Browse files

Small fixes to sealerwatch

parent 01d486b5
No related branches found
No related tags found
No related merge requests found
...@@ -382,21 +382,28 @@ sub colour_split ...@@ -382,21 +382,28 @@ sub colour_split
$col . substr( $name, 1 ) . ansi::normal(); $col . substr( $name, 1 ) . ansi::normal();
} }
my $maxy = 2;
sub presentation_top sub presentation_top
{ {
my $block = shift; my $block = shift;
return if not defined $block; return if not defined $block;
# #
my $warning = ''; 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 print
ansi::CUP(), ansi::CUP(),
ansi::normal(), ansi::normal(),
tools::gmt($block->timestamp), tools::gmt($block->timestamp),
$warning, $warning,
ansi::EL(0), ansi::EL(0),
ansi::CUP(scalar(keys %signers) + 2, 1); ansi::CUP($maxy, 1);
} }
while ( defined $block || sleep 1 ) while ( defined $block || sleep 1 )
...@@ -414,7 +421,7 @@ while ( defined $block || sleep 1 ) ...@@ -414,7 +421,7 @@ while ( defined $block || sleep 1 )
$number = $block->number; $number = $block->number;
if ( exists $cache{ $number - 1 }{'block'} ) 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, # If we do have any information about previous blocks,
# see if the hash matches. If we were in a side branch # see if the hash matches. If we were in a side branch
# we would eventually get wrong hashes, because we # we would eventually get wrong hashes, because we
...@@ -422,8 +429,15 @@ while ( defined $block || sleep 1 ) ...@@ -422,8 +429,15 @@ while ( defined $block || sleep 1 )
# This is a good way to determine if we're side tracked. # This is a good way to determine if we're side tracked.
if ( $parent->hash ne $block->parentHash ) 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 # 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}; delete $cache{$number};
$number --; $number --;
next; next;
...@@ -470,7 +484,8 @@ while ( defined $block || sleep 1 ) ...@@ -470,7 +484,8 @@ while ( defined $block || sleep 1 )
defined $alias ? $alias : '', defined $alias ? $alias : '',
ansi::EL(0); 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; $number = $block->number + 1;
select( undef, undef,undef, 0.2 ); select( undef, undef,undef, 0.2 );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment