s243a

plugins.WebOfTrust.introduction.downloadSolutions

May 25th, 2015
469
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.71 KB | None | 0 0
  1. //From line 194 of: https://github.com/freenet/plugin-WebOfTrust/blob/master/src/plugins/WebOfTrust/introduction/IntroductionServer.java
  2.     private void downloadSolutions(final OwnIdentity inserter) throws FetchException {     
  3.         synchronized(mPuzzleStore) {
  4.             final ObjectSet<OwnIntroductionPuzzle> puzzles = mPuzzleStore.getUnsolvedByInserter(inserter);
  5.             Logger.normal(this, "Identity " + inserter.getNickname() + " has " + puzzles.size() + " unsolved puzzles stored. " +
  6.                     "Trying to fetch solutions ...");
  7.            
  8.             for(final OwnIntroductionPuzzle p : puzzles) {
  9.                 try {
  10.                 final FetchContext fetchContext = mClient.getFetchContext();
  11.                 fetchContext.maxArchiveLevels = 0; // Because archives can become huge and WOT does not use them, we should disallow them. See JavaDoc of the variable.
  12.                 // -1 means retry forever. Does make sense here: After 2 retries the fetches go into the cooldown queue, ULPRs are used. So if someone inserts
  13.                 // the puzzle solution during that, we might get to know it.
  14.                 fetchContext.maxSplitfileBlockRetries = -1;
  15.                 fetchContext.maxNonSplitfileRetries = -1;
  16.                 final ClientGetter g = mClient.fetch(
  17.                     p.getSolutionURI(), XMLTransformer.MAX_INTRODUCTION_BYTE_SIZE,
  18.                         this, fetchContext, RequestStarter.UPDATE_PRIORITY_CLASS);
  19.                 addFetch(g);
  20.                 if(logDEBUG) Logger.debug(this, "Trying to fetch captcha solution for " + p.getRequestURI() + " at " + p.getSolutionURI().toString());
  21.                 }
  22.                 catch(RuntimeException e) {
  23.                     Logger.error(this, "Error while trying to fetch captcha solution at " + p.getSolutionURI());
  24.                 }
  25.             }
  26.            
  27.             Logger.normal(this, "Finishing with starting fetches for the puzzle solutions of " + inserter.getNickname());
  28.         }
  29.     }
Add Comment
Please, Sign In to add comment