chat.list: carry the access hash into the dialog cursor - #17
Merged
Conversation
messages.getDialogs resolves its cursor against offset_peer, and both places
that built one used access_hash=0. A hashless peer does not resolve, so the
server answers from the top of the list instead of from the cursor: the next
page repeats the first, and the walk either stops seeing anything new or
returns the same rows forever.
The hash is already in hand. Every getDialogs reply carries the entity for
each peer it mentions, so fetch_dialogs now returns that entity map beside the
rows and both cursor builders use it:
* _offset_peer resolves the peer through utils.get_input_peer;
* _peer_state stores the hash in the page cursor, and _state_peer restores
it, so a resumed page starts where the previous one ended.
Measured on a live 936-dialog account, chat.list at 100 rows per page
following next_cursor: 34 rows in one page before, 600+ across six pages
after.
Both keep the hashless form as a fallback rather than raising: a stalled
cursor loses dialogs, an exception loses the whole call.
This is not the whole enumeration story. The fetch_all walk in _all_dialogs
has a separate stall that this does not fix — it still returns ~101 on that
same account — and chat.list's has_more is computed AFTER the type filter is
applied, so a filtered page of 34 out of 100 reads as the last page and drops
the cursor. Both are noted where a reader will meet them.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
messages.getDialogsresolves its cursor againstoffset_peer, and bothplaces that built one used
access_hash=0. A hashless peer does not resolve,so the server answers from the top of the list instead of from the cursor: the
next page repeats the first, and the walk either stops seeing anything new or
returns the same rows forever.
The hash is already in hand. Every
getDialogsreply carries the entity foreach peer it mentions, so
fetch_dialogsnow returns that entity map besidethe rows and both cursor builders use it:
_offset_peerresolves the peer throughutils.get_input_peer;_peer_statestores the hash in the page cursor, and_state_peerrestoresit, so a resumed page starts where the previous one ended.
Measured on a live 936-dialog account,
chat.listat 100 rows per pagefollowing
next_cursor: 34 rows in one page before, 600+ across six pagesafter.
Both keep the hashless form as a fallback rather than raising: a stalled
cursor loses dialogs, an exception loses the whole call.
Known limits, noted in the code
This is not the whole enumeration story. The
fetch_allwalk in_all_dialogshas a separate stall that this does not fix (it still returns~101 on that same account), and
chat.list'shas_moreis computed after thetype filter is applied, so a filtered page of 34 out of 100 reads as the last
page and drops the cursor. Both are noted where a reader will meet them.