Skip to content

Commit

Permalink
use match
Browse files Browse the repository at this point in the history
  • Loading branch information
sapinb committed Sep 27, 2024
1 parent cdbc2d1 commit 91b78bb
Showing 1 changed file with 45 additions and 44 deletions.
89 changes: 45 additions & 44 deletions sequencer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,50 +136,51 @@ fn main_inner(args: Args) -> anyhow::Result<()> {
bitcoin_client,
)?;

Check warning on line 137 in sequencer/src/main.rs

View check run for this annotation

Codecov / codecov/patch

sequencer/src/main.rs#L126-L137

Added lines #L126 - L137 were not covered by tests

// If we're a sequencer, start the sequencer db and duties task.
if let ClientMode::Sequencer(sequencer_config) = &config.client.client_mode {
let broadcast_database = init_broadcaster_database(rbdb.clone(), ops_config);
let broadcast_handle = start_broadcaster_tasks(
broadcast_database,
ctx.pool.clone(),
&executor,
ctx.bitcoin_client.clone(),
);
let seq_db = init_sequencer_database(rbdb.clone(), ops_config);

start_sequencer_tasks(
ctx.clone(),
&config,
sequencer_config,
&executor,
seq_db,
checkpoint_handle.clone(),
broadcast_handle,
&mut methods,
)?;
};

if let ClientMode::FullNode(fullnode_config) = &config.client.client_mode {
let sequencer_rpc = &fullnode_config.sequencer_rpc;
info!(?sequencer_rpc, "initing fullnode task");

let rpc_client = runtime.block_on(sync_client(sequencer_rpc));
let sync_peer = RpcSyncPeer::new(rpc_client, 10);
let l2_sync_context = L2SyncContext::new(
sync_peer,
ctx.l2_block_manager.clone(),
ctx.sync_manager.clone(),
);
// NOTE: this might block for some time during first run with empty db until genesis block
// is generated
let mut l2_sync_state =
express_sync::block_until_csm_ready_and_init_sync_state(&l2_sync_context)?;

executor.spawn_critical_async("l2-sync-manager", async move {
express_sync::sync_worker(&mut l2_sync_state, &l2_sync_context)
.await
.map_err(Into::into)
});
match &config.client.client_mode {

Check warning on line 139 in sequencer/src/main.rs

View check run for this annotation

Codecov / codecov/patch

sequencer/src/main.rs#L139

Added line #L139 was not covered by tests
// If we're a sequencer, start the sequencer db and duties task.
ClientMode::Sequencer(sequencer_config) => {
let broadcast_database = init_broadcaster_database(rbdb.clone(), ops_config);
let broadcast_handle = start_broadcaster_tasks(
broadcast_database,
ctx.pool.clone(),
&executor,
ctx.bitcoin_client.clone(),
);
let seq_db = init_sequencer_database(rbdb.clone(), ops_config);

start_sequencer_tasks(
ctx.clone(),
&config,
sequencer_config,
&executor,
seq_db,
checkpoint_handle.clone(),
broadcast_handle,
&mut methods,
)?;

Check warning on line 160 in sequencer/src/main.rs

View check run for this annotation

Codecov / codecov/patch

sequencer/src/main.rs#L141-L160

Added lines #L141 - L160 were not covered by tests
}
ClientMode::FullNode(fullnode_config) => {
let sequencer_rpc = &fullnode_config.sequencer_rpc;
info!(?sequencer_rpc, "initing fullnode task");

Check warning on line 164 in sequencer/src/main.rs

View check run for this annotation

Codecov / codecov/patch

sequencer/src/main.rs#L162-L164

Added lines #L162 - L164 were not covered by tests

let rpc_client = runtime.block_on(sync_client(sequencer_rpc));
let sync_peer = RpcSyncPeer::new(rpc_client, 10);
let l2_sync_context = L2SyncContext::new(
sync_peer,
ctx.l2_block_manager.clone(),
ctx.sync_manager.clone(),
);

Check warning on line 172 in sequencer/src/main.rs

View check run for this annotation

Codecov / codecov/patch

sequencer/src/main.rs#L166-L172

Added lines #L166 - L172 were not covered by tests
// NOTE: this might block for some time during first run with empty db until genesis
// block is generated
let mut l2_sync_state =
express_sync::block_until_csm_ready_and_init_sync_state(&l2_sync_context)?;

Check warning on line 176 in sequencer/src/main.rs

View check run for this annotation

Codecov / codecov/patch

sequencer/src/main.rs#L175-L176

Added lines #L175 - L176 were not covered by tests

executor.spawn_critical_async("l2-sync-manager", async move {
express_sync::sync_worker(&mut l2_sync_state, &l2_sync_context)
.await
.map_err(Into::into)
});
}

Check warning on line 183 in sequencer/src/main.rs

View check run for this annotation

Codecov / codecov/patch

sequencer/src/main.rs#L178-L183

Added lines #L178 - L183 were not covered by tests
}

executor.spawn_critical_async(
Expand Down

0 comments on commit 91b78bb

Please sign in to comment.