class MinimumGasPriceCalculator {

    public Coin calculate(Coin previousMGP, Coin targetMGP) {
        BlockGasPriceRange priceRange = new BlockGasPriceRange(previousMGP);
        if (priceRange.inRange(targetMGP)) {
            return targetMGP;
        }

        if (previousMGP.compareTo(targetMGP) < 0) {
            return priceRange.getUpperLimit();
        }

        return priceRange.getLowerLimit();
    }

}