bittorrent: fix check-bitfield, add a test.
parent
6aa8f640c8
commit
2300311641
|
@ -1,4 +1,9 @@
|
|||
USING: bittorrent io.sockets tools.test ;
|
||||
USING: bittorrent sequences io.sockets tools.test ;
|
||||
|
||||
|
||||
{ { t f t t f t f t } } [
|
||||
8 <iota> [ B{ 0b10110101 } check-bitfield ] map
|
||||
] unit-test
|
||||
|
||||
{
|
||||
{
|
||||
|
|
|
@ -40,7 +40,7 @@ torrent-port [ 6881 ] initialize
|
|||
'[ _ _ [ set-bit ] [ clear-bit ] if ] change-nth ;
|
||||
|
||||
: check-bitfield ( n bitfield -- ? )
|
||||
[ bitfield-index swap ] dip nth bit? ;
|
||||
[ bitfield-index swap ] dip nth swap bit? ;
|
||||
|
||||
|
||||
! http
|
||||
|
|
Loading…
Reference in New Issue