| 1 | 29 | ▶ | use v5.40; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 2 | 29 | ▶ | use feature 'class'; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 3 | 29 | ▶ | no warnings 'experimental::class'; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 4 | 4 | ▶ | class Net::BitTorrent::Protocol::BEP52 v2.1.1 : isa(Net::BitTorrent::Protocol::BEP03) { | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 5 | |||||||||||||||||||
| 6 | # BEP 52 Hash Request | ||||||||||||||||||
| 7 | # infohash (v2 only), pieces root, proof layer, base layer, index, length | ||||||||||||||||||
| 8 | 1 | ▶ | method send_hash_request ( $pieces_root, $proof_layer, $base_layer, $index, $length ) { | ||||||||||||||||
|
Subroutine
send_hash_request: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||
| 9 | 1 | $self->send_message( $self->HASH_REQUEST, pack( 'a32 C C N N', $pieces_root, $proof_layer, $base_layer, $index, $length ) ); | |||||||||||||||||
| 10 | } | ||||||||||||||||||
| 11 | |||||||||||||||||||
| 12 | # BEP 52 Hashes | ||||||||||||||||||
| 13 | # pieces root, proof layer, base layer, index, length, hashes | ||||||||||||||||||
| 14 | 0 | ▶ | method send_hashes ( $pieces_root, $proof_layer, $base_layer, $index, $length, $hashes ) { | ||||||||||||||||
|
Subroutine
send_hashes: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||
| 15 | 0 | $self->send_message( $self->HASHES, pack( 'a32 C C N N a*', $pieces_root, $proof_layer, $base_layer, $index, $length, $hashes ) ); | |||||||||||||||||
| 16 | } | ||||||||||||||||||
| 17 | |||||||||||||||||||
| 18 | # BEP 52 Hash Reject | ||||||||||||||||||
| 19 | 0 | ▶ | method send_hash_reject ( $pieces_root, $proof_layer, $base_layer, $index, $length ) { | ||||||||||||||||
|
Subroutine
send_hash_reject: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||
| 20 | 0 | $self->send_message( $self->HASH_REJECT, pack( 'a32 C C N N', $pieces_root, $proof_layer, $base_layer, $index, $length ) ); | |||||||||||||||||
| 21 | } | ||||||||||||||||||
| 22 | |||||||||||||||||||
| 23 | 50 | ▶ | method _handle_message ( $id, $payload ) { | ||||||||||||||||
|
Subroutine
_handle_message: called CC=7 SCAR=33.9
| |||||||||||||||||||
| 24 | 50 | ▶ | if ( $id == $self->HASH_REQUEST ) { | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 25 | 0 | ▶ | return $self->_emit_log( 'warn', 'HASH_REQUEST payload too short' ) if length($payload) != 42; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 26 | 0 | $self->_emit( hash_request => unpack( 'a32 C C N N', $payload ) ); | |||||||||||||||||
| 27 | } | ||||||||||||||||||
| 28 | elsif ( $id == $self->HASHES ) { | ||||||||||||||||||
| 29 | 0 | my $plen = length($payload); | |||||||||||||||||
| 30 | 0 | ▶ | return $self->_emit_log( 'warn', 'HASHES payload too short' ) if $plen < 42; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 31 | 0 | my ( $root, $proof, $base, $idx, $len, $hashes ) = unpack( 'a32 C C N N a*', $payload ); | |||||||||||||||||
| 32 | 0 | $self->_emit( hashes => $root, $proof, $base, $idx, $len, $hashes ); | |||||||||||||||||
| 33 | } | ||||||||||||||||||
| 34 | elsif ( $id == $self->HASH_REJECT ) { | ||||||||||||||||||
| 35 | 0 | ▶ | return $self->_emit_log( 'warn', 'HASH_REJECT payload too short' ) if length($payload) != 42; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 36 | 0 | $self->_emit( hash_reject => unpack( 'a32 C C N N', $payload ) ); | |||||||||||||||||
| 37 | } | ||||||||||||||||||
| 38 | else { | ||||||||||||||||||
| 39 | 50 | $self->SUPER::_handle_message( $id, $payload ); | |||||||||||||||||
| 40 | } | ||||||||||||||||||
| 41 | } | ||||||||||||||||||
| 42 | 29 | } 1; | |||||||||||||||||