forked from I2P_Developers/i2p.i2p
2007-03-08 zzz
* i2psnark changes to improve upload performance:
* Implement total uploader limit (10)
* Don't timeout non-piece messages out
* Change chunk size to 32K (was 64K)
* Change request limit to 64K (was 256K)
* i2psnark: Disconnect from seeds when complete
This commit is contained in:
@@ -287,7 +287,7 @@ public class Snark
|
||||
/*
|
||||
* Don't start a tunnel if the torrent isn't going to be started.
|
||||
* If we are starting,
|
||||
* startTorrent() will call trackerclient.start() which will force a connect.
|
||||
* startTorrent() will force a connect.
|
||||
*
|
||||
boolean ok = I2PSnarkUtil.instance().connect();
|
||||
if (!ok) fatal("Unable to connect to I2P");
|
||||
@@ -368,6 +368,9 @@ public class Snark
|
||||
activity = "Checking storage";
|
||||
storage = new Storage(meta, slistener);
|
||||
storage.check(rootDataDir);
|
||||
// have to figure out when to reopen
|
||||
// if (!start)
|
||||
// storage.close();
|
||||
}
|
||||
catch (IOException ioe)
|
||||
{
|
||||
@@ -751,4 +754,22 @@ public class Snark
|
||||
public interface CompleteListener {
|
||||
public void torrentComplete(Snark snark);
|
||||
}
|
||||
|
||||
/** Maintain a total uploader cap
|
||||
** This should be configurable
|
||||
*/
|
||||
private final static int MAX_TOTAL_UPLOADERS = 10;
|
||||
public static boolean overUploadLimit(int uploaders) {
|
||||
PeerCoordinatorSet coordinators = PeerCoordinatorSet.instance();
|
||||
if (coordinators == null || uploaders <= 0)
|
||||
return false;
|
||||
int totalUploaders = 0;
|
||||
for (Iterator iter = coordinators.iterator(); iter.hasNext(); ) {
|
||||
PeerCoordinator c = (PeerCoordinator)iter.next();
|
||||
if (!c.halted())
|
||||
totalUploaders += c.uploaders;
|
||||
}
|
||||
Snark.debug("Total uploaders: " + totalUploaders, Snark.DEBUG);
|
||||
return totalUploaders > MAX_TOTAL_UPLOADERS;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user