@@ -11,7 +11,6 @@ use alloy_provider::{
11
11
} ;
12
12
use alloy_rpc_types:: { BlockId , Transaction } ;
13
13
use alloy_serde:: WithOtherFields ;
14
- use alloy_transport:: Transport ;
15
14
use eyre:: WrapErr ;
16
15
use futures:: {
17
16
channel:: mpsc:: { unbounded, UnboundedReceiver , UnboundedSender } ,
@@ -30,7 +29,6 @@ use std::{
30
29
collections:: VecDeque ,
31
30
fmt,
32
31
future:: IntoFuture ,
33
- marker:: PhantomData ,
34
32
path:: Path ,
35
33
pin:: Pin ,
36
34
sync:: {
@@ -146,9 +144,8 @@ enum BackendRequest {
146
144
/// This handler will remain active as long as it is reachable (request channel still open) and
147
145
/// requests are in progress.
148
146
#[ must_use = "futures do nothing unless polled" ]
149
- pub struct BackendHandler < T , P > {
147
+ pub struct BackendHandler < P > {
150
148
provider : P ,
151
- transport : PhantomData < T > ,
152
149
/// Stores all the data.
153
150
db : BlockchainDb ,
154
151
/// Requests currently in progress
@@ -168,10 +165,9 @@ pub struct BackendHandler<T, P> {
168
165
block_id : Option < BlockId > ,
169
166
}
170
167
171
- impl < T , P > BackendHandler < T , P >
168
+ impl < P > BackendHandler < P >
172
169
where
173
- T : Transport + Clone ,
174
- P : Provider < T , AnyNetwork > + Clone + Unpin + ' static ,
170
+ P : Provider < AnyNetwork > + Clone + Unpin + ' static ,
175
171
{
176
172
fn new (
177
173
provider : P ,
@@ -189,7 +185,6 @@ where
189
185
queued_requests : Default :: default ( ) ,
190
186
incoming : rx,
191
187
block_id,
192
- transport : PhantomData ,
193
188
}
194
189
}
195
190
@@ -382,10 +377,9 @@ where
382
377
}
383
378
}
384
379
385
- impl < T , P > Future for BackendHandler < T , P >
380
+ impl < P > Future for BackendHandler < P >
386
381
where
387
- T : Transport + Clone + Unpin ,
388
- P : Provider < T , AnyNetwork > + Clone + Unpin + ' static ,
382
+ P : Provider < AnyNetwork > + Clone + Unpin + ' static ,
389
383
{
390
384
type Output = ( ) ;
391
385
@@ -648,14 +642,9 @@ impl SharedBackend {
648
642
/// dropped.
649
643
///
650
644
/// NOTE: this should be called with `Arc<Provider>`
651
- pub async fn spawn_backend < T , P > (
652
- provider : P ,
653
- db : BlockchainDb ,
654
- pin_block : Option < BlockId > ,
655
- ) -> Self
645
+ pub async fn spawn_backend < P > ( provider : P , db : BlockchainDb , pin_block : Option < BlockId > ) -> Self
656
646
where
657
- T : Transport + Clone + Unpin ,
658
- P : Provider < T , AnyNetwork > + Unpin + ' static + Clone ,
647
+ P : Provider < AnyNetwork > + Unpin + ' static + Clone ,
659
648
{
660
649
let ( shared, handler) = Self :: new ( provider, db, pin_block) ;
661
650
// spawn the provider handler to a task
@@ -666,14 +655,13 @@ impl SharedBackend {
666
655
667
656
/// Same as `Self::spawn_backend` but spawns the `BackendHandler` on a separate `std::thread` in
668
657
/// its own `tokio::Runtime`
669
- pub fn spawn_backend_thread < T , P > (
658
+ pub fn spawn_backend_thread < P > (
670
659
provider : P ,
671
660
db : BlockchainDb ,
672
661
pin_block : Option < BlockId > ,
673
662
) -> Self
674
663
where
675
- T : Transport + Clone + Unpin ,
676
- P : Provider < T , AnyNetwork > + Unpin + ' static + Clone ,
664
+ P : Provider < AnyNetwork > + Unpin + ' static + Clone ,
677
665
{
678
666
let ( shared, handler) = Self :: new ( provider, db, pin_block) ;
679
667
@@ -696,14 +684,13 @@ impl SharedBackend {
696
684
}
697
685
698
686
/// Returns a new `SharedBackend` and the `BackendHandler`
699
- pub fn new < T , P > (
687
+ pub fn new < P > (
700
688
provider : P ,
701
689
db : BlockchainDb ,
702
690
pin_block : Option < BlockId > ,
703
- ) -> ( Self , BackendHandler < T , P > )
691
+ ) -> ( Self , BackendHandler < P > )
704
692
where
705
- T : Transport + Clone + Unpin ,
706
- P : Provider < T , AnyNetwork > + Unpin + ' static + Clone ,
693
+ P : Provider < AnyNetwork > + Unpin + ' static + Clone ,
707
694
{
708
695
let ( backend, backend_rx) = unbounded ( ) ;
709
696
let cache = Arc :: new ( FlushJsonBlockCacheDB ( Arc :: clone ( db. cache ( ) ) ) ) ;
@@ -916,14 +903,13 @@ impl DatabaseRef for SharedBackend {
916
903
mod tests {
917
904
use super :: * ;
918
905
use crate :: cache:: { BlockchainDbMeta , JsonBlockCacheDB } ;
919
- use alloy_provider:: { ProviderBuilder , RootProvider } ;
906
+ use alloy_provider:: ProviderBuilder ;
920
907
use alloy_rpc_client:: ClientBuilder ;
921
- use alloy_transport_http:: { Client , Http } ;
922
908
use serde:: Deserialize ;
923
909
use std:: { collections:: BTreeSet , fs, path:: PathBuf } ;
924
910
use tiny_http:: { Response , Server } ;
925
911
926
- pub fn get_http_provider ( endpoint : & str ) -> RootProvider < Http < Client > , AnyNetwork > {
912
+ pub fn get_http_provider ( endpoint : & str ) -> impl Provider < AnyNetwork > + Clone {
927
913
ProviderBuilder :: new ( )
928
914
. network :: < AnyNetwork > ( )
929
915
. on_client ( ClientBuilder :: default ( ) . http ( endpoint. parse ( ) . unwrap ( ) ) )
0 commit comments