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

Store jobs in separate storage entries #72

Closed
webmaster128 opened this issue Oct 16, 2022 · 0 comments · Fixed by #75
Closed

Store jobs in separate storage entries #72

webmaster128 opened this issue Oct 16, 2022 · 0 comments · Fixed by #75
Milestone

Comments

@webmaster128
Copy link
Collaborator

Currently we store jobs in a Vec. This is very inefficient since we need to read the whol list and save the whole list on updates.

        let mut jobs = DRAND_JOBS
            .may_load(deps.storage, round)?
            .unwrap_or_default();
        jobs.push(job);
        DRAND_JOBS.save(deps.storage, round, &jobs)?;

All removed at the same time:

        if let Some(jobs) = DRAND_JOBS.may_load(deps.storage, round)? {
            DRAND_JOBS.remove(deps.storage, round);

            for job in jobs {
                // Use IbcMsg::SendPacket to send packages to the proxies.
                let msg = process_job(env.block.time, job, beacon)?;
                out_msgs.push(msg.into());
            }
        }

Better use Deque (in cw-store-plus 0.15.2) which gives us a stack or queue storage.

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 a pull request may close this issue.

1 participant