1
1
use builder:: {
2
2
config:: BuilderConfig ,
3
3
service:: serve_builder,
4
- tasks:: {
5
- block:: sim:: Simulator ,
6
- cache:: { BundlePoller , CacheTask , TxPoller } ,
7
- metrics:: MetricsTask ,
8
- submit:: SubmitTask ,
9
- } ,
4
+ tasks:: { block:: sim:: Simulator , metrics:: MetricsTask , submit:: SubmitTask } ,
10
5
} ;
11
6
use init4_bin_base:: {
12
7
deps:: tracing:: { info, info_span} ,
@@ -26,12 +21,12 @@ async fn main() -> eyre::Result<()> {
26
21
let config = BuilderConfig :: from_env ( ) ?. clone ( ) ;
27
22
let constants = SignetSystemConstants :: pecorino ( ) ;
28
23
29
- // Initialize the oauth token
30
- let token = config. oauth_token ( ) ;
31
-
32
- // Set up the EnvTask
24
+ // Spawn the EnvTask
33
25
let env_task = config. env_task ( ) ;
34
- let ( env_watcher, env_jh) = env_task. spawn ( ) ;
26
+ let ( block_env, env_jh) = env_task. spawn ( ) ;
27
+
28
+ // Spawn the cache system
29
+ let cache_system = config. spawn_cache_system ( block_env) ;
35
30
36
31
// Prep providers and contracts
37
32
let ( host_provider, quincey) =
@@ -47,24 +42,12 @@ async fn main() -> eyre::Result<()> {
47
42
let submit =
48
43
SubmitTask { zenith, quincey, config : config. clone ( ) , outbound_tx_channel : tx_channel } ;
49
44
50
- // Tx Poller pulls transactions from the cache
51
- let tx_poller = TxPoller :: new ( & config) ;
52
- let ( tx_receiver, tx_poller_jh) = tx_poller. spawn ( ) ;
53
-
54
- // Bundle Poller pulls bundles from the cache
55
- let bundle_poller = BundlePoller :: new ( & config, token) ;
56
- let ( bundle_receiver, bundle_poller_jh) = bundle_poller. spawn ( ) ;
57
-
58
- // Set up the cache task
59
- let cache_task = CacheTask :: new ( env_watcher. clone ( ) , bundle_receiver, tx_receiver) ;
60
- let ( sim_cache, cache_jh) = cache_task. spawn ( ) ;
61
-
62
45
// Set up tx submission
63
46
let ( submit_channel, submit_jh) = submit. spawn ( ) ;
64
47
65
48
// Set up the simulator
66
49
let sim = Simulator :: new ( & config, ru_provider. clone ( ) ) ;
67
- let build_jh = sim. spawn_simulator_task ( constants, sim_cache, submit_channel) ;
50
+ let build_jh = sim. spawn_simulator_task ( constants, cache_system . sim_cache , submit_channel) ;
68
51
69
52
// Start the healthcheck server
70
53
let server = serve_builder ( ( [ 0 , 0 , 0 , 0 ] , config. builder_port ) ) ;
@@ -74,16 +57,17 @@ async fn main() -> eyre::Result<()> {
74
57
drop ( init_span_guard) ;
75
58
76
59
select ! {
77
- _ = cache_jh => {
78
- info!( "cache task finished" ) ;
79
- } ,
60
+
80
61
_ = env_jh => {
81
62
info!( "env task finished" ) ;
82
63
} ,
83
- _ = tx_poller_jh => {
64
+ _ = cache_system. cache_task => {
65
+ info!( "cache task finished" ) ;
66
+ } ,
67
+ _ = cache_system. tx_poller => {
84
68
info!( "tx_poller finished" ) ;
85
69
} ,
86
- _ = bundle_poller_jh => {
70
+ _ = cache_system . bundle_poller => {
87
71
info!( "bundle_poller finished" ) ;
88
72
} ,
89
73
_ = submit_jh => {
0 commit comments