mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: add check empty when broadcasting transactions (#13008)
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
@ -121,7 +121,11 @@ impl<N: NetworkPrimitives> TransactionsHandle<N> {
|
||||
///
|
||||
/// Note: this only propagates the transactions that are known to the pool.
|
||||
pub fn propagate_hashes_to(&self, hash: impl IntoIterator<Item = TxHash>, peer: PeerId) {
|
||||
self.send(TransactionsCommand::PropagateHashesTo(hash.into_iter().collect(), peer))
|
||||
let hashes = hash.into_iter().collect::<Vec<_>>();
|
||||
if hashes.is_empty() {
|
||||
return
|
||||
}
|
||||
self.send(TransactionsCommand::PropagateHashesTo(hashes, peer))
|
||||
}
|
||||
|
||||
/// Request the active peer IDs from the [`TransactionsManager`].
|
||||
@ -132,7 +136,12 @@ impl<N: NetworkPrimitives> TransactionsHandle<N> {
|
||||
}
|
||||
|
||||
/// Manually propagate full transactions to a specific peer.
|
||||
///
|
||||
/// Do nothing if transactions are empty.
|
||||
pub fn propagate_transactions_to(&self, transactions: Vec<TxHash>, peer: PeerId) {
|
||||
if transactions.is_empty() {
|
||||
return
|
||||
}
|
||||
self.send(TransactionsCommand::PropagateTransactionsTo(transactions, peer))
|
||||
}
|
||||
|
||||
@ -140,7 +149,12 @@ impl<N: NetworkPrimitives> TransactionsHandle<N> {
|
||||
///
|
||||
/// It's up to the [`TransactionsManager`] whether the transactions are sent as hashes or in
|
||||
/// full.
|
||||
///
|
||||
/// Do nothing if transactions are empty.
|
||||
pub fn propagate_transactions(&self, transactions: Vec<TxHash>) {
|
||||
if transactions.is_empty() {
|
||||
return
|
||||
}
|
||||
self.send(TransactionsCommand::PropagateTransactions(transactions))
|
||||
}
|
||||
|
||||
@ -149,6 +163,9 @@ impl<N: NetworkPrimitives> TransactionsHandle<N> {
|
||||
&self,
|
||||
peers: Vec<PeerId>,
|
||||
) -> Result<HashMap<PeerId, HashSet<TxHash>>, RecvError> {
|
||||
if peers.is_empty() {
|
||||
return Ok(Default::default())
|
||||
}
|
||||
let (tx, rx) = oneshot::channel();
|
||||
self.send(TransactionsCommand::GetTransactionHashes { peers, tx });
|
||||
rx.await
|
||||
|
||||
Reference in New Issue
Block a user