diff --git a/workflows/src/main/java/com/r3/developers/apples/workflows/RedeemApplesFlow.java b/workflows/src/main/java/com/r3/developers/apples/workflows/RedeemApplesFlow.java index dd5e0fd..70c2d41 100644 --- a/workflows/src/main/java/com/r3/developers/apples/workflows/RedeemApplesFlow.java +++ b/workflows/src/main/java/com/r3/developers/apples/workflows/RedeemApplesFlow.java @@ -78,7 +78,7 @@ public String call(@NotNull ClientRequestBody requestBody) { StateAndRef appleStampStateAndRef; try { appleStampStateAndRef = utxoLedgerService - .findUnconsumedStatesByType(AppleStamp.class) + .findUnconsumedStatesByExactType(AppleStamp.class, 100, Instant.now()).getResults() .stream() .filter(stateAndRef -> stateAndRef.getState().getContractState().getId().equals(stampId)) .iterator() @@ -90,7 +90,7 @@ public String call(@NotNull ClientRequestBody requestBody) { StateAndRef basketOfApplesStampStateAndRef; try { basketOfApplesStampStateAndRef = utxoLedgerService - .findUnconsumedStatesByType(BasketOfApples.class) + .findUnconsumedStatesByExactType(BasketOfApples.class, 100, Instant.now()).getResults() .stream() .filter( stateAndRef -> stateAndRef.getState().getContractState().getOwner().equals( diff --git a/workflows/src/main/java/com/r3/developers/cordapptemplate/utxoexample/workflows/GetChatFlow.java b/workflows/src/main/java/com/r3/developers/cordapptemplate/utxoexample/workflows/GetChatFlow.java index 2f32d7f..61d301d 100644 --- a/workflows/src/main/java/com/r3/developers/cordapptemplate/utxoexample/workflows/GetChatFlow.java +++ b/workflows/src/main/java/com/r3/developers/cordapptemplate/utxoexample/workflows/GetChatFlow.java @@ -14,6 +14,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.time.Instant; import java.util.*; import static java.util.Objects.*; import static java.util.stream.Collectors.toList; @@ -41,7 +42,7 @@ public String call(ClientRequestBody requestBody) { // Note, this code brings all unconsumed states back, then filters them. // This is an inefficient way to perform this operation when there are a large number of chats. // Note, you will get this error if you input an id which has no corresponding ChatState (common error). - List> chatStateAndRefs = ledgerService.findUnconsumedStatesByType(ChatState.class); + List> chatStateAndRefs = ledgerService.findUnconsumedStatesByExactType(ChatState.class, 100, Instant.now()).getResults(); List> chatStateAndRefsWithId = chatStateAndRefs.stream() .filter(sar -> sar.getState().getContractState().getId().equals(flowArgs.getId())).collect(toList()); if (chatStateAndRefsWithId.size() != 1) throw new CordaRuntimeException("Multiple or zero Chat states with id " + flowArgs.getId() + " found"); diff --git a/workflows/src/main/java/com/r3/developers/cordapptemplate/utxoexample/workflows/ListChatsFlow.java b/workflows/src/main/java/com/r3/developers/cordapptemplate/utxoexample/workflows/ListChatsFlow.java index b2fab36..f8e7aa0 100644 --- a/workflows/src/main/java/com/r3/developers/cordapptemplate/utxoexample/workflows/ListChatsFlow.java +++ b/workflows/src/main/java/com/r3/developers/cordapptemplate/utxoexample/workflows/ListChatsFlow.java @@ -11,6 +11,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.time.Instant; import java.util.*; import java.util.stream.Collectors; @@ -33,7 +34,7 @@ public String call(ClientRequestBody requestBody) { log.info("ListChatsFlow.call() called"); // Queries the VNode's vault for unconsumed states and converts the result to a serializable DTO. - List> states = utxoLedgerService.findUnconsumedStatesByType(ChatState.class); + List> states = utxoLedgerService.findUnconsumedStatesByExactType(ChatState.class, 100, Instant.now()).getResults(); List results = states.stream().map( stateAndRef -> new ChatStateResults( stateAndRef.getState().getContractState().getId(), diff --git a/workflows/src/main/java/com/r3/developers/cordapptemplate/utxoexample/workflows/UpdateChatFlow.java b/workflows/src/main/java/com/r3/developers/cordapptemplate/utxoexample/workflows/UpdateChatFlow.java index 96f7d8b..69d2273 100644 --- a/workflows/src/main/java/com/r3/developers/cordapptemplate/utxoexample/workflows/UpdateChatFlow.java +++ b/workflows/src/main/java/com/r3/developers/cordapptemplate/utxoexample/workflows/UpdateChatFlow.java @@ -58,7 +58,7 @@ public String call(ClientRequestBody requestBody) { // Note, this code brings all unconsumed states back, then filters them. // This is an inefficient way to perform this operation when there are a large number of chats. // Note, you will get this error if you input an id which has no corresponding ChatState (common error). - List> chatStateAndRefs = ledgerService.findUnconsumedStatesByType(ChatState.class); + List> chatStateAndRefs = ledgerService.findUnconsumedStatesByExactType(ChatState.class, 100, Instant.now()).getResults(); List> chatStateAndRefsWithId = chatStateAndRefs.stream() .filter(sar -> sar.getState().getContractState().getId().equals(flowArgs.getId())).collect(toList()); if (chatStateAndRefsWithId.size() != 1) throw new CordaRuntimeException("Multiple or zero Chat states with id " + flowArgs.getId() + " found");