Skip to content

Commit 69ca083

Browse files
authored
chore: bump alloy 0.11 (#41)
* chore: bump alloy 0.11 * rustfmt
1 parent 029852a commit 69ca083

File tree

2 files changed

+19
-35
lines changed

2 files changed

+19
-35
lines changed

Cargo.toml

+5-7
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,10 @@ rustdoc-args = ["--cfg", "docsrs"]
2626

2727
[dependencies]
2828
alloy-primitives = { version = "0.8.5", features = ["map"] }
29-
alloy-provider = { version = "0.9", default-features = false }
30-
alloy-rpc-types = { version = "0.9", features = ["eth"] }
31-
alloy-serde = { version = "0.9", default-features = false }
32-
alloy-transport = { version = "0.9", default-features = false }
33-
alloy-consensus = { version = "0.9", default-features = false }
29+
alloy-provider = { version = "0.11", default-features = false }
30+
alloy-rpc-types = { version = "0.11", features = ["eth"] }
31+
alloy-serde = { version = "0.11", default-features = false }
32+
alloy-consensus = { version = "0.11", default-features = false }
3433

3534
eyre = "0.6"
3635
futures = "0.3"
@@ -52,6 +51,5 @@ tracing = "0.1"
5251
url = "2"
5352

5453
[dev-dependencies]
55-
alloy-rpc-client = "0.9"
56-
alloy-transport-http = "0.9"
54+
alloy-rpc-client = "0.11"
5755
tiny_http = "0.12"

src/backend.rs

+14-28
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use alloy_provider::{
1111
};
1212
use alloy_rpc_types::{BlockId, Transaction};
1313
use alloy_serde::WithOtherFields;
14-
use alloy_transport::Transport;
1514
use eyre::WrapErr;
1615
use futures::{
1716
channel::mpsc::{unbounded, UnboundedReceiver, UnboundedSender},
@@ -30,7 +29,6 @@ use std::{
3029
collections::VecDeque,
3130
fmt,
3231
future::IntoFuture,
33-
marker::PhantomData,
3432
path::Path,
3533
pin::Pin,
3634
sync::{
@@ -146,9 +144,8 @@ enum BackendRequest {
146144
/// This handler will remain active as long as it is reachable (request channel still open) and
147145
/// requests are in progress.
148146
#[must_use = "futures do nothing unless polled"]
149-
pub struct BackendHandler<T, P> {
147+
pub struct BackendHandler<P> {
150148
provider: P,
151-
transport: PhantomData<T>,
152149
/// Stores all the data.
153150
db: BlockchainDb,
154151
/// Requests currently in progress
@@ -168,10 +165,9 @@ pub struct BackendHandler<T, P> {
168165
block_id: Option<BlockId>,
169166
}
170167

171-
impl<T, P> BackendHandler<T, P>
168+
impl<P> BackendHandler<P>
172169
where
173-
T: Transport + Clone,
174-
P: Provider<T, AnyNetwork> + Clone + Unpin + 'static,
170+
P: Provider<AnyNetwork> + Clone + Unpin + 'static,
175171
{
176172
fn new(
177173
provider: P,
@@ -189,7 +185,6 @@ where
189185
queued_requests: Default::default(),
190186
incoming: rx,
191187
block_id,
192-
transport: PhantomData,
193188
}
194189
}
195190

@@ -382,10 +377,9 @@ where
382377
}
383378
}
384379

385-
impl<T, P> Future for BackendHandler<T, P>
380+
impl<P> Future for BackendHandler<P>
386381
where
387-
T: Transport + Clone + Unpin,
388-
P: Provider<T, AnyNetwork> + Clone + Unpin + 'static,
382+
P: Provider<AnyNetwork> + Clone + Unpin + 'static,
389383
{
390384
type Output = ();
391385

@@ -648,14 +642,9 @@ impl SharedBackend {
648642
/// dropped.
649643
///
650644
/// 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
656646
where
657-
T: Transport + Clone + Unpin,
658-
P: Provider<T, AnyNetwork> + Unpin + 'static + Clone,
647+
P: Provider<AnyNetwork> + Unpin + 'static + Clone,
659648
{
660649
let (shared, handler) = Self::new(provider, db, pin_block);
661650
// spawn the provider handler to a task
@@ -666,14 +655,13 @@ impl SharedBackend {
666655

667656
/// Same as `Self::spawn_backend` but spawns the `BackendHandler` on a separate `std::thread` in
668657
/// its own `tokio::Runtime`
669-
pub fn spawn_backend_thread<T, P>(
658+
pub fn spawn_backend_thread<P>(
670659
provider: P,
671660
db: BlockchainDb,
672661
pin_block: Option<BlockId>,
673662
) -> Self
674663
where
675-
T: Transport + Clone + Unpin,
676-
P: Provider<T, AnyNetwork> + Unpin + 'static + Clone,
664+
P: Provider<AnyNetwork> + Unpin + 'static + Clone,
677665
{
678666
let (shared, handler) = Self::new(provider, db, pin_block);
679667

@@ -696,14 +684,13 @@ impl SharedBackend {
696684
}
697685

698686
/// Returns a new `SharedBackend` and the `BackendHandler`
699-
pub fn new<T, P>(
687+
pub fn new<P>(
700688
provider: P,
701689
db: BlockchainDb,
702690
pin_block: Option<BlockId>,
703-
) -> (Self, BackendHandler<T, P>)
691+
) -> (Self, BackendHandler<P>)
704692
where
705-
T: Transport + Clone + Unpin,
706-
P: Provider<T, AnyNetwork> + Unpin + 'static + Clone,
693+
P: Provider<AnyNetwork> + Unpin + 'static + Clone,
707694
{
708695
let (backend, backend_rx) = unbounded();
709696
let cache = Arc::new(FlushJsonBlockCacheDB(Arc::clone(db.cache())));
@@ -916,14 +903,13 @@ impl DatabaseRef for SharedBackend {
916903
mod tests {
917904
use super::*;
918905
use crate::cache::{BlockchainDbMeta, JsonBlockCacheDB};
919-
use alloy_provider::{ProviderBuilder, RootProvider};
906+
use alloy_provider::ProviderBuilder;
920907
use alloy_rpc_client::ClientBuilder;
921-
use alloy_transport_http::{Client, Http};
922908
use serde::Deserialize;
923909
use std::{collections::BTreeSet, fs, path::PathBuf};
924910
use tiny_http::{Response, Server};
925911

926-
pub fn get_http_provider(endpoint: &str) -> RootProvider<Http<Client>, AnyNetwork> {
912+
pub fn get_http_provider(endpoint: &str) -> impl Provider<AnyNetwork> + Clone {
927913
ProviderBuilder::new()
928914
.network::<AnyNetwork>()
929915
.on_client(ClientBuilder::default().http(endpoint.parse().unwrap()))

0 commit comments

Comments
 (0)