File tree Expand file tree Collapse file tree 2 files changed +28
-8
lines changed
Expand file tree Collapse file tree 2 files changed +28
-8
lines changed Original file line number Diff line number Diff line change @@ -252,14 +252,7 @@ impl BlockRangeScanner {
252252 ) -> TransportResult < ConnectedBlockRangeScanner < N > > {
253253 let provider =
254254 RootProvider :: < N > :: new ( ClientBuilder :: default ( ) . ws ( WsConnect :: new ( ws_url) ) . await ?) ;
255- Ok ( ConnectedBlockRangeScanner {
256- provider,
257- config : Config {
258- blocks_read_per_epoch : self . blocks_read_per_epoch ,
259- reorg_rewind_depth : self . reorg_rewind_depth ,
260- block_confirmations : self . block_confirmations ,
261- } ,
262- } )
255+ self . connect_provider ( provider)
263256 }
264257
265258 /// Connects to the provider via IPC
@@ -272,6 +265,18 @@ impl BlockRangeScanner {
272265 ipc_path : String ,
273266 ) -> TransportResult < ConnectedBlockRangeScanner < N > > {
274267 let provider = RootProvider :: < N > :: new ( ClientBuilder :: default ( ) . ipc ( ipc_path. into ( ) ) . await ?) ;
268+ self . connect_provider ( provider)
269+ }
270+
271+ /// Connects to an existing provider
272+ ///
273+ /// # Errors
274+ ///
275+ /// Returns an error if the connection fails
276+ pub fn connect_provider < N : Network > (
277+ self ,
278+ provider : RootProvider < N > ,
279+ ) -> TransportResult < ConnectedBlockRangeScanner < N > > {
275280 Ok ( ConnectedBlockRangeScanner {
276281 provider,
277282 config : Config {
Original file line number Diff line number Diff line change @@ -107,6 +107,21 @@ impl EventScanner {
107107 ConnectedEventScanner { block_range_scanner, event_listeners : Vec :: default ( ) } ;
108108 Ok ( Client { event_scanner } )
109109 }
110+
111+ /// Connects to an existing provider
112+ ///
113+ /// # Errors
114+ ///
115+ /// Returns an error if the connection fails
116+ pub fn connect_provider < N : Network > (
117+ self ,
118+ provider : RootProvider < N > ,
119+ ) -> Result < Client < N > , EventScannerError > {
120+ let block_range_scanner = self . block_range_scanner . connect_provider ( provider) ?;
121+ let event_scanner =
122+ ConnectedEventScanner { block_range_scanner, event_listeners : Vec :: default ( ) } ;
123+ Ok ( Client { event_scanner } )
124+ }
110125}
111126
112127pub struct ConnectedEventScanner < N : Network > {
You can’t perform that action at this time.
0 commit comments