[tor-commits] [collector/master] Switch to streamlined digest methods.

karsten at torproject.org karsten at torproject.org
Wed May 17 14:32:37 UTC 2017


commit 807cfeb5b29518ebcdadf83b2d70eee1c49a5104
Author: Karsten Loesing <karsten.loesing at gmx.net>
Date:   Sat May 13 20:39:09 2017 +0200

    Switch to streamlined digest methods.
---
 .../collector/persist/BridgeExtraInfoPersistence.java       |  2 +-
 .../persist/BridgeServerDescriptorPersistence.java          |  2 +-
 .../torproject/collector/persist/ExtraInfoPersistence.java  |  2 +-
 .../collector/persist/ServerDescriptorPersistence.java      |  2 +-
 .../torproject/collector/relaydescs/ReferenceChecker.java   | 13 +++++++------
 5 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/src/main/java/org/torproject/collector/persist/BridgeExtraInfoPersistence.java b/src/main/java/org/torproject/collector/persist/BridgeExtraInfoPersistence.java
index 72db7c5..5bab4c0 100644
--- a/src/main/java/org/torproject/collector/persist/BridgeExtraInfoPersistence.java
+++ b/src/main/java/org/torproject/collector/persist/BridgeExtraInfoPersistence.java
@@ -24,7 +24,7 @@ public class BridgeExtraInfoPersistence
         BRIDGEDESCS,
         EXTRA_INFOS,
         file + DASH + EXTRA_INFOS).toString();
-    String digest = desc.getExtraInfoDigest().toLowerCase();
+    String digest = desc.getDigestSha1Hex().toLowerCase();
     this.storagePath = Paths.get(
         BRIDGEDESCS,
         parts[0], // year
diff --git a/src/main/java/org/torproject/collector/persist/BridgeServerDescriptorPersistence.java b/src/main/java/org/torproject/collector/persist/BridgeServerDescriptorPersistence.java
index f1abb98..3b4227e 100644
--- a/src/main/java/org/torproject/collector/persist/BridgeServerDescriptorPersistence.java
+++ b/src/main/java/org/torproject/collector/persist/BridgeServerDescriptorPersistence.java
@@ -24,7 +24,7 @@ public class BridgeServerDescriptorPersistence
         BRIDGEDESCS,
         SERVERDESCS,
         file + DASH + SERVERDESCS).toString();
-    String digest = desc.getServerDescriptorDigest().toLowerCase();
+    String digest = desc.getDigestSha1Hex().toLowerCase();
     this.storagePath = Paths.get(
         BRIDGEDESCS,
         parts[0], // year
diff --git a/src/main/java/org/torproject/collector/persist/ExtraInfoPersistence.java b/src/main/java/org/torproject/collector/persist/ExtraInfoPersistence.java
index 9a944a7..a6ae774 100644
--- a/src/main/java/org/torproject/collector/persist/ExtraInfoPersistence.java
+++ b/src/main/java/org/torproject/collector/persist/ExtraInfoPersistence.java
@@ -24,7 +24,7 @@ public class ExtraInfoPersistence
         RELAYDESCS,
         EXTRA_INFOS,
         file + DASH + EXTRA_INFOS).toString();
-    String digest = desc.getExtraInfoDigest();
+    String digest = desc.getDigestSha1Hex();
     this.storagePath = Paths.get(
         RELAYDESCS,
         EXTRA_INFO,
diff --git a/src/main/java/org/torproject/collector/persist/ServerDescriptorPersistence.java b/src/main/java/org/torproject/collector/persist/ServerDescriptorPersistence.java
index 642da7b..e1adfbc 100644
--- a/src/main/java/org/torproject/collector/persist/ServerDescriptorPersistence.java
+++ b/src/main/java/org/torproject/collector/persist/ServerDescriptorPersistence.java
@@ -26,7 +26,7 @@ public class ServerDescriptorPersistence
         RELAY_DESCRIPTORS,
         SERVERDESCS,
         file + DASH + SERVERDESCS).toString();
-    String digest = desc.getServerDescriptorDigest();
+    String digest = desc.getDigestSha1Hex();
     this.storagePath = Paths.get(
         RELAY_DESCRIPTORS,
         SERVERDESC,
diff --git a/src/main/java/org/torproject/collector/relaydescs/ReferenceChecker.java b/src/main/java/org/torproject/collector/relaydescs/ReferenceChecker.java
index 1b0025b..59db27f 100644
--- a/src/main/java/org/torproject/collector/relaydescs/ReferenceChecker.java
+++ b/src/main/java/org/torproject/collector/relaydescs/ReferenceChecker.java
@@ -238,7 +238,7 @@ public class ReferenceChecker {
         / ((double) consensus.getStatusEntries().size());
     for (NetworkStatusEntry entry :
         consensus.getStatusEntries().values()) {
-      for (String digest : entry.getMicrodescriptorDigests()) {
+      for (String digest : entry.getMicrodescriptorDigestsSha256Base64()) {
         this.addReference(referencing, String.format("D-%s", digest),
             entryWeight, entry.getPublishedMillis() + THREE_HOURS);
       }
@@ -259,23 +259,24 @@ public class ReferenceChecker {
   }
 
   private void readServerDescriptor(ServerDescriptor serverDescriptor) {
-    String referenced = serverDescriptor.getExtraInfoDigest() == null ? ""
-        : String.format("E-%s", serverDescriptor.getExtraInfoDigest());
+    String referenced = serverDescriptor.getExtraInfoDigestSha1Hex() == null
+        ? "" : String.format("E-%s",
+        serverDescriptor.getExtraInfoDigestSha1Hex());
     this.addReference(String.format("S-%s",
-        serverDescriptor.getServerDescriptorDigest()), referenced, 0.01,
+        serverDescriptor.getDigestSha1Hex()), referenced, 0.01,
         serverDescriptor.getPublishedMillis() + SIX_HOURS);
   }
 
   private void readExtraInfoDescriptor(
       ExtraInfoDescriptor extraInfoDescriptor) {
     this.addReference(String.format("E-%s",
-        extraInfoDescriptor.getExtraInfoDigest()), "", 0.005,
+        extraInfoDescriptor.getDigestSha1Hex()), "", 0.005,
         extraInfoDescriptor.getPublishedMillis() + SIX_HOURS);
   }
 
   private void readMicrodescriptor(Microdescriptor microdesc) {
     this.addReference(
-        String.format("D-%s", microdesc.getMicrodescriptorDigest()), "",
+        String.format("D-%s", microdesc.getDigestSha256Base64()), "",
         0.0, this.currentTimeMillis + THIRTY_DAYS);
   }
 



More information about the tor-commits mailing list