X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ffreenet%2Fwot%2FDefaultIdentity.java;h=f00fa4ed40535c64f3f30184b06abd8fba6e6679;hb=c7d7acf5f7325f4b8ffa8c564275782601a79059;hp=d262d57eaae048d549bcf34fa4eac448ebda7b43;hpb=437147c8b5d4c6630b6ee9323f9778bb9c13e7f4;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/DefaultIdentity.java b/src/main/java/net/pterodactylus/sone/freenet/wot/DefaultIdentity.java index d262d57..f00fa4e 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/DefaultIdentity.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/DefaultIdentity.java @@ -24,12 +24,13 @@ import java.util.Map; import java.util.Set; import net.pterodactylus.sone.freenet.plugin.PluginException; -import net.pterodactylus.util.cache.Cache; import net.pterodactylus.util.cache.CacheException; import net.pterodactylus.util.cache.CacheItem; 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. @@ -57,7 +58,7 @@ public class DefaultIdentity implements Identity { private final Map properties = Collections.synchronizedMap(new HashMap()); /** Cached trust. */ - private final Cache trustCache = new MemoryCache(new ValueRetriever() { + private final WritableCache trustCache = new MemoryCache(new ValueRetriever() { @Override @SuppressWarnings("synthetic-access") @@ -69,7 +70,7 @@ public class DefaultIdentity implements Identity { } } - }); + }, new TimedMap>(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 //