From 87c5ad8b88c7fa9a8cff1a9ecccb5c393628a0d5 Mon Sep 17 00:00:00 2001 From: Tudor Malene Date: Mon, 5 Mar 2018 16:27:50 +0000 Subject: [PATCH] CORDA-1150 - better log messages (#2721) * CORDA-1150 better log messages * CORDA-1150 better log messages * CORDA-1150 better log messages --- .../internal/network/NetworkBootstrapper.kt | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/node-api/src/main/kotlin/net/corda/nodeapi/internal/network/NetworkBootstrapper.kt b/node-api/src/main/kotlin/net/corda/nodeapi/internal/network/NetworkBootstrapper.kt index 7b7649cb9d..b88b51f0dd 100644 --- a/node-api/src/main/kotlin/net/corda/nodeapi/internal/network/NetworkBootstrapper.kt +++ b/node-api/src/main/kotlin/net/corda/nodeapi/internal/network/NetworkBootstrapper.kt @@ -188,12 +188,15 @@ class NetworkBootstrapper { } private fun generateWhitelist(whitelistFile: Path, excludeWhitelistFile: Path, cordapps: List?): Map> { + val existingWhitelist = if (whitelistFile.exists()) readContractWhitelist(whitelistFile) else emptyMap() - println("Found existing whitelist:") - existingWhitelist.forEach { println(it.outputString()) } + + println(if (existingWhitelist.isEmpty()) "No existing whitelist file found." else "Found existing whitelist: ${whitelistFile}") val excludeContracts = if (excludeWhitelistFile.exists()) readExcludeWhitelist(excludeWhitelistFile) else emptyList() - println("Exclude Contracts from whitelist: $excludeContracts") + if (excludeContracts.isNotEmpty()) { + println("Exclude contracts from whitelist: ${excludeContracts.joinToString()}}") + } val newWhiteList: Map = cordapps?.flatMap { cordappJarPath -> val jarHash = getJarHash(cordappJarPath) @@ -202,8 +205,7 @@ class NetworkBootstrapper { } }?.filter { (contractClassName, _) -> contractClassName !in excludeContracts }?.toMap() ?: emptyMap() - println("Calculating whitelist for current CorDapps:") - newWhiteList.forEach { (contract, attachment) -> println("$contract:$attachment") } + println("Calculating whitelist for current installed CorDapps..") val merged = (newWhiteList.keys + existingWhitelist.keys).map { contractClassName -> val existing = existingWhitelist[contractClassName] ?: emptyList() @@ -211,9 +213,7 @@ class NetworkBootstrapper { contractClassName to (if (newHash == null || newHash in existing) existing else existing + newHash) }.toMap() - println("Final whitelist:") - merged.forEach { println(it.outputString()) } - + println("CorDapp whitelist " + (if (existingWhitelist.isEmpty()) "generated" else "updated") + " in ${whitelistFile}") return merged } @@ -243,10 +243,10 @@ class NetworkBootstrapper { private fun NodeInfo.notaryIdentity(): Party { return when (legalIdentities.size) { - // Single node notaries have just one identity like all other nodes. This identity is the notary identity + // Single node notaries have just one identity like all other nodes. This identity is the notary identity 1 -> legalIdentities[0] - // Nodes which are part of a distributed notary have a second identity which is the composite identity of the - // cluster and is shared by all the other members. This is the notary identity. + // Nodes which are part of a distributed notary have a second identity which is the composite identity of the + // cluster and is shared by all the other members. This is the notary identity. 2 -> legalIdentities[1] else -> throw IllegalArgumentException("Not sure how to get the notary identity in this scenerio: $this") }