Skip to content

Commit

Permalink
Merge branch 'i2p.i2p.2.4.0-reverse-throttler' into 'master'
Browse files Browse the repository at this point in the history
I2p.i2p.2.4.0 reverse throttler

Closes #453

See merge request i2p-hackers/i2p.i2p!145
  • Loading branch information
eyedeekay committed Nov 7, 2023
2 parents 3db4f23 + 57eb706 commit ea8b3f0
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ public Job createJob(I2NPMessage receivedMessage, RouterIdentity from, Hash from
_context.statManager().addRateData("netDb.nonFFLookupsDropped", 1);
return null;
}
if ((!_facade.shouldThrottleLookup(dlm.getFrom(), dlm.getReplyTunnel())
&& !_facade.shouldThrottleBurstLookup(dlm.getFrom(), dlm.getReplyTunnel()))
if (!_facade.shouldThrottleLookup(dlm.getFrom(), dlm.getReplyTunnel())
|| _context.routerHash().equals(dlm.getFrom())) {
Job j = new HandleFloodfillDatabaseLookupMessageJob(_context, dlm, from, fromHash, _msgIDBloomXor);
// if (false) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ public class FloodfillNetworkDatabaseFacade extends KademliaNetworkDatabaseFacad
private final Set<Hash> _verifiesInProgress;
private FloodThrottler _floodThrottler;
private LookupThrottler _lookupThrottler;
private LookupThrottler _lookupThrottlerBurst;
private final Job _ffMonitor;
private final int DROP_LOOKUP_BURST = 10;
private final int DROP_LOOKUP_BURST_INTERVAL = 30*1000;

/**
* This is the flood redundancy. Entries are
Expand Down Expand Up @@ -112,7 +109,6 @@ public synchronized void startup() {
} else {
isFF = _context.getBooleanProperty(FloodfillMonitorJob.PROP_FLOODFILL_PARTICIPANT);
_lookupThrottler = new LookupThrottler();
_lookupThrottlerBurst = new LookupThrottler(DROP_LOOKUP_BURST, DROP_LOOKUP_BURST_INTERVAL);
}

long down = _context.router().getEstimatedDowntime();
Expand Down Expand Up @@ -240,11 +236,6 @@ boolean shouldThrottleLookup(Hash from, TunnelId id) {
return _lookupThrottler == null || _lookupThrottler.shouldThrottle(from, id);
}

boolean shouldThrottleBurstLookup(Hash from, TunnelId id) {
// null before startup
return _lookupThrottlerBurst == null || _lookupThrottlerBurst.shouldThrottle(from, id);
}

/**
* If we are floodfill AND the key is not throttled,
* flood it, otherwise don't.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ class LookupThrottler {
private final int MAX_LOOKUPS; // DEFAULT=20
private final long CLEAN_TIME; // DEFAULT=3*60*1000
LookupThrottler() {
MAX_LOOKUPS = 20;
CLEAN_TIME = 3*60*1000;
MAX_LOOKUPS = 14;
CLEAN_TIME = 2*60*1000;
this.counter = new ObjectCounter<ReplyTunnel>();
SimpleTimer2.getInstance().addPeriodicEvent(new Cleaner(), CLEAN_TIME);
}
Expand Down

0 comments on commit ea8b3f0

Please sign in to comment.