Changeset 3eef403b


Ignore:
Timestamp:
Mar 18, 2010 12:31:44 PM (10 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
2e8fd23
Parents:
f3b78fc
Message:

concurrent

File:
1 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/router/KeyManager.java

    rf3b78fc r3eef403b  
    1313import java.io.FileOutputStream;
    1414import java.io.IOException;
    15 import java.util.HashMap;
    1615import java.util.HashSet;
    1716import java.util.Map;
    1817import java.util.Set;
     18import java.util.concurrent.ConcurrentHashMap;
    1919
    2020import net.i2p.data.DataFormatException;
     
    4242    private SigningPrivateKey _signingPrivateKey;
    4343    private SigningPublicKey _signingPublicKey;
    44     private final Map _leaseSetKeys; // Destination --> LeaseSetKeys
     44    private final Map<Hash, LeaseSetKeys> _leaseSetKeys; // Destination --> LeaseSetKeys
    4545    private SynchronizeKeysJob _synchronizeJob;
    4646   
     
    6464        setSigningPrivateKey(null);
    6565        setSigningPublicKey(null);
    66         _leaseSetKeys = new HashMap();
     66        _leaseSetKeys = new ConcurrentHashMap();
    6767    }
    6868   
     
    103103        _log.info("Registering keys for destination " + dest.calculateHash().toBase64());
    104104        LeaseSetKeys keys = new LeaseSetKeys(dest, leaseRevocationPrivateKey, endpointDecryptionKey);
    105         synchronized (_leaseSetKeys) {
    106             _leaseSetKeys.put(dest.calculateHash(), keys);
    107         }
     105        _leaseSetKeys.put(dest.calculateHash(), keys);
    108106    }
    109107   
     
    119117        if (_log.shouldLog(Log.INFO))
    120118            _log.info("Unregistering keys for destination " + dest.calculateHash().toBase64());
    121         LeaseSetKeys rv = null;
    122         synchronized (_leaseSetKeys) {
    123             rv = (LeaseSetKeys)_leaseSetKeys.remove(dest.calculateHash());
    124         }
    125         return rv;
     119        return _leaseSetKeys.remove(dest.calculateHash());
    126120    }
    127121   
     
    130124    }
    131125    public LeaseSetKeys getKeys(Hash dest) {
    132         synchronized (_leaseSetKeys) {
    133             return (LeaseSetKeys)_leaseSetKeys.get(dest);
    134         }
    135     }
    136    
    137     public Set getAllKeys() {
     126            return _leaseSetKeys.get(dest);
     127    }
     128   
     129    public Set<LeaseSetKeys> getAllKeys() {
    138130        HashSet keys = new HashSet();
    139         synchronized (_leaseSetKeys) {
    140             keys.addAll(_leaseSetKeys.values());
    141         }
     131        keys.addAll(_leaseSetKeys.values());
    142132        return keys;
    143133    }
Note: See TracChangeset for help on using the changeset viewer.