From d2ea5633fb82269d7c3e683b453b7b342ef6d589 Mon Sep 17 00:00:00 2001 From: CalDescent Date: Sun, 9 May 2021 08:25:24 +0100 Subject: [PATCH] Fixed divide by zero exception. Block.calcKeyDistance() cannot be called on some trimmed blocks, because the minter level is unable to be inferred in some cases. This generally hasn't been an issue, but the new Block.logDebugInfo() method is invoking it for all blocks. For now I am adding defensiveness to the debug method, but longer term we might want to add defensiveness to Block.calcKeyDistance() itself, if we ever encounter this issue again. I will leave it alone for now, to reduce risk. --- src/main/java/org/qortal/block/Block.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/qortal/block/Block.java b/src/main/java/org/qortal/block/Block.java index 384ca193..41adbd78 100644 --- a/src/main/java/org/qortal/block/Block.java +++ b/src/main/java/org/qortal/block/Block.java @@ -2021,7 +2021,7 @@ public class Block { LOGGER.debug(String.format("Online accounts: %d", this.getBlockData().getOnlineAccountsCount())); BlockSummaryData blockSummaryData = new BlockSummaryData(this.getBlockData()); - if (this.getParent() == null || this.getParent().getSignature() == null || blockSummaryData == null) + if (this.getParent() == null || this.getParent().getSignature() == null || blockSummaryData == null || minterLevel == 0) return; blockSummaryData.setMinterLevel(minterLevel);