Skip to content

Commit ebdd197

Browse files
committed
refactor: apply clippy suggestions
1 parent 01f2e97 commit ebdd197

File tree

5 files changed

+20
-30
lines changed

5 files changed

+20
-30
lines changed

src/clients/beacon/mod.rs

+3-8
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,8 @@ impl CommonBeaconClient for BeaconClient {
6161
let path = format!("v2/beacon/blocks/{}", { block_id.to_detailed_string() });
6262
let url = self.base_url.join(path.as_str())?;
6363

64-
json_get!(&self.client, url, BlockResponse, self.exp_backoff.clone()).map(|res| match res {
65-
Some(r) => Some(r.into()),
66-
None => None,
67-
})
64+
json_get!(&self.client, url, BlockResponse, self.exp_backoff.clone())
65+
.map(|res| res.map(|r| r.into()))
6866
}
6967

7068
async fn get_block_header(&self, block_id: BlockId) -> ClientResult<Option<BlockHeader>> {
@@ -77,10 +75,7 @@ impl CommonBeaconClient for BeaconClient {
7775
BlockHeaderResponse,
7876
self.exp_backoff.clone()
7977
)
80-
.map(|res| match res {
81-
Some(r) => Some(r.into()),
82-
None => None,
83-
})
78+
.map(|res| res.map(|r| r.into()))
8479
}
8580

8681
async fn get_blobs(&self, block_id: BlockId) -> ClientResult<Option<Vec<Blob>>> {

src/clients/beacon/types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ impl BlockIdResolution for BlockId {
241241
match self {
242242
BlockId::Slot(slot) => Ok(*slot),
243243
_ => match beacon_client
244-
.get_block_header(self.clone().into())
244+
.get_block_header(self.clone())
245245
.await
246246
.map_err(|err| BlockIdResolutionError::FailedBlockIdResolution {
247247
block_id: self.clone(),

src/indexer/mod.rs

+9-11
Original file line numberDiff line numberDiff line change
@@ -111,17 +111,15 @@ impl Indexer<ReqwestTransport> {
111111
},
112112
};
113113

114-
let last_synced_block = sync_state
115-
.map(|state| {
116-
state
117-
.last_upper_synced_slot
118-
.map(|last_upper_synced_slot| BlockHeader {
119-
slot: last_upper_synced_slot,
120-
root: B256::ZERO,
121-
parent_root: B256::ZERO,
122-
})
123-
})
124-
.flatten();
114+
let last_synced_block = sync_state.and_then(|state| {
115+
state
116+
.last_upper_synced_slot
117+
.map(|last_upper_synced_slot| BlockHeader {
118+
slot: last_upper_synced_slot,
119+
root: B256::ZERO,
120+
parent_root: B256::ZERO,
121+
})
122+
});
125123

126124
let upper_indexed_block_id = match &last_synced_block {
127125
Some(block) => block.slot.into(),

src/slots_processor/helpers.rs

+5-8
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,11 @@ pub fn create_tx_hash_versioned_hashes_mapping(
1212
let mut tx_to_versioned_hashes = HashMap::new();
1313

1414
if let Some(transactions) = block.transactions.as_transactions() {
15-
transactions
16-
.iter()
17-
.for_each(|tx| match &tx.blob_versioned_hashes {
18-
Some(versioned_hashes) => {
19-
tx_to_versioned_hashes.insert(tx.hash, versioned_hashes.clone());
20-
}
21-
None => {}
22-
});
15+
transactions.iter().for_each(|tx| {
16+
if let Some(versioned_hashes) = tx.blob_versioned_hashes.as_ref() {
17+
tx_to_versioned_hashes.insert(tx.hash, versioned_hashes.clone());
18+
}
19+
});
2320
}
2421

2522
Ok(tx_to_versioned_hashes)

src/slots_processor/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ impl SlotsProcessor<ReqwestTransport> {
309309
if block.slot != new_head_header.slot {
310310
self.process_block(block)
311311
.await
312-
.with_context(|| format!("Failed to sync forwarded block"))?;
312+
.with_context(|| "Failed to sync forwarded block")?;
313313
}
314314
}
315315

@@ -331,7 +331,7 @@ impl SlotsProcessor<ReqwestTransport> {
331331
rewinded_blocks.push(old_blobscan_block.hash);
332332
}
333333

334-
Err(anyhow!("No common block found").into())
334+
Err(anyhow!("No common block found"))
335335
}
336336

337337
/// Returns the path of blocks with execution payload from the head block to the provided block.

0 commit comments

Comments
 (0)