public void run() { directory.loadFromStore(); directory.waitUntilLoaded(); setCurrentConsensus(directory.getCurrentConsensusDocument()); while (!isStopped) { checkCertificates(); checkConsensus(); checkDescriptors(); try { Thread.sleep(5000); } catch (InterruptedException e) { Thread.currentThread().interrupt(); return; } } }
private void checkCertificates() { if (isDownloadingCertificates || directory.getRequiredCertificates().isEmpty()) { return; } isDownloadingCertificates = true; executor.execute(new DownloadCertificatesTask()); }
private boolean needConsensusDownload() { if (directory.hasPendingConsensus()) { return false; } if (currentConsensus == null || !currentConsensus.isLive()) { if (currentConsensus == null) { logger.info("Downloading consensus because we have no consensus document"); } else { logger.info("Downloading consensus because the document we have is not live"); } return true; } return consensusDownloadTime.before(new Date()); }