From 472e1da792d0d14edaf66be53fe523b276cbffe9 Mon Sep 17 00:00:00 2001 From: CalDescent Date: Wed, 26 Jan 2022 22:34:15 +0000 Subject: [PATCH] Added debug level logging in higherWeightChainExists() for better visibility. --- .../java/org/qortal/controller/BlockMinter.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/qortal/controller/BlockMinter.java b/src/main/java/org/qortal/controller/BlockMinter.java index 4ed2a27f..f4222750 100644 --- a/src/main/java/org/qortal/controller/BlockMinter.java +++ b/src/main/java/org/qortal/controller/BlockMinter.java @@ -1,6 +1,8 @@ package org.qortal.controller; import java.math.BigInteger; +import java.text.DecimalFormat; +import java.text.NumberFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; @@ -501,6 +503,8 @@ public class BlockMinter extends Thread { // Can't make decisions without knowing the block candidate weight return false; } + NumberFormat formatter = new DecimalFormat("0.###E0"); + List peers = Network.getInstance().getHandshakedPeers(); // Loop through handshaked peers and check for any new block candidates for (Peer peer : peers) { @@ -514,10 +518,18 @@ public class BlockMinter extends Thread { BigInteger ourChainWeight = ourChainWeightSinceCommonBlock.add(blockCandidateWeight); BigInteger peerChainWeight = commonBlockData.getChainWeight(); if (peerChainWeight.compareTo(ourChainWeight) >= 0) { - // This peer has a higher weight chain than ours (including our block candidate) + // This peer has a higher weight chain than ours + LOGGER.debug("Peer {} is on a higher weight chain ({}) than ours ({})", peer, formatter.format(peerChainWeight), formatter.format(ourChainWeight)); return true; + + } else { + LOGGER.debug("Peer {} is on a lower weight chain ({}) than ours ({})", peer, formatter.format(peerChainWeight), formatter.format(ourChainWeight)); } + } else { + LOGGER.debug("Peer {} has no chain weight", peer); } + } else { + LOGGER.debug("Peer {} has no common block data", peer); } } return false;