On Thu, Apr 9, 2009 at 6:14 AM, Matthew Toseland <t...@amphibian.dyndns.org> wrote: > On Wednesday 08 April 2009 01:28:41 Daniel Cheng wrote: >> On Wed, Apr 8, 2009 at 4:02 AM, Matthew Toseland >> <t...@amphibian.dyndns.org> wrote: >> > On Tuesday 07 April 2009 16:26:42 j16s...@freenetproject.org wrote: >> >> Author: j16sdiz >> >> Date: 2009-04-07 15:26:41 +0000 (Tue, 07 Apr 2009) >> >> New Revision: 26609 >> >> >> >> Modified: >> >> trunk/freenet/src/freenet/crypt/Yarrow.java >> >> Log: >> >> Use int[] instead of Integer, save autoboxing and put() >> >> >> >> Modified: trunk/freenet/src/freenet/crypt/Yarrow.java >> >> =================================================================== >> >> --- trunk/freenet/src/freenet/crypt/Yarrow.java 2009-04-07 15:06:39 > UTC (rev >> > 26608) >> >> +++ trunk/freenet/src/freenet/crypt/Yarrow.java 2009-04-07 15:26:41 > UTC (rev >> > 26609) >> >> @@ -444,12 +444,12 @@ >> >> private MessageDigest fast_pool, slow_pool; >> >> private int fast_entropy, slow_entropy; >> >> private boolean fast_select; >> >> - private Map<EntropySource, Integer> entropySeen; >> >> + private Map<EntropySource, int[]> entropySeen; >> >> >> >> private void accumulator_init(String digest) throws >> > NoSuchAlgorithmException { >> >> fast_pool = MessageDigest.getInstance(digest); >> >> slow_pool = MessageDigest.getInstance(digest); >> >> - entropySeen = new HashMap<EntropySource, Integer>(); >> >> + entropySeen = new HashMap<EntropySource, int[]>(); >> >> } >> >> >> >> @Override >> >> @@ -515,21 +515,21 @@ >> >> slow_entropy += actualEntropy; >> >> >> >> if(source != null) { >> >> - Integer contributedEntropy = > entropySeen.get(source); >> >> - if(contributedEntropy == null) >> >> - contributedEntropy = > Integer.valueOf(actualEntropy); >> >> - else >> >> - contributedEntropy = > Integer.valueOf(actualEntropy + >> > contributedEntropy.intValue()); >> >> - entropySeen.put(source, > contributedEntropy); >> >> + int[] contributedEntropy = > entropySeen.get(source); >> >> + if(contributedEntropy == null) { >> >> + contributedEntropy = new > int[] { actualEntropy }; >> >> + entropySeen.put(source, > contributedEntropy); >> >> + } else >> >> + contributedEntropy[0]++; >> > >> > Wrong. >> > contributedEntropy[0] += actualEntropy; >> > Please do not make mistakes in crypt/! >> > Otherwise it's a neat optimisation, although using a MutableInt would be >> > cleaner. >> >> fixed in r26629. >> >> (this is in the reseed from entropy source code path.) >> btw, the current code maybe reseeding too infrequent. >> >> This is the current reseed logic: >> (1) we have more then (SLOW_THRESHOLD * 2) bits in slow_entropy >> _AND_ >> (2) those entropy are from TWO DIFFERENT source, each contribute more > then >> THRESHOLD bits >> >> However, we have ONLY TWO sources, >> the TWO DIFFERENT sources requirement is too hard to meet. > > Yeah. And one of the sources (incoming packet hashes) always reports 0, as it > may be observable/influencible. Ideas? > > BTW, what are the two sources? >
FNPPacketMangler , private final EntropySource fnpTimingSource; private final EntropySource myPacketDataSource; fnpTimeingSource is the packet arrivial time myPacketDataSource is the hash of packets. _______________________________________________ Devl mailing list Devl@freenetproject.org http://emu.freenetproject.org/cgi-bin/mailman/listinfo/devl