Skip to content

Commit

Permalink
Improve ipns publisher logging
Browse files Browse the repository at this point in the history
  • Loading branch information
ianopolous committed Dec 21, 2023
1 parent 638589f commit d4c7aea
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/main/java/org/peergos/IpnsPublisher.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,20 @@ public static void main(String[] a) throws Exception {
.map(line -> KeyKt.unmarshalPrivateKey(ArrayOps.hexToBytes(line.split(" ")[0])))
.collect(Collectors.toList());

System.out.println("Resolving " + keys.size() + " keys");
for (int c=0; c < 100; c++) {
long t0 = System.currentTimeMillis();
List<Integer> recordCounts = resolve(keys, ipfs);
Files.write(Paths.get("publish-resolve-counts-" + LocalDateTime.now().withNano(0) + ".txt"), recordCounts.stream()
.map(i -> i.toString())
.collect(Collectors.toList()));
Path resultsFile = Paths.get("publish-resolve-counts-" + LocalDateTime.now().withNano(0) + ".txt");
Files.write(resultsFile,
recordCounts.stream()
.map(Object::toString)
.collect(Collectors.toList()));
long t1 = System.currentTimeMillis();
System.out.println("Resolved " + recordCounts.stream().filter(n -> n > 0).count() + "/" + recordCounts.size()
+ " in " + (t1-t0)/1000 + "s");
String total = "Resolved " + recordCounts.stream().filter(n -> n > 0).count() + "/" + recordCounts.size()
+ " in " + (t1 - t0) / 1000 + "s";
System.out.println(total);
Files.write(resultsFile, total.getBytes(), StandardOpenOption.APPEND);
}
} else {
keys = IntStream.range(0, keycount)
Expand Down Expand Up @@ -104,9 +109,13 @@ public static Stream<PublishResult> publish(List<PrivKey> publishers, byte[] val

public static List<Integer> resolve(List<PrivKey> publishers, EmbeddedIpfs ipfs) {
List<Integer> res = new ArrayList<>();
int done = 0;
for (PrivKey publisher : publishers) {
List<IpnsRecord> records = ipfs.resolveRecords(publisher.publicKey(), 30);
res.add(records.size());
done++;
if (done % 10 == 0)
System.out.println("resolved " + done);
}
return res;
}
Expand Down

0 comments on commit d4c7aea

Please sign in to comment.