Vixen
02b45cc4
csharp
public record class LedgerIntent

A movement of value somebody is asking for. Applied whole or not at all.

Read the guide page for this →

Remarks

⚠ Several movements, not one, and that is not a convenience. A trade takes a sword off one character and puts gold on another; a purchase moves gold to Vendor and an item out of Loot. If those were two appends, a crash between them is a lost sword, and no amount of retrying fixes a half-applied trade because the retry's idempotency key already exists.

LeaseEpoch is ADR-021 reaching the database: a realm may only move a character's value while it holds that character's lease, and an intent naming a superseded epoch is refused. Without it, a realm that lost its lease mid-combat and is still simulating would keep writing — which is exactly the window the lease exists to close.

Fields and properties (5)

  • public IdempotencyKey Key

    What this is, and what makes the retry free.

  • public long LeaseEpoch

    The epoch the acting realm holds for Player.

  • public DateTimeOffset At

    When the realm decided it. Its clock, recorded rather than trusted.

  • public ImmutableArray<AssetMovement> Movements

    The legs, which must sum to zero per asset.

  • public string Detail

    Why, for the support tool. Free text, and the only field nothing depends on.

Methods (3)

  • public bool IsBalanced()

    Whether the legs balance — the invariant a store refuses to break.

  • public static LedgerIntent Transfer(IdempotencyKey key, long epoch, DateTimeOffset at, LedgerAccount from, LedgerAccount to, AssetId asset, long quantity)

    The commonest shape: one asset, from one account to another.

  • public override string ToString()

    Returns a string that represents the current object.

Used by (6)

  • ConservationTestsVixen.Live.Persistence.Tests
  • ILedgerVixen.Live.Persistence
  • LedgerTestsVixen.Live.Persistence.Tests
  • MemoryPersistenceVixen.Live.Persistence
  • SqlPersistenceVixen.Live.Persistence
  • TransferFleetVixen.Live.Realm.Tests