Corda:Corda 如何处理代码中的附件传输?

Corda: How does Corda handle attachments transfer in Code?

在阅读有关附件的文档时,我看到“(附件)这些文件在需要时从发送交易的节点自动请求并在本地缓存,因此如果再次遇到它们不会重新请求。”

任何人都可以帮助我解释它是如何完成的吗?

如果一个节点知道附件的哈希值,它可以从上传它的原始节点请求它?

它实际上是如何“从发送给他们的发件人那里请求它的”。是否有任何知道哈希的节点可以请求附件?

来自 Corda-ledger Slack 的问题:http://slack.corda.net/

交易包含附件的哈希值。接收节点检查其保险库中的哈希值。如果它不存在,它会向发送它的发件人请求它。他们将其存储在他们的数据库中。如果哈希再次包含在交易中,它将从他们自己的保险库中加载

查看 FetchAttachmentsFlow

的代码
/**
 * Given a set of hashes either loads from local storage or requests them from the other peer. Downloaded
 * attachments are saved to local storage automatically.
 */
class FetchAttachmentsFlow(requests: Set<SecureHash>,
                           otherSide: FlowSession) : FetchDataFlow<Attachment, ByteArray>(requests, otherSide, DataType.ATTACHMENT)

这里是link:https://github.com/corda/corda/blob/release/4.1/core/src/main/kotlin/net/corda/core/internal/FetchDataFlow.kt#L148