mirror of
https://github.com/corda/corda.git
synced 2025-01-30 16:14:39 +00:00
Notary logs warning on startup when it's not in the whitelist (#5857)
This commit is contained in:
parent
18c9e4a9da
commit
1718af3a79
@ -56,14 +56,16 @@ class NotaryLoader(
|
||||
}
|
||||
|
||||
fun loadService(myNotaryIdentity: PartyAndCertificate?, services: ServiceHubInternal, cordappLoader: CordappLoader): NotaryService {
|
||||
|
||||
val notaryKey = myNotaryIdentity?.owningKey
|
||||
?: throw IllegalArgumentException("Unable to start notary service: notary identity not found")
|
||||
|
||||
warnIfNotaryNotWhitelisted(myNotaryIdentity, services)
|
||||
validateNotaryType(myNotaryIdentity, services)
|
||||
|
||||
val serviceClass = builtInServiceClass ?: scanCorDapps(cordappLoader)
|
||||
log.info("Starting notary service: $serviceClass")
|
||||
|
||||
val notaryKey = myNotaryIdentity?.owningKey
|
||||
?: throw IllegalArgumentException("Unable to start notary service: notary identity not found")
|
||||
|
||||
/** Some notary implementations only work with Java serialization. */
|
||||
maybeInstallSerializationFilter(serviceClass)
|
||||
|
||||
@ -78,15 +80,26 @@ class NotaryLoader(
|
||||
}
|
||||
}
|
||||
|
||||
/** Validates that the notary is correctly configured by comparing the configured type against the type advertised in the network map cache */
|
||||
private fun validateNotaryType(myNotaryIdentity: PartyAndCertificate?, services: ServiceHubInternal) {
|
||||
var configuredAsValidatingNotary = services.configuration.notary?.validating
|
||||
val notaryParty = myNotaryIdentity?.party ?: throw IllegalStateException("Could not establish notary identity of this node")
|
||||
var validatingNotaryInNetworkMapCache = services.networkMapCache.isValidatingNotary(notaryParty)
|
||||
/** Log a warning if the notary is not whitelisted in the network parameters. */
|
||||
private fun warnIfNotaryNotWhitelisted(myNotaryIdentity: PartyAndCertificate, services: ServiceHubInternal) {
|
||||
val ourParty = myNotaryIdentity.party
|
||||
if (!services.networkMapCache.isNotary(ourParty)) {
|
||||
log.warn("Provided notary identity is not in whitelist")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates that the notary is correctly configured by comparing the configured type against the
|
||||
* type advertised in the network map cache.
|
||||
*/
|
||||
private fun validateNotaryType(myNotaryIdentity: PartyAndCertificate, services: ServiceHubInternal) {
|
||||
val configuredAsValidatingNotary = services.configuration.notary?.validating
|
||||
val notaryParty = myNotaryIdentity.party
|
||||
val validatingNotaryInNetworkMapCache = services.networkMapCache.isValidatingNotary(notaryParty)
|
||||
|
||||
if(configuredAsValidatingNotary != validatingNotaryInNetworkMapCache) {
|
||||
throw IllegalStateException("There is a discrepancy in the configured notary type and the one advertised in the network parameters - shutting down. "
|
||||
+ "Configured as validating: ${configuredAsValidatingNotary}. Advertised as validating: ${validatingNotaryInNetworkMapCache}")
|
||||
log.warn("There is a discrepancy in the configured notary type and the one advertised in the network parameters. " +
|
||||
"Configured as validating: $configuredAsValidatingNotary. Advertised as validating: $validatingNotaryInNetworkMapCache")
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user