Interface ISafetyService
- Namespace
- NArk.Abstractions.Safety
- Assembly
- NArk.Abstractions.dll
Provides distributed locking to prevent concurrent operations on the same resources (e.g., double-spending the same VTXO, concurrent batch signing for the same wallet).
public interface ISafetyService
Methods
LockKeyAsync(string, CancellationToken)
Acquires an exclusive lock on a single key. Dispose the result to release.
Task<CompositeDisposable> LockKeyAsync(string key, CancellationToken ct)
Parameters
keystringctCancellationToken
Returns
LockKeysAsync(ImmutableSortedSet<string>, CancellationToken)
Acquires exclusive locks on multiple keys atomically (sorted to prevent deadlocks). Dispose the result to release all locks.
Task<CompositeDisposable> LockKeysAsync(ImmutableSortedSet<string> keys, CancellationToken ct)
Parameters
keysImmutableSortedSet<string>ctCancellationToken
Returns
TryLockByTimeAsync(string, TimeSpan)
Attempts to acquire a time-limited lock. Returns true if acquired, false if already held.
Task<bool> TryLockByTimeAsync(string key, TimeSpan timeSpan)