Corda:TwoPartyTradeFlow 抛出异常 "Failed requirement: "

Corda: TwoPartyTradeFlow throws Exception "Failed requirement: "

我最近在 Java 中重新创建了交易者演示。出于某种原因,交易无法正常进行并出现错误:“java.lang.IllegalArgumentException:要求失败。”被抛出,没有进一步的信息(通常我希望看到哪个需求失败了)。代码一直运行到调用 TwoPartyTradeFlow.Seller.

这是我在流程中的代码。流从传递 "amount" 和 "otherParty" 的 API 调用。我正在检索我在另一个流程中发行的商业票据,该票据属于要与买方交易的卖方。

public Seller(int amount, Party otherParty) {
            this.buyerParty = otherParty;
            this.amount = amount;
        }

@Suspendable
@Override
public SignedTransaction call() throws FlowException {
    ServiceHub serviceHub = getServiceHub();
    Logger logger = getLogger();
    FlowSession otherPartySession = initiateFlow(buyerParty);

    StateAndRef<CommercialPaper.State> cp = serviceHub.getVaultService().queryBy(CommercialPaper.State.class).getStates().stream().findFirst().get();

    Amount<Currency> amountWithCurr = new Amount<>(amount, CHF);
    PartyAndCertificate cpOwner = serviceHub.getKeyManagementService().freshKeyAndCert(getOurIdentityAndCert(), false);
    final OpaqueBytes ref = OpaqueBytes.of((byte) 0x01);
    PartyAndReference partyAndReference = new PartyAndReference(cpOwner.getParty(), ref);

    progressTracker.setCurrentStep(RECEIVING_CASH);
    otherPartySession.send(amount);

    progressTracker.setCurrentStep(TRADING);

    TwoPartyTradeFlow.Seller seller = new TwoPartyTradeFlow.Seller(
            otherPartySession, cp, amountWithCurr, cpOwner, progressTracker.getChildProgressTracker(TRADING)
    );
    return subFlow(seller);
    }

}

这是堆栈跟踪:

[1;31mE 13:59:46+0200 [qtp527148155-115] template.DVPApi.throwException - 

java.lang.IllegalArgumentException: Failed requirement.
[m java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: Failed requirement.
        at java.util.concurrent.CompletableFuture.reportGet(Unknown Source) ~[?:1.8.0_161]
        at java.util.concurrent.CompletableFuture.get(Unknown Source) ~[?:1.8.0_161]
        at net.corda.core.internal.concurrent.CordaFutureImpl.get(CordaFutureImpl.kt) ~[corda-core-2.0.0.jar:?]
        at com.template.DVPApi.createDVP(DVPApi.java:152) [cordapp-0.1.jar:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_161]
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_161]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_161]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_161]
        at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory.invoke(ResourceMethodInvocationHandlerFactory.java:81) [jersey-server-2.25.jar:?]
        at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.run(AbstractJavaResourceMethodDispatcher.java:144) [jersey-server-2.25.jar:?]
        at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161) [jersey-server-2.25.jar:?]
        at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:160) [jersey-server-2.25.jar:?]
        at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99) [jersey-server-2.25.jar:?]
        at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389) [jersey-server-2.25.jar:?]
        at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347) [jersey-server-2.25.jar:?]
        at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102) [jersey-server-2.25.jar:?]
        at org.glassfish.jersey.server.ServerRuntime.run(ServerRuntime.java:326) [jersey-server-2.25.jar:?]
        at org.glassfish.jersey.internal.Errors.call(Errors.java:271) [jersey-common-2.25.jar:?]
        at org.glassfish.jersey.internal.Errors.call(Errors.java:267) [jersey-common-2.25.jar:?]
        at org.glassfish.jersey.internal.Errors.process(Errors.java:315) [jersey-common-2.25.jar:?]
        at org.glassfish.jersey.internal.Errors.process(Errors.java:297) [jersey-common-2.25.jar:?]
        at org.glassfish.jersey.internal.Errors.process(Errors.java:267) [jersey-common-2.25.jar:?]
        at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317) [jersey-common-2.25.jar:?]
        at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305) [jersey-server-2.25.jar:?]
        at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154) [jersey-server-2.25.jar:?]
        at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:473) [jersey-container-servlet-core-2.25.jar:?]
        at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:427) [jersey-container-servlet-core-2.25.jar:?]
        at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:388) [jersey-container-servlet-core-2.25.jar:?]
        at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:341) [jersey-container-servlet-core-2.25.jar:?]
        at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:228) [jersey-container-servlet-core-2.25.jar:?]
        at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:841) [jetty-servlet-9.4.7.v20170914.jar:9.4.7.v20170914]
        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:535) [jetty-servlet-9.4.7.v20170914.jar:9.4.7.v20170914]
        at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:188) [jetty-server-9.4.7.v20170914.jar:9.4.7.v20170914]
        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1253) [jetty-server-9.4.7.v20170914.jar:9.4.7.v20170914]
        at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:168) [jetty-server-9.4.7.v20170914.jar:9.4.7.v20170914]
        at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:473) [jetty-servlet-9.4.7.v20170914.jar:9.4.7.v20170914]
        at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:166) [jetty-server-9.4.7.v20170914.jar:9.4.7.v20170914]
        at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1155) [jetty-server-9.4.7.v20170914.jar:9.4.7.v20170914]
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) [jetty-server-9.4.7.v20170914.jar:9.4.7.v20170914]
        at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:126) [jetty-server-9.4.7.v20170914.jar:9.4.7.v20170914]
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132) [jetty-server-9.4.7.v20170914.jar:9.4.7.v20170914]
        at org.eclipse.jetty.server.Server.handle(Server.java:561) [jetty-server-9.4.7.v20170914.jar:9.4.7.v20170914]
        at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:334) [jetty-server-9.4.7.v20170914.jar:9.4.7.v20170914]
        at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251) [jetty-server-9.4.7.v20170914.jar:9.4.7.v20170914]
        at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279) [jetty-io-9.4.7.v20170914.jar:9.4.7.v20170914]
        at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:104) [jetty-io-9.4.7.v20170914.jar:9.4.7.v20170914]
        at org.eclipse.jetty.io.ChannelEndPoint.run(ChannelEndPoint.java:124) [jetty-io-9.4.7.v20170914.jar:9.4.7.v20170914]
        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:679) [jetty-util-9.4.7.v20170914.jar:9.4.7.v20170914]
        at org.eclipse.jetty.util.thread.QueuedThreadPool.run(QueuedThreadPool.java:597) [jetty-util-9.4.7.v20170914.jar:9.4.7.v20170914]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_161]
