Skip to content

feat(db): make payment_hash and hash_index unique#13

Open
bogdanserdinov wants to merge 1 commit into
mainfrom
feat/make-hashes-unique
Open

feat(db): make payment_hash and hash_index unique#13
bogdanserdinov wants to merge 1 commit into
mainfrom
feat/make-hashes-unique

Conversation

@bogdanserdinov
Copy link
Copy Markdown
Contributor

No description provided.

@bogdanserdinov bogdanserdinov requested review from gofman8 and txalkan May 21, 2026 13:24
@bogdanserdinov bogdanserdinov self-assigned this May 21, 2026
Comment thread internal/lspapi/db.go
status TEXT NOT NULL,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
UNIQUE(order_id, hash_index),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @bogdanserdinov,

Double-checking this: hash_index is only unique within an order, so enforcing UNIQUE(hash_index) is too strong. It makes values like 1 usable only once across the whole system, which will break the next peer/order that starts its pool at 1.

payment_hash can be globally unique as the intended invariant. Please make sure it's enforced where it's looked up and acted on, not only in async_hash_pool.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants