-
Notifications
You must be signed in to change notification settings - Fork 12
v1: Initial implementation #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Abstract db handling logic - Add mongodb implementation
- Keep track of last processed slot. - Refactor slot processing logic. - Handle `unwrap()` calls properly.
ci: fix CD workflow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall it's coming together! A few comments, mainly about being a tad more idiomatic about some things. Feel free to close/ignore what you feel like deferring for later.
src/beacon_chain/mod.rs
Outdated
pub async fn get_block( | ||
&self, | ||
slot: Option<u32>, | ||
) -> Result<Option<Block>, Box<dyn error::Error>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we wanna have fancier error handling (totally doable later down the line) we could probably use anyhow
to easily bubble up/downcast errors and define all the possible error types for this API client with thiserror
(here's a good example)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was having a bit of trouble finding the best approach for error handling.
This definitely seems the way to go. Thank you for sharing this crate and example!.
src/slots/mod.rs
Outdated
utils::web3::{calculate_versioned_hash, get_eip_4844_tx, get_tx_versioned_hashes}, | ||
}; | ||
|
||
type StdErr = Box<dyn error::Error>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again, recommend using anyhow :D
src/slots/mod.rs
Outdated
let beacon_block = match beacon_api.get_block(Some(slot)).await? { | ||
Some(block) => block, | ||
None => { | ||
info!( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice! Have you looked into tracing
? it's essentially logging on steroids—will help with instrumenting robust logging and we could eventually trace all API calls which will help debug stuff in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found out about it yesterday when I was working on parallelizing the indexer.
The concept of structured spans, as opposed to conventional logs, makes it a more suitable choice for asynchronous and multi-threading environments.
Thank you for sharing!
- Move env variables logic to its own file. - Generalize std error.
- Use `reqwest` client. - Add try/catch instantiation - Rewrite functions to make it more idiomatic
Resolves #2 , resolves #8
Notes: