public static void main(String[] args) throws IOException, InterruptedException {
final TorrentController controller = new TorrentController(
new PeerWireProtocol(), new InMemoryTorrentStorage());
controller.start(1234);
final Torrent torrent = Torrent.load(Paths.get("test.torrent"));
System.out.println("Torrent hash is " + torrent.getHash().getString());
// controller.checkExistingData(torrent);
controller.registerTorrent(torrent);
final TorrentPeer peer = new TorrentPeer(torrent);
peer.setAddress(new InetSocketAddress(Inet4Address
.getByName("127.0.0.1"), 34096));
torrent.getSwarm().addPeer(peer);
while(true) {
Thread.sleep(1000);
System.out.println((peer.getTrafficControl().getCurrentDownloadSpeed() / 1024) + " kb/s");
//peer.getTrafficControl().setDownloadSpeedLimit(32 * 1024);
torrent.getTrafficControl().setDownloadSpeedLimit(256 * 1024);
}
// System.out.println(((StandardTorrentStrategy)
// torrent.getStrategy()).getPieceSelector()
// .selectPiece(peer));