Matthew Toseland wrote:
> 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.
>   
It doesn't seem particularly complicated to me, but then I just 
implemented it.
> 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.
>   
I'm using N2NMs as a generic message type and I thought you were cool 
with that after our earlier discussion about differential node 
references.  Because of this, I don't assume all functionality of N2NMs, 
as only previously used by N2NTMs, to be darknet-only.  As for own 
routing on top of Freenet, that's one of the things I've been wanting to 
play with once I got N2NMs into FCP.  My current assumption, and my 
implementation reflects it, is that queuing a N2NM for an opennet peer 
doesn't make sense because we have no idea if we'll ever re-connect to 
that currently disconnected peer.
> 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?
>   
I don't always queue because queuing is only needed for disconnected 
peers, though I supposed we could sendAsync it and then the connection 
dies before it's delivered.
Currently, I like the idea of N2NMs not being darknet-only.  Sure we 
could say they are now, change differential node refs to a dedicated 
message and give them opennet access when someone asks for it, but 
implementing that might be harder then if it's got the darknet-only 
assumption even more coded in than it was.

To me, this commit is quite straight-forward, but then again, maybe I 
don't see the complexity because I coded it.
>> 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
>>
>>
>>     
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> Devl mailing list
>> Devl at freenetproject.org
>> http://emu.freenetproject.org/cgi-bin/mailman/listinfo/devl


Reply via email to