Skip to content

Commit 5ccbc34

Browse files
authored
Merge branch 'main' into tracing-fixes
2 parents 67acfdb + 18922b2 commit 5ccbc34

File tree

7 files changed

+39
-8
lines changed

7 files changed

+39
-8
lines changed

src/block_range_scanner.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ impl IntoScannerResult<RangeInclusive<BlockNumber>> for RangeInclusive<BlockNumb
120120
}
121121
}
122122

123-
#[derive(Clone)]
123+
#[derive(Clone, Debug)]
124124
pub struct BlockRangeScanner {
125125
pub max_block_range: u64,
126126
pub past_blocks_storage_capacity: RingBufferCapacity,
@@ -174,6 +174,7 @@ impl BlockRangeScanner {
174174
}
175175
}
176176

177+
#[derive(Debug)]
177178
pub struct ConnectedBlockRangeScanner<N: Network> {
178179
provider: RobustProvider<N>,
179180
max_block_range: u64,

src/block_range_scanner/reorg_handler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::{
1313

1414
use super::ring_buffer::RingBuffer;
1515

16-
#[derive(Clone)]
16+
#[derive(Clone, Debug)]
1717
pub(crate) struct ReorgHandler<N: Network = Ethereum> {
1818
provider: RobustProvider<N>,
1919
buffer: RingBuffer<BlockHash>,

src/block_range_scanner/ring_buffer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ macro_rules! impl_from_unsigned {
2020

2121
impl_from_unsigned!(RingBufferCapacity; u8, u16, u32, usize);
2222

23-
#[derive(Clone)]
23+
#[derive(Clone, Debug)]
2424
pub(crate) struct RingBuffer<T> {
2525
inner: VecDeque<T>,
2626
capacity: RingBufferCapacity,

src/block_range_scanner/sync_handler.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ use crate::{
1111
};
1212

1313
/// Represents the initial state when starting a sync operation
14+
#[derive(Debug)]
1415
enum SyncState {
1516
/// Start block is already at or beyond the confirmed tip - go straight to live
1617
AlreadyLive { start_block: BlockNumber },
1718
/// Start block is behind - need to catch up first, then go live
1819
NeedsCatchup { start_block: BlockNumber, confirmed_tip: BlockNumber },
1920
}
2021

22+
#[derive(Debug)]
2123
pub(crate) struct SyncHandler<N: Network> {
2224
provider: RobustProvider<N>,
2325
max_block_range: u64,

src/event_scanner/listener.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::event_scanner::{EventScannerResult, filter::EventFilter};
22
use tokio::sync::mpsc::Sender;
33

4-
#[derive(Clone)]
4+
#[derive(Clone, Debug)]
55
pub(crate) struct EventListener {
66
pub filter: EventFilter,
77
pub sender: Sender<EventScannerResult>,

src/event_scanner/scanner/mod.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,34 +24,39 @@ mod sync;
2424
/// Default number of maximum concurrent fetches for each scanner mode.
2525
pub const DEFAULT_MAX_CONCURRENT_FETCHES: usize = 24;
2626

27-
#[derive(Default)]
27+
#[derive(Default, Debug)]
2828
pub struct Unspecified;
29+
#[derive(Debug)]
2930
pub struct Historic {
3031
pub(crate) from_block: BlockId,
3132
pub(crate) to_block: BlockId,
3233
/// Controls how many log-fetching RPC requests can run in parallel during the scan.
3334
pub(crate) max_concurrent_fetches: usize,
3435
}
36+
#[derive(Debug)]
3537
pub struct Live {
3638
pub(crate) block_confirmations: u64,
3739
/// Controls how many log-fetching RPC requests can run in parallel during the scan.
3840
pub(crate) max_concurrent_fetches: usize,
3941
}
42+
#[derive(Debug)]
4043
pub struct LatestEvents {
4144
pub(crate) count: usize,
4245
pub(crate) from_block: BlockId,
4346
pub(crate) to_block: BlockId,
4447
/// Controls how many log-fetching RPC requests can run in parallel during the scan.
4548
pub(crate) max_concurrent_fetches: usize,
4649
}
47-
#[derive(Default)]
50+
#[derive(Default, Debug)]
4851
pub struct Synchronize;
52+
#[derive(Debug)]
4953
pub struct SyncFromLatestEvents {
5054
pub(crate) count: usize,
5155
pub(crate) block_confirmations: u64,
5256
/// Controls how many log-fetching RPC requests can run in parallel during the scan.
5357
pub(crate) max_concurrent_fetches: usize,
5458
}
59+
#[derive(Debug)]
5560
pub struct SyncFromBlock {
5661
pub(crate) from_block: BlockId,
5762
pub(crate) block_confirmations: u64,
@@ -78,13 +83,14 @@ impl Default for Live {
7883
}
7984
}
8085

86+
#[derive(Debug)]
8187
pub struct EventScanner<M = Unspecified, N: Network = Ethereum> {
8288
config: M,
8389
block_range_scanner: ConnectedBlockRangeScanner<N>,
8490
listeners: Vec<EventListener>,
8591
}
8692

87-
#[derive(Default)]
93+
#[derive(Default, Debug)]
8894
pub struct EventScannerBuilder<M> {
8995
pub(crate) config: M,
9096
pub(crate) block_range_scanner: BlockRangeScanner,

src/robust_provider/builder.rs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::{pin::Pin, time::Duration};
1+
use std::{fmt::Debug, pin::Pin, time::Duration};
22

33
use alloy::{network::Network, providers::RootProvider};
44

@@ -28,6 +28,28 @@ pub struct RobustProviderBuilder<N: Network, P: IntoRootProvider<N>> {
2828
reconnect_interval: Duration,
2929
}
3030

31+
impl<N: Network, P: IntoRootProvider<N>> Debug for RobustProviderBuilder<N, P> {
32+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
33+
struct FallbacksDebug(usize);
34+
35+
impl Debug for FallbacksDebug {
36+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
37+
write!(f, "[{} fallback provider(s)]", self.0)
38+
}
39+
}
40+
41+
f.debug_struct("RobustProviderBuilder")
42+
.field("primary_provider", &"")
43+
.field("fallback_providers", &FallbacksDebug(self.fallback_providers.len()))
44+
.field("call_timeout", &self.call_timeout)
45+
.field("subscription_timeout", &self.subscription_timeout)
46+
.field("max_retries", &self.max_retries)
47+
.field("min_delay", &self.min_delay)
48+
.field("reconnect_interval", &self.reconnect_interval)
49+
.finish()
50+
}
51+
}
52+
3153
impl<N: Network, P: IntoRootProvider<N>> RobustProviderBuilder<N, P> {
3254
/// Create a new [`RobustProvider`] with default settings.
3355
///

0 commit comments

Comments
 (0)