-
Notifications
You must be signed in to change notification settings - Fork 48
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
refactor: move PhotonIndexer to light-client crate #1525
Conversation
fn decode_hash(account: &str) -> [u8; 32] { | ||
let bytes = bs58::decode(account).into_vec().unwrap(); | ||
let mut arr = [0u8; 32]; | ||
arr.copy_from_slice(&bytes); | ||
arr | ||
} |
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.
The following avoids the vector allocation. (Just a suggestion below didn't test it.)
fn decode_hash(account: &str) -> [u8; 32] { | |
let bytes = bs58::decode(account).into_vec().unwrap(); | |
let mut arr = [0u8; 32]; | |
arr.copy_from_slice(&bytes); | |
arr | |
} | |
fn decode_hash(account: &str) -> [u8; 32] { | |
let mut arr = [0u8; 32]; | |
bs58::decode(account) | |
.into(&mut arr) | |
.expect("Failed to decode base58 string"); | |
arr | |
} |
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 be better to return a result
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.
Thanks, done 301544d.
We already have cleaner implementation for conversions like this btw, but there is a mess with photon_client & sdk types that needs to be untangled first.
I started doing it here, but its not finished yet #1515
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.
Just the one comment else lgtm
No description provided.