On Tuesday 11 November 2008 20:49, xor at freenetproject.org wrote:
> Author: xor
> Date: 2008-11-11 20:49:33 +0000 (Tue, 11 Nov 2008)
> New Revision: 23491
> 
> Modified:
>    trunk/plugins/WoT/introduction/IntroductionPuzzle.java
>    trunk/plugins/WoT/introduction/IntroductionServer.java
> Log:
> Implement puzzle solution downloading in the IntroductionServer.
> 
...
> Modified: trunk/plugins/WoT/introduction/IntroductionServer.java
> ===================================================================
> --- trunk/plugins/WoT/introduction/IntroductionServer.java    2008-11-11 
19:45:03 UTC (rev 23490)
> +++ trunk/plugins/WoT/introduction/IntroductionServer.java    2008-11-11 
20:49:33 UTC (rev 23491)
...
>       
> -     private void downloadSolutions(OwnIdentity identity) {
> +     /**
> +      * Called when the node can't fetch a file OR when there is a newer 
edition.
> +      * In our case, called when there is no solution to a puzzle in the 
network.
> +      */
> +     public synchronized void onFailure(FetchException e, ClientGetter 
> state) {
> +             Logger.normal(this, "Downloading puzzle solution " + 
> state.getURI() + " 
failed: ", e);

With retries = -1 this should never happen unless a client inserts bogus data 
to the puzzle slot.

> +
> +             mRequests.remove(state);
> +     }
> +
> +     /**
> +      * Called when a file is successfully fetched. We then add the identity 
which
> +      * solved the puzzle.
> +      */
> +     public synchronized void onSuccess(FetchResult result, ClientGetter 
> state) 
{
> +             Logger.debug(this, "Fetched puzzle solution: " + 
> state.getURI());
> +
> +             try {
> +                     IntroductionPuzzle p = 
> IntroductionPuzzle.getBySolutionURI(db, 
state.getURI());
> +                     Identity newIdentity = p.importSolutionFromXML(db, 
result.asBucket().getInputStream());
> +                     OwnIdentity puzzleOwner = (OwnIdentity)p.getInserter();
> +                     
> +                     puzzleOwner.setTrust(db, newIdentity, (byte)0, null); 
> /* FIXME: is 0 the 
proper trust for newly imported identities? */

No, because nobody will see them.
>               
> +                     state.cancel(); /* FIXME: is this necessary */ 
> +                     mRequests.remove(state);
> +             } catch (Exception e) {
> +                     Logger.error(this, "Parsing failed for "+ 
> state.getURI(), e);
> +             }
>       }
> +     
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 827 bytes
Desc: not available
URL: 
<https://emu.freenetproject.org/pipermail/devl/attachments/20081112/f4223163/attachment.pgp>

Reply via email to