Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Provider ref count #7343

Closed
gavofyork opened this issue Oct 16, 2020 · 0 comments · Fixed by #7363
Closed

Provider ref count #7343

gavofyork opened this issue Oct 16, 2020 · 0 comments · Fixed by #7363
Assignees
Labels
I7-refactor Code needs refactoring. U2-some_time_soon Issue is worth doing soon. Z3-substantial Can be fixed by an experienced coder with a working knowledge of the codebase.

Comments

@gavofyork
Copy link
Member

gavofyork commented Oct 16, 2020

Introduce a second ref-count in the account store.

The current ref count basically says "if non-zero then: the account cannot be mutated into a state where it would be auto-deleted". The new ref count would say "if zero then: the account should be auto-deleted". So we now have two ref-counts: providers and consumers.

The rules would be:

  • providers == 0 && consumers == 0: delete account
  • providers == 0 && consumers > 0: invalid operation (revert state)
  • providers > 0: ensure account exists

A consumer must ensure (as they already do now) that they only bump the ref when the providers count is non-zero (which used to be that the account already exists). This would let us have arbitrary, separate pieces of state which could imply account existence

This way, we can decouple balances from system completely and just wire in the ED logic through a trait if desired.

Then you could optionally bump a provider/consumer ref count (or not) depending on the balances trait impl. System wouldn’t care - its only interface would be this ref count.

@gavofyork gavofyork added I7-refactor Code needs refactoring. U2-some_time_soon Issue is worth doing soon. Z3-substantial Can be fixed by an experienced coder with a working knowledge of the codebase. labels Oct 16, 2020
@gavofyork gavofyork self-assigned this Oct 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
I7-refactor Code needs refactoring. U2-some_time_soon Issue is worth doing soon. Z3-substantial Can be fixed by an experienced coder with a working knowledge of the codebase.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant