diff --git a/src/main/java/org/qortal/repository/BlockArchiveReader.java b/src/main/java/org/qortal/repository/BlockArchiveReader.java index cff272a8..b6d7cdd6 100644 --- a/src/main/java/org/qortal/repository/BlockArchiveReader.java +++ b/src/main/java/org/qortal/repository/BlockArchiveReader.java @@ -145,20 +145,22 @@ public class BlockArchiveReader { } private String getFilenameForHeight(int height) { - Iterator it = this.fileListCache.entrySet().iterator(); - while (it.hasNext()) { - Map.Entry pair = (Map.Entry)it.next(); - if (pair == null && pair.getKey() == null && pair.getValue() == null) { - continue; - } - Triple heightInfo = (Triple) pair.getValue(); - Integer startHeight = heightInfo.getA(); - Integer endHeight = heightInfo.getB(); - - if (height >= startHeight && height <= endHeight) { - // Found the correct file - String filename = (String) pair.getKey(); - return filename; + synchronized (this.fileListCache) { + Iterator it = this.fileListCache.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry pair = (Map.Entry) it.next(); + if (pair == null && pair.getKey() == null && pair.getValue() == null) { + continue; + } + Triple heightInfo = (Triple) pair.getValue(); + Integer startHeight = heightInfo.getA(); + Integer endHeight = heightInfo.getB(); + + if (height >= startHeight && height <= endHeight) { + // Found the correct file + String filename = (String) pair.getKey(); + return filename; + } } }