Skip to content

Commit 92867b4

Browse files
committed
feat: add SlotProcessorManager
1 parent b258d2c commit 92867b4

File tree

8 files changed

+386
-258
lines changed

8 files changed

+386
-258
lines changed

src/blobscan_client/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ mod jwt_manager;
1414

1515
pub mod types;
1616

17-
#[derive(Debug)]
17+
#[derive(Debug, Clone)]
1818
pub struct BlobscanClient {
1919
base_url: String,
2020
client: reqwest::Client,

src/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::{
1010

1111
use super::env::{get_env_vars, Environment};
1212

13-
#[derive(Debug)]
13+
#[derive(Debug, Clone)]
1414
pub struct Context {
1515
pub beacon_client: BeaconClient,
1616
pub blobscan_client: BlobscanClient,

src/main.rs

+7-10
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
use anyhow::Result;
2-
use tracing::Instrument;
2+
use slot_processor_manager::SlotProcessorManager;
33

44
use crate::{
55
context::create_context,
6-
slot_processor::SlotProcessor,
76
utils::telemetry::{get_subscriber, init_subscriber},
87
};
8+
99
use std::{thread, time::Duration};
1010

1111
mod beacon_client;
1212
mod blobscan_client;
1313
mod context;
1414
mod env;
15-
mod slot_processor;
15+
mod slot_processor_manager;
1616
mod utils;
1717

1818
#[tokio::main]
@@ -23,27 +23,24 @@ async fn main() -> Result<()> {
2323
init_subscriber(subscriber);
2424

2525
let context = create_context()?;
26-
let slot_processor = SlotProcessor::new(&context, None);
2726
let mut current_slot = match context.blobscan_client.get_slot().await? {
28-
Some(last_slot) => last_slot + 1,
27+
Some(last_slot) => last_slot,
2928
None => 0,
3029
};
30+
let slot_processor_manager = SlotProcessorManager::try_new(context.clone(), None)?;
3131

3232
loop {
3333
if let Some(latest_beacon_block) = context.beacon_client.get_block(None).await? {
3434
let latest_slot: u32 = latest_beacon_block.slot.parse()?;
3535

36-
let slot_span = tracing::trace_span!("", slot = latest_slot);
37-
3836
if current_slot < latest_slot {
39-
slot_processor
37+
slot_processor_manager
4038
.process_slots(current_slot, latest_slot)
41-
.instrument(slot_span)
4239
.await?;
43-
4440
current_slot = latest_slot;
4541
}
4642
}
43+
4744
thread::sleep(Duration::from_secs(10));
4845
}
4946
}

src/slot_processor.rs

-246
This file was deleted.

0 commit comments

Comments
 (0)