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

MilestoneVotes migration #213

Closed
f-gate opened this issue Sep 14, 2023 · 0 comments
Closed

MilestoneVotes migration #213

f-gate opened this issue Sep 14, 2023 · 0 comments
Labels

Comments

@f-gate
Copy link
Member

f-gate commented Sep 14, 2023

The problem is that this bit of code will be used in the rutnime api to collect total votes.
This means that we will iterate over the keys of a Project key, thereby doing up to T::MaxMilestonesPerProject iterations which is obviously dreadful.

    #[pallet::storage]
    #[pallet::getter(fn milestone_votes)]
    pub(super) type MilestoneVotes<T: Config> = StorageDoubleMap<
        _,
        Identity,
        ProjectKey,
        Identity,
        MilestoneKey,
        Vote<BalanceOf<T>>,
        OptionQuery,
    >;

Suggested change:

    #[pallet::storage]
    #[pallet::getter(fn milestone_votes)]
    pub(super) type MilestoneVotes<T: Config> = StorageMap<
        _,
        Identity,
        ProjectKey,
        BoundedBTreeMap<MilestoneKey, Vote<BalanceOf<T>>, T::MaxMilestonesPerProject>,
        ValueQuery,
    >;
@f-gate f-gate added enhancement New feature or request Priority | High debt labels Sep 14, 2023
This was referenced Sep 20, 2023
@f-gate f-gate closed this as completed Nov 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant