feat: event system and state extension

This commit is contained in:
Pravdyvy 2026-01-20 16:28:15 +02:00
parent b143beef37
commit 93bc4d51c3
3 changed files with 12 additions and 5 deletions

View File

@ -1,4 +1,4 @@
use std::sync::Arc;
use std::{collections::HashMap, sync::Arc};
use anyhow::Result;
use bedrock_client::{BasicAuthCredentials, BedrockClient};
@ -45,6 +45,7 @@ impl IndexerCore {
// No state setup for now, future task.
state: IndexerState {
latest_seen_block: Arc::new(RwLock::new(0)),
finality_map: Arc::new(RwLock::new(HashMap::new())),
},
})
}
@ -93,7 +94,7 @@ impl IndexerCore {
}
// Sending data into sequencer, may need to be expanded.
let message = IndexerToSequencerMessage::BlockObserved {
let message = IndexerToSequencerMessage::FinalizedBlockObserved {
l1_block_id: block_info.height,
l2_block_height: l2_block.block_id,
};

View File

@ -1,7 +1,13 @@
#[derive(Debug, Clone)]
pub enum IndexerToSequencerMessage {
BlockObserved {
FinalizedBlockObserved {
l1_block_id: u64,
l2_block_height: u64,
},
BlockEnteredChain {
l2_block_height: u64,
},
ChainRestructurization {
new_l1_last_block_height: u64,
},
}

View File

@ -1,9 +1,9 @@
use std::sync::Arc;
use std::{collections::HashMap, sync::Arc};
use tokio::sync::RwLock;
#[derive(Debug, Clone)]
pub struct IndexerState {
// Only one field for now, for testing.
pub latest_seen_block: Arc<RwLock<u64>>,
pub finality_map: Arc<RwLock<HashMap<u64, u64>>>,
}