Caused by: java.lang.IllegalArgumentException: Failed requirement.

这是商业票据发行流程的代码,以防它以错误的方式发行商业票据并导致 TwoPartyTradeFlow 失败。

public CommercialPaperIssueFlow(CordaX500Name recipientName, CordaX500Name issuerName, Amount<Currency> price) {
        this.recipientName = recipientName;
        this.issuerName = issuerName;
        this.price = price;
    }

    @Suspendable
    @Override
    public SignedTransaction call() throws FlowException {

        ServiceHub serviceHub = getServiceHub();
        final Party notary = serviceHub.getNetworkMapCache().getNotaryIdentities().get(0);
        final Party recipient = serviceHub.getNetworkMapCache().getPeerByLegalName(recipientName);
        final Party issuer = serviceHub.getNetworkMapCache().getPeerByLegalName(issuerName);
        CommercialPaper abstractCP = new CommercialPaper();

        PartyAndReference partyAndReference = new PartyAndReference(issuer, ref);

        Instant maturityDate = Instant.MAX;

        final Amount<Issued<Currency>> faceValue = new Amount<Issued<Currency>>(price.getQuantity(),
                price.getDisplayTokenSize(),
                new Issued<Currency>(partyAndReference,
                        price.getToken()));


        TransactionBuilder cpBuilder = abstractCP.generateIssue(partyAndReference,
                faceValue, maturityDate, notary);

        progressTracker.setCurrentStep(ISSUING_CP);
        cpBuilder.setTimeWindow(Instant.now(), Duration.ofSeconds(100));
        SignedTransaction partiallySignedCP = serviceHub.signInitialTransaction(cpBuilder);

        SignedTransaction signedCP = subFlow(new FinalityFlow(partiallySignedCP));


        progressTracker.setCurrentStep(MOVING_CP);
        // Make transaction to move it to a new key
        TransactionBuilder transactionBuilder = new TransactionBuilder(notary);
        abstractCP.generateMove(transactionBuilder, signedCP.getTx().outRef(0), recipient);
        SignedTransaction partiallySignedMoveCP = serviceHub.signInitialTransaction(transactionBuilder);
        return subFlow(new FinalityFlow(partiallySignedMoveCP));
    }

在此先感谢您提供的任何帮助,因为我真的不知道为什么会出现此错误。

编辑: 这是日志文件中的 Stacktrace:

