*** empty log message ***

This commit is contained in:
Arvid Norberg 2004-01-28 11:37:46 +00:00
parent 7d1f292e67
commit 03561913df
7 changed files with 29 additions and 21 deletions

View File

@ -112,7 +112,7 @@ peers in a separate fast-resume file.</li>
<li>possibility to limit the number of connections.</li>
<li>delays have messages if there's no other outgoing traffic to the peer, and doesn't
send have messages to peers that already has the piece. This saves bandwidth.</li>
<li>Does not have any requirements on the piece order in a torrent that it resumes. This
<li>does not have any requirements on the piece order in a torrent that it resumes. This
means it can resume a torrent downloaded by any client.</li>
</ul>
</blockquote>

View File

@ -44,7 +44,7 @@ The current state includes the following features:
* possibility to limit the number of connections.
* delays have messages if there's no other outgoing traffic to the peer, and doesn't
send have messages to peers that already has the piece. This saves bandwidth.
* Does not have any requirements on the piece order in a torrent that it resumes. This
* does not have any requirements on the piece order in a torrent that it resumes. This
means it can resume a torrent downloaded by any client.
__ http://home.elp.rr.com/tur/multitracker-spec.txt

View File

@ -225,7 +225,7 @@ until reannouncing yourself.</td>
</tr>
<tr><td>uint16_t</td>
<td>port</td>
<td>The peers listen port.</td>
<td>The peer's listen port.</td>
</tr>
</tbody>
</table>
@ -260,7 +260,7 @@ scrape.</td>
<td>transaction_id</td>
<td>Randomized by client.</td>
</tr>
<tr><td>int8[20]</td>
<tr><td>int8_t[20]</td>
<td>info_hash</td>
<td>The info hash that is to be scraped.</td>
</tr>
@ -352,7 +352,7 @@ leechers.</td>
<td>Must match the transaction_id sent
from the client.</td>
</tr>
<tr><td>int8[]</td>
<tr><td>int8_t[]</td>
<td>error_string</td>
<td>The rest of the packet is a string
describing the error.</td>

View File

@ -131,7 +131,7 @@ The rest of the server reply is a variable number of the following structure:
+=============+=====================+========================================+
| int32_t | ip | The ip of a peer in the swarm. |
+-------------+---------------------+----------------------------------------+
| uint16_t | port | The peers listen port. |
| uint16_t | port | The peer's listen port. |
+-------------+---------------------+----------------------------------------+
@ -151,7 +151,7 @@ Client sends packet:
+-------------+---------------------+----------------------------------------+
| int32_t | transaction_id | Randomized by client. |
+-------------+---------------------+----------------------------------------+
| int8[20] | info_hash | The info hash that is to be scraped. |
| int8_t[20] | info_hash | The info hash that is to be scraped. |
+-------------+---------------------+----------------------------------------+
Server replies with packet:
@ -195,7 +195,7 @@ In case of a tracker error, the server replies with this packet:
| int32_t | transaction_id | Must match the transaction_id sent |
| | | from the client. |
+-------------+---------------------+----------------------------------------+
| int8[] | error_string | The rest of the packet is a string |
| int8_t[] | error_string | The rest of the packet is a string |
| | | describing the error. |
+-------------+---------------------+----------------------------------------+

View File

@ -66,8 +66,7 @@ POSSIBILITY OF SUCH DAMAGE.
// TODO: each time a block is 'taken over'
// from another peer. That peer must be given
// a chance to request another block instead.
// Where it also could become not-interested.
// a chance to become not-interested.
namespace libtorrent
{
@ -199,7 +198,8 @@ namespace libtorrent
boost::shared_ptr<libtorrent::socket> get_socket() const { return m_socket; }
const peer_id& get_peer_id() const { return m_peer_id; }
const std::vector<bool>& get_bitfield() const { return m_have_piece; }
const std::vector<bool>& get_bitfield() const
{ return m_have_piece; }
// this will cause this peer_connection to be disconnected.
// what it does is that it puts a reference to it in
@ -446,6 +446,12 @@ namespace libtorrent
// the pieces the other end have
std::vector<bool> m_have_piece;
// the number of pieces this peer
// has. Must be the same as
// std::count(m_have_piece.begin(),
// m_have_piece.end(), true)
int m_num_pieces;
// the queue of requests we have got
// from this peer
std::deque<peer_request> m_requests;

View File

@ -98,6 +98,7 @@ namespace libtorrent
, m_interesting(false)
, m_choked(true)
, m_supports_extensions(false)
, m_num_pieces(0)
, m_free_upload(0)
, m_send_quota(100)
, m_send_quota_left(100)
@ -160,6 +161,7 @@ namespace libtorrent
, m_interesting(false)
, m_choked(true)
, m_supports_extensions(false)
, m_num_pieces(0)
, m_free_upload(0)
, m_send_quota(100)
, m_send_quota_left(100)
@ -454,8 +456,9 @@ namespace libtorrent
else
{
m_have_piece[index] = true;
++m_num_pieces;
m_torrent->peer_has(index);
if (!m_torrent->have_piece(index) && !is_interesting())
m_torrent->get_policy().peer_is_interesting(*this);
@ -491,11 +494,13 @@ namespace libtorrent
if (have && !m_have_piece[i])
{
m_have_piece[i] = true;
++m_num_pieces;
piece_list.push_back(i);
}
else if (!have && m_have_piece[i])
{
m_have_piece[i] = false;
--m_num_pieces;
m_torrent->peer_lost(i);
}
}
@ -1705,6 +1710,11 @@ namespace libtorrent
void peer_connection::check_invariant() const
{
assert(has_data() == m_selector.is_writability_monitored(m_socket));
assert(m_num_pieces == std::count(
m_have_piece.begin()
, m_have_piece.end()
, true));
}
#endif

View File

@ -243,7 +243,7 @@ namespace libtorrent
i != pieces.end();
++i)
{
*i = i - pieces.begin();
*i = static_cast<int>(i - pieces.begin());
}
std::srand((unsigned int)std::time(0));
std::vector<int> targets(pieces);
@ -1333,8 +1333,6 @@ namespace libtorrent
// case 1
if (this_should_move && !other_should_move)
{
INVARIANT_CHECK;
assert(piece_index != current_slot);
const int other_slot = piece_index;
@ -1372,8 +1370,6 @@ namespace libtorrent
// case 2
else if (!this_should_move && other_should_move)
{
INVARIANT_CHECK;
assert(piece_index != current_slot);
const int other_piece = current_slot;
@ -1406,8 +1402,6 @@ namespace libtorrent
}
else if (this_should_move && other_should_move)
{
INVARIANT_CHECK;
assert(piece_index != current_slot);
assert(piece_index >= 0);
@ -1463,8 +1457,6 @@ namespace libtorrent
}
else
{
INVARIANT_CHECK;
assert(m_piece_to_slot[current_slot] == has_no_slot || piece_index != current_slot);
assert(m_slot_to_piece[current_slot] == unallocated);
assert(piece_index == unassigned || m_piece_to_slot[piece_index] == has_no_slot);