API: ServiceHub¶
Within FlowLogic.call, the flow developer has access to the node’s ServiceHub, which provides access to the
various services the node provides. The services offered by the ServiceHub are split into the following categories:
ServiceHub.networkMapCache- Provides information on other nodes on the network (e.g. notaries…)
ServiceHub.identityService- Allows you to resolve anonymous identities to well-known identities if you have the required certificates
ServiceHub.attachments- Gives you access to the node’s attachments
ServiceHub.validatedTransactions- Gives you access to the transactions stored in the node
ServiceHub.vaultService- Stores the node’s current and historic states
ServiceHub.keyManagementService- Manages signing transactions and generating fresh public keys
ServiceHub.myInfo- Other information about the node
ServiceHub.clock- Provides access to the node’s internal time and date
在 FlowLogic.call 中,flow 开发者能够访问节点的 ServiceHub,其提供了访问很多节点提供的服务。ServiceHub 提供的服务包括以下的类别:
ServiceHub.networkMapCache:提供了网络中其他节点的信息(比如 notaries)ServiceHub.identityService:如果你有所需的认证信息,允许你将匿名的 identities 变为 well-known 的 identitiesServiceHub.attachments:给你访问节点附件的权限ServiceHub.validatedTransactions:给你访问节点存储的 transactions 的权限ServiceHub.vaultService:存储了节点的当前和历史的 statesServiceHub.keyManagementService:管理签名 transactions 和生成新的公钥ServiceHub.myInfor:关于节点的其他信息ServiceHub.clock:提供访问节点的内部时间和日期
Additional, ServiceHub exposes the following properties:
ServiceHub.loadStateandServiceHub.toStateAndRefto resolve aStateRefinto aTransactionStateor aStateAndRefServiceHub.signInitialTransactionto sign aTransactionBuilderand convert it into aSignedTransactionServiceHub.createSignatureandServiceHub.addSignatureto create and add signatures to aSignedTransaction
另外,ServiceHub 暴露了以下的属性:
ServiceHub.loadState和ServiceHub.toStateAndRef来将一个StateRef变成一个TransactionState或者一个StateAndRefServiceHub.signInitialTransaction用来给一个TransactionBuilder签名并且将其转换成一个SignedTransactionServiceHub.createSignature和ServiceHub.addSignature用来向SignedTransaction创建和添加签名