fileListCache is now an immutable Map, which is thread safe. Thanks to catbref for this idea.

This commit is contained in:
CalDescent 2022-03-11 10:59:07 +00:00
parent b764172500
commit 6aad6a1618

View File

@ -63,7 +63,7 @@ public class BlockArchiveReader {
map.put(filename, new Triple(startHeight, endHeight, range));
}
}
this.fileListCache = map;
this.fileListCache = Map.copyOf(map);
}
public Triple<BlockData, List<TransactionData>, List<ATStateData>> fetchBlockAtHeight(int height) {
@ -145,7 +145,6 @@ public class BlockArchiveReader {
}
private String getFilenameForHeight(int height) {
synchronized (this.fileListCache) {
Iterator it = this.fileListCache.entrySet().iterator();
while (it.hasNext()) {
Map.Entry pair = (Map.Entry) it.next();
@ -162,7 +161,6 @@ public class BlockArchiveReader {
return filename;
}
}
}
return null;
}