class LimitedNewPooledTransactionHashesMessages {

  public static LimitedNewPooledTransactionHashesMessages createLimited(
      final Iterable<Hash> hashes) {
    final List<Hash> includedTransactions = new ArrayList<>();
    final BytesValueRLPOutput message = new BytesValueRLPOutput();
    int count = 0;
    message.startList();
    for (final Hash txHash : hashes) {
      final BytesValueRLPOutput encodedHashes = new BytesValueRLPOutput();
      encodedHashes.writeBytes(txHash);
      Bytes encodedBytes = encodedHashes.encoded();

      message.writeRLPUnsafe(encodedBytes);
      includedTransactions.add(txHash);
      // Check if last transaction to add to the message
      count++;
      if (count >= MAX_COUNT) {
        break;
      }
    }
    message.endList();
    return new LimitedNewPooledTransactionHashesMessages(
        new NewPooledTransactionHashesMessage(message.encoded()), includedTransactions);
  }

  public  LimitedNewPooledTransactionHashesMessages(
      final NewPooledTransactionHashesMessage transactionsMessage,
      final List<Hash> includedTransactions);

}