r27003 - trunk/freenet/src/freenet/client/async
[email protected] Sat, 18 Apr 2009 18:08:31 +0000
| Newsgroups | gmane.network.freenet.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: toad
Date: 2009-04-18 18:08:30 +0000 (Sat, 18 Apr 2009)
New Revision: 27003
Modified:
trunk/freenet/src/freenet/client/async/USKManager.java
Log:
Two hintUpdate() methods for applications such as Freetalk/WoT that might get non-authoritative hints to edition numbers.
Modified: trunk/freenet/src/freenet/client/async/USKManager.java
===================================================================
--- trunk/freenet/src/freenet/client/async/USKManager.java 2009-04-18 18:00:47 UTC (rev 27002)
+++ trunk/freenet/src/freenet/client/async/USKManager.java 2009-04-18 18:08:30 UTC (rev 27003)
@@ -3,6 +3,7 @@
* http://www.gnu.org/ for further details of the GPL. */
package freenet.client.async;
+import java.net.MalformedURLException;
import java.util.HashMap;
import java.util.Vector;
@@ -126,7 +127,43 @@
public USKFetcherTag getFetcherForInsertDontSchedule(USK usk, short prioClass, USKFetcherCallback cb, RequestClient client, ObjectContainer container, ClientContext context, boolean persistent) {
return getFetcher(usk, persistent ? new FetchContext(backgroundFetchContext, FetchContext.IDENTICAL_MASK, false, null) : backgroundFetchContext, true, client.persistent(), cb, true, container, context);
}
+
+ /**
+ * A non-authoritative hint that a specific edition *might* exist. At the moment,
+ * we just fetch the block. We do not fetch the contents, and it is possible that
+ * USKFetcher's are also fetching the block.
+ * @param usk
+ * @param edition
+ * @param context
+ */
+ public void hintUpdate(USK usk, long edition, ClientContext context) {
+ if(edition < lookupLatestSlot(usk)) return;
+ FreenetURI uri = usk.copy(edition).getURI();
+ final ClientGetter get = new ClientGetter(new NullClientCallback(), uri, new FetchContext(backgroundFetchContext, FetchContext.IDENTICAL_MASK, false, null), RequestStarter.UPDATE_PRIORITY_CLASS, USKManager.this, new NullBucket(), null);
+ try {
+ get.start(null, context);
+ } catch (FetchException e) {
+ // Ignore
+ }
+ }
+ /**
+ * A non-authoritative hint that a specific edition *might* exist. At the moment,
+ * we just fetch the block. We do not fetch the contents, and it is possible that
+ * USKFetcher's are also fetching the block.
+ * @param context
+ * @throws MalformedURLException If the uri passed in is not a USK.
+ */
+ public void hintUpdate(FreenetURI uri, ClientContext context) throws MalformedURLException {
+ if(uri.getSuggestedEdition() < lookupLatestSlot(USK.create(uri))) return;
+ final ClientGetter get = new ClientGetter(new NullClientCallback(), uri, new FetchContext(backgroundFetchContext, FetchContext.IDENTICAL_MASK, false, null), RequestStarter.UPDATE_PRIORITY_CLASS, USKManager.this, new NullBucket(), null);
+ try {
+ get.start(null, context);
+ } catch (FetchException e) {
+ // Ignore
+ }
+ }
+
public void startTemporaryBackgroundFetcher(USK usk, ClientContext context, final FetchContext fctx, boolean prefetchContent) {
USK clear = usk.clearCopy();
USKFetcher sched = null;