Corda CollectSignaturesFlow中的流异常

Corda CollectSignaturesFlow中的流异常,corda,Corda,我正在创建一个流,从另一方的CollectSignaturesFlow获取签名,我在日志中面临以下问题 @InitiatingFlow @StartableByRPC public static class BGInitiator extends FlowLogic<SignedTransaction> { private final Party manufacturer; private final Party regulator; private fin

我正在创建一个流,从另一方的CollectSignaturesFlow获取签名,我在日志中面临以下问题

@InitiatingFlow
@StartableByRPC
public static class BGInitiator extends FlowLogic<SignedTransaction> {

    private final Party manufacturer;
    private final Party regulator;
    private final String bgData;

    public BGInitiator(Party manufacturer,Party regulator, String bgData) {
        this.manufacturer = manufacturer;
        this.regulator = regulator;
        this.bgData = bgData;
    }
    private final Step GENERATING_TRANSACTION = new Step("Generating transaction based on YO.");
    private final Step BUILDING_TRANSACTION = new Step("Verifying contract constraints.");
    private final Step SIGNING_TRANSACTION = new Step("Signing transaction with our private key.");
    private final Step GATHERING_SIGS = new Step("Gathering the counterparty's signature.") {
        @Override
        public ProgressTracker childProgressTracker() {
            return CollectSignaturesFlow.Companion.tracker();
        }
    };
    private final Step FINALISING_TRANSACTION = new Step("Obtaining notary signature and recording transaction.") {
        @Override
        public ProgressTracker childProgressTracker() {
            return FinalityFlow.Companion.tracker();
        }
    };

    private final ProgressTracker progressTracker = new ProgressTracker(
            GENERATING_TRANSACTION,
            BUILDING_TRANSACTION,
            SIGNING_TRANSACTION,
            GATHERING_SIGS,
            FINALISING_TRANSACTION
    );

    @Override
    public ProgressTracker getProgressTracker() {
        return progressTracker;
    }

    @Suspendable
    @Override
    public SignedTransaction call() throws FlowException {
        progressTracker.setCurrentStep(GENERATING_TRANSACTION);

        Party notary = getServiceHub().getNetworkMapCache().getNotaryIdentities().get(0);
        BGState bgState = new BGState(getOurIdentity(),manufacturer,regulator,bgData);

        progressTracker.setCurrentStep(BUILDING_TRANSACTION);
        final List<PublicKey> requiredSigners = bgState.getParticipantKeys();
        final List<Party> parties = bgState.getParties();
         final PublicKey me = bgState.getSeller().getOwningKey();


        final TransactionBuilder tb = new TransactionBuilder(notary)
                .addOutputState(bgState,BGContract.BG_CONTRACT_ID)
                .addCommand(new BGContract.Commands.Send(),requiredSigners);

        progressTracker.setCurrentStep(SIGNING_TRANSACTION);
        final SignedTransaction ptx = getServiceHub().signInitialTransaction(tb,me);

        progressTracker.setCurrentStep(GATHERING_SIGS);



        FlowSession manufacturerflow = initiateFlow(manufacturer);
        final SignedTransaction stx = subFlow(new CollectSignaturesFlow(ptx,ImmutableSet.of(manufacturerflow),ImmutableList.of(me),GATHERING_SIGS.childProgressTracker()));

        progressTracker.setCurrentStep(FINALISING_TRANSACTION);
        return subFlow(new FinalityFlow(stx,FINALISING_TRANSACTION.childProgressTracker()));
    }
}
我相信我通过了所需的流程会话,我仍然能得到这个。有没有办法解决这个问题

编辑1:当我使用下面的代码将flowsession替换为多个会话并执行它时,流发生了变化,甚至没有在日志中写入任何内容。我想知道以下是否是获取签名的正确方法

 List<FlowSession> flowSessions = parties.stream().map(a -> initiateFlow(a)).collect(Collectors.toList());
        final SignedTransaction stx = subFlow(new CollectSignaturesFlow(ptx,flowSessions,ImmutableList.of(me),GATHERING_SIGS.childProgressTracker()));
List flowSessions=parties.stream().map(a->initiateFlow(a)).collect(collector.toList());
final SignedTransaction stx=子流(新的CollectSignaturesFlow(ptx、flowSessions、ImmutableList.of(me)、GATHERING_SIGS.childProgressTracker());
BGState中的getParties()代码:

public List<Party> getParties(){
    return Arrays.asList(manufacturer,regulator);
}
public List getParties(){
返回阵列。asList(制造商、调节器);
}
国家定义:

public class BGState implements LinearState,QueryableState {

private final Party seller;
private final Party manufacturer;
private final Party regulator;
private final String senderToReceiverInformation;
private final UniqueIdentifier linearId;



public BGState(Party seller, Party manufacturer,Party regulator,String senderToReceiverInformation) {
    this.seller = seller;
    this. manufacturer= manufacturer;
    this.regulator = regulator;
    this.senderToReceiverInformation = senderToReceiverInformation;
    this.linearId = new UniqueIdentifier();
}


public Party getSeller() {
    return seller;
}

public Party getManufacturer() {
    return manufacturer;
}

public Party getRegulator() {
    return regulator;
}



@NotNull
@Override
public UniqueIdentifier getLinearId() {
    return linearId;
}

@NotNull
@Override
public PersistentState generateMappedObject(MappedSchema schema) {
    if (schema instanceof BGSchema) {
        return new BGSchema.Bg760(
                this.seller,
                this.manufacturer,
                this.regulator,
                this.senderToReceiverInformation,
                this.linearId
        );
    } else {
        throw new IllegalArgumentException("Unrecognised schema $schema");
    }
}

@NotNull
@Override
public Iterable<MappedSchema> supportedSchemas() {
    return ImmutableList.of(new BGSchema());
}

@NotNull
@Override
public List<AbstractParty> getParticipants() {
    return Arrays.asList(seller,manufacturer,regulator);
}
public List<PublicKey> getParticipantKeys(){
    return  getParticipants().stream().map(AbstractParty :: getOwningKey).collect(Collectors.toList());
}
public List<Party> getParties(){
    return Arrays.asList(manufacturer,regulator);
}
公共类BGState实现LinearState、QueryableState{
私人最终卖方;
私人最终方制造商;
私人最后一方监管者;
私有最终字符串发送者接收信息;
专用最终唯一标识符;
公共BGState(第三方卖方、第三方制造商、第三方调节器、字符串发送器或接收方信息){
this.seller=卖方;
这个。制造商=制造商;
this.regulator=调节器;
this.senderToReceiverInformation=senderToReceiverInformation;
this.linearId=新的唯一标识符();
}
公共方getSeller(){
退货卖家;
}
公众参与方(制造商){
退货制造商;
}
公众党{
回流调节器;
}
@NotNull
@凌驾
公共唯一标识符getLinearId(){
回归线性化;
}
@NotNull
@凌驾
公共PersistentState generateMappedObject(MappedSchema){
if(BGSchema的模式实例){
返回新的BGSchema.Bg760(
这个卖方,
这个制造商,
这是一个监管机构,
此.senderToReceiverInformation,
这是莱娜丽德
);
}否则{
抛出新的IllegalArgumentException(“未识别的模式$schema”);
}
}
@NotNull
@凌驾
公共Iterable supportedSchemas(){
返回ImmutableList.of(new BGSchema());
}
@NotNull
@凌驾
公开名单{
返回阵列。asList(卖方、制造商、调节器);
}
公共列表getParticipantKeys(){
返回getParticipants().stream().map(AbstractParty::getOwningKey).collect(Collectors.toList());
}
公众参与方名单(){
返回阵列。asList(制造商、调节器);
}

}

传递给
CollectSignaturesFlow
FlowSession
列表必须与交易所需的签名人完全对应


在这种情况下,没有为监管机构传递任何
FlowSession
,监管机构是所需的签名者之一。

BGState
中-您的案例中有3名参与者,因此您需要传递除发起节点
FlowSession
之外的其他两方

FlowSession manufacturerflow = initiateFlow(manufacturer); 
FlowSession regulator = initiateFlow(manufacturer); 
final SignedTransaction stx = subFlow(new CollectSignaturesFlow(ptx,ImmutableSet.of(manufacturerflow,regulator),ImmutableList.of(me),GATHERING_SIGS.childProgressTracker()));


您是否也可以发布BGState的定义,以显示如何确定
参与者
?嘿,谢谢@joel,我忘记了,并加入了一个额外的签名方,关于编辑1有什么帮助吗?@joel您可以发布状态定义吗?我需要它来确定所需的签名者是否与会话一致。嗨@Joel,我附上了状态定义
FlowSession manufacturerflow = initiateFlow(manufacturer); 
FlowSession regulator = initiateFlow(manufacturer); 
final SignedTransaction stx = subFlow(new CollectSignaturesFlow(ptx,ImmutableSet.of(manufacturerflow,regulator),ImmutableList.of(me),GATHERING_SIGS.childProgressTracker()));