From e86b2c175f0ab2f2a004ec63b193e3f01782a472 Mon Sep 17 00:00:00 2001 From: Dan Cline <6798349+Rjected@users.noreply.github.com> Date: Fri, 2 Feb 2024 15:19:03 -0500 Subject: [PATCH] feat: remove blobs associated with discarded blob txs (#6361) --- crates/transaction-pool/src/pool/mod.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/transaction-pool/src/pool/mod.rs b/crates/transaction-pool/src/pool/mod.rs index 894f0a9b3f..1f0a28117e 100644 --- a/crates/transaction-pool/src/pool/mod.rs +++ b/crates/transaction-pool/src/pool/mod.rs @@ -748,8 +748,17 @@ where } /// Enforces the size limits of pool and returns the discarded transactions if violated. + /// + /// If some of the transactions are blob transactions, they are also removed from the blob + /// store. pub(crate) fn discard_worst(&self) -> HashSet { - self.pool.write().discard_worst().into_iter().map(|tx| *tx.hash()).collect() + let discarded = self.pool.write().discard_worst(); + + // delete any blobs associated with discarded blob transactions + self.delete_discarded_blobs(discarded.iter()); + + // then collect into tx hashes + discarded.into_iter().map(|tx| *tx.hash()).collect() } /// Inserts a blob transaction into the blob store