我可以解析来自 CordaRPCOps 的指针吗?
Can I resolve pointer from CordaRPCOps?
考虑以下几点:
data class ChildState(
val name: Party,
override val linearId : UniqueIdentifier = UniqueIdentifier()
) : LinearState
data class ParentState(
val name : Party,
val children : LinearPointer<ChildState>,
override val linearId : UniqueIdentifier = UniqueIdentifier()
) : LinearState
我能否像 this Mathew Lyton post 似乎建议的那样,使用 CordaRPCOps 从模块外部获取仅查询父级的子状态?像这样:
// rpc.proxy is a NodeRPCConnection containing the CordaRPCOps
val parentStateData = rpc.proxy.vaultQueryBy<ParentState>().states.single().state.data
// perhaps something like this?
parentStateData.children.resolve(rpc.proxy)
Corda 中 StatePointer
的默认实现不支持使用 CordaRPCOps
解析指针。它只能使用 ServiceHub
或 LedgerTransation
来解决。以下是 Corda 中 StatePointer
class 中定义的方法。
/**
* Resolves a [StatePointer] to a [StateAndRef] via a vault query. This method will either return a [StateAndRef]
* or return an exception.
*
* @param services a [ServiceHub] implementation is required to resolve the pointer.
*/
@DeleteForDJVM
abstract fun resolve(services: ServiceHub): StateAndRef<T>
/**
* Resolves a [StatePointer] to a [StateAndRef] from inside a [LedgerTransaction]. The intuition here is that all
* of the pointed-to states will be included in the transaction as reference states.
*
* @param ltx the [LedgerTransaction] containing the [pointer] and pointed-to states.
*/
abstract fun resolve(ltx: LedgerTransaction): StateAndRef<T>
在 rpc 客户端中 ServiceHub
和 LedgerTransaction
都不可访问,因此为了使用 CordaRPCOps
解析指针,您需要编写一个自定义实现作为在你提到的 blog 中描述。
考虑以下几点:
data class ChildState(
val name: Party,
override val linearId : UniqueIdentifier = UniqueIdentifier()
) : LinearState
data class ParentState(
val name : Party,
val children : LinearPointer<ChildState>,
override val linearId : UniqueIdentifier = UniqueIdentifier()
) : LinearState
我能否像 this Mathew Lyton post 似乎建议的那样,使用 CordaRPCOps 从模块外部获取仅查询父级的子状态?像这样:
// rpc.proxy is a NodeRPCConnection containing the CordaRPCOps
val parentStateData = rpc.proxy.vaultQueryBy<ParentState>().states.single().state.data
// perhaps something like this?
parentStateData.children.resolve(rpc.proxy)
Corda 中 StatePointer
的默认实现不支持使用 CordaRPCOps
解析指针。它只能使用 ServiceHub
或 LedgerTransation
来解决。以下是 Corda 中 StatePointer
class 中定义的方法。
/**
* Resolves a [StatePointer] to a [StateAndRef] via a vault query. This method will either return a [StateAndRef]
* or return an exception.
*
* @param services a [ServiceHub] implementation is required to resolve the pointer.
*/
@DeleteForDJVM
abstract fun resolve(services: ServiceHub): StateAndRef<T>
/**
* Resolves a [StatePointer] to a [StateAndRef] from inside a [LedgerTransaction]. The intuition here is that all
* of the pointed-to states will be included in the transaction as reference states.
*
* @param ltx the [LedgerTransaction] containing the [pointer] and pointed-to states.
*/
abstract fun resolve(ltx: LedgerTransaction): StateAndRef<T>
在 rpc 客户端中 ServiceHub
和 LedgerTransaction
都不可访问,因此为了使用 CordaRPCOps
解析指针,您需要编写一个自定义实现作为在你提到的 blog 中描述。