1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-11-15 17:02:06 +01:00

Only keep most recent signatures for datum in CertificationSet

This commit is contained in:
Paul Schaub 2023-07-05 17:05:41 +02:00
parent f77522e42f
commit e478d146ad
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -77,6 +77,7 @@ class CertificationSet(
/** /**
* Add a single [Certification] into this objects [certifications]. * 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. * @param certification [Certification] with the same issuer fingerprint and target fingerprint as this object.
*/ */
@ -89,7 +90,18 @@ class CertificationSet(
certificationsForUserId = ArrayList() certificationsForUserId = ArrayList()
_certifications[certification.userId] = certificationsForUserId _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 { override fun toString(): String {