Discussion:
[libtorrent] writing pieces from peer_plugin
Bedeho Mender
2016-11-08 14:55:34 UTC
Permalink
There is no direct way to write a piece to disk from a peer_plugin, you
seem to have to use torrent_handle::add_piece(..). However, this leave no
link between the piece and the peer, and hence the
peer_plugin::on_piece_pass/fail cannot be invoked.

Is there a way to add a full pieces from a peer such that the relevant
peer_plugin::on_piece_pass/fail are actually called?

An alternative is to hook into torrent_plugin::::on_piece_pass/fail, but it
has overhead of having to maintain explicit piece=>peer mapping.

Bedeho

Arvid Norberg
2016-11-14 01:36:49 UTC
Permalink
Post by Bedeho Mender
There is no direct way to write a piece to disk from a peer_plugin, you
seem to have to use torrent_handle::add_piece(..). However, this leave no
link between the piece and the peer, and hence the
peer_plugin::on_piece_pass/fail cannot be invoked.
Is there a way to add a full pieces from a peer such that the relevant
peer_plugin::on_piece_pass/fail are actually called?
The way this used to work was for the plugin to call
peer_connection::incoming_piece(). With Steven's cleanup of the plugin
interface, that function isn't exposed. It should probably be added to
peer_connection_handle to support this use case.
--
Arvid Norberg
Steven Siloti
2016-11-14 01:52:31 UTC
Permalink
Post by Arvid Norberg
Post by Bedeho Mender
There is no direct way to write a piece to disk from a peer_plugin, you
seem to have to use torrent_handle::add_piece(..). However, this leave no
link between the piece and the peer, and hence the
peer_plugin::on_piece_pass/fail cannot be invoked.
Is there a way to add a full pieces from a peer such that the relevant
peer_plugin::on_piece_pass/fail are actually called?
The way this used to work was for the plugin to call
peer_connection::incoming_piece(). With Steven's cleanup of the plugin
interface, that function isn't exposed. It should probably be added to
peer_connection_handle to support this use case.
--
Arvid Norberg
As long as you're building your plugin as part of libtorrent you can use
peer_connection_handle::native_handle() to gain access to
peer_connection::incoming_piece(). If you want to build your plugin
separately then incoming_piece will need to be added to
peer_connection_handle.
Bedeho Mender
2016-11-14 10:47:33 UTC
Permalink
Thanks Arvid & Steven,

By 'part of libtorrent', do you mean that it is an actual plugin which runs
on the libtorrent thread?
if so, then yes, if no, then I am not sure. We are certainly not trying to
add pieces on a peer from the user thread.

On the proposed solution of peer_connection::incoming_piece(peer_request):

1) are you sure it will not be a problem that libtorrent has not requested
this piece, and thus that peer_request will not be familiar?
2) are you sure that it will not be a problem that we are talking about a
full piece, not just a block, which is what peer_request typically
describes?

this otherwise looks like an excellent solution, so I hope it works.


Post by Steven Siloti
Post by Arvid Norberg
Post by Bedeho Mender
There is no direct way to write a piece to disk from a peer_plugin, you
seem to have to use torrent_handle::add_piece(..). However, this leave
no
Post by Arvid Norberg
Post by Bedeho Mender
link between the piece and the peer, and hence the
peer_plugin::on_piece_pass/fail cannot be invoked.
Is there a way to add a full pieces from a peer such that the relevant
peer_plugin::on_piece_pass/fail are actually called?
The way this used to work was for the plugin to call
peer_connection::incoming_piece(). With Steven's cleanup of the plugin
interface, that function isn't exposed. It should probably be added to
peer_connection_handle to support this use case.
--
Arvid Norberg
As long as you're building your plugin as part of libtorrent you can use
peer_connection_handle::native_handle() to gain access to
peer_connection::incoming_piece(). If you want to build your plugin
separately then incoming_piece will need to be added to
peer_connection_handle.
------------------------------------------------------------
------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
Libtorrent-discuss mailing list
https://lists.sourceforge.net/lists/listinfo/libtorrent-discuss
Loading...