Source:
private boolean addProtectedStorageEntry(ProtectedStorageEntry protectedStorageEntry, @Nullable NodeAddress sender, @Nullable BroadcastHandler.Listener listener, boolean allowBroadcast) { ProtectedStoragePayload protectedStoragePayload = protectedStorageEntry.getProtectedStoragePayload(); ByteArray hashOfPayload = get32ByteHashAsByteArray(protectedStoragePayload); if (protectedStoragePayload instanceof AddOncePayload && removedAddOncePayloads.contains(hashOfPayload)) { log.warn("We have already removed that AddOncePayload by a previous removeDataMessage. " + "We ignore that message. ProtectedStoragePayload: {}", protectedStoragePayload.toString()); return false; } if (protectedStorageEntry.isExpired(clock)) { log.warn("We received an expired protectedStorageEntry from ppper {}. getCreationTimeStamp={}, protectedStorageEntry={}", sender != null ? sender.getFullAddress() : "sender is null", new Date(protectedStorageEntry.getCreationTimeStamp()), protectedStorageEntry); return false; } ProtectedStorageEntry storedEntry = map.get(hashOfPayload); if (storedEntry != null && !hasSequenceNrIncreased(protectedStorageEntry.getSequenceNumber(), hashOfPayload)) { return false; } MapValue sequenceNumberMapValue = sequenceNumberMap.get(hashOfPayload); if (sequenceNumberMapValue != null && protectedStorageEntry.getSequenceNumber() < sequenceNumberMapValue.sequenceNr) { return false; } if (!protectedStorageEntry.isValidForAddOperation()) return false; if (storedEntry != null && !protectedStorageEntry.matchesRelevantPubKey(storedEntry)) return false; map.put(hashOfPayload, protectedStorageEntry); hashMapChangedListeners.forEach(e -> e.onAdded(Collections.singletonList(protectedStorageEntry))); sequenceNumberMap.put(hashOfPayload, new MapValue(protectedStorageEntry.getSequenceNumber(), this.clock.millis())); sequenceNumberMapStorage.queueUpForSave(SequenceNumberMap.clone(sequenceNumberMap), 2000); if (allowBroadcast) broadcaster.broadcast(new AddDataMessage(protectedStorageEntry), sender, listener); if (protectedStoragePayload instanceof PersistablePayload) protectedDataStoreService.put(hashOfPayload, protectedStorageEntry); return true; }

Target:
private boolean addProtectedStorageEntry(ProtectedStorageEntry protectedStorageEntry, @Nullable NodeAddress sender, @Nullable BroadcastHandler.Listener listener, boolean allowBroadcast) { ProtectedStoragePayload protectedStoragePayload = protectedStorageEntry.getProtectedStoragePayload(); ByteArray hashOfPayload = get32ByteHashAsByteArray(protectedStoragePayload); if (protectedStoragePayload instanceof AddOncePayload && removedAddOncePayloads.contains(hashOfPayload)) { log.warn("We have already removed that AddOncePayload by a previous removeDataMessage. " + "We ignore that message. ProtectedStoragePayload: {}", protectedStoragePayload.toString()); return false; } if (protectedStorageEntry.isExpired(clock)) { log.warn("We received an expired protectedStorageEntry from peer {}. getCreationTimeStamp={}, protectedStorageEntry={}", sender != null ? sender.getFullAddress() : "sender is null", new Date(protectedStorageEntry.getCreationTimeStamp()), protectedStorageEntry); return false; } ProtectedStorageEntry storedEntry = map.get(hashOfPayload); if (storedEntry != null && !hasSequenceNrIncreased(protectedStorageEntry.getSequenceNumber(), hashOfPayload)) { return false; } MapValue sequenceNumberMapValue = sequenceNumberMap.get(hashOfPayload); if (sequenceNumberMapValue != null && protectedStorageEntry.getSequenceNumber() < sequenceNumberMapValue.sequenceNr) { return false; } if (!protectedStorageEntry.isValidForAddOperation()) return false; if (storedEntry != null && !protectedStorageEntry.matchesRelevantPubKey(storedEntry)) return false; map.put(hashOfPayload, protectedStorageEntry); hashMapChangedListeners.forEach(e -> e.onAdded(Collections.singletonList(protectedStorageEntry))); sequenceNumberMap.put(hashOfPayload, new MapValue(protectedStorageEntry.getSequenceNumber(), this.clock.millis())); sequenceNumberMapStorage.queueUpForSave(SequenceNumberMap.clone(sequenceNumberMap), 2000); if (allowBroadcast) broadcaster.broadcast(new AddDataMessage(protectedStorageEntry), sender, listener); if (protectedStoragePayload instanceof PersistablePayload) protectedDataStoreService.put(hashOfPayload, protectedStorageEntry); return true; }