mpetazzoni / ttorrent

BitTorrent Java library with tracker and download client
http://mpetazzoni.github.com/ttorrent/
Apache License 2.0
1.38k stars 502 forks source link

Adding Seeders in v2.0 #227

Closed asadsm closed 5 years ago

asadsm commented 5 years ago

In v 1.5 I used the following code to start a seeder:

Client seeder = new Client(InetAddress.getLocalHost(), new SharedTorrent(torrent, new File(dirName), true));

In v 2.0 I'm using the following but this goes through the whole process of validation. Is there a way to avoid that? seeder.downloadTorrentAsync(torrentFile.getAbsolutePath(), torrentFile.getParent(), InetAddress.getLocalHost());

Basically calling the downloadTorrent on the machine which contains the initial data to torrent. Any way to avoid this download path?

Dead-off commented 5 years ago

SimpleClient doesn't support it, you can use CommunicationManager

ExecutorService workingExecutor = Executors.newFixedThreadPool(8);
ExecutorService validatorExecutor = Executors.newFixedThreadPool(8);
CommunicationManager cm = new CommunicationManager(workingExecutor, validatorExecutor);
cm.start(InetAddress.getLocalHost());
cm.addTorrent("/path/to/torrent", "/path/to/data/dir", FullyPieceStorageFactory.INSTANCE)
//don't forget to shutdown executors when you will stop your program, 

So library will skip validation and mark all pieces as valid.

asadsm commented 5 years ago

Perfect. Thanks!