force custodian for all TRX
This commit is contained in:
parent
0fbfa69fa8
commit
f7589aa3bc
@ -7,6 +7,7 @@ import java.util.List;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import djmil.cordacheckers.VNode;
|
||||
import net.corda.v5.application.flows.CordaInject;
|
||||
import net.corda.v5.application.flows.InitiatingFlow;
|
||||
import net.corda.v5.application.flows.SubFlow;
|
||||
@ -18,6 +19,7 @@ import net.corda.v5.base.types.MemberX500Name;
|
||||
import net.corda.v5.crypto.SecureHash;
|
||||
import net.corda.v5.ledger.utxo.UtxoLedgerService;
|
||||
import net.corda.v5.ledger.utxo.transaction.UtxoSignedTransaction;
|
||||
import net.corda.v5.membership.MemberInfo;
|
||||
|
||||
@InitiatingFlow(protocol = "gamestate-commit")
|
||||
public class CommitTrx implements SubFlow<SecureHash> {
|
||||
@ -25,7 +27,7 @@ public class CommitTrx implements SubFlow<SecureHash> {
|
||||
private final static Logger log = LoggerFactory.getLogger(CommitTrx.class);
|
||||
private final UtxoSignedTransaction utxTrxCandidate;
|
||||
private final MemberX500Name counterpartyName;
|
||||
private final MemberX500Name custodyName;
|
||||
private /*final*/ MemberX500Name custodyName;
|
||||
|
||||
public CommitTrx(UtxoSignedTransaction signedTransaction, MemberX500Name counterpartyName) {
|
||||
this.utxTrxCandidate = signedTransaction;
|
||||
@ -61,6 +63,11 @@ public class CommitTrx implements SubFlow<SecureHash> {
|
||||
final FlowSession session = flowMessaging.initiateFlow(this.counterpartyName);
|
||||
List<FlowSession> sessionsList = new LinkedList<FlowSession>(Arrays.asList(session));
|
||||
|
||||
if (custodyName == null) {
|
||||
custodyName = findCustodian().getName();
|
||||
log.info("GameState: [UGLY FIX] backchain validation failure for custodian");
|
||||
}
|
||||
|
||||
if (custodyName != null) {
|
||||
sessionsList.add(flowMessaging.initiateFlow(custodyName));
|
||||
}
|
||||
@ -73,4 +80,13 @@ public class CommitTrx implements SubFlow<SecureHash> {
|
||||
log.info("GameState commit " +trxId);
|
||||
return trxId;
|
||||
}
|
||||
|
||||
@Suspendable
|
||||
MemberInfo findCustodian() {
|
||||
return memberLookup.lookup()
|
||||
.stream()
|
||||
.filter(member -> VNode.isCordaCherckersCustodian(member) )
|
||||
.reduce((a,b) -> {throw new IllegalStateException("Multiple Custodian VNodes");})
|
||||
.orElseThrow( () -> new IllegalStateException("No Custodian VNode found"));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user