On Mon, Jul 21, 2003 at 08:54:43PM -0400, Nick Tarleton wrote:
> On Monday 21 July 2003 08:24 pm, Nick Tarleton wrote:
> > To me, it looks like a CHK contains log2 of the (padded) size of the data.
> > From ClientCHK.encode:
> > chk = new CHK(storables, Util.log2(getPaddedLength()));
> > In about an hour expect some code to pull that out of a text CHK. ;-)
> 
> And here it is. Seems to work quite well.


This is completely contrary to what Oskar told me. He told me that the
byte in question only indicated the size of the verification chunks, and
that they were implementation dependant, although our particular impl
used some fixed bit shift of the overall size. He must have implemented
it and then forgotten it :)

It does however appear to work, for files from just under 1MB down to
just under 1kB... files below this are rounded to 1kB.

I will add the following:
1. An FCP command.
2. A client.cli.Main command.
3. A ?maxsize= parameter in fproxy for NIM forms.

> import freenet.client.*;
> import freenet.Key;
> 
> public class CHKSize {
>       public static void main(String[] args) throws Exception {
>               ClientKey clientKey = ClientCHK.createFromRequestURI(new 
> FreenetURI(args[0]));
>               Key key = clientKey.getKey();
>               byte[] val = key.getVal();
>               byte log2size = val[val.length - 3];
>               System.out.print("Estimated key size: ");
>               System.out.println(Math.pow(2.0, (double)(log2size & 0xFF)));
>       }
> }             


-- 
Matthew J Toseland - [EMAIL PROTECTED]
Freenet Project Official Codemonkey - http://freenetproject.org/
ICTHUS - Nothing is impossible. Our Boss says so.

Attachment: pgp00000.pgp
Description: PGP signature

Reply via email to