class AdminLogsRemoveCache implements JsonRpcMethod {

  @Override
  public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
    final Optional<BlockParameter> startBlockParameter =
        requestContext.getOptionalParameter(0, BlockParameter.class);
    final Optional<BlockParameter> stopBlockParameter =
        requestContext.getOptionalParameter(1, BlockParameter.class);

    final long startBlock;
    if (startBlockParameter.isEmpty() || startBlockParameter.get().isEarliest()) {
      startBlock = BlockHeader.GENESIS_BLOCK_NUMBER;
    } else if (startBlockParameter.get().getNumber().isPresent()) {
      startBlock = startBlockParameter.get().getNumber().get();
      blockchainQueries
          .getBlockchain()
          .getBlockByNumber(startBlock)
          .orElseThrow(() -> new IllegalStateException("Block not found, " + startBlock));
    } else {
      // latest, pending
      startBlock = blockchainQueries.headBlockNumber();
    }

    final long stopBlock;
    if (stopBlockParameter.isEmpty()) {
      if (startBlockParameter.isEmpty()) {
        stopBlock = blockchainQueries.headBlockNumber();
      } else {
        stopBlock = startBlock;
      }
    } else if (stopBlockParameter.get().isEarliest()) {
      stopBlock = BlockHeader.GENESIS_BLOCK_NUMBER;
    } else if (stopBlockParameter.get().getNumber().isPresent()) {
      stopBlock = stopBlockParameter.get().getNumber().get();
      blockchainQueries
          .getBlockchain()
          .getBlockByNumber(stopBlock)
          .orElseThrow(() -> new IllegalStateException("Block not found, " + stopBlock));
    } else {
      // latest, pending
      stopBlock = blockchainQueries.headBlockNumber();
    }

    if (stopBlock < startBlock) {
      return new JsonRpcErrorResponse(
          requestContext.getRequest().getId(), JsonRpcError.INVALID_PARAMS);
    }

    final TransactionLogBloomCacher transactionLogBloomCacher =
        blockchainQueries
            .getTransactionLogBloomCacher()
            .orElseThrow(
                () ->
                    new InternalError(
                        "Error attempting to get TransactionLogBloomCacher. Please ensure that the TransactionLogBloomCacher is enabled."));

    transactionLogBloomCacher.removeSegments(startBlock, stopBlock);

    return new JsonRpcSuccessResponse(
        requestContext.getRequest().getId(), Map.of("Status", "Cache Removed"));
  }

  public  AdminLogsRemoveCache(final BlockchainQueries blockchainQueries);

}