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

simplifies parse [sanitized] vote transaction #22127

Merged
merged 1 commit into from
Dec 30, 2021

Conversation

behzadnouri
Copy link
Contributor

Problem

verbose convoluted code.

Summary of Changes

simplified the code; removed ~30 lines of code.

@codecov
Copy link

codecov bot commented Dec 27, 2021

Codecov Report

Merging #22127 (c14f30d) into master (c9c7862) will increase coverage by 0.0%.
The diff coverage is 70.3%.

@@           Coverage Diff           @@
##           master   #22127   +/-   ##
=======================================
  Coverage    81.1%    81.1%           
=======================================
  Files         521      521           
  Lines      146326   146311   -15     
=======================================
- Hits       118788   118787    -1     
+ Misses      27538    27524   -14     

Comment on lines +54 to +56
let first_instruction = message.instructions.first()?;
let program_id_index = usize::from(first_instruction.program_id_index);
let program_id = message.account_keys.get(program_id_index)?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let first_instruction = message.instructions.first()?;
let program_id_index = usize::from(first_instruction.program_id_index);
let program_id = message.account_keys.get(program_id_index)?;
let program_id = message.program_id(0)?;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. but I prefer to keep this commit precisely the same logic as the existing code.
We can introduce that change in a separate commit

if !crate::check_id(program_id) {
return None;
}
let first_account = usize::from(*first_instruction.accounts.first()?);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let first_account = usize::from(*first_instruction.accounts.first()?);
let first_instruction = message.instructions.first()?;
let first_account = usize::from(*first_instruction.accounts.first()?);

@behzadnouri behzadnouri merged commit d421ccb into solana-labs:master Dec 30, 2021
@behzadnouri behzadnouri deleted the parse-vote branch December 30, 2021 16:03
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