Class BlindCache
- java.lang.Object
-
- net.i2p.router.networkdb.kademlia.BlindCache
-
class BlindCache extends Object
Cache of blinding data. See proposal 123.- Since:
- 0.9.40
-
-
Constructor Summary
Constructors Constructor Description BlindCache(RouterContext ctx)
Caller MUST call startup() to load persistent cache from disk
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addToCache(BlindData bd)
Persists immediately if secret or privkey is non-nullHash
getBlindedHash(Destination dest)
The hash to lookup for a dest.Hash
getBlindedHash(SigningPublicKey spk)
The hash to lookup for a SPK known to be blinded.List<BlindData>
getData()
For console ConfigKeyringHelperBlindData
getData(Destination dest)
The cached data or nullBlindData
getData(SigningPublicKey spk)
The cached data or nullHash
getHash(Destination dest)
The hash to lookup for a dest.Hash
getHash(Hash h)
The hash to lookup for a dest hash.BlindData
getReverseData(SigningPublicKey spk)
The cached data or nullboolean
removeBlindData(SigningPublicKey spk)
For console ConfigKeyringHelper.void
rollover()
Refresh all the data at midnightvoid
setBlinded(Destination dest)
Add the destination to the cache entry.void
setBlinded(Destination dest, SigType blindedType, String secret)
Mark a destination as known to be blindedvoid
shutdown()
May be restarted by calling startup() again.void
startup()
-
-
-
Constructor Detail
-
BlindCache
public BlindCache(RouterContext ctx)
Caller MUST call startup() to load persistent cache from disk
-
-
Method Detail
-
shutdown
public void shutdown()
May be restarted by calling startup() again.
-
startup
public void startup()
-
getHash
public Hash getHash(Destination dest)
The hash to lookup for a dest. If known to be blinded, returns the current blinded hash. If not known to be blinded, returns the standard dest hash.- Parameters:
dest
- may or may not be blinded- Returns:
- the unblinded or blinded hash
-
getHash
public Hash getHash(Hash h)
The hash to lookup for a dest hash. If known to be blinded, returns the current blinded hash. If not known to be blinded, returns h.- Parameters:
h
- may or may not be blinded- Returns:
- the blinded hash or h
-
getBlindedHash
public Hash getBlindedHash(Destination dest)
The hash to lookup for a dest. If known to be blinded, returns the current blinded hash. If not known to be blinded, returns null.- Parameters:
dest
- may or may not be blinded- Returns:
- the blinded hash or null if not blinded
-
getBlindedHash
public Hash getBlindedHash(SigningPublicKey spk)
The hash to lookup for a SPK known to be blinded. Default blinded type assumed. Secret assumed null.- Parameters:
spk
- known to be blinded- Returns:
- the blinded hash
- Throws:
IllegalArgumentException
- on various errors
-
setBlinded
public void setBlinded(Destination dest, SigType blindedType, String secret)
Mark a destination as known to be blinded- Parameters:
dest
- known to be blindedblindedType
- null for defaultsecret
- may be null- Throws:
IllegalArgumentException
- on various errors
-
setBlinded
public void setBlinded(Destination dest)
Add the destination to the cache entry. Must previously be in cache.- Parameters:
dest
- known to be blinded- Throws:
IllegalArgumentException
- on various errors
-
addToCache
public void addToCache(BlindData bd)
Persists immediately if secret or privkey is non-null
-
getData
public BlindData getData(Destination dest)
The cached data or null
-
getData
public BlindData getData(SigningPublicKey spk)
The cached data or null- Parameters:
spk
- the unblinded public key
-
getReverseData
public BlindData getReverseData(SigningPublicKey spk)
The cached data or null- Parameters:
spk
- the blinded public key
-
rollover
public void rollover()
Refresh all the data at midnight
-
getData
public List<BlindData> getData()
For console ConfigKeyringHelper- Returns:
- list is copied
- Since:
- 0.9.41
-
removeBlindData
public boolean removeBlindData(SigningPublicKey spk)
For console ConfigKeyringHelper. Persists immediately if removed.- Parameters:
spk
- the unblinded public key- Returns:
- true if removed
- Since:
- 0.9.41
-
-