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