From c95ac554cbc0d10866562623f4599eb09d5803e2 Mon Sep 17 00:00:00 2001 From: victor Date: Tue, 3 Nov 2009 14:57:21 +0000 Subject: [PATCH] now with leecher git-svn-id: https://ttuki.vtt.fi/svn/p2p-next/TUD/p2tp/trunk@496 e16421f0-f15b-0410-abcd-98678b794739 --- BUGS | 4 ++++ datagram.cpp | 2 ++ exec/leecher.cpp | 34 ++++++++++++++++++++++++++++++++++ hashtree.cpp | 13 +++++++++++-- p2tp.cpp | 2 +- p2tp.h | 2 +- 6 files changed, 53 insertions(+), 4 deletions(-) create mode 100644 exec/leecher.cpp diff --git a/BUGS b/BUGS index 2dfe512..8fb861c 100644 --- a/BUGS +++ b/BUGS @@ -1,5 +1,9 @@ * hints, data for non-existing ranges * opens multiple channels to the same address + * hints do not expire + * RTT calculations need improvement (test) + * google-log is unnecessary + * reduce template use (peer queue) v hints do not expire * survive 10% loss * unlimited ping pong diff --git a/datagram.cpp b/datagram.cpp index 3c07bd4..86f1b6e 100644 --- a/datagram.cpp +++ b/datagram.cpp @@ -46,6 +46,8 @@ char* Datagram::TimeStr (tint time) { int Datagram::Send () { int r = sendto(sock,(const char *)buf+offset,length-offset,0, (struct sockaddr*)&(addr.addr),sizeof(struct sockaddr_in)); + if (r<0) + perror("can't send"); //offset=0; //length=0; dgrams_up++; diff --git a/exec/leecher.cpp b/exec/leecher.cpp new file mode 100644 index 0000000..17d1aa7 --- /dev/null +++ b/exec/leecher.cpp @@ -0,0 +1,34 @@ +/* + * leecher.cpp + * p2tp + * + * Created by Victor Grishchenko on 11/3/09. + * Copyright 2009 Delft Technical University. All rights reserved. + * + */ +#include "p2tp.h" + + +using namespace p2tp; + + +int main (int argn, char** args) { + + assert(0hex()==string(hash)); + } else + memcpy(bits,hash,SIZE); } string Sha1Hash::hex() const { diff --git a/p2tp.cpp b/p2tp.cpp index 75692d1..81fac8d 100644 --- a/p2tp.cpp +++ b/p2tp.cpp @@ -132,7 +132,7 @@ size_t p2tp::Size (int fdes) { size_t p2tp::Complete (int fdes) { if (FileTransfer::files.size()>fdes && FileTransfer::files[fdes]) - return FileTransfer::files[fdes]->complete(); + return FileTransfer::files[fdes]->is_complete(); else return 0; } diff --git a/p2tp.h b/p2tp.h index 460a66a..e7cbf76 100644 --- a/p2tp.h +++ b/p2tp.h @@ -140,7 +140,7 @@ namespace p2tp { uint64_t complete_kilo () const { return completek_; } uint64_t seq_complete () const { return seq_complete_; } bool is_complete () const - { return seq_complete_==size_; } + { return size_ && seq_complete_==size_; } bins& ack_out () { return ack_out_; } int file_descriptor () const { return fd_; } PiecePicker& picker () { return *picker_; } -- 2.20.1