Skip to content

Commit e0bc705

Browse files
authored
chain/ethereum: Optimize parallel receipt fetching
Remove unnecessary cloning and calls to `.clone()`. Value is still being (cheaply) copied, but removing explicit `.clone()` calls helps with performance audits.
1 parent 7d021ea commit e0bc705

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

chain/ethereum/src/ethereum_adapter.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,13 +1080,7 @@ impl EthereumAdapterTrait for EthereumAdapter {
10801080
transaction_receipts: Vec::new(),
10811081
})));
10821082
}
1083-
1084-
let hashes: Vec<_> = block
1085-
.transactions
1086-
.iter()
1087-
.map(|txn| txn.hash.clone())
1088-
.collect();
1089-
1083+
let hashes: Vec<_> = block.transactions.iter().map(|txn| txn.hash).collect();
10901084
let receipts_future = if *FETCH_RECEIPTS_CONCURRENTLY {
10911085
let hash_stream = graph::tokio_stream::iter(hashes);
10921086
let receipt_stream = graph::tokio_stream::StreamExt::map(hash_stream, move |tx_hash| {
@@ -1842,13 +1836,12 @@ async fn fetch_transaction_receipts_in_batch(
18421836
logger: Logger,
18431837
) -> Result<Vec<TransactionReceipt>, IngestorError> {
18441838
let batching_web3 = Web3::new(Batch::new(web3.transport().clone()));
1839+
let eth = batching_web3.eth();
18451840
let receipt_futures = hashes
18461841
.into_iter()
1847-
.map(|hash| {
1842+
.map(move |hash| {
18481843
let logger = logger.cheap_clone();
1849-
batching_web3
1850-
.eth()
1851-
.transaction_receipt(hash.clone())
1844+
eth.transaction_receipt(hash)
18521845
.map_err(|web3_error| IngestorError::from(web3_error))
18531846
.and_then(move |some_receipt| async move {
18541847
resolve_transaction_receipt(some_receipt, hash, block_hash, logger)

0 commit comments

Comments
 (0)