Use monotonic created_at when publishing replaceable events #122
Labels
No labels
app:activities
app:chat
app:events
app:forum
app:libra
app:market
app:restaurant
app:tasks
app:wallet
app:webapp
bug
enhancement
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
aiolabs/webapp#122
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
From the nostr-patterns review — and directly the lesson from the ticket-count live-update debugging.
Problem
Relays only push a replaceable update to open subscriptions when
created_atis strictly newer (verified against our relay). Publishers that stampcreated_at = floor(Date.now()/1000)(second resolution) can emit two versions in the same second — the relay treats the second as not-newer and won't propagate it to live subscribers (it only shows on a reload/re-query).useBookmarks(NIP-51 kind-10003) republishes the whole list on every toggle with second-resolutioncreated_at— rapid toggles can collide. (Theaiolabs/eventsextension'snostr_publisherusesint(time.time())too — tracked separately.)Proposed fix
When publishing a replaceable event, use a monotonic timestamp:
created_at = max(floor(Date.now()/1000), lastKnownCreatedAt + 1). Apply inuseBookmarks(webapp); file/flag the same for the events extension.Testing
Unit test the timestamp helper: two publishes "in the same second" produce strictly increasing
created_at; a publish after a future-dated prior bumps past it.To be done as a PR (gap #2 of the review).