This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
Provider ref count #7343
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.
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 accountproviders == 0 && consumers > 0
: invalid operation (revert state)providers > 0
: ensure account existsA 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 existenceThis 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.
The text was updated successfully, but these errors were encountered: