[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [onionoo/master] Try harder not to look up host names repeatedly.



commit 6a75fb77a174cdde424206ed078309b16c61e3eb
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date:   Mon Jun 18 20:20:28 2012 +0200

    Try harder not to look up host names repeatedly.
---
 src/org/torproject/onionoo/CurrentNodes.java |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/org/torproject/onionoo/CurrentNodes.java b/src/org/torproject/onionoo/CurrentNodes.java
index 0cfcbf6..489ca97 100644
--- a/src/org/torproject/onionoo/CurrentNodes.java
+++ b/src/org/torproject/onionoo/CurrentNodes.java
@@ -274,14 +274,21 @@ public class CurrentNodes {
       String address, SortedSet<String> orAddressesAndPorts,
       SortedSet<String> exitAddresses, long validAfterMillis, int orPort,
       int dirPort, SortedSet<String> relayFlags, long consensusWeight,
-      String countryCode, String hostname, long lastRdnsLookup) {
+      String countryCode, String hostName, long lastRdnsLookup) {
     if (validAfterMillis >= cutoff &&
         (!this.currentRelays.containsKey(fingerprint) ||
         this.currentRelays.get(fingerprint).getLastSeenMillis() <
         validAfterMillis)) {
+      Node previousRelay = this.currentRelays.containsKey(fingerprint)
+          ? this.currentRelays.get(fingerprint) : null;
+      if (previousRelay != null && hostName == null &&
+          previousRelay.getAddress().equals(address)) {
+        hostName = previousRelay.getHostName();
+        lastRdnsLookup = previousRelay.getLastRdnsLookup();
+      }
       Node entry = new Node(nickname, fingerprint, address,
           orAddressesAndPorts, exitAddresses, validAfterMillis, orPort,
-          dirPort, relayFlags, consensusWeight, countryCode, hostname,
+          dirPort, relayFlags, consensusWeight, countryCode, hostName,
           lastRdnsLookup);
       this.currentRelays.put(fingerprint, entry);
       if (validAfterMillis > this.lastValidAfterMillis) {

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits