🚧 Try to only allow identities that have no or positive trust
[Sone.git] / src / main / kotlin / net / pterodactylus / sone / freenet / wot / DefaultIdentity.kt
index fe84584..88527b3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Sone - DefaultIdentity.java - Copyright Â© 2010–2019 David Roden
+ * Sone - DefaultIdentity.kt - Copyright Â© 2010–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
@@ -17,7 +17,9 @@
 
 package net.pterodactylus.sone.freenet.wot
 
-import java.util.Collections.*
+import java.util.Collections.synchronizedMap
+import java.util.Collections.synchronizedSet
+import kotlin.collections.set
 
 /**
  * A Web of Trust identity.
@@ -77,6 +79,10 @@ open class DefaultIdentity(private val id: String, private val nickname: String?
                }
        }
 
+       override fun getTrust(): Map<OwnIdentity, Trust> = synchronized(trustCache) {
+               trustCache.toMap()
+       }
+
        override fun getTrust(ownIdentity: OwnIdentity) = synchronized(trustCache) {
                trustCache[ownIdentity]
        }