Corda:TwoPartyTradeFlow抛出异常"失败的要求:"

时间:2018-05-08 12:37:37

标签: corda

我最近在Java中重新创建了trader-demo。由于某种原因,事务不起作用,并且抛出错误:“java.lang.IllegalArgumentException:Failed requirement。”,没有进一步的信息(通常我希望看到哪个要求失败)。代码将一直运行,直到它调用TwoPartyTradeFlow.Seller。

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

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);
    }

}

这是Stacktrace:

[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$1.invoke(ResourceMethodInvocationHandlerFactory.java:81) [jersey-server-2.25.jar:?]
        at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.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$2.run(ServerRuntime.java:326) [jersey-server-2.25.jar:?]
        at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271) [jersey-common-2.25.jar:?]
        at org.glassfish.jersey.internal.Errors$1.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$2.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$2.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.

以下是CommercialPaper Issue流程的代码,以防它以错误的方式发布CommercialPaper并导致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.access$201(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$1$thread$1.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.access$201(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$1$thread$1.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: 现在,由于我摆脱了这个例外,还有另一个错误阻止交易发生。 Counterparty拒绝具有此异常的会话请求: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.access$201(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$1$thread$1.run(AffinityExecutor.kt:69) [corda-node-2.0.0.jar:?]

调用return subFlow(seller);

时,卖家Flow会抛出错误

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

@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;
        }
    }

我的会话有什么问题?

1 个答案:

答案 0 :(得分:0)

由于以下声明,会话被其他节点拒绝:买方流程中的private Logger logger = getLogger();。我在实际进入流程之前得到了记录器(也许它试图将记录器绑定到一个尚未存在的流程或其他东西)。将它移动到调用方法就可以了,现在可以正常工作。