我正在努力理解我所面临的问题的原因。
我有一个带有合同的模块和带有验证器的模块。合同模块中使用了一些验证器。例如:
override fun verify(tx: LedgerTransaction){
validator.validate(tx.outputs)
}
我开始我的流程,在合同验证期间,我看到:ClassNotFoundException所以在类加载器中找不到来自Validators模块的类。显然,节点中存在带有 Validators 的 CorDapp。
在调试 Corda Framework 时,我可以看到AttachmentStorageInternal在启动期间会上传附件,但只有那些包含 Contracts的jar 。
private fun loadContractsIntoAttachmentStore(): Map<SecureHash, URL> =
cordapps.filter { !it.contractClassNames.isEmpty() }.map {
it.jarPath.openStream().use { stream -> //some code}
此外,我可以看到在验证阶段,当ClassNotFoundException或ClassNotDefFoundException发生时,Corda 将尝试加载丢失的类,但它会尝试仅从节点启动时上传的合同附件中找到它。
fun AttachmentStorage.internalFindTrustedAttachmentForClass(className: String): Attachment? {
val allTrusted = queryAttachments(
AttachmentQueryCriteria.AttachmentsQueryCriteria().withUploader(Builder.`in`(TRUSTED_UPLOADERS)),
AttachmentSort(listOf(AttachmentSort.AttachmentSortColumn(AttachmentSort.AttachmentSortAttribute.VERSION, Sort.Direction.DESC))))
for (attId in allTrusted) {
- 有人能指出我,Corda 将如何加载 Contract 的
verify()方法在我的实现中可能需要的辅助类吗? - 是否可以在 Contacts 的 CorDapp 中使用其他模块中的类?