Update of /cvsroot/freenet/freenet/src/freenet/message
In directory sc8-pr-cvs1:/tmp/cvs-serv25857/src/freenet/message
Modified Files:
Tag: stable
Accepted.java AnnouncementComplete.java
AnnouncementExecute.java AnnouncementFailed.java
AnnouncementReply.java DataInsert.java DataNotFound.java
DataReply.java DataRequest.java DataSend.java Identify.java
InsertReply.java InsertRequest.java NodeAnnouncement.java
NodeMessage.java QueryAborted.java QueryRejected.java
QueryRestarted.java Request.java StoreData.java
VoidMessage.java
Log Message:
5029: Merge from unstable after months of work. MASSIVE changes.
Highlights:
* Next Generation Routing, massive related changes
* Major changes to handling of messages and connections (PeerHandler and related
changes)
* Even more non-blocking I/O
* Documentation improvements
* Lots of new diagnostics and config options
* Lots of bug fixes and performance tweaking
* Probably lots of new bugs too!
Index: Accepted.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/message/Accepted.java,v
retrieving revision 1.1.1.1
retrieving revision 1.1.1.1.6.1
diff -u -w -r1.1.1.1 -r1.1.1.1.6.1
--- Accepted.java 13 Jan 2002 05:24:37 -0000 1.1.1.1
+++ Accepted.java 28 Oct 2003 20:20:33 -0000 1.1.1.1.6.1
@@ -21,8 +21,8 @@
super(source, raw);
}
- public RawMessage toRawMessage(Presentation t) {
- RawMessage raw = super.toRawMessage(t);
+ public RawMessage toRawMessage(Presentation t, PeerHandler ph) {
+ RawMessage raw = super.toRawMessage(t,ph);
//raw.messageType=messageName;
return raw;
}
@@ -31,5 +31,11 @@
return messageName;
}
+ public final boolean hasTrailer() {
+ return false;
+ }
+ public final long trailerLength() {
+ return 0;
+ }
}
Index: AnnouncementComplete.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/message/AnnouncementComplete.java,v
retrieving revision 1.1.1.1
retrieving revision 1.1.1.1.6.1
diff -u -w -r1.1.1.1 -r1.1.1.1.6.1
--- AnnouncementComplete.java 13 Jan 2002 05:24:38 -0000 1.1.1.1
+++ AnnouncementComplete.java 28 Oct 2003 20:20:33 -0000 1.1.1.1.6.1
@@ -30,8 +30,8 @@
in = (raw.trailingFieldLength == 0 ? null : raw.trailingFieldStream);
}
- public RawMessage toRawMessage(Presentation p) {
- RawMessage raw = super.toRawMessage(p);
+ public RawMessage toRawMessage(Presentation p, PeerHandler ph) {
+ RawMessage raw = super.toRawMessage(p,ph);
//raw.messageType = messageName;
raw.trailingFieldName = "Keys";
raw.trailingFieldLength = keys.streamLength();
@@ -41,6 +41,14 @@
return raw;
}
+ public boolean hasTrailer() {
+ return keys.streamLength() != 0;
+ }
+
+ public long trailerLength() {
+ return keys.streamLength();
+ }
+
public String getMessageName() {
return messageName;
}
Index: AnnouncementExecute.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/message/AnnouncementExecute.java,v
retrieving revision 1.1.1.1
retrieving revision 1.1.1.1.6.1
diff -u -w -r1.1.1.1 -r1.1.1.1.6.1
--- AnnouncementExecute.java 13 Jan 2002 05:24:38 -0000 1.1.1.1
+++ AnnouncementExecute.java 28 Oct 2003 20:20:34 -0000 1.1.1.1.6.1
@@ -46,8 +46,8 @@
in = raw.trailingFieldStream;
}
- public RawMessage toRawMessage(Presentation p) {
- RawMessage raw = super.toRawMessage(p);
+ public RawMessage toRawMessage(Presentation p, PeerHandler ph) {
+ RawMessage raw = super.toRawMessage(p,ph);
////raw.messageType = messageName;
raw.fs.add("RefSignature", refSignature);
raw.trailingFieldName = "Values";
@@ -57,6 +57,14 @@
return raw;
}
+ public boolean hasTrailer() {
+ return vals.streamLength() != 0;
+ }
+
+ public long trailerLength() {
+ return vals.streamLength();
+ }
+
public String getMessageName() {
return messageName;
}
Index: AnnouncementFailed.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/message/AnnouncementFailed.java,v
retrieving revision 1.2.4.1.2.1
retrieving revision 1.2.4.1.2.2
diff -u -w -r1.2.4.1.2.1 -r1.2.4.1.2.2
--- AnnouncementFailed.java 1 Jul 2003 02:27:14 -0000 1.2.4.1.2.1
+++ AnnouncementFailed.java 28 Oct 2003 20:20:34 -0000 1.2.4.1.2.2
@@ -53,7 +53,7 @@
if (reasonS == null)
reason = 0;
else {
- reason = (int) Fields.stringToLong(reasonS);
+ reason = (int) Fields.hexToLong(reasonS);
otherFields.remove("Reason");
}
} catch (NumberFormatException e) {
@@ -61,14 +61,22 @@
}
}
- public RawMessage toRawMessage(Presentation p) {
- RawMessage raw = super.toRawMessage(p);
+ public RawMessage toRawMessage(Presentation p, PeerHandler ph) {
+ RawMessage raw = super.toRawMessage(p,ph);
//raw.messageType = messageName;
- raw.fs.add("Reason",Fields.longToString(reason));
+ raw.fs.add("Reason",Fields.longToHex(reason));
return raw;
}
+ public final boolean hasTrailer() {
+ return false;
+ }
+
+ public final long trailerLength() {
+ return 0;
+ }
+
public String getMessageName() {
return messageName;
}
Index: AnnouncementReply.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/message/AnnouncementReply.java,v
retrieving revision 1.1.1.1
retrieving revision 1.1.1.1.6.1
diff -u -w -r1.1.1.1 -r1.1.1.1.6.1
--- AnnouncementReply.java 13 Jan 2002 05:24:38 -0000 1.1.1.1
+++ AnnouncementReply.java 28 Oct 2003 20:20:34 -0000 1.1.1.1.6.1
@@ -37,13 +37,21 @@
}
}
- public RawMessage toRawMessage(Presentation p) {
- RawMessage raw = super.toRawMessage(p);
+ public RawMessage toRawMessage(Presentation p, PeerHandler ph) {
+ RawMessage raw = super.toRawMessage(p,ph);
//raw.messageType = messageName;
raw.fs.add("ReturnValue",Fields.bytesToHex(returnVal));
return raw;
}
+ public final boolean hasTrailer() {
+ return false;
+ }
+
+ public final long trailerLength() {
+ return 0;
+ }
+
public String getMessageName() {
return messageName;
}
Index: DataInsert.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/message/DataInsert.java,v
retrieving revision 1.1.1.1.6.1
retrieving revision 1.1.1.1.6.2
diff -u -w -r1.1.1.1.6.1 -r1.1.1.1.6.2
--- DataInsert.java 5 Jul 2003 01:09:54 -0000 1.1.1.1.6.1
+++ DataInsert.java 28 Oct 2003 20:20:34 -0000 1.1.1.1.6.2
@@ -46,8 +46,8 @@
super(source, raw);
}
- public RawMessage toRawMessage(Presentation t) {
- RawMessage raw=super.toRawMessage(t);
+ public RawMessage toRawMessage(Presentation t, PeerHandler ph) {
+ RawMessage raw=super.toRawMessage(t,ph);
//raw.messageType="DataInsert";
// System.out.println(raw.toString());
return raw;
Index: DataNotFound.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/message/DataNotFound.java,v
retrieving revision 1.2
retrieving revision 1.2.6.1
diff -u -w -r1.2 -r1.2.6.1
--- DataNotFound.java 1 Apr 2002 21:51:14 -0000 1.2
+++ DataNotFound.java 28 Oct 2003 20:20:34 -0000 1.2.6.1
@@ -43,13 +43,21 @@
}
}
- public RawMessage toRawMessage(Presentation t) {
- RawMessage raw=super.toRawMessage(t);
+ public RawMessage toRawMessage(Presentation t, PeerHandler ph) {
+ RawMessage raw=super.toRawMessage(t,ph);
raw.fs.add("TimeSinceQuery",
Fields.longToHex(System.currentTimeMillis() - timeOfQuery));
return raw;
}
+ public final boolean hasTrailer() {
+ return false;
+ }
+
+ public final long trailerLength() {
+ return 0;
+ }
+
public String getMessageName() {
return messageName;
}
Index: DataReply.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/message/DataReply.java,v
retrieving revision 1.1.1.1.6.1
retrieving revision 1.1.1.1.6.2
diff -u -w -r1.1.1.1.6.1 -r1.1.1.1.6.2
--- DataReply.java 9 Jul 2003 00:38:48 -0000 1.1.1.1.6.1
+++ DataReply.java 28 Oct 2003 20:20:34 -0000 1.1.1.1.6.2
@@ -26,12 +26,15 @@
public class DataReply extends DataSend {
public static final String messageName = "DataReply";
-
+ public Exception initException; // DO NOT MERGE TO STABLE
public DataReply(long idnum,
FieldSet fs, long length) throws UnknownHostException {
super(idnum, fs, null, length);
+ if(Core.logger.shouldLog(Core.logger.DEBUG))
+ initException = new Exception("new DataReply (a)");
+ else initException = null;
}
// if we're creating a new DataReply, it's to send it,
@@ -45,10 +48,13 @@
throws InvalidMessageException, BadAddressException {
super(source, raw);
+ if(Core.logger.shouldLog(Core.logger.DEBUG))
+ initException = new Exception("new DataReply (b)");
+ else initException = null;
}
- public RawMessage toRawMessage(Presentation t) {
- RawMessage raw=super.toRawMessage(t);
+ public RawMessage toRawMessage(Presentation t, PeerHandler ph) {
+ RawMessage raw=super.toRawMessage(t,ph);
//raw.messageType="DataReply";
return raw;
}
Index: DataRequest.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/message/DataRequest.java,v
retrieving revision 1.1.1.1.4.1.2.1
retrieving revision 1.1.1.1.4.1.2.2
diff -u -w -r1.1.1.1.4.1.2.1 -r1.1.1.1.4.1.2.2
--- DataRequest.java 5 Jul 2003 01:09:54 -0000 1.1.1.1.4.1.2.1
+++ DataRequest.java 28 Oct 2003 20:20:34 -0000 1.1.1.1.4.1.2.2
@@ -24,11 +24,11 @@
public static final String messageName = "DataRequest";
- public DataRequest(long idnum, long htl, Key key, NodeReference ref) {
+ public DataRequest(long idnum, int htl, Key key, NodeReference ref) {
super(idnum, htl, key, ref);
}
- public DataRequest(long idnum, long htl, Key key, NodeReference ref,
+ public DataRequest(long idnum, int htl, Key key, NodeReference ref,
FieldSet otherFields) {
super(idnum, htl, key, ref, otherFields);
}
@@ -37,12 +37,20 @@
super(source, raw);
}
- public RawMessage toRawMessage(Presentation t) {
- RawMessage raw=super.toRawMessage(t);
+ public RawMessage toRawMessage(Presentation t, PeerHandler ph) {
+ RawMessage raw=super.toRawMessage(t,ph);
//raw.messageType="DataRequest";
return raw;
}
+ public final boolean hasTrailer() {
+ return false;
+ }
+
+ public final long trailerLength() {
+ return 0;
+ }
+
public String getMessageName() {
return messageName;
}
@@ -50,12 +58,15 @@
public State getInitialState() {
stateTime = System.currentTimeMillis();
if(receivedTime > 1000*1000*1000) {
+ long t = stateTime - receivedTime;
Core.diagnostics.occurrenceContinuous("messageInitialStateTime",
- stateTime - receivedTime);
+ t);
+ if(t > 1000)
+ Core.logger.log(this, "Long messageInitialStateTime "+t+" : "+
+ this, Logger.NORMAL);
}
return new NewDataRequest(id);
}
-
}
Index: DataSend.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/message/DataSend.java,v
retrieving revision 1.2.6.1
retrieving revision 1.2.6.2
diff -u -w -r1.2.6.1 -r1.2.6.2
--- DataSend.java 1 Jul 2003 02:27:14 -0000 1.2.6.1
+++ DataSend.java 28 Oct 2003 20:20:34 -0000 1.2.6.2
@@ -35,7 +35,7 @@
super(idnum, otherfields);
this.in = data;
this.length = length;
- logDEBUG = Core.logger.shouldLog(Logger.DEBUG);
+ logDEBUG = Core.logger.shouldLog(Logger.DEBUG,this);
if(logDEBUG)
Core.logger.log(this, "DataSend constructed", new Exception("debug"),
Logger.DEBUG);
@@ -53,11 +53,19 @@
throw new InvalidMessageException("Data sending message requires "
+ "the trailing field length to "
+ "be specified");
- logDEBUG = Core.logger.shouldLog(Logger.DEBUG);
+ logDEBUG = Core.logger.shouldLog(Logger.DEBUG,this);
}
- public RawMessage toRawMessage(Presentation t) {
- RawMessage raw=super.toRawMessage(t);
+ public boolean hasTrailer() {
+ return length != 0;
+ }
+
+ public long trailerLength() {
+ return length;
+ }
+
+ public RawMessage toRawMessage(Presentation t, PeerHandler ph) {
+ RawMessage raw=super.toRawMessage(t,ph);
// this was screwing the sending of DataReply because
// the trailing field length wasn't getting filled in
@@ -111,6 +119,7 @@
* @param n The node to cache into.
* @param searchKey The key to cache as.
* @return a DataState that will read the data into the store
+ * @exception StoreIOException If writing to the datastore fails.
* @exception IOException If creating the stream to CACHE the data fails.
* @exception DataNotValidIOException If the data does not validate
* for the provided key.
@@ -126,8 +135,14 @@
if(logDEBUG)
Core.logger.log(this, "Trying to cache data: "+searchKey+":"+length+
":"+in, Core.logger.DEBUG);
- KeyOutputStream out = n.ds.putData(searchKey, length, storables);
- return new ReceiveData(n.randSource.nextLong(), this.id, vis, out, length);
+ KeyOutputStream out;
+ try {
+ out = n.ds.putData(searchKey, length, storables);
+ } catch (IOException e) {
+ if(e instanceof StoreIOException) throw e;
+ else throw new StoreIOException(e);
+ }
+ return new ReceiveData(n.getRandSource().nextLong(), this.id, vis, out,
length);
}
/** Used to swallow a DataInsert.
@@ -138,7 +153,7 @@
Storables storables = getStorables();
if (storables == null) throw new IOException();
VerifyingInputStream vin = new VerifyingInputStream(in, length);
- (new EatData(n.randSource.nextLong(), vin, length)).schedule(n);
+ (new EatData(n.getRandSource().nextLong(), vin, length)).schedule(n);
// FIXME -- should use ControlInputStream but i haven't made
// sure it will work yet
}
Index: Identify.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/message/Identify.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -w -r1.1.2.1 -r1.1.2.2
--- Identify.java 15 Aug 2003 03:05:46 -0000 1.1.2.1
+++ Identify.java 28 Oct 2003 20:20:34 -0000 1.1.2.2
@@ -1,12 +1,14 @@
package freenet.message;
import freenet.*;
import freenet.node.*;
+import freenet.node.states.FNP.NewIdentify;
import freenet.support.*;
import java.util.*;
import freenet.node.states.request.*;
public class Identify extends NodeMessage {
+ protected final FieldSet nodeRef;
protected final NodeReference sourceRef;
public static final String messageName="Identify";
@@ -14,16 +16,17 @@
public Identify(long id, NodeReference ref) {
super(id);
sourceRef = ref;
+ nodeRef = null;
}
public Identify(ConnectionHandler source, RawMessage raw)
throws InvalidMessageException {
super(source, raw);
- FieldSet nodeRef = otherFields.getSet("Source");
+ nodeRef = otherFields.getSet("Source");
if(nodeRef == null)
throw new InvalidMessageException("No reference found");
try {
- // there is no reason to verify this.
+ // Verifying it is far too expensive to do here
sourceRef = new NodeReference(nodeRef, false,
source.peerIdentity());
} catch (BadReferenceException e) {
@@ -33,22 +36,37 @@
otherFields.remove("Source");
}
- public RawMessage toRawMessage(Presentation t) {
- RawMessage raw=super.toRawMessage(t);
+ public RawMessage toRawMessage(Presentation t, PeerHandler ph) {
+ RawMessage raw=super.toRawMessage(t, ph);
raw.fs.add("Source", sourceRef.getFieldSet(false));
return raw;
}
+ public final boolean hasTrailer() {
+ return false;
+ }
+
+ public final long trailerLength() {
+ return 0;
+ }
+
public String getMessageName() {
return messageName;
}
- public State getInitialState() {
- return null;
- // Only used in ConnectionHandler
+ public final State getInitialState() {
+ return new NewIdentify(id);
+ }
+
+ public final NodeReference getVerifiedSource()
+ throws BadReferenceException {
+ if(sourceRef.isSigned()) return sourceRef;
+ if(nodeRef == null) return null;
+ return new NodeReference(nodeRef, true,
+ source.peerIdentity());
}
- public NodeReference getSource() {
+ public final NodeReference getSource() {
return sourceRef;
}
}
Index: InsertReply.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/message/InsertReply.java,v
retrieving revision 1.1.1.1
retrieving revision 1.1.1.1.6.1
diff -u -w -r1.1.1.1 -r1.1.1.1.6.1
--- InsertReply.java 13 Jan 2002 05:24:38 -0000 1.1.1.1
+++ InsertReply.java 28 Oct 2003 20:20:34 -0000 1.1.1.1.6.1
@@ -17,12 +17,20 @@
super(source, raw);
}
- public RawMessage toRawMessage(Presentation t) {
- RawMessage raw=super.toRawMessage(t);
+ public RawMessage toRawMessage(Presentation t, PeerHandler ph) {
+ RawMessage raw=super.toRawMessage(t,ph);
// //raw.messageType="InsertReply";
return raw;
}
+ public final boolean hasTrailer() {
+ return false;
+ }
+
+ public final long trailerLength() {
+ return 0;
+ }
+
public String getMessageName() {
return messageName;
}
Index: InsertRequest.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/message/InsertRequest.java,v
retrieving revision 1.1.1.1.4.1
retrieving revision 1.1.1.1.4.1.2.1
diff -u -w -r1.1.1.1.4.1 -r1.1.1.1.4.1.2.1
--- InsertRequest.java 4 Mar 2003 19:58:34 -0000 1.1.1.1.4.1
+++ InsertRequest.java 28 Oct 2003 20:20:34 -0000 1.1.1.1.4.1.2.1
@@ -17,12 +17,12 @@
public static final String messageName = "InsertRequest";
- public InsertRequest(long idnum, long htl, Key key, NodeReference ref,
+ public InsertRequest(long idnum, int htl, Key key, NodeReference ref,
FieldSet otherFields) {
super(idnum, htl, key, ref, otherFields);
}
- public InsertRequest(long idnum, long htl, Key key, NodeReference ref) {
+ public InsertRequest(long idnum, int htl, Key key, NodeReference ref) {
super(idnum, htl, key, ref);
}
@@ -40,8 +40,8 @@
return new NewInsertRequest(id);
}
- public RawMessage toRawMessage(Presentation t) {
- RawMessage raw=super.toRawMessage(t);
+ public RawMessage toRawMessage(Presentation t, PeerHandler ph) {
+ RawMessage raw=super.toRawMessage(t,ph);
//raw.messageType="InsertRequest";
return raw;
}
Index: NodeAnnouncement.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/message/NodeAnnouncement.java,v
retrieving revision 1.3
retrieving revision 1.3.6.1
diff -u -w -r1.3 -r1.3.6.1
--- NodeAnnouncement.java 2 Jul 2002 07:42:55 -0000 1.3
+++ NodeAnnouncement.java 28 Oct 2003 20:20:34 -0000 1.3.6.1
@@ -65,8 +65,8 @@
throw new InvalidMessageException("No Commit value");
} else {
try {
- hopsToLive = (int) Fields.stringToLong(hopS);
- depth = (int) Fields.stringToLong(depthS);
+ hopsToLive = (int) Fields.hexToLong(hopS);
+ depth = (int) Fields.hexToLong(depthS);
announcee = new NodeReference(afs, true);
anSource = new NodeReference(sfs, false,
source.peerIdentity());
@@ -85,11 +85,11 @@
otherFields.remove("CommitValue");
}
- public RawMessage toRawMessage(Presentation p) {
- RawMessage raw = super.toRawMessage(p);
+ public RawMessage toRawMessage(Presentation p, PeerHandler ph) {
+ RawMessage raw = super.toRawMessage(p,ph);
//raw.messageType = messageName;
- raw.fs.add("HopsToLive",Fields.longToString(hopsToLive));
- raw.fs.add("Depth", Fields.longToString(depth));
+ raw.fs.add("HopsToLive",Fields.longToHex(hopsToLive));
+ raw.fs.add("Depth", Fields.longToHex(depth));
raw.fs.add("Announcee", announcee.getFieldSet());
raw.fs.add("CommitValue", Fields.bytesToHex(commitVal));
raw.fs.add("Source", anSource.getFieldSet(false));
@@ -97,6 +97,14 @@
}
+ public final boolean hasTrailer() {
+ return false;
+ }
+
+ public final long trailerLength() {
+ return 0;
+ }
+
public String getMessageName() {
return messageName;
}
Index: NodeMessage.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/message/NodeMessage.java,v
retrieving revision 1.1.1.1.4.4.2.1
retrieving revision 1.1.1.1.4.4.2.2
diff -u -w -r1.1.1.1.4.4.2.1 -r1.1.1.1.4.4.2.2
--- NodeMessage.java 11 Apr 2003 00:01:34 -0000 1.1.1.1.4.4.2.1
+++ NodeMessage.java 28 Oct 2003 20:20:34 -0000 1.1.1.1.4.4.2.2
@@ -96,12 +96,12 @@
String ids = fs.get("UniqueID");
if (ids == null)
throw new InvalidMessageException("no UniqueID field");
- long id = Fields.stringToLong(ids);
+ long id = Fields.hexToLong(ids);
if (((id>>>32) & 0xffffffffL) == (id & 0xffffffffL)) {
throw new InvalidMessageException("Read heisenbug UniqueID: "
+ Fields.longToHex(id) + ". killed chain");
}
- Core.randSource.acceptEntropy(uniqueIdEntropy, id, 64);
+ Core.getRandSource().acceptEntropy(uniqueIdEntropy, id, 64);
fs.remove("UniqueID");
return id;
} catch (NumberFormatException e) {
@@ -113,11 +113,11 @@
/** Converts this message to something that can be sent over the wire,
* using the given Presentation.
*/
- public RawMessage toRawMessage(Presentation t) {
- RawMessage r = super.toRawMessage(t);
+ public RawMessage toRawMessage(Presentation t, PeerHandler ph) {
+ RawMessage r = super.toRawMessage(t,ph);
r.fs.add("UniqueID", Fields.longToHex(id));
// do heisenbug testing
- long test = Fields.stringToLong(Fields.longToHex(id));
+ long test = Fields.hexToLong(Fields.longToHex(id));
if(((id >>> 32) & 0xffffffffL) == (id & 0xffffffffL)) {
String s = "PANIC! Just recreated heisenbug! ID: "
+ Fields.longToHex(id);
Index: QueryAborted.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/message/QueryAborted.java,v
retrieving revision 1.1.1.1
retrieving revision 1.1.1.1.6.1
diff -u -w -r1.1.1.1 -r1.1.1.1.6.1
--- QueryAborted.java 13 Jan 2002 05:24:39 -0000 1.1.1.1
+++ QueryAborted.java 28 Oct 2003 20:20:34 -0000 1.1.1.1.6.1
@@ -18,12 +18,20 @@
// keepAlive = false;
}
- public RawMessage toRawMessage(Presentation t) {
- RawMessage raw=super.toRawMessage(t);
+ public RawMessage toRawMessage(Presentation t, PeerHandler ph) {
+ RawMessage raw=super.toRawMessage(t,ph);
//raw.messageType=messageName;
return raw;
}
+ public final boolean hasTrailer() {
+ return false;
+ }
+
+ public final long trailerLength() {
+ return 0;
+ }
+
public String getMessageName() {
return messageName;
}
Index: QueryRejected.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/message/QueryRejected.java,v
retrieving revision 1.4.6.2
retrieving revision 1.4.6.3
diff -u -w -r1.4.6.2 -r1.4.6.3
--- QueryRejected.java 23 Jul 2003 01:56:51 -0000 1.4.6.2
+++ QueryRejected.java 28 Oct 2003 20:20:35 -0000 1.4.6.3
@@ -46,7 +46,7 @@
if (hopsString == null || hopsString.equals(""))
throw new InvalidMessageException("Can't find Hops To Live field");
try {
- hopsToLive = Fields.stringToLong(hopsString);
+ hopsToLive = Fields.hexToLong(hopsString);
} catch (NumberFormatException e) {
throw new InvalidMessageException("Failed to read number " + e);
}
@@ -58,7 +58,7 @@
String attenuationString = otherFields.get("Attenuation");
if (attenuationString != null) {
try {
- attenuation = Fields.stringToLong(attenuationString);
+ attenuation = Fields.hexToLong(attenuationString);
} catch (NumberFormatException e) {
throw new InvalidMessageException("Failed to read number " + e);
}
@@ -107,16 +107,24 @@
// Public Methods
- public RawMessage toRawMessage(Presentation t) {
- RawMessage raw=super.toRawMessage(t);
- raw.fs.add("HopsToLive",Fields.longToString(hopsToLive));
- raw.fs.add("Attenuation",Fields.longToString(attenuation));
+ public RawMessage toRawMessage(Presentation t, PeerHandler ph) {
+ RawMessage raw=super.toRawMessage(t,ph);
+ raw.fs.add("HopsToLive",Fields.longToHex(hopsToLive));
+ raw.fs.add("Attenuation",Fields.longToHex(attenuation));
if (reason != null)
raw.fs.add("Reason",reason);
//raw.messageType=messageName;
return raw;
}
+ public final boolean hasTrailer() {
+ return false;
+ }
+
+ public final long trailerLength() {
+ return 0;
+ }
+
public int hopsToLive() {
return (int) hopsToLive;
}
Index: QueryRestarted.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/message/QueryRestarted.java,v
retrieving revision 1.1.1.1
retrieving revision 1.1.1.1.6.1
diff -u -w -r1.1.1.1 -r1.1.1.1.6.1
--- QueryRestarted.java 13 Jan 2002 05:24:39 -0000 1.1.1.1
+++ QueryRestarted.java 28 Oct 2003 20:20:35 -0000 1.1.1.1.6.1
@@ -27,13 +27,21 @@
}
- public RawMessage toRawMessage(Presentation t) {
- RawMessage raw=super.toRawMessage(t);
+ public RawMessage toRawMessage(Presentation t, PeerHandler ph) {
+ RawMessage raw=super.toRawMessage(t,ph);
//raw.messageType="QueryRestarted";
raw.trailingFieldName="EndMessage";
return raw;
}
+ public final boolean hasTrailer() {
+ return false;
+ }
+
+ public final long trailerLength() {
+ return 0;
+ }
+
public String getMessageName() {
return messageName;
}
Index: Request.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/message/Request.java,v
retrieving revision 1.3.4.2.2.1
retrieving revision 1.3.4.2.2.2
diff -u -w -r1.3.4.2.2.1 -r1.3.4.2.2.2
--- Request.java 15 Aug 2003 03:05:47 -0000 1.3.4.2.2.1
+++ Request.java 28 Oct 2003 20:20:35 -0000 1.3.4.2.2.2
@@ -8,19 +8,19 @@
public abstract class Request extends NodeMessage implements HTLMessage {
public final Key searchKey;
- public long hopsToLive;
+ public int hopsToLive;
public long stateTime = -1;
protected final NodeReference requestSource;
- public Request(long id, long htl, Key key, NodeReference ref) {
+ public Request(long id, int htl, Key key, NodeReference ref) {
super(id);
searchKey = key;
hopsToLive = htl;
requestSource = ref;
}
- public Request(long id, long htl, Key key,
+ public Request(long id, int htl, Key key,
NodeReference ref, FieldSet otherFields) {
super(id, otherFields);
@@ -41,16 +41,26 @@
throw new InvalidMessageException("Can't find SearchKey field");
try {
searchKey = Key.readKey(keyString);
- hopsToLive = Fields.stringToLong(hopsString);
+ hopsToLive = Fields.hexToInt(hopsString);
// there is no reason to verify this.
- if (nodeRef == null) {
- requestSource = source.targetReference();
+ NodeReference ref = source.targetReference();
+ if (ref == null) {
+ Core.logger.log(this, "Getting requestSource from message: "+this+
+ ","+nodeRef+" for "+source, Logger.MINOR);
if(nodeRef == null)
throw new InvalidMessageException("Can't find Source field");
- } else {
- requestSource = new NodeReference(nodeRef, false,
- source.peerIdentity());
+ // Do not verify at this stage; if it's useful we should do it later
+ ref = new NodeReference(nodeRef, false, false, source.peerIdentity());
+ if(ref.isSigned()) {
+ source.setTargetReference(ref);
+ Core.logger.log(this, "Set targetReference on "+source+" to "+ref,
+ Logger.DEBUG);
}
+ } else if (nodeRef != null)
+ Core.logger.log(this, "Message "+this+" for "+source+" has "+
+ nodeRef+" but conn has "+ref,
+ Logger.MINOR);
+ requestSource = ref;
} catch (KeyException k) {
throw new InvalidMessageException("Failed to load key: " + k);
} catch (NumberFormatException e) {
@@ -64,15 +74,29 @@
otherFields.remove("Source");
}
- public RawMessage toRawMessage(Presentation t, ConnectionHandler ch) {
- RawMessage raw=super.toRawMessage(t,ch);
+ public RawMessage toRawMessage(Presentation t, PeerHandler ph) {
+ RawMessage raw=super.toRawMessage(t,ph);
raw.fs.add("SearchKey", searchKey.toString());
- raw.fs.add("HopsToLive", Fields.longToString(hopsToLive));
- if(ch != null && ch.targetReference() != null) {
+ raw.fs.add("HopsToLive", Fields.longToHex(hopsToLive));
+ if(ph != null && ph.getReference() != null) {
// We have received Identify from them, so they will have ours too
- } else
+ } else {
+ Core.logger.log(this, "Putting Source on message: "+this+
+ " in toRawMessage("+t+","+ph+"): "+
+ requestSource+":"+
+ requestSource.getFieldSet(false),
+ new Exception("debug"), Logger.MINOR);
raw.fs.add("Source", requestSource.getFieldSet(false));
+ }
return raw;
+ }
+
+ public boolean hasTrailer() {
+ return false;
+ }
+
+ public long trailerLength() {
+ return 0;
}
public int hopsToLive() {
Index: StoreData.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/message/StoreData.java,v
retrieving revision 1.3.6.3
retrieving revision 1.3.6.4
diff -u -w -r1.3.6.3 -r1.3.6.4
--- StoreData.java 22 Apr 2003 20:07:44 -0000 1.3.6.3
+++ StoreData.java 28 Oct 2003 20:20:35 -0000 1.3.6.4
@@ -48,7 +48,7 @@
requestsPerHour = -1;
String rateAsString = otherFields.get("RequestRate");
if (rateAsString != null) {
- requestsPerHour = Fields.stringToLong(rateAsString);
+ requestsPerHour = Fields.hexToLong(rateAsString);
}
String hopsAsString = otherFields.get("HopsSinceReset");
@@ -72,16 +72,24 @@
}
}
- public RawMessage toRawMessage(Presentation t) {
- RawMessage raw = super.toRawMessage(t);
+ public RawMessage toRawMessage(Presentation t, PeerHandler ph) {
+ RawMessage raw = super.toRawMessage(t,ph);
if (dataSource != null) {
raw.fs.add("DataSource", dataSource.getFieldSet());
}
if (requestsPerHour != -1) {
- raw.fs.add("RequestRate",Fields.longToString(requestsPerHour));
+ raw.fs.add("RequestRate",Fields.longToHex(requestsPerHour));
}
raw.fs.add("HopsSinceReset", Fields.intToHex(hopsSinceReset));
return raw;
+ }
+
+ public final boolean hasTrailer() {
+ return false;
+ }
+
+ public final long trailerLength() {
+ return 0;
}
public int hopsSinceReset() {
Index: VoidMessage.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/message/VoidMessage.java,v
retrieving revision 1.1.1.1
retrieving revision 1.1.1.1.6.1
diff -u -w -r1.1.1.1 -r1.1.1.1.6.1
--- VoidMessage.java 13 Jan 2002 05:24:39 -0000 1.1.1.1
+++ VoidMessage.java 28 Oct 2003 20:20:35 -0000 1.1.1.1.6.1
@@ -58,8 +58,8 @@
}
}
- public RawMessage toRawMessage(Presentation p) {
- RawMessage r = super.toRawMessage(p);
+ public RawMessage toRawMessage(Presentation p, PeerHandler ph) {
+ RawMessage r = super.toRawMessage(p,ph);
r.messageType = messageName;
r.close = close;
r.sustain = sustain;
@@ -70,6 +70,14 @@
return r;
}
+ public boolean hasTrailer() {
+ return dataLength > 0;
+ }
+
+ public final long trailerLength() {
+ return dataLength;
+ }
+
public String getMessageName() {
return messageName;
}
_______________________________________________
cvs mailing list
[EMAIL PROTECTED]
http://dodo.freenetproject.org/cgi-bin/mailman/listinfo/cvs