private void executeSaveToDisk(final PendingTransactions pendingTransactionsToSave) {
      final File saveFile = configuration.getSaveFile();
      final boolean appending = saveFile.exists();
      try (final BufferedWriter bw =
          new BufferedWriter(new FileWriter(saveFile, StandardCharsets.US_ASCII, appending))) {
        final var allTxs = pendingTransactionsToSave.getPendingTransactions();
        LOG.info(
            "{} {} transactions to file {}",
            appending ? "Appending" : "Saving",
            allTxs.size(),
            saveFile);

        final long processedTxCount =
            allTxs.parallelStream()
                .takeWhile(unused -> !isCancelled.get())
                .map(
                    ptx -> {
                      final BytesValueRLPOutput rlp = new BytesValueRLPOutput();
                      ptx.getTransaction().writeTo(rlp, EncodingContext.POOLED_TRANSACTION);
                      return ptx.getScore()
                          + (ptx.isReceivedFromLocalSource() ? "l" : "r")
                          + rlp.encoded().toBase64String();
                    })
                .mapToInt(
                    line -> {
                      synchronized (bw) {
                        try {
                          bw.write(line);
                          bw.newLine();
                        } catch (IOException e) {
                          throw new RuntimeException(e);
                        }
                      }
                      return 1;
                    })
                .sum();

        if (isCancelled.get()) {
          LOG.info(
              "{} {} transactions to file {}, before operation was cancelled",
              appending ? "Appended" : "Saved",
              processedTxCount,
              saveFile);
        } else {
          LOG.info(
              "{} {} transactions to file {}",
              appending ? "Appended" : "Saved",
              processedTxCount,
              saveFile);
        }
      } catch (IOException e) {
        LOG.error("Error while saving txpool content to disk", e);
      }
    }
Maintains the set of pending transactions received from JSON-RPC or other nodes. Transactions are
removed automatically when they are included in a block on the canonical chain and re-added if a
re-org removes them from the canonical chain again.

<p>This class is safe for use across multiple threads.
ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPool.java