Skip to content

Commit

Permalink
feat(stableMinGasPrice): add extra logs to MinimumGasPriceCalculator
Browse files Browse the repository at this point in the history
  • Loading branch information
Vovchyk committed Oct 16, 2024
1 parent 3502926 commit eec8e4b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions rskj-core/src/main/java/co/rsk/mine/BlockGasPriceRange.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,9 @@ public Coin getUpperLimit() {
public Coin getLowerLimit() {
return lowerLimit;
}

@Override
public String toString() {
return "[" + lowerLimit + ", " + upperLimit + "]";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,17 @@

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
* Created by mario on 22/12/16.
*/
public class MinimumGasPriceCalculator {

private static final Logger logger = LoggerFactory.getLogger(MinimumGasPriceCalculator.class);

private final MinGasPriceProvider minGasPriceProvider;

public MinimumGasPriceCalculator(MinGasPriceProvider minGasPriceProvider) {
Expand All @@ -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();
}

}

0 comments on commit eec8e4b

Please sign in to comment.