mirror of
https://github.com/corda/corda.git
synced 2025-02-11 13:16:10 +00:00
CORDA-1670 fix multiple CorDapps for flow check (#3436)
* CORDA-1670 fix multiple CorDapps for flow check * CORDA-1670 fix multiple CorDapps for flow check * CORDA-1670 address code review comment
This commit is contained in:
parent
1d95ffba3a
commit
4ea8091667
@ -15,6 +15,7 @@ import net.corda.node.NodeRegistrationOption
|
|||||||
import net.corda.node.SerialFilter
|
import net.corda.node.SerialFilter
|
||||||
import net.corda.node.VersionInfo
|
import net.corda.node.VersionInfo
|
||||||
import net.corda.node.defaultSerialFilter
|
import net.corda.node.defaultSerialFilter
|
||||||
|
import net.corda.node.internal.cordapp.MultipleCordappsForFlowException
|
||||||
import net.corda.node.services.config.NodeConfiguration
|
import net.corda.node.services.config.NodeConfiguration
|
||||||
import net.corda.node.services.config.NodeConfigurationImpl
|
import net.corda.node.services.config.NodeConfigurationImpl
|
||||||
import net.corda.node.services.config.shouldStartLocalShell
|
import net.corda.node.services.config.shouldStartLocalShell
|
||||||
@ -135,6 +136,9 @@ open class NodeStartup(val args: Array<String>) {
|
|||||||
try {
|
try {
|
||||||
cmdlineOptions.baseDirectory.createDirectories()
|
cmdlineOptions.baseDirectory.createDirectories()
|
||||||
startNode(conf, versionInfo, startTime, cmdlineOptions)
|
startNode(conf, versionInfo, startTime, cmdlineOptions)
|
||||||
|
} catch (e: MultipleCordappsForFlowException) {
|
||||||
|
logger.error(e.message)
|
||||||
|
return false
|
||||||
} catch (e: CouldNotCreateDataSourceException) {
|
} catch (e: CouldNotCreateDataSourceException) {
|
||||||
logger.error(e.message, e.cause)
|
logger.error(e.message, e.cause)
|
||||||
return false
|
return false
|
||||||
|
@ -50,7 +50,7 @@ class CordappLoader private constructor(private val cordappJarPaths: List<Restri
|
|||||||
cordapps.flatMap { corDapp -> corDapp.allFlows.map { flow -> flow to corDapp } }
|
cordapps.flatMap { corDapp -> corDapp.allFlows.map { flow -> flow to corDapp } }
|
||||||
.groupBy { it.first }
|
.groupBy { it.first }
|
||||||
.mapValues {
|
.mapValues {
|
||||||
require(it.value.size == 1) { "There are multiple CorDapp jars on the classpath for flow ${it.value.first().first.name}: ${it.value.map { it.second.name }.joinToString()}." }
|
if(it.value.size > 1) { throw MultipleCordappsForFlowException("There are multiple CorDapp JARs on the classpath for flow ${it.value.first().first.name}: [ ${it.value.joinToString { it.second.name }} ].") }
|
||||||
it.value.single().second
|
it.value.single().second
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -363,3 +363,8 @@ class CordappLoader private constructor(private val cordappJarPaths: List<Restri
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Thrown when scanning CorDapps.
|
||||||
|
*/
|
||||||
|
class MultipleCordappsForFlowException(message: String) : Exception(message)
|
||||||
|
@ -41,6 +41,9 @@ open class CordappProviderImpl(private val cordappLoader: CordappLoader,
|
|||||||
|
|
||||||
private fun verifyInstalledCordapps(attachmentStorage: AttachmentStorage) {
|
private fun verifyInstalledCordapps(attachmentStorage: AttachmentStorage) {
|
||||||
|
|
||||||
|
// This will invoke the lazy flowCordappMap property, thus triggering the MultipleCordappsForFlow check.
|
||||||
|
cordappLoader.flowCordappMap
|
||||||
|
|
||||||
if (whitelistedContractImplementations.isEmpty()) {
|
if (whitelistedContractImplementations.isEmpty()) {
|
||||||
log.warn("The network parameters don't specify any whitelisted contract implementations. Please contact your zone operator. See https://docs.corda.net/network-map.html")
|
log.warn("The network parameters don't specify any whitelisted contract implementations. Please contact your zone operator. See https://docs.corda.net/network-map.html")
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user