avkiev Posted January 29, 2009 Report Share Posted January 29, 2009 How works "Autodetect of pieces length" during creating torrent-file ?I think - it is smth like that:int AutoPieceLenInK(long Filelen){ if (FileLen < s1) return(32); if (FileLen < s2) return(64); if (FileLen < s3) return(128); if (FileLen < s4) return(256); if (FileLen < s5) return(512); if (FileLen < s6) return(1024); if (FileLen < s7) return(2048); return(4096);}Which values has constants s1-s7 ?Could you, please, share source code of this function ?Thanks in advance Link to comment Share on other sites More sharing options...
moogly Posted January 29, 2009 Report Share Posted January 29, 2009 uT 1.8.2 has 16-kB piece size now! Why do you not see source code of an open-source client ? It's surely the same values.uT is a closed source freeware. Link to comment Share on other sites More sharing options...
avkiev Posted January 29, 2009 Author Report Share Posted January 29, 2009 Give me a URL, please, of open-source Link to comment Share on other sites More sharing options...
moogly Posted January 29, 2009 Report Share Posted January 29, 2009 There are many open source bittorrent clients.http://www.transmissionbt.com/http://www.qbittorrent.org/http://deluge-torrent.org/ (not sure if Deluge allows creating torrents)http://azureus.sourceforge.net/etc...and the most importanthttp://en.wikipedia.org/wiki/Comparison_of_BitTorrent_software Link to comment Share on other sites More sharing options...
avkiev Posted January 29, 2009 Author Report Share Posted January 29, 2009 Thank you very much. The answer is: public static final long TO_DEFAULT_FIXED_PIECE_SIZE = 256*1024; public static final long TO_DEFAULT_VARIABLE_PIECE_SIZE_MIN = 32*1024; public static final long TO_DEFAULT_VARIABLE_PIECE_SIZE_MAX = 2*1024*1024; public static final long TO_DEFAULT_VARIABLE_PIECE_NUM_LOWER = 1024; public static final long TO_DEFAULT_VARIABLE_PIECE_NUM_UPPER = 2048; public static final long[] STANDARD_PIECE_SIZES = { 32*1024, 48*1024, 64*1024, 96*1024, 128*1024, 192*1024, 256*1024, 384*1024, 512*1024, 768*1024, 1024*1024, 1536*1024, 2*1024*1024, 3*1024*1024, 4*1024*1024 }; public static long getComputedPieceSize( long total_size, long _piece_min_size, long _piece_max_size, long _piece_num_lower, long _piece_num_upper ) { long piece_length = -1; long current_piece_size = _piece_min_size; while( current_piece_size <= _piece_max_size ){ long pieces = total_size / current_piece_size; if ( pieces <= _piece_num_upper ){ piece_length = current_piece_size; break; } current_piece_size = current_piece_size << 1; } // if we haven't set a piece length here then there are too many pieces even // at maximum piece size. Go for largest piece size if ( piece_length == -1 ){ // just go for the maximum piece size piece_length = _piece_max_size; } return( piece_length ); } Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.