Changeset 8a4c469


Ignore:
Timestamp:
May 31, 2019 3:26:20 PM (10 months ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
1109331
Parents:
b4f331e6
Message:

Blinding: cache b32, sort by b32 on /configkeyring

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • apps/routerconsole/java/src/net/i2p/router/web/helpers/ConfigKeyringHelper.java

    rb4f331e6 r8a4c469  
    22
    33import java.io.IOException;
     4import java.io.Serializable;
    45import java.io.StringWriter;
     6import java.util.Collections;
     7import java.util.Comparator;
    58import java.util.List;
    69import java.util.Map;
     
    9093        if (!local) {
    9194            List<BlindData> bdata = _context.netDb().getBlindData();
    92             // TODO sort by hostname
     95            if (bdata.size() > 1)
     96                Collections.sort(bdata, new BDComparator());
    9397            for (BlindData bd : bdata) {
    9498                buf.append("\n<tr><td>");
     
    142146        buf.append("</table>\n");
    143147    }
     148
     149    /** @since 0.9.41 */
     150    private static class BDComparator implements Comparator<BlindData>, Serializable {
     151         public int compare(BlindData l, BlindData r) {
     152             return l.toBase32().compareTo(r.toBase32());
     153        }
     154    }
    144155}
  • core/java/src/net/i2p/data/BlindData.java

    rb4f331e6 r8a4c469  
    2929    private boolean _authRequired;
    3030    private long _date;
     31    private String _b32;
    3132
    3233    /**
     
    218219     */
    219220    public synchronized String toBase32() {
    220         return Blinding.encode(_clearSPK, _secret != null, _authKey != null);
    221     }
    222 
    223     /**
    224      *  @since 0.9.41
    225      */
    226     public void setSecretRequired() {
     221        if (_b32 == null)
     222            _b32 = Blinding.encode(_clearSPK, _secretRequired, _authRequired);
     223        return _b32;
     224    }
     225
     226    /**
     227     *  @since 0.9.41
     228     */
     229    public synchronized void setSecretRequired() {
    227230        _secretRequired = true;
     231        _b32 = null;
    228232    }
    229233
     
    238242     *  @since 0.9.41
    239243     */
    240     public void setAuthRequired() {
     244    public synchronized void setAuthRequired() {
    241245        _authRequired = true;
     246        _b32 = null;
    242247    }
    243248
Note: See TracChangeset for help on using the changeset viewer.