How to provide a CorDapp with custom config in Corda?

▼魔方 西西 提交于 2019-11-28 11:48:50

Corda 3 doesn't have built-in support for providing arbitrary configuration files to nodes. Support for this will be added in Corda 4 using CorDapp configuration files: https://docs.corda.net/head/cordapp-build-systems.html#cordapp-configuration-files.

In the meantime, you can place a local file within the node directory and read from it directly within a flow. For example, if I place a configuration file called properties.txt in the node's root directory, I can then read back its contents using the following flow:

@InitiatingFlow
@StartableByRPC
class ReadPropertiesFlow : FlowLogic<String>() {
    override val progressTracker = ProgressTracker()

    @Suspendable
    override fun call() = File("./properties.txt").readText()
}

The node's working directory is always the node's root directory (except for when using the MockNetwork for flow tests).

Alternatively, you could store information directly in the node's database. See NODE_PROPERTIES table in database for an example.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!