diff --git a/rskj-core/src/main/java/co/rsk/mine/BlockGasPriceRange.java b/rskj-core/src/main/java/co/rsk/mine/BlockGasPriceRange.java index e69c688ffd..340a83b9b1 100644 --- a/rskj-core/src/main/java/co/rsk/mine/BlockGasPriceRange.java +++ b/rskj-core/src/main/java/co/rsk/mine/BlockGasPriceRange.java @@ -51,4 +51,9 @@ public Coin getUpperLimit() { public Coin getLowerLimit() { return lowerLimit; } + + @Override + public String toString() { + return "[" + lowerLimit + "; " + upperLimit + "]"; + } } diff --git a/rskj-core/src/main/java/co/rsk/mine/MinimumGasPriceCalculator.java b/rskj-core/src/main/java/co/rsk/mine/MinimumGasPriceCalculator.java index eff3c8e934..c0569a9f44 100644 --- a/rskj-core/src/main/java/co/rsk/mine/MinimumGasPriceCalculator.java +++ b/rskj-core/src/main/java/co/rsk/mine/MinimumGasPriceCalculator.java @@ -20,6 +20,8 @@ import co.rsk.core.Coin; import co.rsk.mine.gas.provider.MinGasPriceProvider; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * This is the implementation of RSKIP-09 @@ -27,6 +29,8 @@ */ public class MinimumGasPriceCalculator { + private static final Logger logger = LoggerFactory.getLogger(MinimumGasPriceCalculator.class); + private final MinGasPriceProvider minGasPriceProvider; public MinimumGasPriceCalculator(MinGasPriceProvider minGasPriceProvider) { @@ -37,14 +41,16 @@ public Coin calculate(Coin previousMGP) { BlockGasPriceRange priceRange = new BlockGasPriceRange(previousMGP); Coin targetMGP = minGasPriceProvider.getMinGasPriceAsCoin(); if (priceRange.inRange(targetMGP)) { + logger.debug("Previous MGP: {}. Target MGP: {} is in range: {}. Returning target MGP", previousMGP, targetMGP, priceRange); return targetMGP; } if (previousMGP.compareTo(targetMGP) < 0) { + logger.debug("Previous MGP: {}. Target MGP: {} is not in range: {}. Returning upper boundary: {}", previousMGP, targetMGP, priceRange, priceRange.getUpperLimit()); return priceRange.getUpperLimit(); } + logger.debug("Previous MGP: {}. Target MGP: {} is not in range: {}. Returning lower boundary: {}", previousMGP, targetMGP, priceRange, priceRange.getLowerLimit()); return priceRange.getLowerLimit(); } - }