11//! Bundler service responsible for fetching bundles and sending them to the simulator.
2- pub use crate :: config:: BuilderConfig ;
3- use crate :: tasks:: oauth:: Authenticator ;
2+ use crate :: tasks:: oauth:: SharedToken ;
43use oauth2:: TokenResponse ;
54use reqwest:: { Client , Url } ;
65use serde:: { Deserialize , Serialize } ;
76use signet_bundle:: SignetEthBundle ;
87use tokio:: sync:: mpsc:: { UnboundedReceiver , UnboundedSender , unbounded_channel} ;
98use tokio:: task:: JoinHandle ;
109use tokio:: time;
11- use tracing:: { Instrument , debug, trace} ;
10+ use tracing:: { Instrument , debug, trace, warn} ;
11+
12+ pub use crate :: config:: BuilderConfig ;
13+
1214/// Holds a bundle from the cache with a unique ID and a Zenith bundle.
1315#[ derive( Debug , Clone , Serialize , Deserialize ) ]
1416pub struct Bundle {
@@ -26,12 +28,12 @@ pub struct TxPoolBundleResponse {
2628}
2729
2830/// The BundlePoller polls the tx-pool for bundles.
29- #[ derive( Debug , Clone ) ]
31+ #[ derive( Debug ) ]
3032pub struct BundlePoller {
3133 /// The builder configuration values.
3234 pub config : BuilderConfig ,
3335 /// Authentication module that periodically fetches and stores auth tokens.
34- pub authenticator : Authenticator ,
36+ pub token : SharedToken ,
3537 /// Holds a Reqwest client
3638 pub client : Client ,
3739 /// Defines the interval at which the bundler polls the tx-pool for bundles.
@@ -41,28 +43,26 @@ pub struct BundlePoller {
4143/// Implements a poller for the block builder to pull bundles from the tx-pool.
4244impl BundlePoller {
4345 /// Creates a new BundlePoller from the provided builder config.
44- pub fn new ( config : & BuilderConfig , authenticator : Authenticator ) -> Self {
45- Self {
46- config : config. clone ( ) ,
47- authenticator,
48- client : Client :: new ( ) ,
49- poll_interval_ms : 1000 ,
50- }
46+ pub fn new ( config : & BuilderConfig , token : SharedToken ) -> Self {
47+ Self { config : config. clone ( ) , token, client : Client :: new ( ) , poll_interval_ms : 1000 }
5148 }
5249
5350 /// Creates a new BundlePoller from the provided builder config and with the specified poll interval in ms.
5451 pub fn new_with_poll_interval_ms (
5552 config : & BuilderConfig ,
56- authenticator : Authenticator ,
53+ token : SharedToken ,
5754 poll_interval_ms : u64 ,
5855 ) -> Self {
59- Self { config : config. clone ( ) , authenticator , client : Client :: new ( ) , poll_interval_ms }
56+ Self { config : config. clone ( ) , token , client : Client :: new ( ) , poll_interval_ms }
6057 }
6158
6259 /// Fetches bundles from the transaction cache and returns them.
6360 pub async fn check_bundle_cache ( & mut self ) -> eyre:: Result < Vec < Bundle > > {
6461 let bundle_url: Url = Url :: parse ( & self . config . tx_pool_url ) ?. join ( "bundles" ) ?;
65- let token = self . authenticator . fetch_oauth_token ( ) . await ?;
62+ let Some ( token) = self . token . read ( ) else {
63+ warn ! ( "No token available, skipping bundle fetch" ) ;
64+ return Ok ( vec ! [ ] ) ;
65+ } ;
6666
6767 let result = self
6868 . client
0 commit comments