X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Ffreenet%2Fwot%2FIdentityLoader.kt;h=474ab578695ff85fd81596300b5f1211d4174cc1;hp=417894e5a80a1813f9b021bab026ac2555999da4;hb=438378deab1514f0f608d975ef65f5b7aea44ccb;hpb=9c1bd449767e243193d50ce135a8ceb758a309fb diff --git a/src/main/kotlin/net/pterodactylus/sone/freenet/wot/IdentityLoader.kt b/src/main/kotlin/net/pterodactylus/sone/freenet/wot/IdentityLoader.kt index 417894e..474ab57 100644 --- a/src/main/kotlin/net/pterodactylus/sone/freenet/wot/IdentityLoader.kt +++ b/src/main/kotlin/net/pterodactylus/sone/freenet/wot/IdentityLoader.kt @@ -1,5 +1,5 @@ /* - * Sone - IdentityLoader.java - Copyright © 2013–2019 David Roden + * Sone - IdentityLoader.kt - Copyright © 2013–2020 David Roden * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -38,15 +38,20 @@ class IdentityLoader @Inject constructor(private val webOfTrustConnector: WebOfT @Throws(PluginException::class) private fun loadTrustedIdentitiesForOwnIdentities(ownIdentities: Collection) = - ownIdentities.associateWith { ownIdentity -> - if (ownIdentity.doesNotHaveCorrectContext()) { - emptySet() - } else { - time({ stopwatch, identities -> "Loaded ${identities.size} identities for ${ownIdentity.nickname} in ${stopwatch.elapsed(MILLISECONDS) / 1000.0}s." }) { - webOfTrustConnector.loadTrustedIdentities(ownIdentity, context?.context) + ownIdentities + .also { logger.fine { "Getting trusted identities for ${it.size} own identities..." } } + .associateWith { ownIdentity -> + logger.fine { "Getting trusted identities for $ownIdentity..." } + if (ownIdentity.doesNotHaveCorrectContext()) { + logger.fine { "Skipping $ownIdentity because of incorrect context." } + emptySet() + } else { + logger.fine { "Loading trusted identities for $ownIdentity from WoT..." } + time({ stopwatch, identities -> "Loaded ${identities.size} identities for ${ownIdentity.nickname} in ${stopwatch.elapsed(MILLISECONDS) / 1000.0}s." }) { + webOfTrustConnector.loadTrustedIdentities(ownIdentity, context?.context) + } + } } - } - } private fun OwnIdentity.doesNotHaveCorrectContext() = context?.let { it.context !in contexts } ?: false