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

Aggregated account data #196

Merged
merged 10 commits into from Apr 6, 2022
Merged

Aggregated account data #196

merged 10 commits into from Apr 6, 2022

Conversation

pifragile
Copy link
Contributor

@pifragile pifragile requested a review from clangenb April 5, 2022 07:19
Copy link
Member

@clangenb clangenb left a comment

Choose a reason for hiding this comment

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

Looks good, I also like the refactoring you started, (which created space for even more refactoring, which I'd like to see :))

ceremonies/rpc/runtime-api/src/lib.rs Outdated Show resolved Hide resolved
ceremonies/rpc/src/lib.rs Outdated Show resolved Hide resolved
ceremonies/src/lib.rs Show resolved Hide resolved
ceremonies/src/lib.rs Outdated Show resolved Hide resolved
ceremonies/src/lib.rs Outdated Show resolved Hide resolved
ceremonies/assignment/src/lib.rs Show resolved Hide resolved
ceremonies/rpc/src/lib.rs Outdated Show resolved Hide resolved
ceremonies/src/lib.rs Outdated Show resolved Hide resolved
Comment on lines +918 to +922
let mut meetup_location_index: Option<MeetupIndexType> = None;
let mut meetup_time: Option<T::Moment> = None;
let mut meetup_registry: Option<Vec<T::AccountId>> = None;
let mut meetup_index: Option<MeetupIndexType> = None;

Copy link
Member

Choose a reason for hiding this comment

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

Why do you predefine those fields, we same some lines of code if this is defined in place.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i do it because i use a bunch of if statements to assign those variables. if i dont predefine them here, they woule be undefined in some cases. if there is a more elegant solution to this, please give me a hint :)

Copy link
Member

@clangenb clangenb Apr 6, 2022

Choose a reason for hiding this comment

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

It needs a bit of thinking, but I think you can. The code is hard to read like this, I'd want to change that. Basically, all the fields are null if participant_meetup_index is None correct? Then I'd propose the following:

let participant_meetup_index = match Self::get_meetup_index() {
    Some(p_index) => p_index,
    None => return Some(AggregatedAccountDataPersonal::new_unassigned(participant_type));
}

.... continue as usual

This pattern would, however, require extracting get_agregated_account_data_personal as advised above. I think you did not see that message because it was a hidden conversation.

ceremonies/src/tests.rs Show resolved Hide resolved
@clangenb clangenb requested a review from brenzi April 5, 2022 18:57
@clangenb
Copy link
Member

clangenb commented Apr 5, 2022

@brenzi I only have code-quality remarks. I think from the functionality it looks fine, so from my point of view we can merge this to get it into the parachain.

@brenzi
Copy link
Member

brenzi commented Apr 5, 2022

well, an unwarp() in the runtime is not only a code quality problem. It is serious. but it's not part of an extrinsic execution, only rpc, so not strictly critical

@brenzi
Copy link
Member

brenzi commented Apr 6, 2022

Thanks for your very modular fixes. That makes it a bliss to review!

@brenzi brenzi merged commit af4b4f4 into master Apr 6, 2022
@clangenb clangenb deleted the aggregated-account-data branch April 22, 2022 14:21
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.

Custom RPC: Aggregated Account Data
3 participants