examples/appnet-api-server/src/main/java/com/hedera/hashgraph/identity/hcs/example/appnet/AppnetStorage.java
/**
    * Stores a newly received credential status change message in local storage.
    * Before storing it, validates if the message is not a duplicate and if it is valid.
    *
    * @param envelope The credential status change message in an envelope.
  */
Stores a newly received credential status change message in local storage.
Before storing it, validates if the message is not a duplicate and if it is valid.

@param envelope The credential status change message in an envelope.
Stores a newly received credential status change message in local storage . Before storing it validates if the message is not a duplicate and if it is valid . @param envelope The credential status change message in an envelope .
public void storeVcStatus(final MessageEnvelope<HcsVcMessage> envelope) {
    if (envelope == null) {
      log.warn("Empty envelope received, message ignored.");
      return;
    }
    if (signatures.contains(envelope.getSignature())) {
      log.warn("Duplicate message signature detected, message ignored: " + envelope.getSignature());
      return;
    }
    signatures.add(envelope.getSignature());
    persistSignatures();
    HcsVcMessage msg = envelope.open();
    MessageEnvelope<HcsVcMessage> existing = vcStorage.get(msg.getCredentialHash());
    if (existing != null
            && (envelope.getConsensusTimestamp().isBefore(existing.getConsensusTimestamp())
            || (HcsVcOperation.REVOKE.equals(existing.open().getOperation())
            && !HcsVcOperation.REVOKE.equals(msg.getOperation())))) {
      log.warn("Outdated VC message received, ignored.");
      return;
    }
    log.info("New VC message " + msg.getOperation() + " received for: " + msg.getCredentialHash());
    vcStorage.put(msg.getCredentialHash(), envelope);
    persistVCs(msg.getTimestamp());
  }
public void storeVcStatus ( final MessageEnvelope < HcsVcMessage > envelope ) { if ( envelope == null ) { log . warn ( "Empty envelope received, message ignored." ) ; return ; } if ( signatures . contains ( envelope . getSignature ( ) ) ) { log . warn ( "Duplicate message signature detected, message ignored: " + envelope . getSignature ( ) ) ; return ; } signatures . add ( envelope . getSignature ( ) ) ; persistSignatures ( ) ; HcsVcMessage msg = envelope . open ( ) ; MessageEnvelope < HcsVcMessage > existing = vcStorage . get ( msg . getCredentialHash ( ) ) ; if ( existing != null && ( envelope . getConsensusTimestamp ( ) . isBefore ( existing . getConsensusTimestamp ( ) ) || ( HcsVcOperation . REVOKE . equals ( existing . open ( ) . getOperation ( ) ) && ! HcsVcOperation . REVOKE . equals ( msg . getOperation ( ) ) ) ) ) { log . warn ( "Outdated VC message received, ignored." ) ; return ; } log . info ( "New VC message " + msg . getOperation ( ) + " received for: " + msg . getCredentialHash ( ) ) ; vcStorage . put ( msg . getCredentialHash ( ) , envelope ) ; persistVCs ( msg . getTimestamp ( ) ) ; }
Stores a newly received credential status change message in local storage.
Stores a newly received credential status change message in local storage .
// Skip messages that are older than the once collected or if we already have a REVOKED message