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

ES-1992: Replace deprecated methods with recommended usage #75

Merged
merged 1 commit into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
Expand Up @@ -78,7 +78,7 @@ public String call(@NotNull ClientRequestBody requestBody) {
StateAndRef<AppleStamp> appleStampStateAndRef;
try {
appleStampStateAndRef = utxoLedgerService
.findUnconsumedStatesByType(AppleStamp.class)
.findUnconsumedStatesByExactType(AppleStamp.class, 100, Instant.now()).getResults()
.stream()
.filter(stateAndRef -> stateAndRef.getState().getContractState().getId().equals(stampId))
.iterator()
Expand All @@ -90,7 +90,7 @@ public String call(@NotNull ClientRequestBody requestBody) {
StateAndRef<BasketOfApples> basketOfApplesStampStateAndRef;
try {
basketOfApplesStampStateAndRef = utxoLedgerService
.findUnconsumedStatesByType(BasketOfApples.class)
.findUnconsumedStatesByExactType(BasketOfApples.class, 100, Instant.now()).getResults()
.stream()
.filter(
stateAndRef -> stateAndRef.getState().getContractState().getOwner().equals(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<StateAndRef<ChatState>> chatStateAndRefs = ledgerService.findUnconsumedStatesByType(ChatState.class);
List<StateAndRef<ChatState>> chatStateAndRefs = ledgerService.findUnconsumedStatesByExactType(ChatState.class, 100, Instant.now()).getResults();
List<StateAndRef<ChatState>> 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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.time.Instant;
import java.util.*;
import java.util.stream.Collectors;

Expand All @@ -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<StateAndRef<ChatState>> states = utxoLedgerService.findUnconsumedStatesByType(ChatState.class);
List<StateAndRef<ChatState>> states = utxoLedgerService.findUnconsumedStatesByExactType(ChatState.class, 100, Instant.now()).getResults();
List<ChatStateResults> results = states.stream().map( stateAndRef ->
new ChatStateResults(
stateAndRef.getState().getContractState().getId(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<StateAndRef<ChatState>> chatStateAndRefs = ledgerService.findUnconsumedStatesByType(ChatState.class);
List<StateAndRef<ChatState>> chatStateAndRefs = ledgerService.findUnconsumedStatesByExactType(ChatState.class, 100, Instant.now()).getResults();
List<StateAndRef<ChatState>> 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");
Expand Down
Loading