public void addTorrent(SharedTorrent torrent) throws IOException, InterruptedException { torrent.init(); if (!torrent.isInitialized()) { torrent.close(); return; } this.torrents.put(torrent.getHexInfoHash(), torrent); // Initial completion test if (torrent.isComplete()) { torrent.setClientState(ClientState.SEEDING); } else { torrent.setClientState(ClientState.SHARING); } this.announce.addTorrent(torrent, this); }