+ public void addPreKeys(ServiceIdType serviceIdType, List<PreKeyRecord> records) {
+ if (serviceIdType.equals(ServiceIdType.ACI)) {
+ addAciPreKeys(records);
+ } else {
+ addPniPreKeys(records);
+ }
+ }
+
+ public void addAciPreKeys(List<PreKeyRecord> records) {
+ for (var record : records) {
+ if (aciPreKeyIdOffset != record.getId()) {
+ logger.error("Invalid pre key id {}, expected {}", record.getId(), aciPreKeyIdOffset);
+ throw new AssertionError("Invalid pre key id");
+ }
+ getAciPreKeyStore().storePreKey(record.getId(), record);
+ aciPreKeyIdOffset = (aciPreKeyIdOffset + 1) % Medium.MAX_VALUE;
+ }
+ save();
+ }
+
+ public void addPniPreKeys(List<PreKeyRecord> records) {