-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
78 additions
and
11 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
//! Sponsor periodic broadcaster | ||
|
||
use alloy_primitives::Address; | ||
use reth_network::transactions::TransactionsHandle; | ||
use reth_transaction_pool::TransactionPool; | ||
use std::time::Duration; | ||
|
||
/// Periodically broadcasts sponsored transactions from the transaction pool. | ||
/// | ||
/// `p2p` broadcasting can potentially be flaky, and due to the p2p rules, some txs may never make | ||
/// it to the sequencer, this can happen if a message is dropped internally when channel bounds are | ||
/// enforced for example. So, we re-broadcast them every 10 minutes. | ||
pub async fn periodic_broadcaster<P>( | ||
address: Address, | ||
pool: P, | ||
transactions_handle: TransactionsHandle, | ||
) where | ||
P: TransactionPool, | ||
{ | ||
let mut interval_timer = tokio::time::interval(Duration::from_secs(60 * 10)); | ||
|
||
loop { | ||
let transactions = | ||
pool.get_transactions_by_sender(address).into_iter().map(|tx| *tx.hash()).collect(); | ||
|
||
transactions_handle.propagate_transactions(transactions); | ||
|
||
interval_timer.tick().await; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters