On Sunday 04 May 2008 14:11, you wrote:
> Author: j16sdiz
> Date: 2008-05-04 13:11:55 +0000 (Sun, 04 May 2008)
> New Revision: 19733
> 
> Added:
>    
branches/saltedhashstore/freenet/src/freenet/store/SaltedHashFreenetStore.java
> Log:
> SaltedHashFreenetStore basic function (without locking/resizing)
> 
> 
> Added: 
branches/saltedhashstore/freenet/src/freenet/store/SaltedHashFreenetStore.java
> ===================================================================
> --- 
branches/saltedhashstore/freenet/src/freenet/store/SaltedHashFreenetStore.java  
                        
(rev 0)
> +++ 
branches/saltedhashstore/freenet/src/freenet/store/SaltedHashFreenetStore.java  
2008-05-04 13:11:55 UTC (rev 19733)
> +
> +             public StorableBlock getStorableBlock(byte[] routingKey, byte[] 
> fullKey) 
throws KeyVerifyException {
> +                     if (!decrypt(routingKey))
> +                             return null;
> +
> +                     StorableBlock block = callback.construct(data, header, 
> routingKey, 
fullKey);
> +                     byte[] blockRoutingKey = block.getRoutingKey();
> +
> +                     if (!Arrays.equals(blockRoutingKey, routingKey)) {
> +                             // either the data is corrupted or we have 
> found a SHA-1 collision
> +                             // can't recover, as decrypt() depends on a 
> correct route key
> +                             return null;
> +                     }
> +
> +                     return block;
> +             }

If we can't be sure that the Entry isn't re-encrypted, we should copy the 
data/headers here. If we can, we should document it.
> +
> +     /**
> +      * Check if a block is free
> +      * 
> +      * @param offset
> +      * @throws IOException
> +      */
> +     private boolean isFree(long offset) throws IOException {
> +             int split = (int) (offset % FILE_SPLIT);
> +             long rawOffset = (offset / FILE_SPLIT) * entryTotalLength;
> +
> +             ByteBuffer bf = ByteBuffer.allocate((int) ENTRY_HEADER_LENGTH);
> +
> +             do {
> +                     int status = storeFC[split].write(bf, rawOffset + 
> bf.position());
> +                     if (status == -1)
> +                             throw new EOFException();
> +             } while (bf.hasRemaining());
> +
> +             return (bf.getLong(0x30) & ENTRY_FLAG_OCCUPIED) == 0;
> +     }

Why read the whole entry just to check one byte (or one long)?
-------------- 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/20080509/a2343b41/attachment.pgp>

Reply via email to