Examples of USK


Examples of freenet.keys.USK

   
  };

  void updateKnownGood(final USK origUSK, final long number, final ClientContext context) {
    if(logMINOR) Logger.minor(this, "Updating (known good) "+origUSK.getURI()+" : "+number);
    USK clear = origUSK.clearCopy();
    final USKCallback[] callbacks;
    boolean newSlot = false;
    synchronized(this) {
      Long l = latestKnownGoodByClearUSK.get(clear);
      if(logMINOR) Logger.minor(this, "Old known good: "+l);
      if((l == null) || (number > l.longValue())) {
        l = Long.valueOf(number);
        latestKnownGoodByClearUSK.put(clear, l);
        if(logMINOR) Logger.minor(this, "Put "+number);
      } else
        return; // If it's in KnownGood, it will also be in Slot
     
      l = latestSlotByClearUSK.get(clear);
      if(logMINOR) Logger.minor(this, "Old slot: "+l);
      if((l == null) || (number > l.longValue())) {
        l = Long.valueOf(number);
        latestSlotByClearUSK.put(clear, l);
        if(logMINOR) Logger.minor(this, "Put "+number);
        newSlot = true;
      }
     
      callbacks = subscribersByClearUSK.get(clear);
    }
    if(callbacks != null) {
      // Run off-thread, because of locking, and because client callbacks may take some time
          final USK usk = origUSK.copy(number);
          final boolean newSlotToo = newSlot;
          for(final USKCallback callback : callbacks)
            context.mainExecutor.execute(new Runnable() {
              @Override
              public void run() {
View Full Code Here

Examples of freenet.keys.USK

        }
  }
 
  void updateSlot(final USK origUSK, final long number, final ClientContext context) {
    if(logMINOR) Logger.minor(this, "Updating (slot) "+origUSK.getURI()+" : "+number);
    USK clear = origUSK.clearCopy();
    final USKCallback[] callbacks;
    synchronized(this) {
      Long l = latestSlotByClearUSK.get(clear);
      if(logMINOR) Logger.minor(this, "Old slot: "+l);
      if((l == null) || (number > l.longValue())) {
        l = Long.valueOf(number);
        latestSlotByClearUSK.put(clear, l);
        if(logMINOR) Logger.minor(this, "Put "+number);
      } else
        return;
     
      callbacks = subscribersByClearUSK.get(clear);
      if(temporaryBackgroundFetchersPrefetch.containsKey(clear)) {
        temporaryBackgroundFetchersPrefetch.put(clear, System.currentTimeMillis());
        schedulePrefetchChecker();
      }
    }
    if(callbacks != null) {
      // Run off-thread, because of locking, and because client callbacks may take some time
          final USK usk = origUSK.copy(number);
          for(final USKCallback callback : callbacks)
            context.mainExecutor.execute(new Runnable() {
              @Override
              public void run() {
                callback.onFoundEdition(number, usk, // non-persistent
View Full Code Here

Examples of freenet.keys.USK

    long curEd;
    curEd = lookupLatestSlot(origUSK);
    long goodEd;
    goodEd = lookupKnownGood(origUSK);
    synchronized(this) {
      USK clear = origUSK.clearCopy();
      USKCallback[] callbacks = subscribersByClearUSK.get(clear);
      if(callbacks == null) {
        callbacks = new USKCallback[] { cb };
      } else {
        boolean mustAdd = true;
View Full Code Here

Examples of freenet.keys.USK

  }
 
  public void unsubscribe(USK origUSK, USKCallback cb) {
    USKFetcher toCancel = null;
    synchronized(this) {
      USK clear = origUSK.clearCopy();
      USKCallback[] callbacks = subscribersByClearUSK.get(clear);
      if(callbacks == null){ // maybe we should throw something ? shall we allow multiple unsubscriptions ?
        if(logMINOR) Logger.minor(this, "No longer subscribed");
        return;
      }
View Full Code Here

Examples of freenet.keys.USK

  public void onFinished(USKFetcher fetcher) {
    onFinished(fetcher, false);
  }
 
  public void onFinished(USKFetcher fetcher, boolean ignoreError) {
    USK orig = fetcher.getOriginalUSK();
    USK clear = orig.clearCopy();
    synchronized(this) {
      if(backgroundFetchersByClearUSK.get(clear) == fetcher) {
        backgroundFetchersByClearUSK.remove(clear);
        if(!ignoreError) {
          // This shouldn't happen, it's a sanity check: the only way we get cancelled is from USKManager, which removes us before calling cancel().
View Full Code Here

Examples of freenet.keys.USK

      } 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().
View Full Code Here

Examples of freenet.keys.USK

  synchronized void updatedEdition(long ed) {
    if(edition < ed) edition = ed;
  }

  public void start(USKManager manager, ClientContext context) {
    USK usk = origUSK;
    if(usk.suggestedEdition < edition)
      usk = usk.copy(edition);
    else if(persistent) // Copy it to avoid deactivation issues
      usk = usk.copy();
    fetcher = manager.getFetcher(usk, ctx, new USKFetcherWrapper(usk, priority, realTimeFlag ? USKManager.rcRT : USKManager.rcBulk), keepLastData, checkStoreOnly);
    fetcher.addCallback(this);
    fetcher.schedule(context); // non-persistent
    if(logMINOR) Logger.minor(this, "Starting "+fetcher+" for "+this);
  }
View Full Code Here

Examples of freenet.keys.USK

    if(mRequests.get(identity.getID()) != null) {
      Logger.error(this, "Fetch already exists for identity " + identity);
      return;
    }

    final USK usk;
    final long editionHint;
   
    synchronized(mMessageManager) { // Don't acquire the lock twice
      usk = USK.create(WoTMessageList.generateURI(identity, mMessageManager.getUnavailableNewMessageListIndex(identity)));
      editionHint = mMessageManager.getNewMessageListIndexEditionHint(identity);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.