mirror of
https://github.com/pgpainless/pgpainless.git
synced 2025-12-16 17:21:08 +01:00
SubkeyLookup: Switch to batch inserting
This commit is contained in:
parent
d53d62a6e9
commit
1495baaf6e
9 changed files with 110 additions and 86 deletions
|
|
@ -6,7 +6,9 @@ package org.pgpainless.certificate_store;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import pgp.cert_d.SharedPGPCertificateDirectory;
|
||||
|
|
@ -106,18 +108,16 @@ public class SharedPGPCertificateDirectoryAdapter
|
|||
return;
|
||||
}
|
||||
String fingerprint = certificate.getFingerprint();
|
||||
for (Long subkeyId : certificate.getSubkeyIds()) {
|
||||
storeIdentifierForSubkeyId(subkeyId, fingerprint);
|
||||
}
|
||||
storeCertificateSubkeyIds(fingerprint, new ArrayList<>(certificate.getSubkeyIds()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getIdentifiersForSubkeyId(long subkeyId) throws IOException {
|
||||
return subkeyLookup.getIdentifiersForSubkeyId(subkeyId);
|
||||
public Set<String> getCertificatesForSubkeyId(long subkeyId) throws IOException {
|
||||
return subkeyLookup.getCertificatesForSubkeyId(subkeyId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void storeIdentifierForSubkeyId(long subkeyId, String identifier) throws IOException {
|
||||
subkeyLookup.storeIdentifierForSubkeyId(subkeyId, identifier);
|
||||
public void storeCertificateSubkeyIds(String certificate, List<Long> subkeyIds) throws IOException {
|
||||
subkeyLookup.storeCertificateSubkeyIds(certificate, subkeyIds);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ public class SharedPGPCertificateDirectoryAdapterTest {
|
|||
Set<Long> subkeys = certificate.getSubkeyIds();
|
||||
assertEquals(expectedSubkeys, subkeys);
|
||||
for (long subkey : subkeys) {
|
||||
assertEquals(Collections.singleton(fingerprint), store.getIdentifiersForSubkeyId(subkey));
|
||||
assertEquals(Collections.singleton(fingerprint), store.getCertificatesForSubkeyId(subkey));
|
||||
}
|
||||
|
||||
Certificate retrieved = store.getCertificate(fingerprint);
|
||||
|
|
@ -108,7 +108,7 @@ public class SharedPGPCertificateDirectoryAdapterTest {
|
|||
Set<Long> subkeys = certificate.getSubkeyIds();
|
||||
assertEquals(3, subkeys.size());
|
||||
for (long subkey : subkeys) {
|
||||
assertEquals(Collections.singleton(fingerprint), store.getIdentifiersForSubkeyId(subkey));
|
||||
assertEquals(Collections.singleton(fingerprint), store.getCertificatesForSubkeyId(subkey));
|
||||
}
|
||||
|
||||
Certificate retrieved = store.getCertificate(fingerprint);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue