On Wednesday 09 January 2008 00:53, zothar at freenetproject.org wrote:
> Author: zothar
> Date: 2008-01-09 00:53:07 +0000 (Wed, 09 Jan 2008)
> New Revision: 16974
> 
> Modified:
>    trunk/freenet/src/freenet/node/DarknetPeerNode.java
>    trunk/freenet/src/freenet/node/OpennetPeerNode.java
>    trunk/freenet/src/freenet/node/PeerNode.java
>    trunk/freenet/src/freenet/node/SeedClientPeerNode.java
>    trunk/freenet/src/freenet/node/SeedServerPeerNode.java
> Log:
> Implement isDarknet().  Move sendNodeToNodeMessage() to PeerNode and queue 
on not connected only if the peer is a darknet peer.

This is getting awfully complicated.

I had assumed that N2NMs were a mechanism for clients (including fproxy, which 
is an internal client) to communicate with each other. N2NMs are therefore 
only useful on darknet, since on opennet there is no reason to talk to other 
local clients - certainly this reasoning applies to fproxy text messages, and 
certainly it applies to queueing messages. On the other hand, there may be 
some applications for which being able to talk to your opposite client on 
your opennet peers may be useful - namely any application that implements its 
own routed protocol on top of Freenet. Many of these (e.g. currency over 
freenet) require a trust connection - but maybe some wouldn't (e.g. 
broadcasting). I had assumed that not providing any N2NM service for opennet 
peers was a sensible default, which we could change when a client author asks 
for it. But perhaps I was wrong? One obvious limitation with allowing N2NMs 
to/from opennet peers is that queueing is probably a bad idea. However, once 
we have FCP clients, we might want to provide a way to send an N2NM and not 
queue it if the node is disconnected, just drop it, because it's not 
important if it's not delivered quickly. This can easily be implemented on 
top of queueing.

So the simplest solution is to always queue, to only allow N2NMs to/from 
darknet peers, and to have a separate message type for the low-level 
mechanism of differential noderefs (which can of course share code if there 
is any major code to be done). Is the simplest solution the best in this 
case? It seems like premature complexity to me - but maybe it's useful 
complexity?
> 
> Modified: trunk/freenet/src/freenet/node/DarknetPeerNode.java
> ===================================================================
> --- trunk/freenet/src/freenet/node/DarknetPeerNode.java       2008-01-09 
> 00:00:39 
UTC (rev 16973)
> +++ trunk/freenet/src/freenet/node/DarknetPeerNode.java       2008-01-09 
> 00:53:07 
UTC (rev 16974)
> @@ -1257,28 +1257,6 @@
>               }
>       }
>  
> -     public void sendNodeToNodeMessage(SimpleFieldSet fs, int n2nType, 
> boolean 
includeSentTime, long now) {
> -             fs.put("n2nType", n2nType);
> -             if(includeSentTime) {
> -                     fs.put("sentTime", now);
> -             }
> -             try {
> -                     Message n2nm;
> -                     n2nm = DMT.createNodeToNodeMessage(
> -                                     n2nType, 
> fs.toString().getBytes("UTF-8"));
> -                     try {
> -                             sendAsync(n2nm, null, 0, null);
> -                     } catch (NotConnectedException e) {
> -                             if(includeSentTime) {
> -                                     fs.removeValue("sentTime");
> -                             }
> -                             queueN2NM(fs);
> -                     }
> -             } catch (UnsupportedEncodingException e) {
> -                     throw new Error("Impossible: "+e, e);
> -             }
> -     }
> -
>       public int sendFileOfferAccepted(long uid) {
>               storeOffers();
>               long now = System.currentTimeMillis();
> @@ -1509,6 +1487,10 @@
>               return new DarknetPeerNodeStatus(this, noHeavy);
>       }
>  
> +     public boolean isDarknet() {
> +             return true;
> +     }
> +
>       public boolean isOpennet() {
>               return false;
>       }
> 
> Modified: trunk/freenet/src/freenet/node/OpennetPeerNode.java
> ===================================================================
> --- trunk/freenet/src/freenet/node/OpennetPeerNode.java       2008-01-09 
> 00:00:39 
UTC (rev 16973)
> +++ trunk/freenet/src/freenet/node/OpennetPeerNode.java       2008-01-09 
> 00:53:07 
UTC (rev 16974)
> @@ -23,6 +23,10 @@
>               return super.isRoutingCompatible();
>       }
>  
> +     public boolean isDarknet() {
> +             return false;
> +     }
> +
>       public boolean isOpennet() {
>               return true;
>       }
> 
> Modified: trunk/freenet/src/freenet/node/PeerNode.java
> ===================================================================
> --- trunk/freenet/src/freenet/node/PeerNode.java      2008-01-09 00:00:39 UTC 
(rev 16973)
> +++ trunk/freenet/src/freenet/node/PeerNode.java      2008-01-09 00:53:07 UTC 
(rev 16974)
> @@ -2367,6 +2367,8 @@
>               return fs;
>       }
>  
> +     public abstract boolean isDarknet();
> +
>       public abstract boolean isOpennet();
>  
>       /**
> @@ -3498,4 +3500,35 @@
>       }
>       
>       private int handshakeIPAlternator;
> +
> +     public void sendNodeToNodeMessage(SimpleFieldSet fs, int n2nType, 
> boolean 
includeSentTime, long now) {
> +             fs.put("n2nType", n2nType);
> +             if(includeSentTime) {
> +                     fs.put("sentTime", now);
> +             }
> +             try {
> +                     Message n2nm;
> +                     n2nm = DMT.createNodeToNodeMessage(
> +                                     n2nType, 
> fs.toString().getBytes("UTF-8"));
> +                     try {
> +                             sendAsync(n2nm, null, 0, null);
> +                     } catch (NotConnectedException e) {
> +                             if(includeSentTime) {
> +                                     fs.removeValue("sentTime");
> +                             }
> +                             if(isDarknet()) {
> +                                     queueN2NM(fs);
> +                             }
> +                     }
> +             } catch (UnsupportedEncodingException e) {
> +                     throw new Error("Impossible: "+e, e);
> +             }
> +     }
> +
> +     /**
> +      * A method to be to queue an N2NM in a extra peer data file, only 
implemented by DarknetPeerNode
> +      */
> +     public void queueN2NM(SimpleFieldSet fs) {
> +             // Do nothing in the default impl
> +     }
>  }
> 
> Modified: trunk/freenet/src/freenet/node/SeedClientPeerNode.java
> ===================================================================
> --- trunk/freenet/src/freenet/node/SeedClientPeerNode.java    2008-01-09 
00:00:39 UTC (rev 16973)
> +++ trunk/freenet/src/freenet/node/SeedClientPeerNode.java    2008-01-09 
00:53:07 UTC (rev 16974)
> @@ -21,6 +21,10 @@
>               return new PeerNodeStatus(this, noHeavy);
>       }
>  
> +     public boolean isDarknet() {
> +             return false;
> +     }
> +
>       public boolean isOpennet() {
>               return false; // Not exactly
>       }
> 
> Modified: trunk/freenet/src/freenet/node/SeedServerPeerNode.java
> ===================================================================
> --- trunk/freenet/src/freenet/node/SeedServerPeerNode.java    2008-01-09 
00:00:39 UTC (rev 16973)
> +++ trunk/freenet/src/freenet/node/SeedServerPeerNode.java    2008-01-09 
00:53:07 UTC (rev 16974)
> @@ -26,6 +26,10 @@
>               return new PeerNodeStatus(this, noHeavy);
>       }
>  
> +     public boolean isDarknet() {
> +             return false;
> +     }
> +
>       public boolean isOpennet() {
>               return false;
>       }
> 
> _______________________________________________
> cvs mailing list
> cvs at freenetproject.org
> http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs
> 
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: 
<https://emu.freenetproject.org/pipermail/devl/attachments/20080110/2da9a894/attachment.pgp>

Reply via email to