mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-29 17:18:08 -05:00
small refac in rpc crate (#6264)
This commit is contained in:
@@ -21,11 +21,6 @@ use reth_primitives::{
|
||||
use reth_provider::{
|
||||
BlockReaderIdExt, ChainSpecProvider, HeaderProvider, StateProviderBox, TransactionVariant,
|
||||
};
|
||||
use revm_inspectors::tracing::{
|
||||
js::{JsInspector, TransactionContext},
|
||||
FourByteInspector, TracingInspector, TracingInspectorConfig,
|
||||
};
|
||||
|
||||
use reth_revm::database::{StateProviderDatabase, SubState};
|
||||
use reth_rpc_api::DebugApiServer;
|
||||
use reth_rpc_types::{
|
||||
@@ -36,7 +31,10 @@ use reth_rpc_types::{
|
||||
BlockError, Bundle, CallRequest, RichBlock, StateContext,
|
||||
};
|
||||
use revm::{db::CacheDB, primitives::Env};
|
||||
|
||||
use revm_inspectors::tracing::{
|
||||
js::{JsInspector, TransactionContext},
|
||||
FourByteInspector, TracingInspector, TracingInspectorConfig,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::{AcquireError, OwnedSemaphorePermit};
|
||||
|
||||
@@ -640,18 +638,19 @@ where
|
||||
|
||||
/// Handler for `debug_getRawReceipts`
|
||||
async fn raw_receipts(&self, block_id: BlockId) -> RpcResult<Vec<Bytes>> {
|
||||
let receipts =
|
||||
self.inner.provider.receipts_by_block_id(block_id).to_rpc_result()?.unwrap_or_default();
|
||||
let mut all_receipts = Vec::with_capacity(receipts.len());
|
||||
|
||||
for receipt in receipts {
|
||||
let mut buf = Vec::new();
|
||||
let receipt = receipt.with_bloom();
|
||||
receipt.encode(&mut buf);
|
||||
all_receipts.push(buf.into());
|
||||
}
|
||||
|
||||
Ok(all_receipts)
|
||||
Ok(self
|
||||
.inner
|
||||
.provider
|
||||
.receipts_by_block_id(block_id)
|
||||
.to_rpc_result()?
|
||||
.unwrap_or_default()
|
||||
.into_iter()
|
||||
.map(|receipt| {
|
||||
let mut buf = Vec::new();
|
||||
receipt.with_bloom().encode(&mut buf);
|
||||
Bytes::from(buf)
|
||||
})
|
||||
.collect())
|
||||
}
|
||||
|
||||
/// Handler for `debug_getBadBlocks`
|
||||
|
||||
@@ -36,11 +36,10 @@ where
|
||||
tx: &T,
|
||||
content: &mut BTreeMap<Address, BTreeMap<String, Transaction>>,
|
||||
) {
|
||||
let entry = content.entry(tx.sender()).or_default();
|
||||
let key = tx.nonce().to_string();
|
||||
let tx = tx.to_recovered_transaction();
|
||||
let tx = reth_rpc_types_compat::transaction::from_recovered(tx);
|
||||
entry.insert(key, tx);
|
||||
content.entry(tx.sender()).or_default().insert(
|
||||
tx.nonce().to_string(),
|
||||
reth_rpc_types_compat::transaction::from_recovered(tx.to_recovered_transaction()),
|
||||
);
|
||||
}
|
||||
|
||||
let AllPoolTransactions { pending, queued } = self.pool.all_transactions();
|
||||
@@ -93,17 +92,15 @@ where
|
||||
let entry = inspect.entry(tx.sender()).or_default();
|
||||
let key = tx.nonce().to_string();
|
||||
let tx = tx.to_recovered_transaction();
|
||||
let to = tx.to();
|
||||
let gas_price = tx.transaction.max_fee_per_gas();
|
||||
let value = tx.value();
|
||||
let gas = tx.gas_limit();
|
||||
let summary = TxpoolInspectSummary {
|
||||
to,
|
||||
value: value.into(),
|
||||
gas: U256::from(gas),
|
||||
gas_price: U256::from(gas_price),
|
||||
};
|
||||
entry.insert(key, summary);
|
||||
entry.insert(
|
||||
key,
|
||||
TxpoolInspectSummary {
|
||||
to: tx.to(),
|
||||
value: tx.value().into(),
|
||||
gas: U256::from(tx.gas_limit()),
|
||||
gas_price: U256::from(tx.transaction.max_fee_per_gas()),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
let mut inspect = TxpoolInspect::default();
|
||||
|
||||
Reference in New Issue
Block a user