mirror of
https://github.com/corda/corda.git
synced 2025-06-16 22:28:15 +00:00
In preparation for the removal of advertised services, @CordaService no longer expects a static "type" field for the ServiceType.
Instead @CordaServices will use the main identity of the node.
This commit is contained in:
@ -31,8 +31,8 @@ import net.corda.core.transactions.SignedTransaction
|
||||
import net.corda.core.utilities.NetworkHostAndPort
|
||||
import net.corda.core.utilities.cert
|
||||
import net.corda.core.utilities.debug
|
||||
import net.corda.node.internal.cordapp.CordappLoader
|
||||
import net.corda.node.internal.classloading.requireAnnotation
|
||||
import net.corda.node.internal.cordapp.CordappLoader
|
||||
import net.corda.node.services.NotaryChangeHandler
|
||||
import net.corda.node.services.NotifyTransactionHandler
|
||||
import net.corda.node.services.SwapIdentitiesHandler
|
||||
@ -135,9 +135,6 @@ abstract class AbstractNode(open val configuration: NodeConfiguration,
|
||||
lateinit var database: CordaPersistence
|
||||
protected var dbCloser: (() -> Any?)? = null
|
||||
|
||||
var isPreviousCheckpointsPresent = false
|
||||
private set
|
||||
|
||||
protected val _nodeReadyFuture = openFuture<Unit>()
|
||||
/** Completes once the node has successfully registered with the network map service
|
||||
* or has loaded network map data from local database */
|
||||
@ -149,7 +146,7 @@ abstract class AbstractNode(open val configuration: NodeConfiguration,
|
||||
CordaX500Name.build(cert.subject).copy(commonName = null)
|
||||
}
|
||||
|
||||
val cordappLoader: CordappLoader by lazy {
|
||||
private val cordappLoader: CordappLoader by lazy {
|
||||
val scanPackage = System.getProperty("net.corda.node.cordapp.scan.package")
|
||||
if (scanPackage != null) {
|
||||
check(configuration.devMode) { "Package scanning can only occur in dev mode" }
|
||||
@ -205,10 +202,6 @@ abstract class AbstractNode(open val configuration: NodeConfiguration,
|
||||
|
||||
makeVaultObservers()
|
||||
|
||||
checkpointStorage.forEach {
|
||||
isPreviousCheckpointsPresent = true
|
||||
false
|
||||
}
|
||||
startMessagingService(rpcOps)
|
||||
installCoreFlows()
|
||||
|
||||
@ -233,7 +226,7 @@ abstract class AbstractNode(open val configuration: NodeConfiguration,
|
||||
private class ServiceInstantiationException(cause: Throwable?) : Exception(cause)
|
||||
|
||||
private fun installCordaServices() {
|
||||
cordappLoader.cordapps.flatMap { it.filterEnabledServices(info) }.map {
|
||||
cordappLoader.cordapps.flatMap { it.services }.forEach {
|
||||
try {
|
||||
installCordaService(it)
|
||||
} catch (e: NoSuchMethodException) {
|
||||
@ -486,8 +479,8 @@ abstract class AbstractNode(open val configuration: NodeConfiguration,
|
||||
val address: SingleMessageRecipient = networkMapAddress ?:
|
||||
network.getAddressOfParty(PartyInfo.Node(info)) as SingleMessageRecipient
|
||||
// Register for updates, even if we're the one running the network map.
|
||||
return sendNetworkMapRegistration(address).flatMap { response: RegistrationResponse ->
|
||||
check(response.error == null) { "Unable to register with the network map service: ${response.error}" }
|
||||
return sendNetworkMapRegistration(address).flatMap { (error) ->
|
||||
check(error == null) { "Unable to register with the network map service: $error" }
|
||||
// The future returned addMapService will complete on the same executor as sendNetworkMapRegistration, namely the one used by net
|
||||
services.networkMapCache.addMapService(network, address, true, null)
|
||||
}
|
||||
|
@ -2,12 +2,8 @@ package net.corda.node.internal.cordapp
|
||||
|
||||
import net.corda.core.flows.FlowLogic
|
||||
import net.corda.core.node.CordaPluginRegistry
|
||||
import net.corda.core.node.NodeInfo
|
||||
import net.corda.core.node.services.ServiceType
|
||||
import net.corda.core.schemas.MappedSchema
|
||||
import net.corda.core.serialization.SerializeAsToken
|
||||
import net.corda.core.utilities.debug
|
||||
import net.corda.core.utilities.loggerFor
|
||||
import java.net.URL
|
||||
|
||||
/**
|
||||
@ -27,32 +23,4 @@ data class Cordapp(
|
||||
val services: List<Class<out SerializeAsToken>>,
|
||||
val plugins: List<CordaPluginRegistry>,
|
||||
val customSchemas: Set<MappedSchema>,
|
||||
val jarPath: URL) {
|
||||
companion object {
|
||||
private val logger = loggerFor<Cordapp>()
|
||||
}
|
||||
|
||||
fun filterEnabledServices(info: NodeInfo): List<Class<out SerializeAsToken>> {
|
||||
return services.filter {
|
||||
val serviceType = getServiceType(it)
|
||||
if (serviceType != null && info.serviceIdentities(serviceType).isEmpty()) {
|
||||
logger.debug {
|
||||
"Ignoring ${it.name} as a Corda service since $serviceType is not one of our " +
|
||||
"advertised services"
|
||||
}
|
||||
false
|
||||
} else {
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getServiceType(clazz: Class<*>): ServiceType? {
|
||||
return try {
|
||||
clazz.getField("type").get(null) as ServiceType
|
||||
} catch (e: NoSuchFieldException) {
|
||||
logger.warn("${clazz.name} does not have a type field, optimistically proceeding with install.")
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
val jarPath: URL)
|
Reference in New Issue
Block a user