Changeset 3cac01ff


Ignore:
Timestamp:
Aug 17, 2012 2:09:49 PM (8 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
3a54661
Parents:
e015216
Message:
  • i2psnark:
    • Adjust DHT timeouts
    • Add max peers per-torrent in tracker
    • Remove duplicate clean task for nodes
    • Fix another DHT warning message
Location:
apps/i2psnark/java/src/org/klomp/snark
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • apps/i2psnark/java/src/org/klomp/snark/SnarkManager.java

    re015216 r3cac01ff  
    826826                        if (info.isPrivate()) {
    827827                            addMessage(_("ERROR - No I2P trackers in private torrent \"{0}\"", info.getName()));
    828                         } else if (_util.shouldUseOpenTrackers() && _util.getOpenTrackers() != null) {
     828                        } else if (!_util.getOpenTrackers().isEmpty()) {
    829829                            addMessage(_("Warning - No I2P trackers in \"{0}\", will announce to I2P open trackers and DHT only.", info.getName()));
    830830                            //addMessage(_("Warning - No I2P trackers in \"{0}\", will announce to I2P open trackers only.", info.getName()));
     
    909909            torrent.startTorrent();
    910910            addMessage(_("Fetching {0}", name));
    911             boolean haveSavedPeers = false;
    912             if ((_util.connected()) && !haveSavedPeers) {
    913                 addMessage(_("We have no saved peers and no other torrents are running. " +
    914                              "Fetch of {0} will not succeed until you start another torrent.", name));
     911            DHT dht = _util.getDHT();
     912            boolean shouldWarn = _util.connected() &&
     913                                 _util.getOpenTrackers().isEmpty() &&
     914                                 ((!_util.shouldUseDHT()) || dht == null || dht.size() <= 0);
     915            if (shouldWarn) {
     916                addMessage(_("Open trackers are disabled and we have no DHT peers. " +
     917                             "Fetch of {0} may not succeed until you start another torrent, enable open trackers, or enable DHT.", name));
    915918            }
    916919        } else {
  • apps/i2psnark/java/src/org/klomp/snark/dht/DHTNodes.java

    re015216 r3cac01ff  
    3939
    4040    /** stagger with other cleaners */
    41     private static final long CLEAN_TIME = 237*1000;
    42     private static final long MAX_EXPIRE_TIME = 60*60*1000;
    43     private static final long MIN_EXPIRE_TIME = 5*60*1000;
    44     private static final long DELTA_EXPIRE_TIME = 7*60*1000;
    45     private static final int MAX_PEERS = 999;
     41    private static final long CLEAN_TIME = 187*1000;
     42    /** how long since last heard from do we delete  - BEP 5 says 15 minutes */
     43    private static final long MAX_EXPIRE_TIME = 30*60*1000;
     44    private static final long MIN_EXPIRE_TIME = 10*60*1000;
     45    private static final long DELTA_EXPIRE_TIME = 3*60*1000;
     46    private static final int MAX_PEERS = 799;
    4647
    4748    public DHTNodes(I2PAppContext ctx, NID me) {
  • apps/i2psnark/java/src/org/klomp/snark/dht/DHTTracker.java

    re015216 r3cac01ff  
    3535    /** stagger with other cleaners */
    3636    private static final long CLEAN_TIME = 199*1000;
    37     /** make this longer than postman's tracker */
    38     private static final long MAX_EXPIRE_TIME = 95*60*1000;
    39     private static final long MIN_EXPIRE_TIME = 5*60*1000;
    40     private static final long DELTA_EXPIRE_TIME = 7*60*1000;
     37    private static final long MAX_EXPIRE_TIME = 45*60*1000;
     38    private static final long MIN_EXPIRE_TIME = 15*60*1000;
     39    private static final long DELTA_EXPIRE_TIME = 3*60*1000;
    4140    private static final int MAX_PEERS = 2000;
     41    private static final int MAX_PEERS_PER_TORRENT = 150;
    4242
    4343    DHTTracker(I2PAppContext ctx) {
     
    135135                     }
    136136                }
    137                 if (recent <= 0)
     137                if (recent > MAX_PEERS_PER_TORRENT) {
     138                    // too many, delete at random
     139                    // TODO per-torrent adjustable expiration?
     140                    for (Iterator<Peer> iterp = p.values().iterator(); iterp.hasNext() && p.size() > MAX_PEERS_PER_TORRENT; ) {
     141                         iterp.next();
     142                         iterp.remove();
     143                         peerCount--;
     144                    }
     145                    torrentCount++;
     146                } else if (recent <= 0) {
    138147                    iter.remove();
    139                 else
     148                } else {
    140149                    torrentCount++;
     150                }
    141151            }
    142152
  • apps/i2psnark/java/src/org/klomp/snark/dht/KRPC.java

    re015216 r3cac01ff  
    136136    public static final boolean SECURE_NID = true;
    137137
    138     /** how long since last heard from do we delete  - BEP 5 says 15 minutes */
    139     private static final long MAX_NODEINFO_AGE = 60*60*1000;
    140138    /** how long since generated do we delete - BEP 5 says 10 minutes */
    141     private static final long MAX_TOKEN_AGE = 60*60*1000;
     139    private static final long MAX_TOKEN_AGE = 15*60*1000;
    142140    private static final long MAX_INBOUND_TOKEN_AGE = MAX_TOKEN_AGE - 5*60*1000;
    143141    /** how long since sent do we wait for a reply */
     
    14701468            }
    14711469            // TODO sent queries?
    1472             for (Iterator<NodeInfo> iter = _knownNodes.values().iterator(); iter.hasNext(); ) {
    1473                 NodeInfo ni = iter.next();
    1474                 if (ni.lastSeen() < now - MAX_NODEINFO_AGE)
    1475                     iter.remove();
    1476             }
    14771470            if (_log.shouldLog(Log.DEBUG))
    14781471                _log.debug("KRPC cleaner done, now with " +
  • apps/i2psnark/java/src/org/klomp/snark/dht/Peers.java

    re015216 r3cac01ff  
    1717
    1818    public Peers() {
    19         super();
     19        super(8);
    2020    }
    2121}
Note: See TracChangeset for help on using the changeset viewer.