Skip to content
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

Merged
merged 2 commits into from
Jan 27, 2025

Conversation

sergeytimoshin
Copy link
Contributor

No description provided.

Comment on lines 250 to 255
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
}
Copy link
Contributor

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.)

Suggested change
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
}

Copy link
Contributor

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

Copy link
Contributor Author

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

Copy link
Contributor

@ananas-block ananas-block left a 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

@sergeytimoshin sergeytimoshin merged commit 2641ec2 into main Jan 27, 2025
16 checks passed
@sergeytimoshin sergeytimoshin deleted the sergey/move-photon-indexer-to-client branch January 27, 2025 23:06
@sergeytimoshin sergeytimoshin restored the sergey/move-photon-indexer-to-client branch January 31, 2025 17:06
@sergeytimoshin sergeytimoshin deleted the sergey/move-photon-indexer-to-client branch January 31, 2025 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants