Skip to content

[CT-23] Build DeduplicationService #555

@mftee

Description

@mftee

Problem

The same document hash can be submitted multiple times, generating duplicate Stellar transactions. Each duplicate wastes blockchain transaction fees and creates a confusing multi-entry history for the same document.

Proposed Solution

Create a DeduplicationService inside contract/module/dedup/ that provides a reusable guard for preventing duplicate operations on the same hash.

Acceptance Criteria

  • is_duplicate(cache: &CacheBackend, operation: &str, document_hash: &str) async function checks for the existence of a Redis key formatted as {operation}:{document_hash} (e.g. submit:abc123...)
  • Returns Ok(Some(existing_tx_hash)) if a record already exists, Ok(None) if it does not, and Err on Redis failure
  • The submit handler (CT-01) calls is_duplicate with operation=submit and returns 409 with the existing txHash in the response body when a duplicate is detected
  • The revoke handler (CT-02) calls is_duplicate with operation=revoke
  • Unit tests cover: no existing record, existing record found, Redis connection error
  • Implementation files live inside contract/module/dedup/

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions