*** empty log message ***

This commit is contained in:
Magnus Jonsson 2004-01-16 03:58:24 +00:00
parent 430f6e684b
commit e1f433f5db
6 changed files with 40 additions and 25 deletions

View File

@ -35,6 +35,8 @@ POSSIBILITY OF SUCH DAMAGE.
#include <algorithm> #include <algorithm>
#include <vector> #include <vector>
#include <assert.h>
#include <boost/cstdint.hpp>
namespace libtorrent namespace libtorrent
{ {
@ -44,6 +46,9 @@ namespace libtorrent
enum { history = 10 }; enum { history = 10 };
public: public:
typedef boost::int64_t size_type;
stat() stat()
: m_downloaded_payload(0) : m_downloaded_payload(0)
, m_uploaded_payload(0) , m_uploaded_payload(0)
@ -77,14 +82,19 @@ namespace libtorrent
void received_bytes(int bytes_payload, int bytes_protocol) void received_bytes(int bytes_payload, int bytes_protocol)
{ {
assert(bytes_payload>=0);
assert(bytes_protocol>=0);
m_downloaded_payload += bytes_payload; m_downloaded_payload += bytes_payload;
m_total_download_payload += bytes_payload; m_total_download_payload += bytes_payload;
m_downloaded_protocol += bytes_protocol; m_downloaded_protocol += bytes_protocol;
m_total_download_protocol += bytes_protocol; m_total_download_protocol += bytes_protocol;
} }
void sent_bytes(int bytes_payload, int bytes_protocol) void sent_bytes(int bytes_payload, int bytes_protocol)
{ {
assert(bytes_payload>=0);
assert(bytes_protocol>=0);
m_uploaded_payload += bytes_payload; m_uploaded_payload += bytes_payload;
m_total_upload_payload += bytes_payload; m_total_upload_payload += bytes_payload;
@ -102,11 +112,11 @@ namespace libtorrent
float down_peak() const { return m_peak_downloaded_per_second; } float down_peak() const { return m_peak_downloaded_per_second; }
float up_peak() const { return m_peak_uploaded_per_second; } float up_peak() const { return m_peak_uploaded_per_second; }
unsigned int total_payload_upload() const { return m_total_upload_payload; } size_type total_payload_upload() const { return m_total_upload_payload; }
unsigned int total_payload_download() const { return m_total_download_payload; } size_type total_payload_download() const { return m_total_download_payload; }
unsigned int total_protocol_upload() const { return m_total_upload_protocol; } size_type total_protocol_upload() const { return m_total_upload_protocol; }
unsigned int total_protocol_download() const { return m_total_download_protocol; } size_type total_protocol_download() const { return m_total_download_protocol; }
private: private:
@ -130,13 +140,13 @@ namespace libtorrent
// total download/upload counters // total download/upload counters
// only counting payload data // only counting payload data
unsigned int m_total_download_payload; size_type m_total_download_payload;
unsigned int m_total_upload_payload; size_type m_total_upload_payload;
// total download/upload counters // total download/upload counters
// only counting protocol chatter // only counting protocol chatter
unsigned int m_total_download_protocol; size_type m_total_download_protocol;
unsigned int m_total_upload_protocol; size_type m_total_upload_protocol;
// peak mean download/upload rates // peak mean download/upload rates
unsigned int m_peak_downloaded_per_second; unsigned int m_peak_downloaded_per_second;

View File

@ -42,6 +42,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <boost/limits.hpp> #include <boost/limits.hpp>
#include <boost/filesystem/path.hpp> #include <boost/filesystem/path.hpp>
#include <boost/date_time/posix_time/posix_time.hpp> #include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/cstdint.hpp>
#include "libtorrent/torrent_handle.hpp" #include "libtorrent/torrent_handle.hpp"
#include "libtorrent/entry.hpp" #include "libtorrent/entry.hpp"
@ -106,7 +107,7 @@ namespace libtorrent
{ {
public: public:
typedef entry::integer_type size_type; typedef boost::int64_t size_type;
torrent( torrent(
detail::session_impl& ses detail::session_impl& ses

View File

@ -35,6 +35,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <vector> #include <vector>
#include <boost/date_time/posix_time/posix_time.hpp> #include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/cstdint.hpp>
#include "libtorrent/peer_id.hpp" #include "libtorrent/peer_id.hpp"
#include "libtorrent/peer_info.hpp" #include "libtorrent/peer_info.hpp"
@ -63,7 +64,7 @@ namespace libtorrent
struct torrent_status struct torrent_status
{ {
typedef entry::integer_type size_type; typedef boost::int64_t size_type;
torrent_status() torrent_status()
: state(queued_for_checking) : state(queued_for_checking)

View File

@ -36,6 +36,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <string> #include <string>
#include <vector> #include <vector>
#include <boost/cstdint.hpp>
#include "libtorrent/entry.hpp" #include "libtorrent/entry.hpp"
#include "libtorrent/socket.hpp" #include "libtorrent/socket.hpp"
@ -58,7 +59,7 @@ namespace libtorrent
{ {
std::string path; std::string path;
std::string filename; std::string filename;
entry::integer_type size; boost::int64_t size;
}; };
struct announce_entry struct announce_entry
@ -81,6 +82,8 @@ namespace libtorrent
{ {
public: public:
typedef boost::int64_t size_type;
torrent_info(const entry& torrent_file) torrent_info(const entry& torrent_file)
: m_creation_date(boost::gregorian::date(1970 : m_creation_date(boost::gregorian::date(1970
, boost::gregorian::Jan , boost::gregorian::Jan
@ -115,8 +118,8 @@ namespace libtorrent
// the begining) and return the new index to the tracker. // the begining) and return the new index to the tracker.
int prioritize_tracker(int index); int prioritize_tracker(int index);
entry::integer_type total_size() const { return m_total_size; } size_type total_size() const { return m_total_size; }
entry::integer_type piece_length() const { return m_piece_length; } size_type piece_length() const { return m_piece_length; }
int num_pieces() const { return (int)m_piece_hash.size(); } int num_pieces() const { return (int)m_piece_hash.size(); }
const sha1_hash& info_hash() const { return m_info_hash; } const sha1_hash& info_hash() const { return m_info_hash; }
const std::string& name() const { return m_name; } const std::string& name() const { return m_name; }
@ -124,11 +127,11 @@ namespace libtorrent
void convert_file_names(); void convert_file_names();
entry::integer_type piece_size(unsigned int index) const size_type piece_size(unsigned int index) const
{ {
if (index == num_pieces()-1) if (index == num_pieces()-1)
{ {
entry::integer_type s = total_size() % m_piece_length; size_type s = total_size() % m_piece_length;
return (s == 0)?m_piece_length:s; return (s == 0)?m_piece_length:s;
} }
else else
@ -155,7 +158,7 @@ namespace libtorrent
std::vector<announce_entry> m_urls; std::vector<announce_entry> m_urls;
// the length of one piece // the length of one piece
entry::integer_type m_piece_length; size_type m_piece_length;
// the sha-1 hashes of each piece // the sha-1 hashes of each piece
std::vector<sha1_hash> m_piece_hash; std::vector<sha1_hash> m_piece_hash;
@ -164,7 +167,7 @@ namespace libtorrent
std::vector<file_entry> m_files; std::vector<file_entry> m_files;
// the sum of all filesizes // the sum of all filesizes
entry::integer_type m_total_size; size_type m_total_size;
// the hash that identifies this torrent // the hash that identifies this torrent
sha1_hash m_info_hash; sha1_hash m_info_hash;

View File

@ -363,7 +363,7 @@ namespace libtorrent {
class piece_manager::impl class piece_manager::impl
{ {
public: public:
typedef entry::integer_type size_type; typedef boost::int64_t size_type;
impl( impl(
const torrent_info& info const torrent_info& info
@ -629,9 +629,9 @@ namespace libtorrent {
std::size_t bytes_to_read = piece_size; std::size_t bytes_to_read = piece_size;
std::size_t bytes_current_read = 0; std::size_t bytes_current_read = 0;
std::size_t seek_into_next = 0; std::size_t seek_into_next = 0;
entry::integer_type filesize = 0; size_type filesize = 0;
entry::integer_type start_of_read = 0; size_type start_of_read = 0;
entry::integer_type start_of_file = 0; size_type start_of_file = 0;
{ {
boost::mutex::scoped_lock lock(mutex); boost::mutex::scoped_lock lock(mutex);
@ -724,8 +724,8 @@ namespace libtorrent {
{ {
if (bytes_current_read != file_iter->size) if (bytes_current_read != file_iter->size)
{ {
entry::integer_type pos; size_type pos;
entry::integer_type file_end = start_of_file + file_iter->size; size_type file_end = start_of_file + file_iter->size;
for (pos = start_of_read; pos < file_end; for (pos = start_of_read; pos < file_end;
pos += piece_size) pos += piece_size)
@ -804,7 +804,7 @@ namespace libtorrent {
{ {
m_slot_to_piece[current_slot] = -2; m_slot_to_piece[current_slot] = -2;
entry::integer_type last_pos = size_type last_pos =
m_info.total_size() - m_info.total_size() -
m_info.piece_size( m_info.piece_size(
m_info.num_pieces() - 1); m_info.num_pieces() - 1);

View File

@ -192,7 +192,7 @@ namespace libtorrent
// extract sha-1 hashes for all pieces // extract sha-1 hashes for all pieces
// we want this division to round upwards, that's why we have the // we want this division to round upwards, that's why we have the
// extra addition // extra addition
entry::integer_type num_pieces = (m_total_size + m_piece_length - 1) / m_piece_length; size_type num_pieces = (m_total_size + m_piece_length - 1) / m_piece_length;
i = info.dict().find("pieces"); i = info.dict().find("pieces");
if (i == info.dict().end()) throw invalid_torrent_file(); if (i == info.dict().end()) throw invalid_torrent_file();