Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ value class LastMessageHashEpoch internal constructor(internal val resets: Long)
*
* Every reset and every guarded write runs under this object's lock, together with its storage operation, so
* a reset cannot land between a write's check and the write itself.
*
* So the lock is held across the SQL, and neither a reset nor a write may be made from inside a database
* transaction. A caller holding the database while it waits for this lock, against a write holding this lock
* while it waits for the database, would deadlock.
*/
class LastMessageHashResets {
private var resets = 0L
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,17 @@ interface LokiAPIDatabaseProtocol {
/**
* Writes [newValue] as the cursor, unless [publicKey]'s cursors have been reset since [since].
*
* A reset asks for the swarm's history to be fetched again. A poll that was in flight when it happened
* would otherwise finish afterwards and write its position back, undoing the reset, and the history
* would never be fetched. Its messages are still handled; only the cursor write is dropped, so the next
* poll starts from the beginning and dedupe absorbs what it fetches twice.
* A reset asks for the swarm's history to be fetched again. Cursors are kept per snode, so a poll that
* was in flight when it happened would otherwise finish afterwards and write its position back for the
* snode it polled, undoing the reset there. That snode's history would then arrive only through another
* snode, and in a one-snode swarm not at all. The poll's messages are still handled; only the cursor write
* is dropped.
*
* What the next poll fetches then depends on the reset. Where the cursors were cleared, it starts from
* the beginning. A clear by namespace counts as a reset of every swarm, so a swarm whose cursor it did not
* clear starts again from its previous cursor and fetches the in-flight poll's messages a second time.
* Regular messages are deduplicated, config messages rely on merging being repeatable, and a kick message
* seen again is ignored only by the key generation check in its handler.
*
* @return whether the cursor was written.
*/
Expand Down
Loading