Skip to content

DHT Integration: Wire DHT storage to identity API #2

@umwelt

Description

@umwelt

Context

After lib-network DHT storage is implemented, integrate it into zhtp identity API endpoints for distributed storage. This fulfills the Phase 1 deliverable: "Integrate DHT file storage layer".

Scope

  • Update POST /api/v1/identity/create to store in DHT
  • Update GET /api/v1/identity/{did} to retrieve from DHT
  • Add DHT health check endpoint
  • Implement fallback to local storage if DHT unavailable
  • Async replication (don't block API responses)
  • Add storage location to API responses ("dht" or "local")

Dependencies

Acceptance Criteria

  • Identity creation stores in DHT asynchronously
  • Identity retrieval checks DHT first, falls back to local
  • Health check endpoint: GET /api/v1/system/dht/health
  • API response includes storage_location field
  • Timeout handling (3s max for DHT operations)
  • Graceful degradation if DHT down
  • Integration tests with local DHT cluster
  • API documentation updated
  • Monitoring logs for DHT success/failure rates

Technical Notes

  • Use async/await for non-blocking DHT operations
  • Cache identity locally after DHT retrieval
  • Consider eventual consistency (DHT write may take time to replicate)
  • Core SID requirement: "Storage: Encrypted and distributed across a DHT"
  • Existing identity API: zhtp/zhtp/src/api/handlers/identity/mod.rs

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions