]> p2p-next.cs.pub.ro Git - swift-upb.git/commitdiff
twisted picker
authorvictor <victor@e16421f0-f15b-0410-abcd-98678b794739>
Sat, 7 Nov 2009 12:51:45 +0000 (12:51 +0000)
committervictor <victor@e16421f0-f15b-0410-abcd-98678b794739>
Sat, 7 Nov 2009 12:51:45 +0000 (12:51 +0000)
git-svn-id: https://ttuki.vtt.fi/svn/p2p-next/TUD/p2tp/trunk@510 e16421f0-f15b-0410-abcd-98678b794739

exec/leecher.cpp
ext/seq_picker.cpp
transfer.cpp

index 8734d617aa362159dc4bbaa9476e9dbca45fb25e..cee17e47649727b337eaa07e0f1985ac11028c29 100644 (file)
@@ -15,7 +15,7 @@ using namespace p2tp;
 /** P2TP downloader. Params: root hash, filename, tracker ip/port, own ip/port */
 int main (int argn, char** args) {
     
-    srand(Datagram::Time());
+    srand(time(NULL));
     FileTransfer::instance = rand();
     
     if (argn<4) {
index c9b4da2462b28979a20c191cad650f48e510121c..e4a624b1e851135993778b1e5b9deda64eb26b32 100644 (file)
@@ -29,6 +29,7 @@ public:
     }
     
     virtual bin64_t Pick (bins& offer, uint8_t layer) {
+        //dprintf("twist is %lli\n",twist_);
         if (twist_) {
             offer.twist(twist_);
             ack_hint_out_.twist(twist_);
@@ -37,8 +38,6 @@ public:
                 (ack_hint_out_,bin64_t::ALL,layer,bins::FILLED);
         if (twist_) {
             hint = hint.twisted(twist_);
-            //dprintf("found twisted by %lli fixed to (%i,%lli)\n",
-            //        twist_,hint.layer(),hint.offset());
             offer.twist(0);
             ack_hint_out_.twist(0);
         }
index 4e4548454947a5ef1becc0768113a6ad55e42ad8..4ae31b8e9d7b427e6fc7555ed5a676c593887142 100644 (file)
@@ -44,7 +44,6 @@ FileTransfer::FileTransfer (const char* filename, const Sha1Hash& _root_hash) :
     else
         RecoverProgress();
     picker_ = new SeqPiecePicker(this);
-    picker_->Randomize(Datagram::Time()&7);
 }
 
 
@@ -145,6 +144,7 @@ void FileTransfer::SetSize (size_t bytes) { // peaks/root must be already set
     }
     for(int i=0; i<peak_count_; i++)
         hashes_[peaks_[i]] = peak_hashes_[i];
+    picker_->Randomize(rand()&31&(sizek_-1));
 }