This needs some extra stuff added to it
- You DO NOT have transaction safety yet
Right now:
await wallet.Debit(...)
await wallet.Credit(...)
This is not atomic
Real fix:
Use DB transaction:
using var tx = await db.Database.BeginTransactionAsync();
- No concurrency control
Two requests could:
read same balance
both debit
→ double spend
Real fix:
RowVersion (optimistic concurrency)
OR SQL locking (FOR UPDATE equivalent)
- Webhooks are not retry-persistent anymore
You lost:
retry queue persistence
Right now:
fire-and-forget again
- No indexes on hot paths
You should add:
b.Entity()
.HasIndex(t => t.Created);
b.Entity()
.HasIndex(i => new { i.Type, i.Value });
This needs some extra stuff added to it
Right now:
await wallet.Debit(...)
await wallet.Credit(...)
This is not atomic
Real fix:
Use DB transaction:
using var tx = await db.Database.BeginTransactionAsync();
Two requests could:
read same balance
both debit
→ double spend
Real fix:
RowVersion (optimistic concurrency)
OR SQL locking (FOR UPDATE equivalent)
You lost:
retry queue persistence
Right now:
fire-and-forget again
You should add:
b.Entity()
.HasIndex(t => t.Created);
b.Entity()
.HasIndex(i => new { i.Type, i.Value });