refactor: flatten block response from beacon client #123
Annotations
6 warnings
useless conversion to the same type: `clients::beacon::types::BlockId`:
src/clients/beacon/types.rs#L224
warning: useless conversion to the same type: `clients::beacon::types::BlockId`
--> src/clients/beacon/types.rs:224:35
|
224 | .get_block_header(self.clone().into())
| ^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `self.clone()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion
= note: `#[warn(clippy::useless_conversion)]` on by default
|
manual implementation of `Option::map`:
src/clients/beacon/mod.rs#L80
warning: manual implementation of `Option::map`
--> src/clients/beacon/mod.rs:80:20
|
80 | .map(|res| match res {
| ____________________^
81 | | Some(r) => Some(r.into()),
82 | | None => None,
83 | | })
| |_________^ help: try: `res.map(|r| r.into())`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_map
= note: `#[warn(clippy::manual_map)]` on by default
|
called `map(..).flatten()` on `Option`:
src/indexer/mod.rs#L115
warning: called `map(..).flatten()` on `Option`
--> src/indexer/mod.rs:115:14
|
115 | .map(|state| {
| ______________^
116 | | state
117 | | .last_upper_synced_slot
118 | | .map(|last_upper_synced_slot| BlockHeader {
... |
123 | | })
124 | | .flatten();
| |______________________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#map_flatten
= note: `#[warn(clippy::map_flatten)]` on by default
help: try replacing `map` with `and_then` and remove the `.flatten()`
|
115 ~ .and_then(|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 ~ });
|
|
you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`:
src/slots_processor/helpers.rs#L17
warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
--> src/slots_processor/helpers.rs:17:28
|
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 | | });
| |_____________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match
= note: `#[warn(clippy::single_match)]` on by default
help: try
|
17 ~ .for_each(|tx| if let Some(versioned_hashes) = &tx.blob_versioned_hashes {
18 + tx_to_versioned_hashes.insert(tx.hash, versioned_hashes.clone());
19 ~ });
|
|
useless use of `format!`:
src/slots_processor/mod.rs#L301
warning: useless use of `format!`
--> src/slots_processor/mod.rs:301:50
|
301 | ... .with_context(|| format!("Failed to sync forwarded block"))?;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"Failed to sync forwarded block".to_string()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_format
= note: `#[warn(clippy::useless_format)]` on by default
|
useless conversion to the same type: `anyhow::Error`:
src/slots_processor/mod.rs#L327
warning: useless conversion to the same type: `anyhow::Error`
--> src/slots_processor/mod.rs:327:13
|
327 | Err(anyhow!("No common block found").into())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `anyhow!("No common block found")`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion
|