I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 0bcbe6ae authored by zzz's avatar zzz
Browse files
      - Change file limit to 512 (was 256)
      - Change size limit to 10GB (was 5GB)
      - Change request size to 16KB (was 32KB)
      - Change pipeline to 5 (was 3)
parent ae83b420
No related branches found
No related tags found
No related merge requests found
...@@ -23,6 +23,8 @@ package org.klomp.snark; ...@@ -23,6 +23,8 @@ package org.klomp.snark;
import java.util.Iterator; import java.util.Iterator;
import java.util.TimerTask; import java.util.TimerTask;
import net.i2p.data.DataHelper;
/** /**
* TimerTask that monitors the peers and total up/download speeds. * TimerTask that monitors the peers and total up/download speeds.
* Works together with the main Snark class to report periodical statistics. * Works together with the main Snark class to report periodical statistics.
...@@ -83,21 +85,12 @@ class PeerMonitorTask extends TimerTask ...@@ -83,21 +85,12 @@ class PeerMonitorTask extends TimerTask
// Print some statistics // Print some statistics
long downloaded = coordinator.getDownloaded(); long downloaded = coordinator.getDownloaded();
String totalDown; String totalDown = DataHelper.formatSize(downloaded) + "B";
if (downloaded >= 10 * 1024 * 1024)
totalDown = (downloaded / (1024 * 1024)) + "MB";
else
totalDown = (downloaded / 1024 )+ "KB";
long uploaded = coordinator.getUploaded(); long uploaded = coordinator.getUploaded();
String totalUp; String totalUp = DataHelper.formatSize(uploaded) + "B";
if (uploaded >= 10 * 1024 * 1024)
totalUp = (uploaded / (1024 * 1024)) + "MB";
else
totalUp = (uploaded / 1024) + "KB";
int needP = coordinator.storage.needed(); int needP = coordinator.storage.needed();
long needMB long needMB = needP * coordinator.metainfo.getPieceLength(0) / (1024 * 1024);
= needP * coordinator.metainfo.getPieceLength(0) / (1024 * 1024);
int totalP = coordinator.metainfo.getPieces(); int totalP = coordinator.metainfo.getPieces();
long totalMB = coordinator.metainfo.getTotalLength() / (1024 * 1024); long totalMB = coordinator.metainfo.getTotalLength() / (1024 * 1024);
......
...@@ -60,9 +60,9 @@ class PeerState ...@@ -60,9 +60,9 @@ class PeerState
// If we have te resend outstanding requests (true after we got choked). // If we have te resend outstanding requests (true after we got choked).
private boolean resend = false; private boolean resend = false;
private final static int MAX_PIPELINE = 3; // this is for outbound requests private final static int MAX_PIPELINE = 5; // this is for outbound requests
private final static int MAX_PIPELINE_BYTES = 128*1024; // this is for inbound requests private final static int MAX_PIPELINE_BYTES = 128*1024; // this is for inbound requests
public final static int PARTSIZE = 32*1024; // Snark was 16K, i2p-bt uses 64KB public final static int PARTSIZE = 16*1024; // outbound request
private final static int MAX_PARTSIZE = 64*1024; // Don't let anybody request more than this private final static int MAX_PARTSIZE = 64*1024; // Don't let anybody request more than this
PeerState(Peer peer, PeerListener listener, MetaInfo metainfo, PeerState(Peer peer, PeerListener listener, MetaInfo metainfo,
......
...@@ -362,7 +362,7 @@ public class SnarkManager implements Snark.CompleteListener { ...@@ -362,7 +362,7 @@ public class SnarkManager implements Snark.CompleteListener {
public Properties getConfig() { return _config; } public Properties getConfig() { return _config; }
/** hardcoded for sanity. perhaps this should be customizable, for people who increase their ulimit, etc. */ /** hardcoded for sanity. perhaps this should be customizable, for people who increase their ulimit, etc. */
private static final int MAX_FILES_PER_TORRENT = 256; private static final int MAX_FILES_PER_TORRENT = 512;
/** set of filenames that we are dealing with */ /** set of filenames that we are dealing with */
public Set listTorrentFiles() { synchronized (_snarks) { return new HashSet(_snarks.keySet()); } } public Set listTorrentFiles() { synchronized (_snarks) { return new HashSet(_snarks.keySet()); } }
...@@ -543,16 +543,18 @@ public class SnarkManager implements Snark.CompleteListener { ...@@ -543,16 +543,18 @@ public class SnarkManager implements Snark.CompleteListener {
return "Too many files in " + info.getName() + " (" + files.size() + "), deleting it"; return "Too many files in " + info.getName() + " (" + files.size() + "), deleting it";
} else if (info.getPieces() <= 0) { } else if (info.getPieces() <= 0) {
return "No pieces in " + info.getName() + "? deleting it"; return "No pieces in " + info.getName() + "? deleting it";
} else if (info.getPieceLength(0) > 1*1024*1024) { } else if (info.getPieceLength(0) > Storage.MAX_PIECE_SIZE) {
return "Pieces are too large in " + info.getName() + " (" + info.getPieceLength(0)/1024 + "KB), deleting it"; return "Pieces are too large in " + info.getName() + " (" + DataHelper.formatSize(info.getPieceLength(0)) +
} else if (info.getTotalLength() > 10*1024*1024*1024l) { "B), deleting it";
} else if (info.getTotalLength() > Storage.MAX_TOTAL_SIZE) {
System.out.println("torrent info: " + info.toString()); System.out.println("torrent info: " + info.toString());
List lengths = info.getLengths(); List lengths = info.getLengths();
if (lengths != null) if (lengths != null)
for (int i = 0; i < lengths.size(); i++) for (int i = 0; i < lengths.size(); i++)
System.out.println("File " + i + " is " + lengths.get(i) + " long"); System.out.println("File " + i + " is " + lengths.get(i) + " long");
return "Torrents larger than 10GB are not supported yet (because we're paranoid): " + info.getName() + ", deleting it"; return "Torrents larger than " + DataHelper.formatSize(Storage.MAX_TOTAL_SIZE) +
"B are not supported yet (because we're paranoid): " + info.getName() + ", deleting it";
} else { } else {
// ok // ok
return null; return null;
...@@ -637,8 +639,7 @@ public class SnarkManager implements Snark.CompleteListener { ...@@ -637,8 +639,7 @@ public class SnarkManager implements Snark.CompleteListener {
public void torrentComplete(Snark snark) { public void torrentComplete(Snark snark) {
File f = new File(snark.torrent); File f = new File(snark.torrent);
long len = snark.meta.getTotalLength(); long len = snark.meta.getTotalLength();
addMessage("Download complete of " + f.getName() addMessage("Download complete of " + f.getName() + " (size: " + DataHelper.formatSize(len) + "B)");
+ (len < 5*1024*1024 ? " (size: " + (len/1024) + "KB)" : " (size: " + (len/(1024*1024l)) + "MB)"));
updateStatus(snark); updateStatus(snark);
} }
......
...@@ -56,10 +56,11 @@ public class Storage ...@@ -56,10 +56,11 @@ public class Storage
boolean changed; boolean changed;
/** The default piece size. */ /** The default piece size. */
private static int MIN_PIECE_SIZE = 256*1024; private static final int MIN_PIECE_SIZE = 256*1024;
private static int MAX_PIECE_SIZE = 1024*1024; public static final int MAX_PIECE_SIZE = 1024*1024;
/** The maximum number of pieces in a torrent. */ /** The maximum number of pieces in a torrent. */
private static long MAX_PIECES = 100*1024/20; public static final int MAX_PIECES = 10*1024;
public static final long MAX_TOTAL_SIZE = MAX_PIECE_SIZE * (long) MAX_PIECES;
/** /**
* Creates a new storage based on the supplied MetaInfo. This will * Creates a new storage based on the supplied MetaInfo. This will
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment