Check if a transaction is in the mempool before adding it to ensure only new transactions are propagated.
This will fix the bug where transactions are propagated in an endless loop.
@@ -26,6 +26,7 @@ use crate::{
mempool::{
service::{MempoolRequest, MempoolResponse, MempoolServiceError, OutboundMempoolServiceInterface},
Mempool,
+ TxStorageResponse,
},
transactions::transaction::Transaction,
};
@@ -71,6 +72,7 @@ where T: BlockchainBackend
source_peer: Option<CommsPublicKey>,
) -> Result<(), MempoolServiceError>
{
+ if self.mempool.has_tx_with_excess_sig(&tx.body.kernels()[0].excess_sig)? == TxStorageResponse::NotStored {
self.mempool.insert(Arc::new(tx.clone()))?;
let exclude_list = if let Some(peer) = source_peer {
vec![peer]
@@ -78,7 +80,7 @@ where T: BlockchainBackend
Vec::new()
};
self.outbound_nmi.propagate_tx(tx.clone(), exclude_list).await?;
-
+ }
Ok(())
}
