private val currentOwnIdentities = mutableSetOf<OwnIdentity>()
private val strictFiltering = AtomicBoolean(false)
+ private val noNegativeIdentityFilter = NoNegativeIdentityFilter()
override val isConnected: Boolean
get() = notThrowing { webOfTrustConnector.ping() }
private fun Map<OwnIdentity, Set<Identity>>.applyStrictFiltering() =
if (strictFiltering.get()) {
- val identitiesWithTrust = values.flatten()
- .groupBy { it.id }
- .mapValues { (_, identities) ->
- identities.reduce { accIdentity, identity ->
- identity.trust.forEach { (ownIdentity: OwnIdentity?, trust: Trust?) ->
- accIdentity.setTrust(ownIdentity, trust)
- }
- accIdentity
- }
- }
-
- mapValues { (_, trustedIdentities) ->
- trustedIdentities.filter { trustedIdentity ->
- identitiesWithTrust[trustedIdentity.id]!!.trust.all { it.value.hasZeroOrPositiveTrust() }
- }
- }
+ noNegativeIdentityFilter.filter(this)
} else {
this
}
} catch (e: Exception) {
false
}
-
-private fun Trust.hasZeroOrPositiveTrust() =
- if (explicit == null) {
- implicit == null || implicit >= 0
- } else {
- explicit >= 0
- }