utxo comment out sections removed
This commit is contained in:
parent
6e703bca2e
commit
de9f94e9b2
@ -1,16 +1,11 @@
|
|||||||
package com.r3.developers.csdetemplate.utxoexample.workflows;
|
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 {
|
public class GetChatResponse {
|
||||||
|
|
||||||
private String messageFrom;
|
private String messageFrom;
|
||||||
private String message;
|
private String message;
|
||||||
public GetChatResponse() {}
|
public GetChatResponse() {}
|
||||||
|
|
||||||
// @ConstructorForDeserialization
|
|
||||||
public GetChatResponse(String messageFrom, String message) {
|
public GetChatResponse(String messageFrom, String message) {
|
||||||
this.messageFrom = messageFrom;
|
this.messageFrom = messageFrom;
|
||||||
this.message = message;
|
this.message = message;
|
||||||
@ -20,17 +15,7 @@ public class GetChatResponse {
|
|||||||
return messageFrom;
|
return messageFrom;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public void setMessageFrom(String messageFrom) {
|
|
||||||
// this.messageFrom = messageFrom;
|
|
||||||
// }
|
|
||||||
|
|
||||||
public String getMessage() {
|
public String getMessage() {
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public void setMessage(String message) {
|
|
||||||
// this.message = message;
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,17 +2,12 @@ package com.r3.developers.csdetemplate.utxoexample.workflows;
|
|||||||
|
|
||||||
import com.r3.developers.csdetemplate.utxoexample.states.ChatState;
|
import com.r3.developers.csdetemplate.utxoexample.states.ChatState;
|
||||||
import net.corda.v5.application.flows.CordaInject;
|
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.RPCRequestData;
|
||||||
import net.corda.v5.application.flows.RPCStartableFlow;
|
import net.corda.v5.application.flows.RPCStartableFlow;
|
||||||
import net.corda.v5.application.marshalling.JsonMarshallingService;
|
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.annotations.Suspendable;
|
||||||
import net.corda.v5.ledger.common.NotaryLookup;
|
|
||||||
import net.corda.v5.ledger.utxo.StateAndRef;
|
import net.corda.v5.ledger.utxo.StateAndRef;
|
||||||
import net.corda.v5.ledger.utxo.UtxoLedgerService;
|
import net.corda.v5.ledger.utxo.UtxoLedgerService;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -29,7 +24,6 @@ public class ListChatsFlow implements RPCStartableFlow{
|
|||||||
@CordaInject
|
@CordaInject
|
||||||
public UtxoLedgerService utxoLedgerService;
|
public UtxoLedgerService utxoLedgerService;
|
||||||
|
|
||||||
// @NotNull
|
|
||||||
@Suspendable
|
@Suspendable
|
||||||
@Override
|
@Override
|
||||||
public String call(RPCRequestData requestBody) {
|
public String call(RPCRequestData requestBody) {
|
||||||
|
@ -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() {}
|
|
||||||
|
|
||||||
//}
|
|
||||||
|
|
@ -8,23 +8,19 @@ import net.corda.v5.application.flows.RPCRequestData;
|
|||||||
import net.corda.v5.application.flows.RPCStartableFlow;
|
import net.corda.v5.application.flows.RPCStartableFlow;
|
||||||
import net.corda.v5.application.marshalling.JsonMarshallingService;
|
import net.corda.v5.application.marshalling.JsonMarshallingService;
|
||||||
import net.corda.v5.application.membership.MemberLookup;
|
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.annotations.Suspendable;
|
||||||
import net.corda.v5.base.exceptions.CordaRuntimeException;
|
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.StateAndRef;
|
||||||
import net.corda.v5.ledger.utxo.UtxoLedgerService;
|
import net.corda.v5.ledger.utxo.UtxoLedgerService;
|
||||||
import net.corda.v5.ledger.utxo.transaction.UtxoSignedTransaction;
|
import net.corda.v5.ledger.utxo.transaction.UtxoSignedTransaction;
|
||||||
import net.corda.v5.ledger.utxo.transaction.UtxoTransactionBuilder;
|
import net.corda.v5.ledger.utxo.transaction.UtxoTransactionBuilder;
|
||||||
import net.corda.v5.membership.MemberInfo;
|
import net.corda.v5.membership.MemberInfo;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import static java.util.Objects.*;
|
import static java.util.Objects.*;
|
||||||
import static java.util.stream.Collectors.toList;
|
import static java.util.stream.Collectors.toList;
|
||||||
@ -42,17 +38,9 @@ public class UpdateChatFlow implements RPCStartableFlow {
|
|||||||
@CordaInject
|
@CordaInject
|
||||||
public UtxoLedgerService ledgerService;
|
public UtxoLedgerService ledgerService;
|
||||||
|
|
||||||
// @CordaInject
|
|
||||||
// public NotaryLookup notaryLookup;
|
|
||||||
//
|
|
||||||
// @CordaInject
|
|
||||||
// public FlowMessaging flowMessaging;
|
|
||||||
|
|
||||||
@CordaInject
|
@CordaInject
|
||||||
public FlowEngine flowEngine;
|
public FlowEngine flowEngine;
|
||||||
|
|
||||||
|
|
||||||
// @NotNull // this is a jetbrains annotation - we don't want to depend on jet brains packages.
|
|
||||||
@Suspendable
|
@Suspendable
|
||||||
@Override
|
@Override
|
||||||
public String call(RPCRequestData requestBody) {
|
public String call(RPCRequestData requestBody) {
|
||||||
@ -62,16 +50,6 @@ public class UpdateChatFlow implements RPCStartableFlow {
|
|||||||
try {
|
try {
|
||||||
UpdateChatFlowArgs flowArgs = requestBody.getRequestBodyAs(jsonMarshallingService, UpdateChatFlowArgs.class);
|
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>> chatStateAndRefs = ledgerService.findUnconsumedStatesByType(ChatState.class);
|
||||||
List<StateAndRef<ChatState>> chatStateAndRefsWithId = chatStateAndRefs.stream()
|
List<StateAndRef<ChatState>> chatStateAndRefsWithId = chatStateAndRefs.stream()
|
||||||
.filter(sar -> sar.getState().getContractState().getId().equals(flowArgs.getId())).collect(toList());
|
.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 + ".")
|
it -> requireNonNull(memberLookup.lookup(it), "Member not found from public Key "+ it + ".")
|
||||||
).collect(toList());
|
).collect(toList());
|
||||||
|
|
||||||
// Now we want to check that there is only one member other than ourselves in the chat.
|
|
||||||
members.remove(myInfo);
|
members.remove(myInfo);
|
||||||
if(members.size() != 1) throw new RuntimeException("Should be only one participant other than the initiator");
|
if(members.size() != 1) throw new RuntimeException("Should be only one participant other than the initiator");
|
||||||
|
|
||||||
|
@ -1,17 +1,13 @@
|
|||||||
package com.r3.developers.csdetemplate.utxoexample.workflows;
|
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;
|
import java.util.UUID;
|
||||||
//@CordaSerializable
|
|
||||||
public class UpdateChatFlowArgs {
|
public class UpdateChatFlowArgs {
|
||||||
public UpdateChatFlowArgs() {}
|
public UpdateChatFlowArgs() {}
|
||||||
|
|
||||||
private UUID id;
|
private UUID id;
|
||||||
private String message;
|
private String message;
|
||||||
|
|
||||||
// @ConstructorForDeserialization
|
|
||||||
public UpdateChatFlowArgs(UUID id, String message) {
|
public UpdateChatFlowArgs(UUID id, String message) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.message = message;
|
this.message = message;
|
||||||
@ -21,18 +17,7 @@ public class UpdateChatFlowArgs {
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public void setId(UUID id) {
|
|
||||||
// this.id = id;
|
|
||||||
// }
|
|
||||||
|
|
||||||
public String getMessage() {
|
public String getMessage() {
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public void setMessage(String message) {
|
|
||||||
// this.message = message;
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user