-
Notifications
You must be signed in to change notification settings - Fork 5
Refactor: SPO distribution store refactored to use StakeAddress #326
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
…and consistency across modules
# Conflicts: # common/src/stake_addresses.rs # modules/rest_blockfrost/src/handlers/epochs.rs # modules/rest_blockfrost/src/handlers/pools.rs # modules/rest_blockfrost/src/types.rs # modules/tx_unpacker/src/tx_unpacker.rs
…s and use to_/from_binary to encode the entire stake address (network + hash) so we can retrieve the stake address out of it.
…s and use to_/from_binary to encode the entire stake address (network + hash) so we can retrieve the stake address out of it.
…oving `Result` return type and add back documentation for SPDDStore methods and fields
…nd epochs handlers
d6604ec to
aeb3a09
Compare
| fn decode_key(key: &[u8]) -> Result<(u64, PoolId, StakeAddress)> { | ||
| let epoch_bytes: [u8; EPOCH_LEN] = key[..EPOCH_LEN] | ||
| .try_into() | ||
| .map_err(|_| anyhow!("Failed to extract epoch bytes (offset 0-{})", EPOCH_LEN))?; |
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.
How do we feel about error handling like this? I see a few different conventions and I'd be curious to better understand
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 think let epoch_bytes: [u8; EPOCH_LEN] = key[..EPOCH_LEN].try_into()? is fine so that the try_into error bubbles up.
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.
Good call 👍 that appears to be how we've done things elsewhere in this file too so I'll stick with letting it bubble up.
| hex = { workspace = true } | ||
| imbl = { workspace = true } | ||
| serde = { workspace = true } | ||
| serde_json = { workspace = true } |
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.
These weren't being used
| rayon = "1.10.0" | ||
| csv = "1.3.1" | ||
| itertools = "0.14.0" | ||
| tempfile = "3" |
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'm adding this so that the directories we store the test spo data into is cleaned up post test run. It wasn't being cleaned up before.
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.
This should go under [dev-dependencies] since it's only used for tests and shouldn't be included in production builds.
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.
Yes, good catch
f0bfcd1 to
4037f85
Compare
|
|
||
| match serde_json::to_string_pretty(&response) { | ||
| Ok(json) => Ok(RESTResponse::with_json(200, &json)), | ||
| &format!("Failed to serialize DRep delegators: {e}"), |
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.
Would recommend split-view for this diff
| ShelleyAddressPaymentPart::ScriptHash(data) => (data, 1), | ||
| }; | ||
|
|
||
| // TODO: MH - make delegation hash an Option<Hash<28>> type |
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'll do this in another PR!
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.
Great job! This is looking a lot cleaner and I'm glad we were able to reduce the number of queries for the epoch endpoints.
| rayon = "1.10.0" | ||
| csv = "1.3.1" | ||
| itertools = "0.14.0" | ||
| tempfile = "3" |
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.
This should go under [dev-dependencies] since it's only used for tests and shouldn't be included in production builds.
| fn decode_key(key: &[u8]) -> Result<(u64, PoolId, StakeAddress)> { | ||
| let epoch_bytes: [u8; EPOCH_LEN] = key[..EPOCH_LEN] | ||
| .try_into() | ||
| .map_err(|_| anyhow!("Failed to extract epoch bytes (offset 0-{})", EPOCH_LEN))?; |
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 think let epoch_bytes: [u8; EPOCH_LEN] = key[..EPOCH_LEN].try_into()? is fine so that the try_into error bubbles up.
…decode_key` in `spo_distribution_store.rs`, and add `tempfile` as a dev dependency
What
KeyHash->StakeAddresswhere it made senseStakeAddressstruct when decoding the key