class GasLimitRangeAndDeltaValidationRule implements DetachedBlockHeaderValidationRule {

  @Override
  public boolean validate(final BlockHeader header, final BlockHeader parent) {
    final long gasLimit = header.getGasLimit();

    if ((gasLimit < minGasLimit) || (gasLimit > maxGasLimit)) {
      LOG.trace(
          "Header gasLimit = {}, outside range {} --> {}", gasLimit, minGasLimit, maxGasLimit);
      return false;
    }

    final long parentGasLimit = parent.getGasLimit();
    final long difference = Math.abs(parentGasLimit - gasLimit);
    final long bounds = Long.divideUnsigned(parentGasLimit, GASLIMIT_BOUND_DIVISOR);
    if (Long.compareUnsigned(difference, bounds) >= 0) {
      LOG.trace(
          "Invalid block header: gas limit delta {} is out of bounds of {}", gasLimit, bounds);
      return false;
    }

    return true;
  }

  public  GasLimitRangeAndDeltaValidationRule(final long minGasLimit, final long maxGasLimit);

}