Skip to content

Commit 9449e10

Browse files
authored
perf(anvil): remove block_in_place task wrappers (#2695)
1 parent 1087a8a commit 9449e10

File tree

1 file changed

+10
-17
lines changed
  • anvil/src/eth/backend/mem

1 file changed

+10
-17
lines changed

anvil/src/eth/backend/mem/mod.rs

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ impl Backend {
866866
hash: H256,
867867
) -> Result<Option<EthersBlock<TxHash>>, BlockchainError> {
868868
trace!(target: "backend", "get block by hash {:?}", hash);
869-
if let tx @ Some(_) = tokio::task::block_in_place(|| self.mined_block_by_hash(hash)) {
869+
if let tx @ Some(_) = self.mined_block_by_hash(hash) {
870870
return Ok(tx)
871871
}
872872

@@ -882,7 +882,7 @@ impl Backend {
882882
hash: H256,
883883
) -> Result<Option<EthersBlock<Transaction>>, BlockchainError> {
884884
trace!(target: "backend", "get block by hash {:?}", hash);
885-
if let tx @ Some(_) = tokio::task::block_in_place(|| self.get_full_block(hash)) {
885+
if let tx @ Some(_) = self.get_full_block(hash) {
886886
return Ok(tx)
887887
}
888888

@@ -918,7 +918,7 @@ impl Backend {
918918
number: BlockNumber,
919919
) -> Result<Option<EthersBlock<TxHash>>, BlockchainError> {
920920
trace!(target: "backend", "get block by number {:?}", number);
921-
if let tx @ Some(_) = tokio::task::block_in_place(|| self.mined_block_by_number(number)) {
921+
if let tx @ Some(_) = self.mined_block_by_number(number) {
922922
return Ok(tx)
923923
}
924924

@@ -934,7 +934,7 @@ impl Backend {
934934
number: BlockNumber,
935935
) -> Result<Option<EthersBlock<Transaction>>, BlockchainError> {
936936
trace!(target: "backend", "get block by number {:?}", number);
937-
if let tx @ Some(_) = tokio::task::block_in_place(|| self.get_full_block(number)) {
937+
if let tx @ Some(_) = self.get_full_block(number) {
938938
return Ok(tx)
939939
}
940940

@@ -1161,9 +1161,7 @@ impl Backend {
11611161

11621162
/// Returns the traces for the given transaction
11631163
pub async fn trace_transaction(&self, hash: H256) -> Result<Vec<Trace>, BlockchainError> {
1164-
if let Some(traces) =
1165-
tokio::task::block_in_place(|| self.mined_parity_trace_transaction(hash))
1166-
{
1164+
if let Some(traces) = self.mined_parity_trace_transaction(hash) {
11671165
return Ok(traces)
11681166
}
11691167

@@ -1193,8 +1191,7 @@ impl Backend {
11931191
/// Returns the traces for the given block
11941192
pub async fn trace_block(&self, block: BlockNumber) -> Result<Vec<Trace>, BlockchainError> {
11951193
let number = self.convert_block_number(Some(block));
1196-
if let Some(traces) = tokio::task::block_in_place(|| self.mined_parity_trace_block(number))
1197-
{
1194+
if let Some(traces) = self.mined_parity_trace_block(number) {
11981195
return Ok(traces)
11991196
}
12001197

@@ -1211,7 +1208,7 @@ impl Backend {
12111208
&self,
12121209
hash: H256,
12131210
) -> Result<Option<TransactionReceipt>, BlockchainError> {
1214-
if let tx @ Some(_) = tokio::task::block_in_place(|| self.mined_transaction_receipt(hash)) {
1211+
if let tx @ Some(_) = self.mined_transaction_receipt(hash) {
12151212
return Ok(tx)
12161213
}
12171214

@@ -1318,9 +1315,7 @@ impl Backend {
13181315
number: BlockNumber,
13191316
index: Index,
13201317
) -> Result<Option<Transaction>, BlockchainError> {
1321-
if let Some(hash) =
1322-
tokio::task::block_in_place(|| self.mined_block_by_number(number).and_then(|b| b.hash))
1323-
{
1318+
if let Some(hash) = self.mined_block_by_number(number).and_then(|b| b.hash) {
13241319
return Ok(self.mined_transaction_by_block_hash_and_index(hash, index))
13251320
}
13261321

@@ -1339,9 +1334,7 @@ impl Backend {
13391334
hash: H256,
13401335
index: Index,
13411336
) -> Result<Option<Transaction>, BlockchainError> {
1342-
if let tx @ Some(_) = tokio::task::block_in_place(|| {
1343-
self.mined_transaction_by_block_hash_and_index(hash, index)
1344-
}) {
1337+
if let tx @ Some(_) = self.mined_transaction_by_block_hash_and_index(hash, index) {
13451338
return Ok(tx)
13461339
}
13471340

@@ -1374,7 +1367,7 @@ impl Backend {
13741367
hash: H256,
13751368
) -> Result<Option<Transaction>, BlockchainError> {
13761369
trace!(target: "backend", "transaction_by_hash={:?}", hash);
1377-
if let tx @ Some(_) = tokio::task::block_in_place(|| self.mined_transaction_by_hash(hash)) {
1370+
if let tx @ Some(_) = self.mined_transaction_by_hash(hash) {
13781371
return Ok(tx)
13791372
}
13801373

0 commit comments

Comments
 (0)