Use a timed map to forget all trust values after a minute.
[Sone.git] / src / main / java / net / pterodactylus / sone / freenet / wot / DefaultIdentity.java
index 00caf48..f00fa4e 100644 (file)
@@ -30,6 +30,7 @@ import net.pterodactylus.util.cache.DefaultCacheItem;
 import net.pterodactylus.util.cache.MemoryCache;
 import net.pterodactylus.util.cache.ValueRetriever;
 import net.pterodactylus.util.cache.WritableCache;
+import net.pterodactylus.util.collection.TimedMap;
 
 /**
  * A Web of Trust identity.
@@ -69,7 +70,7 @@ public class DefaultIdentity implements Identity {
                        }
                }
 
-       });
+       }, new TimedMap<OwnIdentity, CacheItem<Trust>>(60000));
 
        /**
         * Creates a new identity.
@@ -248,6 +249,18 @@ public class DefaultIdentity implements Identity {
                }
        }
 
+       /**
+        * Sets the trust received for this identity by the given own identity.
+        *
+        * @param ownIdentity
+        *            The own identity that gives the trust
+        * @param trust
+        *            The trust received for this identity
+        */
+       void setTrustPrivate(OwnIdentity ownIdentity, Trust trust) {
+               trustCache.put(ownIdentity, trust);
+       }
+
        //
        // OBJECT METHODS
        //