DataFetcher<Optional<AccountAdapter>> getAccountDataFetcher() {
    return dataFetchingEnvironment -> {
      final BlockchainQueries blockchainQuery =
          dataFetchingEnvironment.getGraphQlContext().get(GraphQLContextType.BLOCKCHAIN_QUERIES);
      final Address addr = dataFetchingEnvironment.getArgument("address");
      final Long bn = dataFetchingEnvironment.getArgument("blockNumber");
      if (bn != null) {
        return blockchainQuery
            .getAndMapWorldState(
                bn,
                ws -> {
                  final Account account = ws.get(addr);
                  if (account == null) {
                    return Optional.of(new EmptyAccountAdapter(addr));
                  }
                  return Optional.of(new AccountAdapter(account));
                })
            .or(
                () -> {
                  if (bn > blockchainQuery.getBlockchain().getChainHeadBlockNumber()) {
                    // block is past chainhead
                    throw new GraphQLException(GraphQLError.INVALID_PARAMS);
                  } else {
                    // we don't have that block
                    throw new GraphQLException(GraphQLError.CHAIN_HEAD_WORLD_STATE_NOT_AVAILABLE);
                  }
                });
      } else {
        // return account on latest block
        final long latestBn = blockchainQuery.latestBlock().get().getHeader().getNumber();
        return blockchainQuery.getAndMapWorldState(
            latestBn,
            ws -> {
              final Account account = ws.get(addr);
              if (account == null) {
                return Optional.of(new EmptyAccountAdapter(addr));
              }
              return Optional.of(new AccountAdapter(account));
            });
      }
    };
  }
Returns a DataFetcher that fetches a specific block in the Ethereum blockchain.

<p>The DataFetcher is a functional interface. It has a single method that takes a
DataFetchingEnvironment object as input. This method fetches a block based on either a block
number or a block hash. If both a block number and a block hash are provided, it throws a
GraphQLException with INVALID_PARAMS error. If neither a block number nor a block hash is
provided, it fetches the latest block.

<p>The fetched block is then wrapped in a {@link NormalBlockAdapter} and returned as an {@code
Optional<NormalBlockAdapter>}.

@return a DataFetcher that fetches a specific block in the Ethereum blockchain
ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/GraphQLDataFetchers.java