Corda - CommonQueryCriteria purpose of externalIds property

Viewed 100

The Corda vault API contains a class called CommonQueryCriteria which is implemented like so:

abstract class CommonQueryCriteria : QueryCriteria() {
    abstract val status: Vault.StateStatus
    open val relevancyStatus: Vault.RelevancyStatus = Vault.RelevancyStatus.ALL
    open val constraintTypes: Set<Vault.ConstraintInfo.Type> = emptySet()
    open val constraints: Set<Vault.ConstraintInfo> = emptySet()
    open val participants: List<AbstractParty>? = null
    abstract val contractStateTypes: Set<Class<out ContractState>>?
    open val externalIds: List<UUID> = emptyList()
    open val exactParticipants: List<AbstractParty>? = null
    override fun visit(parser: IQueryCriteriaParser): Collection<Predicate> {
    return parser.parseCriteria(this)
    }
}

What is the purpose of the externalIds property?

Note: This surely can't be meant to map UniqueIdentifier.externalId because:

  • There is a type mismatch (UUID vs. String?).
  • LinearStateQueryCriteria exists to query states by linearId or externalId.
2 Answers

Though, if we look at the CreateAccount flow provided by the account library, the AccountInfo is created with a UniqueIdentifier with only an id :

val newAccountInfo = AccountInfo(
         name = name,
         host = ourIdentity,
         identifier = UniqueIdentifier(id = identifier)
)

while the constructor of the UniqueIdentifier has both externalId and id:

data class UniqueIdentifier
   constructor(val externalId: String? = null, val id: UUID = UUID.randomUUID())

So, effectively, if it is true that externalId was introduced to support queries with account, the vault queries are actually using the UniqueIdentifier.id of AccountInfo and not its externalId (assuming that nobody is creating an AccountInfo manually overriding the CreateAccount() function, as I suspect).

Related