mirror of
https://github.com/corda/corda.git
synced 2025-01-31 08:25:50 +00:00
Add ability to set custom initiating flows for NotaryService (#6832)
This commit is contained in:
parent
284fd48918
commit
56df286410
@ -14,6 +14,14 @@ abstract class NotaryService : SingletonSerializeAsToken() {
|
|||||||
abstract val services: ServiceHub
|
abstract val services: ServiceHub
|
||||||
abstract val notaryIdentityKey: PublicKey
|
abstract val notaryIdentityKey: PublicKey
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mapping between @InitiatingFlow classes and factory methods that produce responder flows.
|
||||||
|
* Can be overridden in case of advanced notary service that serves both custom and standard flows.
|
||||||
|
*/
|
||||||
|
open val initiatingFlows = mapOf(
|
||||||
|
NotaryFlow.Client::class to ::createServiceFlow
|
||||||
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interfaces for the request and result formats of queries supported by notary services. To
|
* Interfaces for the request and result formats of queries supported by notary services. To
|
||||||
* implement a new query, you must:
|
* implement a new query, you must:
|
||||||
|
@ -189,7 +189,6 @@ import java.util.concurrent.TimeUnit.SECONDS
|
|||||||
import java.util.function.Consumer
|
import java.util.function.Consumer
|
||||||
import javax.persistence.EntityManager
|
import javax.persistence.EntityManager
|
||||||
import javax.sql.DataSource
|
import javax.sql.DataSource
|
||||||
import kotlin.collections.ArrayList
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A base node implementation that can be customised either for production (with real implementations that do real
|
* A base node implementation that can be customised either for production (with real implementations that do real
|
||||||
@ -1026,13 +1025,23 @@ abstract class AbstractNode<S>(val configuration: NodeConfiguration,
|
|||||||
service.run {
|
service.run {
|
||||||
tokenize()
|
tokenize()
|
||||||
runOnStop += ::stop
|
runOnStop += ::stop
|
||||||
flowManager.registerInitiatedCoreFlowFactory(NotaryFlow.Client::class, ::createServiceFlow)
|
registerInitiatingFlows()
|
||||||
start()
|
start()
|
||||||
}
|
}
|
||||||
return service
|
return service
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun NotaryService.registerInitiatingFlows() {
|
||||||
|
if (configuration.notary?.enableOverridableFlows == true) {
|
||||||
|
initiatingFlows.forEach { (flow, factory) ->
|
||||||
|
flowManager.registerInitiatedCoreFlowFactory(flow, factory)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
flowManager.registerInitiatedCoreFlowFactory(NotaryFlow.Client::class, ::createServiceFlow)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected open fun makeKeyManagementService(identityService: PersistentIdentityService): KeyManagementServiceInternal {
|
protected open fun makeKeyManagementService(identityService: PersistentIdentityService): KeyManagementServiceInternal {
|
||||||
// Place the long term identity key in the KMS. Eventually, this is likely going to be separated again because
|
// Place the long term identity key in the KMS. Eventually, this is likely going to be separated again because
|
||||||
// the KMS is meant for derived temporary keys used in transactions, and we're not supposed to sign things with
|
// the KMS is meant for derived temporary keys used in transactions, and we're not supposed to sign things with
|
||||||
|
@ -166,7 +166,8 @@ data class NotaryConfig(
|
|||||||
/** Notary implementation-specific configuration parameters. */
|
/** Notary implementation-specific configuration parameters. */
|
||||||
val extraConfig: Config? = null,
|
val extraConfig: Config? = null,
|
||||||
val raft: RaftConfig? = null,
|
val raft: RaftConfig? = null,
|
||||||
val bftSMaRt: BFTSmartConfig? = null
|
val bftSMaRt: BFTSmartConfig? = null,
|
||||||
|
val enableOverridableFlows: Boolean? = null
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -208,10 +208,22 @@ internal object NotaryConfigSpec : Configuration.Specification<NotaryConfig>("No
|
|||||||
private val extraConfig by nestedObject().map(ConfigObject::toConfig).optional()
|
private val extraConfig by nestedObject().map(ConfigObject::toConfig).optional()
|
||||||
private val raft by nested(RaftConfigSpec).optional()
|
private val raft by nested(RaftConfigSpec).optional()
|
||||||
private val bftSMaRt by nested(BFTSmartConfigSpec).optional()
|
private val bftSMaRt by nested(BFTSmartConfigSpec).optional()
|
||||||
|
private val enableOverridableFlows by boolean().optional()
|
||||||
|
|
||||||
override fun parseValid(configuration: Config, options: Configuration.Options): Valid<NotaryConfig> {
|
override fun parseValid(configuration: Config, options: Configuration.Options): Valid<NotaryConfig> {
|
||||||
val config = configuration.withOptions(options)
|
val config = configuration.withOptions(options)
|
||||||
return valid(NotaryConfig(config[validating], config[serviceLegalName], config[className], config[etaMessageThresholdSeconds], config[extraConfig], config[raft], config[bftSMaRt]))
|
return valid(
|
||||||
|
NotaryConfig(
|
||||||
|
config[validating],
|
||||||
|
config[serviceLegalName],
|
||||||
|
config[className],
|
||||||
|
config[etaMessageThresholdSeconds],
|
||||||
|
config[extraConfig],
|
||||||
|
config[raft],
|
||||||
|
config[bftSMaRt],
|
||||||
|
config[enableOverridableFlows]
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user