1
1
//! 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 ;
4
3
use oauth2:: TokenResponse ;
5
4
use reqwest:: { Client , Url } ;
6
5
use serde:: { Deserialize , Serialize } ;
7
6
use signet_bundle:: SignetEthBundle ;
8
7
use tokio:: sync:: mpsc:: { UnboundedReceiver , UnboundedSender , unbounded_channel} ;
9
8
use tokio:: task:: JoinHandle ;
10
9
use tokio:: time;
11
- use tracing:: { Instrument , debug, trace} ;
10
+ use tracing:: { Instrument , debug, trace, warn} ;
11
+
12
+ pub use crate :: config:: BuilderConfig ;
13
+
12
14
/// Holds a bundle from the cache with a unique ID and a Zenith bundle.
13
15
#[ derive( Debug , Clone , Serialize , Deserialize ) ]
14
16
pub struct Bundle {
@@ -26,12 +28,12 @@ pub struct TxPoolBundleResponse {
26
28
}
27
29
28
30
/// The BundlePoller polls the tx-pool for bundles.
29
- #[ derive( Debug , Clone ) ]
31
+ #[ derive( Debug ) ]
30
32
pub struct BundlePoller {
31
33
/// The builder configuration values.
32
34
pub config : BuilderConfig ,
33
35
/// Authentication module that periodically fetches and stores auth tokens.
34
- pub authenticator : Authenticator ,
36
+ pub token : SharedToken ,
35
37
/// Holds a Reqwest client
36
38
pub client : Client ,
37
39
/// Defines the interval at which the bundler polls the tx-pool for bundles.
@@ -41,28 +43,26 @@ pub struct BundlePoller {
41
43
/// Implements a poller for the block builder to pull bundles from the tx-pool.
42
44
impl BundlePoller {
43
45
/// 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 }
51
48
}
52
49
53
50
/// Creates a new BundlePoller from the provided builder config and with the specified poll interval in ms.
54
51
pub fn new_with_poll_interval_ms (
55
52
config : & BuilderConfig ,
56
- authenticator : Authenticator ,
53
+ token : SharedToken ,
57
54
poll_interval_ms : u64 ,
58
55
) -> 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 }
60
57
}
61
58
62
59
/// Fetches bundles from the transaction cache and returns them.
63
60
pub async fn check_bundle_cache ( & mut self ) -> eyre:: Result < Vec < Bundle > > {
64
61
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
+ } ;
66
66
67
67
let result = self
68
68
. client
0 commit comments