[WARN ] 2018-05-09T17:09:12,893Z [Node thread] utilities.AppendOnlyPersistentMap.set - Double insert in net.corda.node.utilities.AppendOnlyPersistentMap for entity class class net.corda.node.services.identity.PersistentIdentityService$PersistentIdentityNames key C=US,L=New York,O=JonesBank, not inserting the second time
[WARN ] 2018-05-09T17:09:13,133Z [Node thread] flow.[13b767a6-8cd1-4747-867e-7ffe04ed99cb].run - Terminated by unexpected exception
java.lang.IllegalArgumentException: Failed requirement.
    at net.corda.core.utilities.ProgressTracker.setCurrentStep(ProgressTracker.kt:108) ~[corda-core-2.0.0.jar:?]
    at com.template.TxInitiatorFlow$Seller.call(TxInitiatorFlow.java:91) ~[cordapp-0.1.jar:?]
    at com.template.TxInitiatorFlow$Seller.call(TxInitiatorFlow.java:26) ~[cordapp-0.1.jar:?]
    at net.corda.node.services.statemachine.FlowStateMachineImpl.run(FlowStateMachineImpl.kt:96) [corda-node-2.0.0.jar:?]
    at net.corda.node.services.statemachine.FlowStateMachineImpl.run(FlowStateMachineImpl.kt:41) [corda-node-2.0.0.jar:?]
    at co.paralleluniverse.fibers.Fiber.run1(Fiber.java:1092) [quasar-core-0.7.9-jdk8.jar:0.7.9]
    at co.paralleluniverse.fibers.Fiber.exec(Fiber.java:788) [quasar-core-0.7.9-jdk8.jar:0.7.9]
    at co.paralleluniverse.fibers.RunnableFiberTask.doExec(RunnableFiberTask.java:100) [quasar-core-0.7.9-jdk8.jar:0.7.9]
    at co.paralleluniverse.fibers.RunnableFiberTask.run(RunnableFiberTask.java:91) [quasar-core-0.7.9-jdk8.jar:0.7.9]
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_161]
    at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_161]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access1(Unknown Source) [?:1.8.0_161]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source) [?:1.8.0_161]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:1.8.0_161]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:1.8.0_161]
    at net.corda.node.utilities.AffinityExecutor$ServiceAffinityExecutor$thread.run(AffinityExecutor.kt:69) [corda-node-2.0.0.jar:?]
[WARN ] 2018-05-09T17:09:13,543Z [Node thread] statemachine.StateMachineManager.onExistingSessionMessage - Received a session message for unknown session: SessionReject(initiatorSessionId=2776640309751674301, errorMessage=Unable to establish session), from C=GB,L=London,O=CreditSuisse
[INFO ] 2018-05-09T17:12:41,044Z [Node thread] vault.NodeVaultService._queryBy - Vault Query for contract type: class net.corda.finance.contracts.CommercialPaper$State, criteria: VaultQueryCriteria(status=UNCONSUMED, contractStateTypes=null, stateRefs=null, notary=null, softLockingCondition=null, timeCondition=null), pagination: PageSpecification(pageNumber=-1, pageSize=200), sorting: Sort(columns=[])
[WARN ] 2018-05-09T17:12:41,174Z [Node thread] utilities.AppendOnlyPersistentMap.set - Double insert in net.corda.node.utilities.AppendOnlyPersistentMap for entity class class net.corda.node.services.identity.PersistentIdentityService$PersistentIdentityNames key C=US,L=New York,O=JonesBank, not inserting the second time
[WARN ] 2018-05-09T17:12:41,265Z [Node thread] flow.[71832083-4910-416e-abb6-34a0cacfa7a5].run - Terminated by unexpected exception
java.lang.IllegalArgumentException: Failed requirement.
    at net.corda.core.utilities.ProgressTracker.setCurrentStep(ProgressTracker.kt:108) ~[corda-core-2.0.0.jar:?]
    at com.template.TxInitiatorFlow$Seller.call(TxInitiatorFlow.java:91) ~[cordapp-0.1.jar:?]
    at com.template.TxInitiatorFlow$Seller.call(TxInitiatorFlow.java:26) ~[cordapp-0.1.jar:?]
    at net.corda.node.services.statemachine.FlowStateMachineImpl.run(FlowStateMachineImpl.kt:96) [corda-node-2.0.0.jar:?]
    at net.corda.node.services.statemachine.FlowStateMachineImpl.run(FlowStateMachineImpl.kt:41) [corda-node-2.0.0.jar:?]
    at co.paralleluniverse.fibers.Fiber.run1(Fiber.java:1092) [quasar-core-0.7.9-jdk8.jar:0.7.9]
    at co.paralleluniverse.fibers.Fiber.exec(Fiber.java:788) [quasar-core-0.7.9-jdk8.jar:0.7.9]
    at co.paralleluniverse.fibers.RunnableFiberTask.doExec(RunnableFiberTask.java:100) [quasar-core-0.7.9-jdk8.jar:0.7.9]
    at co.paralleluniverse.fibers.RunnableFiberTask.run(RunnableFiberTask.java:91) [quasar-core-0.7.9-jdk8.jar:0.7.9]
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_161]
    at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_161]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access1(Unknown Source) [?:1.8.0_161]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source) [?:1.8.0_161]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:1.8.0_161]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:1.8.0_161]
    at net.corda.node.utilities.AffinityExecutor$ServiceAffinityExecutor$thread.run(AffinityExecutor.kt:69) [corda-node-2.0.0.jar:?]
