added reject and suggest hooks to peer plugins
This commit is contained in:
parent
15a193d363
commit
bdd14cc155
|
@ -149,6 +149,12 @@ namespace libtorrent
|
|||
virtual bool on_cancel(peer_request const& req)
|
||||
{ return false; }
|
||||
|
||||
virtual bool on_reject(peer_request const& req)
|
||||
{ return false; }
|
||||
|
||||
virtual bool on_suggest(int index)
|
||||
{ return false; }
|
||||
|
||||
// called when an extended message is received. If returning true,
|
||||
// the message is not processed by any other plugin and if false
|
||||
// is returned the next plugin in the chain will receive it to
|
||||
|
|
|
@ -687,6 +687,14 @@ namespace libtorrent
|
|||
boost::shared_ptr<torrent> t = m_torrent.lock();
|
||||
assert(t);
|
||||
|
||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||
for (extension_list_t::iterator i = m_extensions.begin()
|
||||
, end(m_extensions.end()); i != end; ++i)
|
||||
{
|
||||
if ((*i)->on_reject(r)) return;
|
||||
}
|
||||
#endif
|
||||
|
||||
std::deque<piece_block>::iterator i = std::find_if(
|
||||
m_download_queue.begin(), m_download_queue.end()
|
||||
, bind(match_request, boost::cref(r), _1, t->block_size()));
|
||||
|
@ -743,7 +751,7 @@ namespace libtorrent
|
|||
void peer_connection::incoming_suggest(int index)
|
||||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
(*m_logger) << time_now_string()
|
||||
<< " <== SUGGEST_PIECE [ piece: " << index << " ]\n";
|
||||
|
@ -751,6 +759,14 @@ namespace libtorrent
|
|||
boost::shared_ptr<torrent> t = m_torrent.lock();
|
||||
if (!t) return;
|
||||
|
||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||
for (extension_list_t::iterator i = m_extensions.begin()
|
||||
, end(m_extensions.end()); i != end; ++i)
|
||||
{
|
||||
if ((*i)->on_suggest(index)) return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (t->have_piece(index)) return;
|
||||
|
||||
if (m_suggested_pieces.size() > 9)
|
||||
|
|
Loading…
Reference in New Issue