Skip to content

Commit

Permalink
Router: give subDbs own blind cache files
Browse files Browse the repository at this point in the history
  • Loading branch information
eyedeekay committed Oct 9, 2023
1 parent 4c7846b commit ad338ef
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class BlindCache {
private final ConcurrentHashMap<Hash, BlindData> _hashCache;
private boolean _changed;

private static final String PERSIST_FILE = "router.blindcache.dat";
private final String PERSIST_FILE;

/**
* Caller MUST call startup() to load persistent cache from disk
Expand All @@ -53,6 +53,21 @@ public BlindCache(RouterContext ctx) {
_cache = new ConcurrentHashMap<SigningPublicKey, BlindData>(32);
_reverseCache = new ConcurrentHashMap<SigningPublicKey, BlindData>(32);
_hashCache = new ConcurrentHashMap<Hash, BlindData>(32);
PERSIST_FILE = "router.blindcache.dat";
}

/**
* Caller MUST call startup() to load persistent cache from disk
*/
public BlindCache(RouterContext ctx, Hash subDb) {
_context = ctx;
_cache = new ConcurrentHashMap<SigningPublicKey, BlindData>(32);
_reverseCache = new ConcurrentHashMap<SigningPublicKey, BlindData>(32);
_hashCache = new ConcurrentHashMap<Hash, BlindData>(32);
if (subDb == null)
PERSIST_FILE = "router." + subDb.toString() + ".blindcache.dat";
else
PERSIST_FILE = "router.blindcache.dat";
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public KademliaNetworkDatabaseFacade(RouterContext context, Hash dbid) {
_reseedChecker = null;
else
_reseedChecker = new ReseedChecker(context);
_blindCache = new BlindCache(context);
_blindCache = new BlindCache(context, dbid);

_localKey = null;
if (_log.shouldLog(Log.DEBUG))
Expand Down

0 comments on commit ad338ef

Please sign in to comment.