Skip to content

buzz-db: extract replaceable-event logic from lib.rs #6

Description

@TheSentinel454

Problem

replace_addressable_event (~150 lines) and replace_parameterized_event (~200 lines) in lib.rs contain complex transactional SQL with advisory locks, stale-write detection, NIP-16/NIP-33 replacement semantics, and mention indexing. This is event-storage logic that belongs with the other event operations.

Proposed change

Move both methods into event.rs (where insert_event, query_events, soft_delete_event already live). Alternatively, if event.rs grows too large, create a dedicated replaceable.rs module. The event_replacement_lock_key helper function (currently in lib.rs) moves with them.

Priority

Medium — high-complexity code in the wrong location, naturally done alongside #2.

🤖 AI review update (2026-08-23)

Do this together with #4 and the narrow transaction work from #3. Prefer a dedicated replaceable.rs rather than growing event.rs beyond its current size. The module should own coordinate construction, advisory locking, stale-write/tie semantics, replacement mutation, mention indexing, and focused concurrency/rollback tests.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions