From 85b562449906f4847ca69e7d85f3859f9eba563c Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Wed, 5 Jul 2023 17:05:41 +0200 Subject: [PATCH] Only keep most recent signatures for datum in CertificationSet --- .../pgpainless/wot/dijkstra/sq/CertificationSet.kt | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/dijkstra/sq/CertificationSet.kt b/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/dijkstra/sq/CertificationSet.kt index 4c23f040..5b558791 100644 --- a/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/dijkstra/sq/CertificationSet.kt +++ b/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/dijkstra/sq/CertificationSet.kt @@ -77,6 +77,7 @@ class CertificationSet( /** * Add a single [Certification] into this objects [certifications]. + * If there are already some [Cer] * * @param certification [Certification] with the same issuer fingerprint and target fingerprint as this object. */ @@ -89,7 +90,18 @@ class CertificationSet( certificationsForUserId = ArrayList() _certifications[certification.userId] = certificationsForUserId } - certificationsForUserId.add(certification) + + if (certificationsForUserId.isEmpty()) { + certificationsForUserId.add(certification) + return + } + + val existing = certificationsForUserId[0] + if (existing.creationTime.before(certification.creationTime)) { + certificationsForUserId.clear() // throw away older certifications + certificationsForUserId.add(certification) + } + // else this certification is older, so ignore } override fun toString(): String {