gzz-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gzz-commits] storm/org/nongnu/storm/pointers PointerBlock.ja...


From: Benja Fallenstein
Subject: [Gzz-commits] storm/org/nongnu/storm/pointers PointerBlock.ja...
Date: Thu, 22 May 2003 17:31:00 -0400

CVSROOT:        /cvsroot/storm
Module name:    storm
Changes by:     Benja Fallenstein <address@hidden>      03/05/22 17:31:00

Modified files:
        org/nongnu/storm/pointers: PointerBlock.java PointerIndex.java 
Added files:
        org/nongnu/storm/pointers: TitleIndex.java 

Log message:
        start on names in pointers, doesn't compile yet

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/storm/storm/org/nongnu/storm/pointers/TitleIndex.java?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/storm/storm/org/nongnu/storm/pointers/PointerBlock.java.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/storm/storm/org/nongnu/storm/pointers/PointerIndex.java.diff?tr1=1.5&tr2=1.6&r1=text&r2=text

Patches:
Index: storm/org/nongnu/storm/pointers/PointerBlock.java
diff -u storm/org/nongnu/storm/pointers/PointerBlock.java:1.2 
storm/org/nongnu/storm/pointers/PointerBlock.java:1.3
--- storm/org/nongnu/storm/pointers/PointerBlock.java:1.2       Fri May  9 
12:42:23 2003
+++ storm/org/nongnu/storm/pointers/PointerBlock.java   Thu May 22 17:31:00 2003
@@ -40,10 +40,12 @@
     private PointerId pointer;
     private long timestamp;
     private BlockId target;
+    private String name;
 
     public PointerId getPointer() { return pointer; }
     public long getTimestamp() { return timestamp; }
     public BlockId getTarget() { return target; }
+    public String getName() { return name; }
 
     public PointerBlock(Block block) 
        throws IOException, GeneralSecurityException {
@@ -69,6 +71,8 @@
 
        timestamp = Long.parseLong(r.readLine());
        target = new BlockId(r.readLine());
+
+       name = r.readLine(); // may be null -> no name given
 
        if(r.readLine() != null) 
            throw new IOException("Pointer block too long");
Index: storm/org/nongnu/storm/pointers/PointerIndex.java
diff -u storm/org/nongnu/storm/pointers/PointerIndex.java:1.5 
storm/org/nongnu/storm/pointers/PointerIndex.java:1.6
--- storm/org/nongnu/storm/pointers/PointerIndex.java:1.5       Wed May 21 
20:14:08 2003
+++ storm/org/nongnu/storm/pointers/PointerIndex.java   Thu May 22 17:31:00 2003
@@ -61,13 +61,20 @@
        return result;
     }
 
-    public BlockId get(PointerId id) 
+    public BlockId get(PointerId id)
+       throws IOException, GeneralSecurityException {
+       PointerBlock b = getPointerBlock(id);
+       if(b == null) return null;
+       return b.getTarget();
+    }
+
+    public PointerBlock getPointerBlock(PointerId id) 
        throws IOException, GeneralSecurityException {
        if(dbg) p("Get: "+id);
 
        Collector c = db.get(id.toString()).block();
        long maxstamp = 0;
-       BlockId result = null;
+       PointerBlock result = null;
        for(Iterator i=c.iterator(); i.hasNext();) {
            IndexedPool.Mapping m = (IndexedPool.Mapping)i.next();
            if(dbg) p("Process: "+m.block+" "+m.value);
@@ -90,7 +97,7 @@
 
                if(p.getPointer().equals(id) &&
                   p.getTimestamp() == timestamp) {
-                   result = p.getTarget();
+                   result = p;
                    maxstamp = timestamp;
                }
            }
@@ -101,6 +108,12 @@
 
     public void set(PointerId id, BlockId target, KeyPair keyPair) 
        throws IOException, GeneralSecurityException {
+       set(id, target, keyPair, null);
+    }
+
+    public void set(PointerId id, BlockId target, KeyPair keyPair,
+                   String newName) 
+       throws IOException, GeneralSecurityException {
        // XXX this assumes that the computer clock
        // is always set correctly: if there is an existing
        // pointer block with a later timestamp (because
@@ -116,6 +129,12 @@
            Base32.encode(keyBytes) + "\n" +
            timestamp + "\n" +
            target.toString();
+
+       if(newName != null) {
+           if(newName.indexOf("\n") >= 0)
+               throw new IllegalArgumentException("Newline in ptr name");
+           data += "\n" + newName;
+       }
 
        Signature s = Signature.getInstance("SHA1withDSA");
        s.initSign(keyPair.getPrivate());




reply via email to

[Prev in Thread] Current Thread [Next in Thread]