From bd08cd3c9b401d560f127809986ef97325aa3edf Mon Sep 17 00:00:00 2001
From: Luke Parker <lukeparker5132@gmail.com>
Date: Wed, 2 Nov 2022 23:46:21 -0400
Subject: [PATCH] Add message expiry to the Tendermint gossip

---
 substrate/tendermint/client/src/authority/gossip.rs | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/substrate/tendermint/client/src/authority/gossip.rs b/substrate/tendermint/client/src/authority/gossip.rs
index fec5c8be..b8af1a08 100644
--- a/substrate/tendermint/client/src/authority/gossip.rs
+++ b/substrate/tendermint/client/src/authority/gossip.rs
@@ -55,4 +55,11 @@ impl<T: TendermintValidator> Validator<T::Block> for TendermintGossip<T> {
 
     ValidationResult::ProcessAndKeep(Self::topic(msg.number().0))
   }
+
+  fn message_expired<'a>(
+    &'a self,
+  ) -> Box<dyn FnMut(<T::Block as Block>::Hash, &[u8]) -> bool + 'a> {
+    let number = self.number.clone();
+    Box::new(move |topic, _| topic != Self::topic(*number.read().unwrap()))
+  }
 }