mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
chore: use BlockId functions directly (#8417)
This commit is contained in:
@ -45,7 +45,7 @@ where
|
|||||||
address: Address,
|
address: Address,
|
||||||
block_id: Option<BlockId>,
|
block_id: Option<BlockId>,
|
||||||
) -> EthResult<U256> {
|
) -> EthResult<U256> {
|
||||||
if block_id == Some(BlockId::Number(BlockNumberOrTag::Pending)) {
|
if block_id == Some(BlockId::pending()) {
|
||||||
let address_txs = self.pool().get_transactions_by_sender(address);
|
let address_txs = self.pool().get_transactions_by_sender(address);
|
||||||
if let Some(highest_nonce) =
|
if let Some(highest_nonce) =
|
||||||
address_txs.iter().map(|item| item.transaction.nonce()).max()
|
address_txs.iter().map(|item| item.transaction.nonce()).max()
|
||||||
|
|||||||
@ -787,9 +787,7 @@ where
|
|||||||
None => return Ok(None),
|
None => return Ok(None),
|
||||||
Some(tx) => {
|
Some(tx) => {
|
||||||
let res = match tx {
|
let res = match tx {
|
||||||
tx @ TransactionSource::Pool(_) => {
|
tx @ TransactionSource::Pool(_) => (tx, BlockId::pending()),
|
||||||
(tx, BlockId::Number(BlockNumberOrTag::Pending))
|
|
||||||
}
|
|
||||||
TransactionSource::Block {
|
TransactionSource::Block {
|
||||||
transaction,
|
transaction,
|
||||||
index,
|
index,
|
||||||
@ -873,17 +871,14 @@ where
|
|||||||
|
|
||||||
// set nonce if not already set before
|
// set nonce if not already set before
|
||||||
if request.nonce.is_none() {
|
if request.nonce.is_none() {
|
||||||
let nonce =
|
let nonce = self.get_transaction_count(from, Some(BlockId::pending()))?;
|
||||||
self.get_transaction_count(from, Some(BlockId::Number(BlockNumberOrTag::Pending)))?;
|
|
||||||
// note: `.to()` can't panic because the nonce is constructed from a `u64`
|
// note: `.to()` can't panic because the nonce is constructed from a `u64`
|
||||||
request.nonce = Some(nonce.to::<u64>());
|
request.nonce = Some(nonce.to::<u64>());
|
||||||
}
|
}
|
||||||
|
|
||||||
let chain_id = self.chain_id();
|
let chain_id = self.chain_id();
|
||||||
|
|
||||||
let estimated_gas = self
|
let estimated_gas = self.estimate_gas_at(request.clone(), BlockId::pending(), None).await?;
|
||||||
.estimate_gas_at(request.clone(), BlockId::Number(BlockNumberOrTag::Pending), None)
|
|
||||||
.await?;
|
|
||||||
let gas_limit = estimated_gas;
|
let gas_limit = estimated_gas;
|
||||||
|
|
||||||
let TransactionRequest {
|
let TransactionRequest {
|
||||||
|
|||||||
@ -7,9 +7,7 @@ use crate::eth::{
|
|||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use jsonrpsee::core::RpcResult as Result;
|
use jsonrpsee::core::RpcResult as Result;
|
||||||
use reth_consensus_common::calc::{base_block_reward, block_reward};
|
use reth_consensus_common::calc::{base_block_reward, block_reward};
|
||||||
use reth_primitives::{
|
use reth_primitives::{revm::env::tx_env_with_recovered, BlockId, Bytes, SealedHeader, B256, U256};
|
||||||
revm::env::tx_env_with_recovered, BlockId, BlockNumberOrTag, Bytes, SealedHeader, B256, U256,
|
|
||||||
};
|
|
||||||
use reth_provider::{BlockReader, ChainSpecProvider, EvmEnvProvider, StateProviderFactory};
|
use reth_provider::{BlockReader, ChainSpecProvider, EvmEnvProvider, StateProviderFactory};
|
||||||
use reth_revm::database::StateProviderDatabase;
|
use reth_revm::database::StateProviderDatabase;
|
||||||
use reth_rpc_api::TraceApiServer;
|
use reth_rpc_api::TraceApiServer;
|
||||||
@ -133,7 +131,7 @@ where
|
|||||||
calls: Vec<(TransactionRequest, HashSet<TraceType>)>,
|
calls: Vec<(TransactionRequest, HashSet<TraceType>)>,
|
||||||
block_id: Option<BlockId>,
|
block_id: Option<BlockId>,
|
||||||
) -> EthResult<Vec<TraceResults>> {
|
) -> EthResult<Vec<TraceResults>> {
|
||||||
let at = block_id.unwrap_or(BlockId::Number(BlockNumberOrTag::Pending));
|
let at = block_id.unwrap_or(BlockId::pending());
|
||||||
let (cfg, block_env, at) = self.inner.eth_api.evm_env_at(at).await?;
|
let (cfg, block_env, at) = self.inner.eth_api.evm_env_at(at).await?;
|
||||||
|
|
||||||
let gas_limit = self.inner.eth_api.call_gas_limit();
|
let gas_limit = self.inner.eth_api.call_gas_limit();
|
||||||
|
|||||||
Reference in New Issue
Block a user