com.r3corda.core.node / ServiceHub

ServiceHub

interface ServiceHub

A service hub simply vends references to the other services a node has. Some of those services may be missing or mocked out. This class is useful to pass to chunks of pluggable code that might have need of many different kinds of functionality and you dont want to hard-code which types in the interface.

Any services exposed to protocols (public view) need to implement SerializeAsToken or similar to avoid their internal state from being serialized in checkpoints.





Properties

clock abstract val clock: Clock
identityService abstract val identityService: IdentityService
keyManagementService abstract val keyManagementService: KeyManagementService
networkMapCache abstract val networkMapCache: NetworkMapCache
networkService abstract val networkService: MessagingService
schedulerService abstract val schedulerService: SchedulerService
storageService abstract val storageService: StorageService
walletService abstract val walletService: WalletService

Functions

invokeProtocolAsync abstract fun <T : Any> invokeProtocolAsync(logicType: Class<out ProtocolLogic<T>>, vararg args: Any?): <ERROR CLASS><T>

Will check logicType and args against a whitelist and if acceptable then construct and initiate the protocol.

loadState open fun loadState(stateRef: StateRef): TransactionState<*>

Given a StateRef loads the referenced transaction and looks up the specified output ContractState.

recordTransactions abstract fun recordTransactions(txs: Iterable<SignedTransaction>): Unit

Given a list of SignedTransactions, writes them to the local storage for validated transactions and then sends them to the wallet for further processing.

open fun recordTransactions(vararg txs: SignedTransaction): <ERROR CLASS>

Given some SignedTransactions, writes them to the local storage for validated transactions and then sends them to the wallet for further processing.

verifyTransaction open fun verifyTransaction(ltx: LedgerTransaction): Unit

Given a LedgerTransaction, looks up all its dependencies in the local database, uses the identity service to map the SignedTransactions the DB gives back into LedgerTransactions, and then runs the smart contracts for the transaction. If no exception is thrown, the transaction is valid.

Extension Functions

fillWithSomeTestCash fun ServiceHub.fillWithSomeTestCash(howMuch: Amount<Currency>, notary: Party = DUMMY_NOTARY, atLeastThisManyStates: Int = 3, atMostThisManyStates: Int = 10, rng: Random = Random(), ref: OpaqueBytes = OpaqueBytes(ByteArray(1, { 0 }))): Wallet

Creates a random set of between (by default) 3 and 10 cash states that add up to the given amount and adds them to the wallet. This is intended for unit tests.

Inheritors

ServiceHubInternal abstract class ServiceHubInternal : ServiceHub