forked from Qortal/qortal
Prune peers every 5 minutes instead of every cycle of the Controller thread.
This should reduce the amount of time the allKnownPeers lock is held.
This commit is contained in:
parent
d81071f254
commit
5db0fa080b
@ -113,6 +113,7 @@ public class Controller extends Thread {
|
|||||||
private long repositoryBackupTimestamp = startTime; // ms
|
private long repositoryBackupTimestamp = startTime; // ms
|
||||||
private long repositoryMaintenanceTimestamp = startTime; // ms
|
private long repositoryMaintenanceTimestamp = startTime; // ms
|
||||||
private long repositoryCheckpointTimestamp = startTime; // ms
|
private long repositoryCheckpointTimestamp = startTime; // ms
|
||||||
|
private long prunePeersTimestamp = startTime; // ms
|
||||||
private long ntpCheckTimestamp = startTime; // ms
|
private long ntpCheckTimestamp = startTime; // ms
|
||||||
private long deleteExpiredTimestamp = startTime + DELETE_EXPIRED_INTERVAL; // ms
|
private long deleteExpiredTimestamp = startTime + DELETE_EXPIRED_INTERVAL; // ms
|
||||||
|
|
||||||
@ -552,6 +553,7 @@ public class Controller extends Thread {
|
|||||||
final long repositoryBackupInterval = Settings.getInstance().getRepositoryBackupInterval();
|
final long repositoryBackupInterval = Settings.getInstance().getRepositoryBackupInterval();
|
||||||
final long repositoryCheckpointInterval = Settings.getInstance().getRepositoryCheckpointInterval();
|
final long repositoryCheckpointInterval = Settings.getInstance().getRepositoryCheckpointInterval();
|
||||||
long repositoryMaintenanceInterval = getRandomRepositoryMaintenanceInterval();
|
long repositoryMaintenanceInterval = getRandomRepositoryMaintenanceInterval();
|
||||||
|
final long prunePeersInterval = 5 * 60 * 1000L; // Every 5 minutes
|
||||||
|
|
||||||
// Start executor service for trimming or pruning
|
// Start executor service for trimming or pruning
|
||||||
PruneManager.getInstance().start();
|
PruneManager.getInstance().start();
|
||||||
@ -649,10 +651,15 @@ public class Controller extends Thread {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Prune stuck/slow/old peers
|
// Prune stuck/slow/old peers
|
||||||
try {
|
if (now >= prunePeersTimestamp + prunePeersInterval) {
|
||||||
Network.getInstance().prunePeers();
|
prunePeersTimestamp = now + prunePeersInterval;
|
||||||
} catch (DataException e) {
|
|
||||||
LOGGER.warn(String.format("Repository issue when trying to prune peers: %s", e.getMessage()));
|
try {
|
||||||
|
LOGGER.debug("Pruning peers...");
|
||||||
|
Network.getInstance().prunePeers();
|
||||||
|
} catch (DataException e) {
|
||||||
|
LOGGER.warn(String.format("Repository issue when trying to prune peers: %s", e.getMessage()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete expired transactions
|
// Delete expired transactions
|
||||||
|
Loading…
Reference in New Issue
Block a user