[WARN ] 2018-05-09T17:12:41,368Z [Node thread] statemachine.StateMachineManager.onExistingSessionMessage - Received a session message for unknown session: SessionReject(initiatorSessionId=7653034215696783817, errorMessage=Unable to establish session), from C=GB,L=London,O=CreditSuisse

部分:

at net.corda.core.utilities.ProgressTracker.setCurrentStep(ProgressTracker.kt:108) ~[corda-core-2.0.0.jar:?]
    at com.template.TxInitiatorFlow$Seller.call(TxInitiatorFlow.java:91) ~[cordapp-0.1.jar:?]
    at com.template.TxInitiatorFlow$Seller.call(TxInitiatorFlow.java:26) ~[cordapp-0.1.jar:?]

这是我认为相关的部分。当在流程中调用 progressTracker.setCurrentStep(TRADING) 时会发生这种情况。 我这样初始化这一步:

private final ProgressTracker.Step TRADING = new ProgressTracker.Step("Starting the trade flow") {
            @Override public ProgressTracker childProgressTracker() {
                return TwoPartyTradeFlow.Seller.Companion.tracker();
            }
        };

编辑 2: 现在,由于我摆脱了这个异常,还有另一个错误阻止了交易的发生。对方拒绝会话请求,并出现以下异常:net.corda.core.flows.UnexpectedFlowEndException: Party C=GB,L=London,O=CreditSuisse rejected session request: Unable to establish session。 这是最新的 Stacktrace:

