Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): alloy 0.10 #40

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ rustdoc-args = ["--cfg", "docsrs"]

[dependencies]
alloy-primitives = { version = "0.8.5", features = ["map"] }

alloy-consensus = { version = "0.9", default-features = false }
alloy-provider = { version = "0.9", default-features = false }
alloy-rpc-types = { version = "0.9", features = ["eth"] }
alloy-serde = { version = "0.9", default-features = false }
alloy-transport = { version = "0.9", default-features = false }
alloy-consensus = { version = "0.9", default-features = false }

eyre = "0.6"
futures = "0.3"
Expand All @@ -53,5 +53,13 @@ url = "2"

[dev-dependencies]
alloy-rpc-client = "0.9"
alloy-transport-http = "0.9"
tiny_http = "0.12"

[patch.crates-io]
alloy-consensus = { git = "https://github.com/alloy-rs/alloy", branch = "dani/rm-T-transport" }
alloy-provider = { git = "https://github.com/alloy-rs/alloy", branch = "dani/rm-T-transport" }
alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", branch = "dani/rm-T-transport" }
alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", branch = "dani/rm-T-transport" }
alloy-serde = { git = "https://github.com/alloy-rs/alloy", branch = "dani/rm-T-transport" }
alloy-transport = { git = "https://github.com/alloy-rs/alloy", branch = "dani/rm-T-transport" }
alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", branch = "dani/rm-T-transport" }
40 changes: 13 additions & 27 deletions src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use alloy_provider::{
};
use alloy_rpc_types::{BlockId, Transaction};
use alloy_serde::WithOtherFields;
use alloy_transport::Transport;
use eyre::WrapErr;
use futures::{
channel::mpsc::{unbounded, UnboundedReceiver, UnboundedSender},
Expand All @@ -30,7 +29,6 @@ use std::{
collections::VecDeque,
fmt,
future::IntoFuture,
marker::PhantomData,
path::Path,
pin::Pin,
sync::{
Expand Down Expand Up @@ -146,9 +144,8 @@ enum BackendRequest {
/// This handler will remain active as long as it is reachable (request channel still open) and
/// requests are in progress.
#[must_use = "futures do nothing unless polled"]
pub struct BackendHandler<T, P> {
pub struct BackendHandler<P> {
provider: P,
transport: PhantomData<T>,
/// Stores all the data.
db: BlockchainDb,
/// Requests currently in progress
Expand All @@ -168,10 +165,9 @@ pub struct BackendHandler<T, P> {
block_id: Option<BlockId>,
}

impl<T, P> BackendHandler<T, P>
impl<P> BackendHandler<P>
where
T: Transport + Clone,
P: Provider<T, AnyNetwork> + Clone + Unpin + 'static,
P: Provider<AnyNetwork> + Clone + Unpin + 'static,
{
fn new(
provider: P,
Expand All @@ -189,7 +185,6 @@ where
queued_requests: Default::default(),
incoming: rx,
block_id,
transport: PhantomData,
}
}

Expand Down Expand Up @@ -382,10 +377,9 @@ where
}
}

impl<T, P> Future for BackendHandler<T, P>
impl<P> Future for BackendHandler<P>
where
T: Transport + Clone + Unpin,
P: Provider<T, AnyNetwork> + Clone + Unpin + 'static,
P: Provider<AnyNetwork> + Clone + Unpin + 'static,
{
type Output = ();

Expand Down Expand Up @@ -648,14 +642,9 @@ impl SharedBackend {
/// dropped.
///
/// NOTE: this should be called with `Arc<Provider>`
pub async fn spawn_backend<T, P>(
provider: P,
db: BlockchainDb,
pin_block: Option<BlockId>,
) -> Self
pub async fn spawn_backend<P>(provider: P, db: BlockchainDb, pin_block: Option<BlockId>) -> Self
where
T: Transport + Clone + Unpin,
P: Provider<T, AnyNetwork> + Unpin + 'static + Clone,
P: Provider<AnyNetwork> + Unpin + 'static + Clone,
{
let (shared, handler) = Self::new(provider, db, pin_block);
// spawn the provider handler to a task
Expand All @@ -666,14 +655,13 @@ impl SharedBackend {

/// Same as `Self::spawn_backend` but spawns the `BackendHandler` on a separate `std::thread` in
/// its own `tokio::Runtime`
pub fn spawn_backend_thread<T, P>(
pub fn spawn_backend_thread<P>(
provider: P,
db: BlockchainDb,
pin_block: Option<BlockId>,
) -> Self
where
T: Transport + Clone + Unpin,
P: Provider<T, AnyNetwork> + Unpin + 'static + Clone,
P: Provider<AnyNetwork> + Unpin + 'static + Clone,
{
let (shared, handler) = Self::new(provider, db, pin_block);

Expand All @@ -696,14 +684,13 @@ impl SharedBackend {
}

/// Returns a new `SharedBackend` and the `BackendHandler`
pub fn new<T, P>(
pub fn new<P>(
provider: P,
db: BlockchainDb,
pin_block: Option<BlockId>,
) -> (Self, BackendHandler<T, P>)
) -> (Self, BackendHandler<P>)
where
T: Transport + Clone + Unpin,
P: Provider<T, AnyNetwork> + Unpin + 'static + Clone,
P: Provider<AnyNetwork> + Unpin + 'static + Clone,
{
let (backend, backend_rx) = unbounded();
let cache = Arc::new(FlushJsonBlockCacheDB(Arc::clone(db.cache())));
Expand Down Expand Up @@ -918,12 +905,11 @@ mod tests {
use crate::cache::{BlockchainDbMeta, JsonBlockCacheDB};
use alloy_provider::{ProviderBuilder, RootProvider};
use alloy_rpc_client::ClientBuilder;
use alloy_transport_http::{Client, Http};
use serde::Deserialize;
use std::{collections::BTreeSet, fs, path::PathBuf};
use tiny_http::{Response, Server};

pub fn get_http_provider(endpoint: &str) -> RootProvider<Http<Client>, AnyNetwork> {
pub fn get_http_provider(endpoint: &str) -> RootProvider<AnyNetwork> {
ProviderBuilder::new()
.network::<AnyNetwork>()
.on_client(ClientBuilder::default().http(endpoint.parse().unwrap()))
Expand Down
Loading