net.corda.core.CordaRuntimeException: Инициатор CollectSignaturesFlow должен передать именно те сеансы, которые необходимы для подписания транзакции. - PullRequest
1 голос
/ 09 мая 2020

Я пытаюсь следовать руководству Corda, но не понимаю, в чем я ошибаюсь ... Модульный тест запускается успешно, но когда я пытаюсь выпустить новую долговую расписку через api, возникает исключение. Это мой рабочий код долгового обязательства. Исключение составляет заголовок, заранее спасибо.

        //get notary reference
        final Party notary = getServiceHub().getNetworkMapCache().getNotaryIdentities().get(0);

        //builder
        final TransactionBuilder builder = new TransactionBuilder(notary);

        final List<PublicKey> partiesKey = this.state.getParticipants()
                .stream().map(AbstractParty::getOwningKey)
                .collect(Collectors.toList());

        //create new issue command
        final Command<IOUContract.Commands.Issue> cmd = new Command<>(
                new IOUContract.Commands.Issue(), partiesKey
                );

        //create a transaction state
        TransactionState<IOUState> txState = new TransactionState<>(this.state,
                IOUContract.IOU_CONTRACT_ID, notary);

        //add to builder command and state
        builder.withItems(cmd, txState);

        //verify sign it
        builder.verify(getServiceHub());

        // Sign the transaction.
        final Party me = getOurIdentity();

        final SignedTransaction ptx = getServiceHub().signInitialTransaction(builder, me.getOwningKey());

        List<Party> otherParties = this.state.getParticipants().stream()
                .filter(x -> x.getOwningKey() != me.getOwningKey())
                .map(el -> (Party)el)
                .collect(Collectors.toList());

        //open flow session with other parties
        List<FlowSession> sessions = otherParties.stream()
                .map(el -> initiateFlow(el))
                .collect(Collectors.toList());

        SignedTransaction fullSign = subFlow(
            new CollectSignaturesFlow(
                ptx,
                sessions,
                ImmutableList.of(me.getOwningKey()),
                CollectSignaturesFlow.Companion.tracker()
            )
        );

        return subFlow(new FinalityFlow(fullSign, sessions));

Если я изменю код в последних 3 строках:

FROM

//open flow session with other parties
    List<FlowSession> sessions = otherParties.stream()
            .map(el -> initiateFlow(el))
            .collect(Collectors.toList());

    SignedTransaction fullSign = subFlow(
        new CollectSignaturesFlow(
            ptx,
            sessions,
            ImmutableList.of(me.getOwningKey()),
            CollectSignaturesFlow.Companion.tracker()
        )
    );

    return subFlow(new FinalityFlow(fullSign, sessions));

К

//open flow session with counter party
        FlowSession lenderFlow = initiateFlow(state.getLender());

        SignedTransaction fullSign = subFlow(
            new CollectSignaturesFlow(
                ptx,
                ImmutableSet.of(lenderFlow),
                ImmutableList.of(me.getOwningKey()),
                CollectSignaturesFlow.Companion.tracker()
            )
        );

        return subFlow(new FinalityFlow(fullSign, ImmutableSet.of(lenderFlow)));

Работает правильно, ПОЧЕМУ? какая разница?

1 Ответ

0 голосов
/ 30 мая 2020

Я считаю, что Адель права в том, что вы передаете не те стороны в подпоток collectSignatures.

Я бы дважды перепроверил содержимое этого списка, чтобы убедиться, что узел, на котором выполняется поток, отсутствует в этом списке.

Просто простая проверка или что-то вроде этого сделает это :

    //Collect all of the required signatures from other Players / Corda nodes using the CollectSignaturesFlow
    for (int i = 0; i < input.getPlayers().length; i++) {
        Party p = input.getPlayers()[i];

        if (p.equals(me)) {
            continue;
        }

        FlowSession session = initiateFlow(p);

        new IdentitySyncFlow.Send(session, partStx.getTx());

        sessionList.add(session);
    }
...