Vixen
c7401864
csharp
public sealed class AccountState

What one account owns, as a state machine a test can drive.

Read the guide page for this →

Remarks

The grains-over-state-machines pattern a fourth time, for the reason PlayerLeaseState gives: a machine a test constructs and drives, and a grain that supplies the one property it cannot give itself, which is never being re-entered.

⚠ There is no lock in this file and there must never be one. What makes it correct is that AccountGrain takes one turn at a time. A lock would make the reason "we remembered to" rather than "the runtime guarantees it".

⚠ Unlocking is idempotent on the address, and there is no idempotency key. Two realms racing to grant the same mount to two characters of one account is ordinary rather than exceptional — that is what "account-wide" means — so the second must be a no-op. A key would make it a no-op only for a retry of the same grant, and two genuinely different grants of one mount would still write two rows.

⚠ An order is assigned here rather than trusted from the caller. Two realms cannot agree on a counter without asking, and asking is this call — so whatever a caller put in the field is ignored. It is a counter and not a clock for the reason doc 28 gives about collections: nothing in that library has one, and a counter is what replays identically.

Fields and properties (4)

  • public int Count

    How many things it owns.

  • public int Earned

    How many achievements it has earned.

  • public int Points

    What those achievements are worth.

  • public uint Revision

    How many times this has changed.

Methods (5)

  • public AccountHoldings Holdings()

    Everything, as one answer.

  • public bool Unlock(AccountUnlock unlock)

    Gives the account something.

  • public bool Earn(string address, int points)

    Records an achievement.

  • public bool Revoke(string address)

    Takes something back.

  • public void Restore(AccountHoldings saved)

    Puts a saved account back, as it was, with no checks.

Used by (2)

  • AccountGrainVixen.Live.Orchestrator
  • AccountStateTestsVixen.Live.Orchestrator.Tests