mirror of
https://github.com/corda/corda.git
synced 2025-02-11 21:26:23 +00:00
ENT-1668 - Don't crash on node startup when network map is not available (#2897)
* ENT-1668: Don't crash on node startup when network map is not available (#2887) Fix ENT-1668 Don't crash on node startup when network map is not available * Add changelog entry
This commit is contained in:
parent
5ac4c7eda7
commit
becfcf8b6c
@ -5,7 +5,7 @@ Here are brief summaries of what's changed between each snapshot release. This i
|
|||||||
from the previous milestone release.
|
from the previous milestone release.
|
||||||
|
|
||||||
Unreleased
|
Unreleased
|
||||||
-----------
|
----------
|
||||||
|
|
||||||
* Update the fast-classpath-scanner dependent library version from 2.0.21 to 2.12.3
|
* Update the fast-classpath-scanner dependent library version from 2.0.21 to 2.12.3
|
||||||
|
|
||||||
@ -21,6 +21,9 @@ Unreleased
|
|||||||
* Fixed security vulnerability when using the ``HashAttachmentConstraint``. Added strict check that the contract JARs
|
* Fixed security vulnerability when using the ``HashAttachmentConstraint``. Added strict check that the contract JARs
|
||||||
referenced in a transaction were deployed on the node.
|
referenced in a transaction were deployed on the node.
|
||||||
|
|
||||||
|
* Fixed node's behaviour on startup when there is no connectivity to network map. Node continues to work normally if it has
|
||||||
|
all the needed network data, waiting in the background for network map to become available.
|
||||||
|
|
||||||
.. _changelog_v3:
|
.. _changelog_v3:
|
||||||
|
|
||||||
Version 3.0
|
Version 3.0
|
||||||
|
@ -10,6 +10,7 @@ import net.corda.nodeapi.internal.network.NETWORK_PARAMS_FILE_NAME
|
|||||||
import net.corda.nodeapi.internal.network.NETWORK_PARAMS_UPDATE_FILE_NAME
|
import net.corda.nodeapi.internal.network.NETWORK_PARAMS_UPDATE_FILE_NAME
|
||||||
import net.corda.nodeapi.internal.network.SignedNetworkParameters
|
import net.corda.nodeapi.internal.network.SignedNetworkParameters
|
||||||
import net.corda.nodeapi.internal.network.verifiedNetworkMapCert
|
import net.corda.nodeapi.internal.network.verifiedNetworkMapCert
|
||||||
|
import java.net.ConnectException
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
import java.nio.file.StandardCopyOption
|
import java.nio.file.StandardCopyOption
|
||||||
import java.security.cert.X509Certificate
|
import java.security.cert.X509Certificate
|
||||||
@ -26,7 +27,13 @@ class NetworkParametersReader(private val trustRoot: X509Certificate,
|
|||||||
val networkParameters by lazy { retrieveNetworkParameters() }
|
val networkParameters by lazy { retrieveNetworkParameters() }
|
||||||
|
|
||||||
private fun retrieveNetworkParameters(): NetworkParameters {
|
private fun retrieveNetworkParameters(): NetworkParameters {
|
||||||
val advertisedParametersHash = networkMapClient?.getNetworkMap()?.payload?.networkParameterHash
|
val advertisedParametersHash = try {
|
||||||
|
networkMapClient?.getNetworkMap()?.payload?.networkParameterHash
|
||||||
|
} catch (e: ConnectException) {
|
||||||
|
logger.info("Couldn't connect to NetworkMap", e)
|
||||||
|
// If NetworkMap is down while restarting the node, we should be still able to continue with parameters from file
|
||||||
|
null
|
||||||
|
}
|
||||||
val signedParametersFromFile = if (networkParamsFile.exists()) {
|
val signedParametersFromFile = if (networkParamsFile.exists()) {
|
||||||
networkParamsFile.readObject<SignedNetworkParameters>()
|
networkParamsFile.readObject<SignedNetworkParameters>()
|
||||||
} else {
|
} else {
|
||||||
@ -45,7 +52,7 @@ class NetworkParametersReader(private val trustRoot: X509Certificate,
|
|||||||
readParametersUpdate(advertisedParametersHash, signedParametersFromFile.raw.hash).verifiedNetworkMapCert(trustRoot)
|
readParametersUpdate(advertisedParametersHash, signedParametersFromFile.raw.hash).verifiedNetworkMapCert(trustRoot)
|
||||||
}
|
}
|
||||||
} else { // No compatibility zone configured. Node should proceed with parameters from file.
|
} else { // No compatibility zone configured. Node should proceed with parameters from file.
|
||||||
signedParametersFromFile?.verifiedNetworkMapCert(trustRoot) ?: throw IllegalArgumentException("Couldn't find network parameters file and compatibility zone wasn't configured")
|
signedParametersFromFile?.verifiedNetworkMapCert(trustRoot) ?: throw IllegalArgumentException("Couldn't find network parameters file and compatibility zone wasn't configured/isn't reachable")
|
||||||
}
|
}
|
||||||
logger.info("Loaded network parameters: $parameters")
|
logger.info("Loaded network parameters: $parameters")
|
||||||
return parameters
|
return parameters
|
||||||
|
Loading…
x
Reference in New Issue
Block a user