@Override public String getText() { return l10n("bookmarkUpdated", new String[]{"name", "edition"}, new String[]{name, Long.toString(key.getSuggestedEdition())}); }
public static InsertableUSK createInsertable(FreenetURI uri, boolean persistent) throws MalformedURLException { if(!uri.getKeyType().equalsIgnoreCase("USK")) throw new MalformedURLException(); InsertableClientSSK ssk = InsertableClientSSK.create(uri.setKeyType("SSK")); return new InsertableUSK(ssk.docName, ssk.pubKeyHash, ssk.cryptoKey, ssk.privKey, uri.getSuggestedEdition(), ssk.cryptoAlgorithm); }
OfficialPluginDescription(String name, String group, boolean essential, long minVer, long recVer, boolean alwaysFetchLatestVersion, boolean usesXML, FreenetURI uri, boolean deprecated, boolean experimental, boolean advanced, boolean unsupported) { this.name = name; this.group = group; this.essential = essential; this.minimumVersion = minVer; this.recommendedVersion = recVer; this.alwaysFetchLatestVersion = alwaysFetchLatestVersion; this.usesXML = usesXML; this.deprecated = deprecated; this.experimental = experimental; this.advanced = advanced; this.unsupported = unsupported; if (alwaysFetchLatestVersion && uri != null) { assert(uri.isUSK()) : "Non-USK URIs do not support updates!"; // Force fetching the latest edition by setting a negative USK edition. long edition = uri.getSuggestedEdition(); if (edition >= 0) { edition = Math.min(-1, -edition); } uri = uri.setSuggestedEdition(edition); } this.uri = uri; }
/** @return True if we updated the edition */ public synchronized boolean setEdition(long ed, NodeClientCore node) { if (key.getSuggestedEdition() >= ed) { if(logMINOR) Logger.minor(this, "Edition "+ed+" is too old, not updating "+key); return false; } key = key.setSuggestedEdition(ed); enableBookmark(); return true; }
/** If the key is a USK and a) we are requested to do an exhaustive search, or b) * there is a later version, then we can't use the download queue as a cache. * @return True if we can't use the download queue, false if we can. */ private boolean bogusUSK(ClientContext context) { if(!uri.isUSK()) return false; long edition = uri.getSuggestedEdition(); if(edition < 0) return true; // Need to do the fetch. USK usk; try { usk = USK.create(uri); } catch (MalformedURLException e) { return false; // Will fail later. } long ret = context.uskManager.lookupKnownGood(usk); if(ret == -1) return false; return ret > edition; }
public static USK create(FreenetURI uri) throws MalformedURLException { if(!uri.isUSK()) throw new MalformedURLException("Not a USK"); return new USK(uri.getRoutingKey(), uri.getCryptoKey(), uri.getExtra(), uri.getDocName(), uri.getSuggestedEdition()); }
if (!b.key.setSuggestedEdition(key.getSuggestedEdition()).equals(key)) { return false;
@Override public HTMLNode getHTMLText() { HTMLNode n = new HTMLNode("div"); NodeL10n.getBase().addL10nSubstitution(n, "BookmarkItem.bookmarkUpdatedWithLink", new String[]{"link", "name", "edition"}, new HTMLNode[] { HTMLNode.link("/"+key), HTMLNode.text(name), HTMLNode.text(key.getSuggestedEdition()) }); return n; }
public void checkUSK(FreenetURI uri, boolean persistent, boolean isMetadata) { try { FreenetURI uu; if(uri.isSSK() && uri.isSSKForUSK()) { uu = uri.setMetaString(null).uskForSSK(); } else if(uri.isUSK()) { uu = uri; } else { return; } USK usk = USK.create(uu); if(!isMetadata) context.uskManager.updateKnownGood(usk, uu.getSuggestedEdition(), context); else // We don't know whether the metadata is fetchable. // FIXME add a callback so if the rest of the request completes we updateKnownGood(). context.uskManager.updateSlot(usk, uu.getSuggestedEdition(), context); } catch (MalformedURLException e) { Logger.error(this, "Caught "+e, e); } catch (Throwable t) { // Don't let the USK hint cause us to not succeed on the block. Logger.error(this, "Caught "+t, t); } } }
@Override public void onGeneratedURI(FreenetURI uri, BaseClientPutter state) { if(logMINOR) Logger.minor(this, "Generated URI for " + darknetOpennetString + " ARK: "+uri); long l = uri.getSuggestedEdition(); if(l < crypto.myARKNumber) { Logger.error(this, "Inserted " + darknetOpennetString + " ARK edition # lower than attempted: "+l+" expected "+crypto.myARKNumber); } else if(l > crypto.myARKNumber) { if(logMINOR) Logger.minor(this, darknetOpennetString + " ARK number moving from "+crypto.myARKNumber+" to "+l); crypto.myARKNumber = l; if(crypto.isOpennet) node.writeOpennetFile(); else node.writeNodeFile(); // We'll broadcast the new ARK edition to our connected peers via a differential node reference SimpleFieldSet fs = new SimpleFieldSet(true); fs.put("ark.number", crypto.myARKNumber); node.peers.locallyBroadcastDiffNodeRef(fs, !crypto.isOpennet, crypto.isOpennet); } }
/** * 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. FIXME would it be more efficient to * pass it along to a USKFetcher? * @param context * @throws MalformedURLException If the uri passed in is not a USK. */ public void hintUpdate(FreenetURI uri, ClientContext context, short priority) throws MalformedURLException { if(uri.getSuggestedEdition() < lookupLatestSlot(USK.create(uri))) { if(logMINOR) Logger.minor(this, "Ignoring hint because edition is "+uri.getSuggestedEdition()+" but latest is "+lookupLatestSlot(USK.create(uri))); return; } uri = uri.sskForUSK(); if(logMINOR) Logger.minor(this, "Doing hint fetch for "+uri); final ClientGetter get = new ClientGetter(new NullClientCallback(rcBulk), uri, new FetchContext(backgroundFetchContext, FetchContext.IDENTICAL_MASK), priority, new NullBucket(), null, null); try { get.start(context); } catch (FetchException e) { if(logMINOR) Logger.minor(this, "Cannot start hint fetch for "+uri+" : "+e, e); // Ignore } }
if(originalURI.isUSK()) { newURI = newURI.uskForSSK(); newURI = newURI.setSuggestedEdition(originalURI.getSuggestedEdition());
if(fr.hasData()) { if(fr.getFetchCount() > 1 && !fr.hasWaited() && fr.getFetchCount() > 1 && key.isUSK() && context.uskManager.lookupKnownGood(USK.create(key)) > key.getSuggestedEdition()) { Logger.normal(this, "Loading later edition..."); fetch.progress.requestImmediateCancel();