Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CORE-16615: introduce new api to find an unconsumed states #1260

Merged
merged 7 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"type": "record",
"name": "FindUnconsumedStatesByExactType",
"doc": "Retrieve the unconsumed visible states of specific type. This only retrieves exact type excluding its states of subclass unlike {@link FindUnconsumedStatesByExactType}. One of several types of ledger persistence request {@link LedgerPersistenceRequest}",
jennyang-r3 marked this conversation as resolved.
Show resolved Hide resolved
"namespace": "net.corda.data.ledger.persistence",
"fields": [
{
"name": "stateClassName",
"type": "string",
"doc": "The fully qualified state class name"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"net.corda.data.ledger.persistence.PersistTransactionIfDoesNotExist",
"net.corda.data.ledger.persistence.FindTransaction",
"net.corda.data.ledger.persistence.FindUnconsumedStatesByType",
"net.corda.data.ledger.persistence.FindUnconsumedStatesByExactType",
"net.corda.data.ledger.persistence.ResolveStateRefs",
"net.corda.data.ledger.persistence.UpdateTransactionStatus",
"net.corda.data.persistence.FindWithNamedQuery",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class LedgerPersistenceRequestSchemaCompatibilityTest {
"net.corda.data.ledger.persistence.PersistTransactionIfDoesNotExist",
"net.corda.data.ledger.persistence.FindTransaction",
"net.corda.data.ledger.persistence.FindUnconsumedStatesByType",
"net.corda.data.ledger.persistence.FindUnconsumedStatesByExactType",
jennyang-r3 marked this conversation as resolved.
Show resolved Hide resolved
"net.corda.data.ledger.persistence.ResolveStateRefs",
"net.corda.data.ledger.persistence.UpdateTransactionStatus",
"net.corda.data.persistence.FindWithNamedQuery",
Expand All @@ -74,6 +75,7 @@ class LedgerPersistenceRequestSchemaCompatibilityTest {
PersistTransactionIfDoesNotExist::class.java.name to PersistTransactionIfDoesNotExist.`SCHEMA$`,
FindTransaction::class.java.name to FindTransaction.`SCHEMA$`,
FindUnconsumedStatesByType::class.java.name to FindUnconsumedStatesByType.`SCHEMA$`,
FindUnconsumedStatesByExactType::class.java.name to FindUnconsumedStatesByExactType.`SCHEMA$`,
ResolveStateRefs::class.java.name to ResolveStateRefs.`SCHEMA$`,
UpdateTransactionStatus::class.java.name to UpdateTransactionStatus.`SCHEMA$`,
FindWithNamedQuery::class.java.name to FindWithNamedQuery.`SCHEMA$`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ public interface UtxoLedgerService {
UtxoFilteredTransactionBuilder filterSignedTransaction(@NotNull UtxoSignedTransaction transaction);

/**
* Finds unconsumed states of the specified {@link ContractState} type in the vault.
* Finds unconsumed states and subclasses of the states of the specified {@link ContractState} type in the vault.
* Only use this if you really care about catching all child classes, it has poor performance.
jennyang-r3 marked this conversation as resolved.
Show resolved Hide resolved
*
* @param <T> The underlying {@link ContractState} type.
* @param type The {@link ContractState} type to find in the vault.
Expand All @@ -97,6 +98,17 @@ public interface UtxoLedgerService {
@Suspendable
<T extends ContractState> List<StateAndRef<T>> findUnconsumedStatesByType(@NotNull Class<T> type);

/**
* Finds unconsumed states of the specified {@link ContractState} type in the vault.
*
* @param <T> The underlying {@link ContractState} type.
* @param type The {@link ContractState} type to find in the vault.
* @return Returns a {@link List} of {@link StateAndRef} of unconsumed states of the specified type, or an empty list if no states could be found.
*/
@NotNull
@Suspendable
<T extends ContractState> List<StateAndRef<T>> findUnconsumedStatesByExactType(@NotNull Class<T> type);

/**
* Verifies, signs, collects signatures, records and broadcasts a {@link UtxoSignedTransaction} to participants and observers.
*
Expand Down