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: rm passthrough txcount request #1970

Merged
merged 1 commit into from
Jan 30, 2025
Merged
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
38 changes: 2 additions & 36 deletions crates/provider/src/layers/cache.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
use crate::{
utils, ParamsWithBlock, Provider, ProviderCall, ProviderLayer, RootProvider, RpcWithBlock,
};
use crate::{ParamsWithBlock, Provider, ProviderCall, ProviderLayer, RootProvider, RpcWithBlock};
use alloy_eips::BlockId;
use alloy_json_rpc::{RpcError, RpcObject, RpcSend};
use alloy_network::Network;
use alloy_primitives::{
keccak256, Address, BlockHash, Bytes, StorageKey, StorageValue, TxHash, B256, U256, U64,
keccak256, Address, BlockHash, Bytes, StorageKey, StorageValue, TxHash, B256, U256,
};
use alloy_rpc_types_eth::{
BlockNumberOrTag, BlockTransactionsKind, EIP1186AccountProofResponse, Filter, Log,
@@ -336,38 +334,6 @@ where
}))
}

fn get_transaction_count(&self, address: Address) -> RpcWithBlock<Address, U64, u64> {
let client = self.inner.weak_client();
let cache = self.cache.clone();
RpcWithBlock::new_provider(move |block_id| {
let req = RequestType::new("eth_getTransactionCount", address).with_block_id(block_id);

let client = client
.upgrade()
.ok_or_else(|| TransportErrorKind::custom_str("RPC client dropped"));
let cache = cache.clone();
ProviderCall::BoxedFuture(Box::pin(async move {
let client = client?;

let result = client
.request(req.method(), req.params())
.map_resp(utils::convert_u64 as fn(U64) -> u64)
.map_params(|params| ParamsWithBlock {
params,
block_id: req.block_id.unwrap_or(BlockId::latest()),
});

let res = result.await?;
// Insert into cache.
let json_str = serde_json::to_string(&res).map_err(TransportErrorKind::custom)?;
let hash = req.params_hash()?;
let _ = cache.put(hash, json_str);

Ok(res)
}))
})
}

fn get_transaction_receipt(
&self,
hash: TxHash,