[INFO ] 2018-05-13T12:53:08,723Z [Node thread] flow.[5b805998-3822-49b3-b12f-4bb306cbbc49].call - successfully instantiated seller, now invoking
[WARN ] 2018-05-13T12:53:08,997Z [Node thread] flow.[5b805998-3822-49b3-b12f-4bb306cbbc49].run - Terminated by unexpected exception
net.corda.core.flows.UnexpectedFlowEndException: Party C=GB,L=London,O=CreditSuisse rejected session request: Unable to establish session
    at net.corda.node.services.statemachine.FlowStateMachineImpl.waitForConfirmation(FlowStateMachineImpl.kt:309) ~[corda-node-2.0.0.jar:?]
    at net.corda.node.services.statemachine.FlowStateMachineImpl.getConfirmedSessionIfPresent(FlowStateMachineImpl.kt:344) ~[corda-node-2.0.0.jar:?]
    at net.corda.node.services.statemachine.FlowStateMachineImpl.sendAndReceive(FlowStateMachineImpl.kt:182) ~[corda-node-2.0.0.jar:?]
    at net.corda.core.internal.FlowStateMachine$DefaultImpls.sendAndReceive$default(FlowStateMachine.kt:28) ~[corda-core-2.0.0.jar:?]
    at net.corda.node.services.statemachine.FlowSessionImpl.sendAndReceive(FlowSessionImpl.kt:22) ~[corda-node-2.0.0.jar:?]
    at net.corda.core.flows.DataVendingFlow.sendPayloadAndReceiveDataRequest(SendTransactionFlow.kt:70) ~[corda-core-2.0.0.jar:?]
    at net.corda.core.flows.DataVendingFlow.call(SendTransactionFlow.kt:48) ~[corda-core-2.0.0.jar:?]
    at net.corda.core.flows.DataVendingFlow.call(SendTransactionFlow.kt:31) ~[corda-core-2.0.0.jar:?]
    at net.corda.core.flows.FlowLogic.subFlow(FlowLogic.kt:243) ~[corda-core-2.0.0.jar:?]
    at net.corda.finance.flows.TwoPartyTradeFlow$Seller.call(TwoPartyTradeFlow.kt:84) ~[corda-finance-2.0.0.jar:?]
    at net.corda.finance.flows.TwoPartyTradeFlow$Seller.call(TwoPartyTradeFlow.kt:58) ~[corda-finance-2.0.0.jar:?]
    at net.corda.core.flows.FlowLogic.subFlow(FlowLogic.kt:243) ~[corda-core-2.0.0.jar:?]
    at com.template.TxInitiatorFlow$Seller.call(TxInitiatorFlow.java:83) ~[cordapp-0.1.jar:?]
    at com.template.TxInitiatorFlow$Seller.call(TxInitiatorFlow.java:25) ~[cordapp-0.1.jar:?]
    at net.corda.node.services.statemachine.FlowStateMachineImpl.run(FlowStateMachineImpl.kt:96) [corda-node-2.0.0.jar:?]
    at net.corda.node.services.statemachine.FlowStateMachineImpl.run(FlowStateMachineImpl.kt:41) [corda-node-2.0.0.jar:?]
    at co.paralleluniverse.fibers.Fiber.run1(Fiber.java:1092) [quasar-core-0.7.9-jdk8.jar:0.7.9]
    at co.paralleluniverse.fibers.Fiber.exec(Fiber.java:788) [quasar-core-0.7.9-jdk8.jar:0.7.9]
    at co.paralleluniverse.fibers.RunnableFiberTask.doExec(RunnableFiberTask.java:100) [quasar-core-0.7.9-jdk8.jar:0.7.9]
    at co.paralleluniverse.fibers.RunnableFiberTask.run(RunnableFiberTask.java:91) [quasar-core-0.7.9-jdk8.jar:0.7.9]
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_161]
    at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_161]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access1(Unknown Source) [?:1.8.0_161]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source) [?:1.8.0_161]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:1.8.0_161]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:1.8.0_161]
    at net.corda.node.utilities.AffinityExecutor$ServiceAffinityExecutor$thread.run(AffinityExecutor.kt:69) [corda-node-2.0.0.jar:?]

调用时在卖家流程中抛出错误 return subFlow(seller);

为了完整起见,这里是交易对手的流程:

@InitiatedBy(Seller.class)
    public static class Buyer extends FlowLogic<SignedTransaction> {
        private FlowSession otherPartyFlow;
        private Logger logger = getLogger();

        public Buyer(FlowSession otherPartyFlow) {
            this.otherPartyFlow = otherPartyFlow;
        }

        private final ProgressTracker.Step SENDING_CASH = new ProgressTracker.Step("Sending Cash");

        private final ProgressTracker progressTracker = new ProgressTracker(SENDING_CASH);

        @Suspendable
        @Override
        public SignedTransaction call() throws FlowException{
            ServiceHub serviceHub = getServiceHub();


            progressTracker.setCurrentStep(SENDING_CASH);
            Amount<Currency> amount = otherPartyFlow.receive(Amount.class).unwrap(data -> data);


            Party notary = serviceHub.getNetworkMapCache().getNotaryIdentities().get(0);
            TwoPartyTradeFlow.Buyer buyer = new TwoPartyTradeFlow.Buyer(
                    otherPartyFlow, notary, amount, CommercialPaper.State.class
            );

            SignedTransaction tradeTX = subFlow(buyer);

            return tradeTX;
        }
    }

我的会话有什么问题?

这段ProgressTracker代码抛出错误:net.corda.core.utilities.ProgressTracker.setCurrentStep(ProgressTracker.kt:108).

对应以下几行:

val index = steps.indexOf(value)
require(index != -1)

require 条件失败时,您会得到一个 java.lang.IllegalArgumentException: Failed requirement.

require 条件在这种情况下失败,因为您尝试设置的步骤(此处为 value)不作为 ProgressTracker 步骤存在(即它在steps 的列表是 -1

请检查您是否已在 ProgressTracker 中包含进度跟踪器步骤,如下所示:https://github.com/corda/cordapp-example/blob/release-V3/java-source/src/main/java/com/example/flow/ExampleFlow.java#L59

我已经打开了一个 PR 来改进未来的此类错误消息,在这里:https://github.com/corda/corda/pull/3116

会话被其他节点拒绝,因为此语句:private Logger logger = getLogger(); 在买方流程中。我在记录器实际进入流程之前就得到了它(也许它试图将记录器绑定到尚不存在的流程或其他东西)。将它移动到调用方法就可以了,现在可以使用了。