@@ -20,6 +20,7 @@ import co.paralleluniverse.fibers.Suspendable
2020import net.corda.core.contracts.ContractState
2121import net.corda.core.contracts.StateAndRef
2222import net.corda.core.contracts.StateRef
23+ import net.corda.core.cordapp.CordappContext
2324import net.corda.core.crypto.SecureHash
2425import net.corda.core.flows.FlowException
2526import net.corda.core.flows.FlowLogic
@@ -51,12 +52,18 @@ val FlowLogic<*>.randomNotary: Party
5152 * Gets the preferred notary from the CorDapp config, or alternatively a default notary in the event that
5253 * a preferred notary has not been specified in the CorDapp config.
5354 *
55+ * @param serviceHub The service hub which will be used to obtain a notary from the config file.
5456 * @param defaultSelector The selector function to obtain a notary if none have been specified in the CorDapp config.
5557 * @return Returns the preferred or default notary.
5658 * @throws IllegalArgumentException If the preferred notary cannot be found in the network map cache.
5759 */
5860@Suspendable
59- inline fun FlowLogic <* >.getPreferredNotary (defaultSelector : (ServiceHub ) -> Party = { firstNotary }): Party {
61+ fun FlowLogic <* >.getPreferredNotary (
62+ serviceHub : ServiceHub = this.serviceHub,
63+ defaultSelector : (ServiceHub ) -> Party = { firstNotary }
64+ ): Party {
65+ val cordappContext: CordappContext = serviceHub.getAppContext()
66+ logger.info(" Using the specified cordapp for notary selection: ${cordappContext.cordapp.name} " )
6067 return if (serviceHub.getAppContext().config.exists(" notary" )) {
6168 val name = CordaX500Name .parse(serviceHub.getAppContext().config.getString(" notary" ))
6269 serviceHub.networkMapCache.getNotary(name) ? : throw IllegalArgumentException (
0 commit comments