diff --git a/src/main/java/org/qortal/api/resource/BlocksResource.java b/src/main/java/org/qortal/api/resource/BlocksResource.java index 6dc13c8a..b9ffe03c 100644 --- a/src/main/java/org/qortal/api/resource/BlocksResource.java +++ b/src/main/java/org/qortal/api/resource/BlocksResource.java @@ -761,7 +761,7 @@ public class BlocksResource { // Use the latest X blocks if only a count is specified if (startHeight == null && endHeight == null && count != null) { - BlockData chainTip = Controller.getInstance().getChainTip(); + BlockData chainTip = repository.getBlockRepository().getLastBlock(); startHeight = chainTip.getHeight() - count; endHeight = chainTip.getHeight(); } diff --git a/src/main/java/org/qortal/repository/BlockArchiveReader.java b/src/main/java/org/qortal/repository/BlockArchiveReader.java index 081917b2..f64b7a2a 100644 --- a/src/main/java/org/qortal/repository/BlockArchiveReader.java +++ b/src/main/java/org/qortal/repository/BlockArchiveReader.java @@ -47,21 +47,23 @@ public class BlockArchiveReader { String[] files = archiveDirFile.list(); Map> map = new HashMap<>(); - for (String file : files) { - Path filePath = Paths.get(file); - String filename = filePath.getFileName().toString(); - - // Parse the filename - if (filename == null || !filename.contains("-") || !filename.contains(".")) { - // Not a usable file - continue; + if (files != null) { + for (String file : files) { + Path filePath = Paths.get(file); + String filename = filePath.getFileName().toString(); + + // Parse the filename + if (filename == null || !filename.contains("-") || !filename.contains(".")) { + // Not a usable file + continue; + } + // Remove the extension and split into two parts + String[] parts = filename.substring(0, filename.lastIndexOf('.')).split("-"); + Integer startHeight = Integer.parseInt(parts[0]); + Integer endHeight = Integer.parseInt(parts[1]); + Integer range = endHeight - startHeight; + map.put(filename, new Triple(startHeight, endHeight, range)); } - // Remove the extension and split into two parts - String[] parts = filename.substring(0, filename.lastIndexOf('.')).split("-"); - Integer startHeight = Integer.parseInt(parts[0]); - Integer endHeight = Integer.parseInt(parts[1]); - Integer range = endHeight - startHeight; - map.put(filename, new Triple(startHeight, endHeight, range)); } this.fileListCache = map; }