Skip to content

Commit 18922b2

Browse files
authored
Add missing Debug impls (#268)
1 parent de8f17a commit 18922b2

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
@@ -121,7 +121,7 @@ impl IntoScannerResult<RangeInclusive<BlockNumber>> for RangeInclusive<BlockNumb
121121
}
122122
}
123123

124-
#[derive(Clone)]
124+
#[derive(Clone, Debug)]
125125
pub struct BlockRangeScanner {
126126
pub max_block_range: u64,
127127
pub past_blocks_storage_capacity: RingBufferCapacity,
@@ -175,6 +175,7 @@ impl BlockRangeScanner {
175175
}
176176
}
177177

178+
#[derive(Debug)]
178179
pub struct ConnectedBlockRangeScanner<N: Network> {
179180
provider: RobustProvider<N>,
180181
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
@@ -14,7 +14,7 @@ use crate::{
1414

1515
use super::ring_buffer::RingBuffer;
1616

17-
#[derive(Clone)]
17+
#[derive(Clone, Debug)]
1818
pub(crate) struct ReorgHandler<N: Network = Ethereum> {
1919
provider: RobustProvider<N>,
2020
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
@@ -12,13 +12,15 @@ use crate::{
1212
};
1313

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

23+
#[derive(Debug)]
2224
pub(crate) struct SyncHandler<N: Network> {
2325
provider: RobustProvider<N>,
2426
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)