utxo comment out sections removed

This commit is contained in:
mattbradburyr3 2023-01-29 20:59:03 +00:00
parent 6e703bca2e
commit de9f94e9b2
5 changed files with 1 additions and 92 deletions

View File

@ -1,16 +1,11 @@
package com.r3.developers.csdetemplate.utxoexample.workflows;
import net.corda.v5.base.annotations.ConstructorForDeserialization;
import net.corda.v5.base.annotations.CordaSerializable;
//@CordaSerializable
public class GetChatResponse {
private String messageFrom;
private String message;
public GetChatResponse() {}
// @ConstructorForDeserialization
public GetChatResponse(String messageFrom, String message) {
this.messageFrom = messageFrom;
this.message = message;
@ -20,17 +15,7 @@ public class GetChatResponse {
return messageFrom;
}
// public void setMessageFrom(String messageFrom) {
// this.messageFrom = messageFrom;
// }
public String getMessage() {
return message;
}
// public void setMessage(String message) {
// this.message = message;
// }
}

View File

@ -2,17 +2,12 @@ package com.r3.developers.csdetemplate.utxoexample.workflows;
import com.r3.developers.csdetemplate.utxoexample.states.ChatState;
import net.corda.v5.application.flows.CordaInject;
import net.corda.v5.application.flows.FlowEngine;
import net.corda.v5.application.flows.RPCRequestData;
import net.corda.v5.application.flows.RPCStartableFlow;
import net.corda.v5.application.marshalling.JsonMarshallingService;
import net.corda.v5.application.membership.MemberLookup;
import net.corda.v5.application.messaging.FlowMessaging;
import net.corda.v5.base.annotations.Suspendable;
import net.corda.v5.ledger.common.NotaryLookup;
import net.corda.v5.ledger.utxo.StateAndRef;
import net.corda.v5.ledger.utxo.UtxoLedgerService;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -29,7 +24,6 @@ public class ListChatsFlow implements RPCStartableFlow{
@CordaInject
public UtxoLedgerService utxoLedgerService;
// @NotNull
@Suspendable
@Override
public String call(RPCRequestData requestBody) {

View File

@ -1,32 +0,0 @@
package com.r3.developers.csdetemplate.utxoexample.workflows;
import com.r3.developers.csdetemplate.utxoexample.states.ChatState;
import net.corda.v5.base.annotations.Suspendable;
import net.corda.v5.base.types.MemberX500Name;
import java.util.Arrays;
import java.util.List;
// I think we should avoid static imports, it's an extra level of complexity we don't need to add.
// The Kotlin helper functions are more simple because Kotlin supports functions which are in the package but
// not in a class.
//public final class ResponderValidationHelpers {
// public final static List<String> bannedWords = Arrays.asList("banana", "apple", "pear");
//
// @Suspendable
// public static boolean checkForBannedWords(String str) {
// return bannedWords.stream().anyMatch(str::contains);
// }
// @Suspendable
// public static boolean checkMessageFromMatchesCounterparty(ChatState state, MemberX500Name otherMember) {
// return state.getMessageFrom().equals(otherMember);
// }
// This class just introduces a scope for some helper functions and should not be instantiated.
// private ResponderValidationHelpers() {}
//}

View File

@ -8,23 +8,19 @@ import net.corda.v5.application.flows.RPCRequestData;
import net.corda.v5.application.flows.RPCStartableFlow;
import net.corda.v5.application.marshalling.JsonMarshallingService;
import net.corda.v5.application.membership.MemberLookup;
import net.corda.v5.application.messaging.FlowMessaging;
import net.corda.v5.base.annotations.Suspendable;
import net.corda.v5.base.exceptions.CordaRuntimeException;
import net.corda.v5.ledger.common.NotaryLookup;
import net.corda.v5.ledger.utxo.StateAndRef;
import net.corda.v5.ledger.utxo.UtxoLedgerService;
import net.corda.v5.ledger.utxo.transaction.UtxoSignedTransaction;
import net.corda.v5.ledger.utxo.transaction.UtxoTransactionBuilder;
import net.corda.v5.membership.MemberInfo;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.time.Duration;
import java.time.Instant;
import java.util.List;
import java.util.stream.Collectors;
import static java.util.Objects.*;
import static java.util.stream.Collectors.toList;
@ -42,17 +38,9 @@ public class UpdateChatFlow implements RPCStartableFlow {
@CordaInject
public UtxoLedgerService ledgerService;
// @CordaInject
// public NotaryLookup notaryLookup;
//
// @CordaInject
// public FlowMessaging flowMessaging;
@CordaInject
public FlowEngine flowEngine;
// @NotNull // this is a jetbrains annotation - we don't want to depend on jet brains packages.
@Suspendable
@Override
public String call(RPCRequestData requestBody) {
@ -62,16 +50,6 @@ public class UpdateChatFlow implements RPCStartableFlow {
try {
UpdateChatFlowArgs flowArgs = requestBody.getRequestBodyAs(jsonMarshallingService, UpdateChatFlowArgs.class);
// Look up state (this is very inefficient)
// Removing this because it's an unnecessary level of abstraction, as it's an example for all abilities of programmer
// we want it to be as straight forward as possible.
// Also it's inconsistent with code below it.
// StateAndRef<ChatState> stateAndRef = findAndExpectExactlyOne(
// ledgerService.findUnconsumedStatesByType(ChatState.class),
// sAndR -> sAndR.getState().getContractState().getId().equals(flowArgs.getId()),
// "Multiple or zero Chat states with id " + flowArgs.getId() + " found"
// );
List<StateAndRef<ChatState>> chatStateAndRefs = ledgerService.findUnconsumedStatesByType(ChatState.class);
List<StateAndRef<ChatState>> chatStateAndRefsWithId = chatStateAndRefs.stream()
.filter(sar -> sar.getState().getContractState().getId().equals(flowArgs.getId())).collect(toList());
@ -86,7 +64,6 @@ public class UpdateChatFlow implements RPCStartableFlow {
it -> requireNonNull(memberLookup.lookup(it), "Member not found from public Key "+ it + ".")
).collect(toList());
// Now we want to check that there is only one member other than ourselves in the chat.
members.remove(myInfo);
if(members.size() != 1) throw new RuntimeException("Should be only one participant other than the initiator");

View File

@ -1,17 +1,13 @@
package com.r3.developers.csdetemplate.utxoexample.workflows;
import net.corda.v5.base.annotations.ConstructorForDeserialization;
import net.corda.v5.base.annotations.CordaSerializable;
import java.util.UUID;
//@CordaSerializable
public class UpdateChatFlowArgs {
public UpdateChatFlowArgs() {}
private UUID id;
private String message;
// @ConstructorForDeserialization
public UpdateChatFlowArgs(UUID id, String message) {
this.id = id;
this.message = message;
@ -21,18 +17,7 @@ public class UpdateChatFlowArgs {
return id;
}
// public void setId(UUID id) {
// this.id = id;
// }
public String getMessage() {
return message;
}
// public void setMessage(String message) {
// this.message = message;
// }
}