On Wed, Aug 6, 2008 at 6:49 PM, Matthew Toseland
<toad at amphibian.dyndns.org> wrote:
> On Wednesday 06 August 2008 10:25, Daniel Cheng wrote:
>> On Wed, Aug 6, 2008 at 1:36 AM, Matthew Toseland
>> <toad at amphibian.dyndns.org> wrote:
>> > Good, but it would be even better to pass in only the narrowly specialised
>> > object you need, rather than Node (in this case, the PRNG and the
>> > UserAlertManager).
>>
>> UserAlertManager have not created yet when we create the datastore.
>
> So set() it later?

fixed at r21701
>>
>> >
>> > On Tuesday 05 August 2008 14:45, j16sdiz at freenetproject.org wrote:
>> >> Author: j16sdiz
>> >> Date: 2008-08-05 13:45:56 +0000 (Tue, 05 Aug 2008)
>> >> New Revision: 21614
>> >>
>> >> Modified:
>> >>    branches/saltedhashstore/freenet/src/freenet/node/Node.java
>> >>
>> >
> branches/saltedhashstore/freenet/src/freenet/store/saltedhash/SaltedHashFreenetStore.java
>> >> Log:
>> >> allow datastore run without node
>> >>
>> >> Modified: branches/saltedhashstore/freenet/src/freenet/node/Node.java
>> >> ===================================================================
>> >> --- branches/saltedhashstore/freenet/src/freenet/node/Node.java
> 2008-08-05
>> > 13:23:53 UTC (rev 21613)
>> >> +++ branches/saltedhashstore/freenet/src/freenet/node/Node.java
> 2008-08-05
>> > 13:45:56 UTC (rev 21614)
>> >> @@ -1410,32 +1410,32 @@
>> >>                               System.out.println("Initializing CHK
> Datastore (" + maxStoreKeys + "
>> > keys)");
>> >>                               chkDatastore = new CHKStore();
>> >>                               SaltedHashFreenetStore chkDataFS =
>> > SaltedHashFreenetStore.construct(storeDir, "CHK-store",
>> >> -                                     chkDatastore, this, maxStoreKeys,
> 0x4800000, true,
>> > shutdownHook);
>> >> +                                     chkDatastore, random, this,
> maxStoreKeys, 0x4800000, true,
>> > shutdownHook);
>> >>                               Logger.normal(this, "Initializing CHK
> Datacache");
>> >>                               System.out.println("Initializing CHK
> Datacache (" + maxCacheKeys + ':'
>> > + maxCacheKeys + " keys)");
>> >>                               chkDatacache = new CHKStore();
>> >>                               SaltedHashFreenetStore chkCacheFS =
>> > SaltedHashFreenetStore.construct(storeDir, "CHK-cache",
>> >> -                                     chkDatacache, this, maxCacheKeys,
> 0x4800000, true,
>> > shutdownHook);
>> >> +                                     chkDatacache, random, this,
> maxCacheKeys, 0x4800000, true,
>> > shutdownHook);
>> >>                               Logger.normal(this, "Initializing pubKey
> Datastore");
>> >>                               System.out.println("Initializing pubKey
> Datastore");
>> >>                               pubKeyDatastore = new PubkeyStore();
>> >>                               SaltedHashFreenetStore pubkeyDataFS =
>> > SaltedHashFreenetStore.construct(storeDir, "PUBKEY-store",
>> >> -                                     pubKeyDatastore, this,
> maxStoreKeys, 0x4800000, true,
>> > shutdownHook);
>> >> +                                     pubKeyDatastore, random, this,
> maxStoreKeys, 0x4800000, true,
>> > shutdownHook);
>> >>                               Logger.normal(this, "Initializing pubKey
> Datacache");
>> >>                               System.out.println("Initializing pubKey
> Datacache (" + maxCacheKeys + "
>> > keys)");
>> >>                               pubKeyDatacache = new PubkeyStore();
>> >>                               SaltedHashFreenetStore pubkeyCacheFS =
>> > SaltedHashFreenetStore.construct(storeDir, "PUBKEY-cache",
>> >> -                                     pubKeyDatacache, this,
> maxCacheKeys, 0x4800000, true,
>> > shutdownHook);
>> >> +                                     pubKeyDatacache, random, this,
> maxCacheKeys, 0x4800000, true,
>> > shutdownHook);
>> >>                               Logger.normal(this, "Initializing SSK
> Datastore");
>> >>                               System.out.println("Initializing SSK
> Datastore");
>> >>                               sskDatastore = new SSKStore(this);
>> >>                               SaltedHashFreenetStore sskDataFS =
>> > SaltedHashFreenetStore.construct(storeDir, "SSK-store",
>> >> -                                     sskDatastore, this, maxStoreKeys,
> 0x4800000, true,
>> > shutdownHook);
>> >> +                                     sskDatastore, random, this,
> maxStoreKeys, 0x4800000, true,
>> > shutdownHook);
>> >>                               Logger.normal(this, "Initializing SSK
> Datacache");
>> >>                               System.out.println("Initializing SSK
> Datacache (" + maxCacheKeys + "
>> > keys)");
>> >>                               sskDatacache = new SSKStore(this);
>> >>                               SaltedHashFreenetStore sskCacheFS =
>> > SaltedHashFreenetStore.construct(storeDir, "SSK-cache",
>> >> -                                     sskDatacache, this, maxCacheKeys,
> 0x4800000, true,
>> > shutdownHook);
>> >> +                                     sskDatacache, random, this,
> maxCacheKeys, 0x4800000, true,
>> > shutdownHook);
>> >>
>> >>                               File migrationFile = new
> File(storeDir, "migrated");
>> >>                               if (!migrationFile.exists()) {
>> >>
>> >> Modified:
>> >
> branches/saltedhashstore/freenet/src/freenet/store/saltedhash/SaltedHashFreenetStore.java
>> >> ===================================================================
>> >> ---
>> >
> branches/saltedhashstore/freenet/src/freenet/store/saltedhash/SaltedHashFreenetStore.java
>> > 2008-08-05 13:23:53 UTC (rev 21613)
>> >> +++
>> >
> branches/saltedhashstore/freenet/src/freenet/store/saltedhash/SaltedHashFreenetStore.java
>> > 2008-08-05 13:45:56 UTC (rev 21614)
>> >> @@ -14,6 +14,7 @@
>> >>  import java.util.List;
>> >>  import java.util.ListIterator;
>> >>  import java.util.Map;
>> >> +import java.util.Random;
>> >>  import java.util.SortedSet;
>> >>  import java.util.TreeMap;
>> >>  import java.util.TreeSet;
>> >> @@ -73,21 +74,23 @@
>> >>       private final int routeKeyLength;
>> >>       private final int fullKeyLength;
>> >>       private final int dataBlockLength;
>> >> +     private final Random random;
>> >>       private final Node node;
>> >>
>> >>       private long storeSize;
>> >>       private int generation;
>> >>       private int flags;
>> >>
>> >> -     public static SaltedHashFreenetStore construct(File baseDir, String
> name,
>> > StoreCallback callback, Node node,
>> >> -             long maxKeys, int bloomFilterSize, boolean bloomCounting,
>> > SemiOrderedShutdownHook shutdownHook)
>> >> +     public static SaltedHashFreenetStore construct(File baseDir, String
> name,
>> > StoreCallback callback, Random random,
>> >> +             Node node, long maxKeys, int bloomFilterSize, boolean
>> > bloomCounting, SemiOrderedShutdownHook shutdownHook)
>> >>               throws IOException {
>> >> -             return new SaltedHashFreenetStore(baseDir, name, callback,
> node, maxKeys,
>> > bloomFilterSize, bloomCounting,
>> >> +             return new SaltedHashFreenetStore(baseDir, name, callback,
> random, node,
>> > maxKeys, bloomFilterSize,
>> >> +                     bloomCounting,
>> >>                       shutdownHook);
>> >>       }
>> >>
>> >> -     private SaltedHashFreenetStore(File baseDir, String name,
> StoreCallback
>> > callback, Node node, long maxKeys,
>> >> -             int bloomFilterSize, boolean bloomCounting,
>> > SemiOrderedShutdownHook shutdownHook)
>> >> +     private SaltedHashFreenetStore(File baseDir, String name,
> StoreCallback
>> > callback, Random random, Node node,
>> >> +             long maxKeys, int bloomFilterSize, boolean bloomCounting,
>> > SemiOrderedShutdownHook shutdownHook)
>> >>               throws IOException {
>> >>               logMINOR = Logger.shouldLog(Logger.MINOR, this);
>> >>               logDEBUG = Logger.shouldLog(Logger.DEBUG, this);
>> >> @@ -102,6 +105,7 @@
>> >>               fullKeyLength = callback.fullKeyLength();
>> >>               dataBlockLength = callback.dataLength();
>> >>
>> >> +             this.random = random;
>> >>               this.node = node;
>> >>               storeSize = maxKeys;
>> >>               this.bloomFilterSize = bloomFilterSize;
>> >> @@ -472,7 +476,7 @@
>> >>
>> >>               private ByteBuffer toMetaDataBuffer() {
>> >>                       ByteBuffer out =
> ByteBuffer.allocate(METADATA_LENGTH);
>> >> -                     cipherManager.encrypt(this, node.random);
>> >> +                     cipherManager.encrypt(this, random);
>> >>
>> >>                       out.put(getDigestedRoutingKey());
>> >>                       out.put(dataEncryptIV);
>> >> @@ -685,7 +689,7 @@
>> >>        * </ul>
>> >>        */
>> >>       private void writeEntry(Entry entry, long offset) throws
> IOException {
>> >> -             cipherManager.encrypt(entry, node.random);
>> >> +             cipherManager.encrypt(entry, random);
>> >>
>> >>               ByteBuffer bf = entry.toMetaDataBuffer();
>> >>               do {
>> >> @@ -785,7 +789,7 @@
>> >>               if (!configFile.exists()) {
>> >>                       // create new
>> >>                       byte[] newsalt = new byte[0x10];
>> >> -                     node.random.nextBytes(newsalt);
>> >> +                     random.nextBytes(newsalt);
>> >>                       cipherManager = new CipherManager(newsalt);
>> >>
>> >>                       writeConfigFile();
>> >> @@ -894,7 +898,7 @@
>> >>                       super.run();
>> >>
>> >>                       try {
>> >> -                             while (node.clientCore == null
> && !shutdown) {
>> >> +                             while (node != null && node.clientCore ==
> null && !shutdown) {
>> >>                                       Thread.sleep(1000);
>> >>                               }
>> >>                               Thread.sleep((int)(CLEANER_PERIOD / 2 +
> CLEANER_PERIOD *
>> > Math.random()));
>> >> @@ -903,6 +907,7 @@
>> >>                       if (shutdown)
>> >>                               return;
>> >>
>> >> +                     if (node != null)
>> >>                       node.clientCore.alerts.register(new UserAlert() {
>> >>                               public String anchor() {
>> >>                                       return "store-cleaner-" + name;
>> >>
>> >> _______________________________________________
>> >> 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
>> >
>> _______________________________________________
>> Devl mailing list
>> Devl at freenetproject.org
>> http://emu.freenetproject.org/cgi-bin/mailman/listinfo/devl
>>
>>
>
> _______________________________________________
> Devl mailing list
> Devl at freenetproject.org
> http://emu.freenetproject.org/cgi-bin/mailman/listinfo/devl
>

Reply via email to