hopefully a non-problematic fix to the num-seeds and num-peers values

This commit is contained in:
Alon Zakai 2007-05-31 09:12:41 +00:00
parent b1320232cc
commit 5e70f78df0
1 changed files with 28 additions and 39 deletions

View File

@ -611,45 +611,34 @@ static PyObject *torrent_get_torrent_state(PyObject *self, PyObject *args)
std::vector<peer_info> peers; std::vector<peer_info> peers;
t.handle.get_peer_info(peers); t.handle.get_peer_info(peers);
long total_seeds = 0; return Py_BuildValue("{s:s,s:l,s:l,s:l,s:l,s:f,s:f,s:d,s:f,s:l,s:l,s:s,s:s,s:f,s:d,s:l,s:l,s:l,s:d,s:l,s:l,s:l,s:l,s:l,s:l,s:d,s:d}",
long total_peers = 0; "name", t.handle.get_torrent_info().name().c_str(),
"num_files", t.handle.get_torrent_info().num_files(),
for (unsigned long i = 0; i < peers.size(); i++) "state", s.state,
if (peers[i].seed) "num_peers", s.num_peers,
total_seeds++; "num_seeds", s.num_seeds,
else "distributed_copies", s.distributed_copies,
total_peers++; "download_rate", s.download_rate,
"total_download", double(s.total_download),
return Py_BuildValue("{s:s,s:l,s:l,s:l,s:l,s:f,s:f,s:d,s:f,s:l,s:l,s:s,s:s,s:f,s:d,s:l,s:l,s:l,s:d,s:l,s:l,s:l,s:l,s:l,s:l,s:d,s:d,s:l,s:l}", "upload_rate", s.upload_rate,
"name", t.handle.get_torrent_info().name().c_str(), "total_upload", long(s.total_upload),
"num_files", t.handle.get_torrent_info().num_files(), "tracker_ok", !s.current_tracker.empty(),
"state", s.state, "next_announce", boost::posix_time::to_simple_string(s.next_announce).c_str(),
"num_peers", s.num_peers, "tracker", s.current_tracker.c_str(),
"num_seeds", s.num_seeds, "progress", float(s.progress),
"distributed_copies", s.distributed_copies, "total_done", double(s.total_done),
"download_rate", s.download_rate, "pieces", long(s.pieces),
"total_download", double(s.total_download), "pieces_done", long(s.num_pieces),
"upload_rate", s.upload_rate, "block_size", long(s.block_size),
"total_upload", long(s.total_upload), "total_size", double(i.total_size()),
"tracker_ok", !s.current_tracker.empty(), "piece_length", long(i.piece_length()),
"next_announce", boost::posix_time::to_simple_string(s.next_announce).c_str(), "num_pieces", long(i.num_pieces()),
"tracker", s.current_tracker.c_str(), "total_peers", long(s.num_incomplete != -1? s.num_incomplete : s.num_peers),
"progress", float(s.progress), "total_seeds", long(s.num_complete != -1? s.num_complete : s.num_seeds),
"total_done", double(s.total_done), "is_paused", long(t.handle.is_paused()),
"pieces", long(s.pieces), "is_seed", long(t.handle.is_seed()),
"pieces_done", long(s.num_pieces), "total_wanted", double(s.total_wanted),
"block_size", long(s.block_size), "total_wanted_done", double(s.total_wanted_done));
"total_size", double(i.total_size()),
"piece_length", long(i.piece_length()),
"num_pieces", long(i.num_pieces()),
"total_seeds", total_seeds,
"total_peers", total_peers,
"is_paused", long(t.handle.is_paused()),
"is_seed", long(t.handle.is_seed()),
"total_wanted", double(s.total_wanted),
"total_wanted_done", double(s.total_wanted_done),
"num_complete", long(s.num_complete),
"num_incomplete", long(s.num_incomplete));
}; };
static PyObject *torrent_pop_event(PyObject *self, PyObject *args) static PyObject *torrent_pop_event(PyObject *self, PyObject *args)