-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Provider ref count #7343
Description
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 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.