【发布时间】:2020-10-13 22:28:26
【问题描述】:
我在 Corda 中使用帐户。在我的代码中成功创建了新帐户,但是我在做这两件事时遇到了困难。 1.) 如何检查账户是否实际创建并存在于节点中,意思是我们是否可以检查Corda中所有账户的列表。
2.) 如何为账户编写响应流程,意味着我的交易流程无法正常工作。如果我们现在开始使用帐户库,响应者流程经典代码是否有任何更改?
我的代码如下:
@InitiatedBy(Proposal.class)
public static class ProposalAcceptance extends FlowLogic<Void> {
//private variable
private FlowSession counterpartySession;
//Constructor
public ProposalAcceptance(FlowSession counterpartySession) {
this.counterpartySession = counterpartySession;
}
@Suspendable
@Override
public Void call() throws FlowException {
SignedTransaction signedTransaction = subFlow(new SignTransactionFlow(counterpartySession) {
@Suspendable
@Override
protected void checkTransaction(SignedTransaction stx) throws FlowException {
/*
* SignTransactionFlow will automatically verify the transaction and its signatures before signing it.
* However, just because a transaction is contractually valid doesn’t mean we necessarily want to sign.
* What if we don’t want to deal with the counterparty in question, or the value is too high,
* or we’re not happy with the transaction’s structure? checkTransaction
* allows us to define these additional checks. If any of these conditions are not met,
* we will not sign the transaction - even if the transaction and its signatures are contractually valid.
* ----------
* For this hello-world cordapp, we will not implement any aditional checks.
* */
}
});
//Stored the transaction into data base.
subFlow(new ReceiveFinalityFlow(counterpartySession));
return null;
}
}
【问题讨论】:
标签: blockchain corda