iT邦幫忙

2019 iT 邦幫忙鐵人賽

DAY 29
0
Blockchain

區塊鏈開發(Blockchain/DLT Application Development)系列 第 29

R3 Corda:Plugins and APIs

Corda 提供了 Plugins 服務,共識僅驗證唯一性,將有效性交由交易雙方驗證。
這提供了隱私性和具擴展性的交易。

使用者若有自行新增註冊流程的需求,Corda 提供 3 種類型的 Plugins 和 API:

  • 節點中的 Web APIs 或網頁靜態內容(Static Content)
  • 流程(Flows)
  • Kyro 序列化流程(Flows)類別

CordaPluginRegistry

PluginRegistry 類別定義:

abstract class CordaPluginRegistry
(
    open val webApis: List<Function<CordaRPCOps, out Any>> = emptyList(),
    open val staticServeDirs: Map<String, String> = emptyMap(),
    open val requiredFlows: Map<String, Set<String>> = emptyMap(),
    open val servicePlugins: List<Function<PluginServiceHub, out Any>> = 
        emptyList()
)
{
    open fun registerRPCKryoTypes(kryo: Kryo): Boolean = false
}

Web APIs:使用 Java API for RESTful Web Services, JAX-RS

@Path("example")
class ExampleApi(val services: CordaRPCOps)
The syntax is as follows:

override val webApis: List<Function<CordaRPCOps, out Any>> = 
    listOf(Function(::ExampleApi))

靜態內容(Static Content)

override val staticServeDirs: Map<String, String> =
    mapOf
    (
        "example" to javaClass
            .classLoader
	        .getResource("exampleWeb")
	        .toExternalForm()
    )

流程(Flows)

override val requiredFlows: Map<String, Set<String>> =
mapOf
(
    ExampleFlow.Initiator::class.java.name to setOf
    (
        argClass1::class.java.name
        , argClass2::class.java.name
        , …)
)

Kyro 序列化流程類別

override fun registerRPCKryoTypes(kryo: Kryo): Boolean 
{        	    
    kryo.register(MyClass::class.java) …
}

上一篇
R3 Corda:節點(Nodes)
下一篇
技術差異
系列文
區塊鏈開發(Blockchain/DLT Application Development)30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言