我要使用两台不同的机器来部署Corda网络:首先,我要使用以下配置来部署公证人和oracle服务:
公证人
myLegalName="O=Notary,L=London,C=GB"
keyStorePassword : "cordacadevpass"
trustStorePassword : "trustpass"
p2pAddress="machine-ip1:10004"
notary : {
validating : false
}
devMode : true
Oracle
myLegalName="O=Oracle,L=London,C=GB"
keyStorePassword : "cordacadevpass"
trustStorePassword : "trustpass"
p2pAddress="machine-ip1:10001"
rpcSettings {
address="0.0.0.0:10002"
adminAddress="0.0.0.0:10003"
}
rpcUsers=[
{
password=test
permissions=[
ALL
]
user=user1
}
]
devMode : true
第二次,我将部署以下参与方节点:
聚会
myLegalName="O=Party,L=London,C=GB"
keyStorePassword : "cordacadevpass"
trustStorePassword : "trustpass"
p2pAddress="machine-ip2:10001"
rpcSettings {
address="0.0.0.0:10002"
adminAddress="0.0.0.0:10003"
}
rpcUsers=[
{
password=test
permissions=[
ALL
]
user=user1
}
]
devMode : true
Party
一旦开始建立事务的流程,就不会引发此异常:
java.lang.IllegalStateException: Need to specify a notary for the state, or set a default one on TransactionBuilder
at net.corda.core.transactions.TransactionBuilder.addOutputState(TransactionBuilder.kt:172)
at net.corda.core.transactions.TransactionBuilder.addOutputState$default(TransactionBuilder.kt:171)
调用函数是:
override fun call(): SignedTransaction {
val notary = serviceHub.networkMapCache.getNotary(CordaX500Name("Notary", "London", "GB"))!!
val issueState = CashOwningState(amount, ourIdentity)
val issueCommand = Command(
CashIssueContract.Commands.Issue(),
issueState.participants.map { it.owningKey })
val txBuilder = TransactionBuilder(notary).withItems(
StateAndContract(issueState, CashIssueContract.TEST_CONTRACT_ID),
issueCommand)
txBuilder.verify(serviceHub)
val fullySignedTx = serviceHub.signInitialTransaction(txBuilder)
return subFlow(FinalityFlow(fullySignedTx, FINALIZING_TX.childProgressTracker()))
}
似乎在网络中找到了Notary
,但是CordApp无法将其识别为公证人。
答案 0 :(得分:0)
这不是CorDapp无法识别公证人的问题。抛出此异常的唯一地方是here:
@JvmOverloads
fun addOutputState(state: ContractState, contract: ContractClassName, constraint: AttachmentConstraint = AutomaticHashConstraint): TransactionBuilder {
checkNotNull(notary) { "Need to specify a notary for the state, or set a default one on TransactionBuilder initialisation" }
addOutputState(state, contract, notary!!, constraint = constraint)
return this
}
在通过公证员实例化TransactionBuilder
时,不检查通过的一方是否实际上是公证人。
您必须尝试将输出状态添加到TransactionBuilder
,而在代码中没有公证人的地方。