Transaction
Atomic transaction mechanism for database modifications.
Lifecycle
- Creation: Initialize with current database tips as parents
- Store Access: Get typed handles for data manipulation
- Staging: Accumulate changes in internal entry
- Commit: Sign, validate, and store finalized entry
Features
- Multiple store changes in single commit
- Automatic authentication using database's default key
- Type-safe store access
- Cryptographic signing and validation
Integration
Entry Management: Creates and manages entries via EntryBuilder
Authentication: Signs operations and validates permissions
CRDT Support: Enables store conflict resolution
Backend Storage: Stores entries with verification status
Authentication Validation
Transaction commit includes comprehensive authentication validation that distinguishes between valid auth states and corrupted configurations.
Validation Process
During commit() (transaction/mod.rs ~line 938-960), the system validates authentication configuration:
- Extract effective settings: Get
_settingsstate at commit time - Check for tombstone: Use
is_tombstone("auth")to detect deleted auth - Retrieve auth value: Use
get("auth")to get configuration - Validate type: Ensure auth is Doc type (if present)
- Parse auth settings: Convert Doc to AuthSettings
- Validate operation: Check signature and permissions
Error Types
Defined in transaction/errors.rs:
AuthenticationRequired: Unsigned op attempted in signed modeNoAuthConfiguration: Auth lookup failed in signed modeCorruptedAuthConfiguration: Auth has wrong type or is deletedSigningKeyNotFound: Requested signing key doesn't existInsufficientPermissions: Key lacks required permissions
All are classified as authentication errors via is_authentication_error().