> -----Original Message-----
> From: devl-bounces at freenetproject.org 
> [mailto:devl-bounces at freenetproject.org] On Behalf Of Matthew Toseland
> > +   
> > +   private synchronized void downloadPuzzles() {
> > +           Query q = db.query();
> > +           q.constrain(Identity.class);
> > +           q.constrain(OwnIdentity.class).not();
> > +           q.descend("lastChange").constrain(new 
> > +Date(System.currentTimeMillis() - 1
> * 24 * 60 * 60 * 1000)).greater();
> > +           q.descend("lastChange").orderDescending(); /* 
> This should choose
> identities in a sufficiently random order */
> 
> You may need some and()'s here. Have you tested this query?
> 
> W.r.t. randomness, how about having a random number as a 
> member of each 
> identity? You could even change it when you download a puzzle for it, 
> admittedly at some performance cost...

Forget to answer the randomness question in my previous mail, 
sorry. I thought about adding a number to identities for randomization.
However, sorting by time of insertion should be sufficiently random:
All threads of WoT sleep for THREAD_PERIOD +/- 50% THREAD_PERIOD,
so the chance that Identity insertion will synchronize around the nextwork
due to autoupdating for example is almost zero I guess.

The only tradeoff is that we will have to include the full time of insertion
in identities, which might be considered as a security issue :| Maybe it
could
be randomized?



Reply via email to