mirror of
https://github.com/logos-blockchain/lssa.git
synced 2026-07-25 17:13:12 +00:00
clippy
This commit is contained in:
parent
13f15530e4
commit
c2f93aff59
@ -19,6 +19,11 @@ use tokio::{sync::mpsc, task::JoinHandle};
|
|||||||
|
|
||||||
use crate::config::BedrockConfig;
|
use crate::config::BedrockConfig;
|
||||||
|
|
||||||
|
/// Channel capacity for the publish inbox. One publish per produced block, drained
|
||||||
|
/// in microseconds by the drive task — 32 is huge headroom and just provides
|
||||||
|
/// backpressure if the drive task stalls (reconnect, long backfill).
|
||||||
|
const PUBLISH_INBOX_CAPACITY: usize = 32;
|
||||||
|
|
||||||
/// Sink for `Event::Published` checkpoints emitted by the drive task.
|
/// Sink for `Event::Published` checkpoints emitted by the drive task.
|
||||||
/// Caller is responsible for persistence (e.g. writing to rocksdb).
|
/// Caller is responsible for persistence (e.g. writing to rocksdb).
|
||||||
pub type CheckpointSink = Box<dyn Fn(SequencerCheckpoint) + Send + 'static>;
|
pub type CheckpointSink = Box<dyn Fn(SequencerCheckpoint) + Send + 'static>;
|
||||||
@ -32,11 +37,6 @@ pub type FinalizedBlockSink = Box<dyn Fn(u64) + Send + 'static>;
|
|||||||
pub type OnDepositEventSink =
|
pub type OnDepositEventSink =
|
||||||
Box<dyn Fn(DepositInfo) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + 'static>;
|
Box<dyn Fn(DepositInfo) -> Pin<Box<dyn Future<Output = ()> + Send>> + Send + 'static>;
|
||||||
|
|
||||||
/// Channel capacity for the publish inbox. One publish per produced block, drained
|
|
||||||
/// in microseconds by the drive task — 32 is huge headroom and just provides
|
|
||||||
/// backpressure if the drive task stalls (reconnect, long backfill).
|
|
||||||
const PUBLISH_INBOX_CAPACITY: usize = 32;
|
|
||||||
|
|
||||||
#[expect(async_fn_in_trait, reason = "We don't care about Send/Sync here")]
|
#[expect(async_fn_in_trait, reason = "We don't care about Send/Sync here")]
|
||||||
pub trait BlockPublisherTrait: Clone {
|
pub trait BlockPublisherTrait: Clone {
|
||||||
async fn new(
|
async fn new(
|
||||||
@ -111,40 +111,44 @@ impl BlockPublisherTrait for ZoneSdkPublisher {
|
|||||||
|
|
||||||
let drive_task = tokio::spawn(async move {
|
let drive_task = tokio::spawn(async move {
|
||||||
loop {
|
loop {
|
||||||
tokio::select! {
|
#[allow(clippy::integer_division_remainder_used)]
|
||||||
// Drain external publish requests by calling the borrowing
|
{
|
||||||
// handle — `&mut sequencer` is only available here.
|
tokio::select! {
|
||||||
Some(data) = publish_rx.recv() => {
|
// Drain external publish requests by calling the
|
||||||
if let Err(e) = sequencer.handle().publish(data) {
|
// borrowing handle — `&mut sequencer` is only
|
||||||
warn!("zone-sdk publish failed: {e:?}");
|
// available here.
|
||||||
|
Some(data) = publish_rx.recv() => {
|
||||||
|
if let Err(e) = sequencer.handle().publish(data) {
|
||||||
|
warn!("zone-sdk publish failed: {e:?}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
event = sequencer.next_event() => {
|
||||||
event = sequencer.next_event() => {
|
let Some(event) = event else { continue };
|
||||||
let Some(event) = event else { continue };
|
match event {
|
||||||
match event {
|
Event::BlocksProcessed {
|
||||||
Event::BlocksProcessed {
|
checkpoint,
|
||||||
checkpoint,
|
channel_update: _,
|
||||||
channel_update: _,
|
finalized,
|
||||||
finalized,
|
} => {
|
||||||
} => {
|
on_checkpoint(checkpoint);
|
||||||
on_checkpoint(checkpoint);
|
for op in finalized.into_iter().flat_map(|item| item.ops) {
|
||||||
for op in finalized.into_iter().flat_map(|item| item.ops) {
|
match op {
|
||||||
match op {
|
FinalizedOp::Inscription(inscription) => {
|
||||||
FinalizedOp::Inscription(inscription) => {
|
if let Some(block_id) =
|
||||||
if let Some(block_id) =
|
block_id_from_inscription(&inscription)
|
||||||
block_id_from_inscription(&inscription)
|
{
|
||||||
{
|
on_finalized_block(block_id);
|
||||||
on_finalized_block(block_id);
|
}
|
||||||
}
|
}
|
||||||
|
FinalizedOp::Deposit(deposit) => {
|
||||||
|
on_deposit_event(deposit).await;
|
||||||
|
}
|
||||||
|
FinalizedOp::Withdraw(_) => {}
|
||||||
}
|
}
|
||||||
FinalizedOp::Deposit(deposit) => {
|
|
||||||
on_deposit_event(deposit).await;
|
|
||||||
}
|
|
||||||
FinalizedOp::Withdraw(_) => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Event::Ready | Event::TurnNotification { .. } => {}
|
||||||
}
|
}
|
||||||
Event::Ready | Event::TurnNotification { .. } => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -173,7 +177,7 @@ impl BlockPublisherTrait for ZoneSdkPublisher {
|
|||||||
self.publish_tx
|
self.publish_tx
|
||||||
.send(data_bounded)
|
.send(data_bounded)
|
||||||
.await
|
.await
|
||||||
.map_err(|_| anyhow!("Drive task is no longer running"))?;
|
.map_err(|_closed| anyhow!("Drive task is no longer running"))?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user