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

mas colores

parent 12b11101
No related branches found
No related tags found
No related merge requests found
...@@ -193,6 +193,12 @@ sub number ...@@ -193,6 +193,12 @@ sub number
return hex( $_[0]->result->{'number'} ); return hex( $_[0]->result->{'number'} );
} }
sub difficulty
{
return if not exists $_[0]->result->{'difficulty'};
return hex( $_[0]->result->{'difficulty'} );
}
sub td sub td
{ {
return if not exists $_[0]->result->{'totalDifficulty'}; return if not exists $_[0]->result->{'totalDifficulty'};
...@@ -339,25 +345,41 @@ sub determine_colour ...@@ -339,25 +345,41 @@ sub determine_colour
if $diff == 0; if $diff == 0;
return ansi::green() return ansi::green()
if $diff < scalar ( keys %signers ); if $diff < scalar ( keys %signers );
return ansi::bgyellow() . ansi::black return ansi::bgyellow() . ansi::black()
if $diff < 720; # one hour if $diff < 720; # one hour
return ansi::red(); return ansi::red();
} }
sub colour_split sub colour_split
{ {
my ($name, $diff, $col) = @_; my ($name, $diff, $col, $difficulty)
= @_;
return $name return $name
if $diff == 0; if $diff == 0;
my $len = length $name; my $len = length $name;
return if ( $diff <= $len )
substr( $name, 0, $len-$diff) . {
(( $col eq '' ) ? ansi::green() : $col) . my $part1 = substr $name, 0,$len-$diff;
substr( $name, $len-$diff ) . my $part2 = substr $name, $len-$diff,1;
ansi::normal() my $part3 = substr $name, $len-$diff+1;
if $diff <= $len; if ( $difficulty == 2 )
{
$part3 = $part2 . $part3;
$part2 = '';
}
$part2 = ansi::bgyellow() . ansi::black() . $part2 . ansi::normal()
if $part2 ne '';
return
$part1 .
$part2 .
(( $col eq '' ) ? ansi::green() : $col) .
$part3 .
ansi::normal();
}
# diff > len # diff > len
return $col . $name . ansi::normal(); return
ansi::red() . substr( $name, 0, 1 ) . ansi::normal() .
$col . substr( $name, 1 ) . ansi::normal();
} }
sub presentation_top sub presentation_top
...@@ -436,7 +458,10 @@ while ( defined $block || sleep 1 ) ...@@ -436,7 +458,10 @@ while ( defined $block || sleep 1 )
my $lastnum = exists $signers{$this} ? $signers{$this} : -12345; my $lastnum = exists $signers{$this} ? $signers{$this} : -12345;
my $diff = $number - $lastnum; my $diff = $number - $lastnum;
my $col = determine_colour( $diff ); my $col = determine_colour( $diff );
my $id = colour_split( $this, $diff, $col ); my $difficulty = ( exists $signers{$this} and exists $cache{$signers{$this}}{'block'} )
? $cache{$signers{$this}}{'block'}->difficulty
: 0;
my $id = colour_split( $this, $diff, $col, $difficulty );
my $flags = $diff == 0 ? '*' : ''; my $flags = $diff == 0 ? '*' : '';
my $alias = alias::translate( $this ); my $alias = alias::translate( $this );
my $numtxt = (not defined $lastnum or $lastnum < 0) ? 'n/a' : $lastnum; my $numtxt = (not defined $lastnum or $lastnum < 0) ? 'n/a' : $lastnum;
...@@ -448,4 +473,5 @@ while ( defined $block || sleep 1 ) ...@@ -448,4 +473,5 @@ while ( defined $block || sleep 1 )
print ansi::ED(0); print ansi::ED(0);
# #
$number = $block->number + 1; $number = $block->number + 1;
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