File Coverage

lib/Finance/Dogechain/Block.pm
Criterion Covered Total %
statement 6 19 31.5
branch 0 2 0.0
condition n/a
subroutine 2 5 40.0
pod 2 3 66.6
total 10 29 34.4


line stmt bran cond sub pod time code
1             package Finance::Dogechain::Block;
2             $Finance::Dogechain::Block::VERSION = '1.20210605.1754';
3 1     1   8 use Mojo::Base -base, -signatures, 'Finance::Dogechain::Base';
  1         1  
  1         6  
4 1     1   760 use Finance::Dogechain::Transaction;
  1         3  
  1         8  
5              
6             has 'block_id';
7             has 'block', sub($self) {
8             my $block = $self->return_field_if_success( '/block/' . $self->block_id, 'block' );
9              
10             convert_transactions_in_place( $block->{txs} ) if $block;
11              
12             return $block;
13             };
14              
15 0     0 0   sub convert_transactions_in_place($txs) {
  0            
  0            
16 0           while (my ($i, $tx_id) = each @$txs) {
17 0           $txs->[$i] = Finance::Dogechain::Transaction->new( tx_id => $tx_id );
18             }
19             }
20              
21 0     0 1   sub transactions($self) {
  0            
  0            
22             # a coinbase block may not come back as a block with a height
23             # so return no transactions
24 0 0         return $self->block ? $self->block->{txs} : [];
25             }
26              
27 0     0 1   sub TO_JSON($self) {
  0            
  0            
28 0           return '[Finance::Dogechain::Block](block_id => ' . $self->block_id . ')';
29             }
30              
31             'to the moon';
32             __END__