-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enha: cleanup importer block and receipt fetching (#2006)
* feat: refactor block and receipt fetching with Alloy types This commit introduces several improvements to block and receipt fetching: - Add new `ExternalBlockWithReceipts` type to handle block and receipt retrieval - Update `BlockchainClient` to return `Option` types for block and receipt fetching - Simplify RPC downloader and importer block fetching logic - Remove temporary deserialization structs - Improve error handling and logging for block retrieval * chore: lint
- Loading branch information
1 parent
05e6001
commit c97aede
Showing
5 changed files
with
64 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use serde::Deserialize; | ||
|
||
use crate::alias::JsonValue; | ||
use crate::eth::primitives::ExternalBlock; | ||
use crate::eth::primitives::ExternalReceipt; | ||
use crate::log_and_err; | ||
|
||
#[derive(Debug, Clone, Deserialize)] | ||
pub struct ExternalBlockWithReceipts { | ||
pub block: ExternalBlock, | ||
pub receipts: Vec<ExternalReceipt>, | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
// Conversions: Other -> Self | ||
// ----------------------------------------------------------------------------- | ||
|
||
impl TryFrom<JsonValue> for ExternalBlockWithReceipts { | ||
type Error = anyhow::Error; | ||
|
||
fn try_from(value: JsonValue) -> Result<Self, Self::Error> { | ||
match ExternalBlockWithReceipts::deserialize(&value) { | ||
Ok(v) => Ok(v), | ||
Err(e) => log_and_err!(reason = e, payload = value, "failed to convert payload value to ExternalBlockWithReceipts"), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters