-
Notifications
You must be signed in to change notification settings - Fork 21
Implement proper pagination for list-payments cli #84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Implement proper pagination for list-payments cli #84
Conversation
|
👋 Thanks for assigning @tankyleo as a reviewer! |
| if payments.len() >= target_count as usize || response.next_page_token.is_none() { | ||
| next_page_token = response.next_page_token; | ||
|
|
||
| if payments.len() >= target_count as usize || next_page_token.is_none() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The point of surfacing the next_page_token back to the user is so that they can continue iterating after we've already satisfied their request to provide at least n payments ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
2faead0 to
7614706
Compare
7614706 to
bfc6312
Compare
bfc6312 to
f44c7fc
Compare
|
🔔 1st Reminder Hey @tankyleo! This PR has been waiting for your review. |
| impl From<ListPaymentsResponse> for CliListPaymentsResponse { | ||
| fn from(response: ListPaymentsResponse) -> Self { | ||
| let next_page_token = response.next_page_token.map(format_page_token); | ||
|
|
||
| CliListPaymentsResponse { payments: response.payments, next_page_token } | ||
| } | ||
| } | ||
|
|
||
| fn format_page_token(token: PageToken) -> String { | ||
| format!("{}:{}", token.token, token.index) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a better fit in the fn handle_list_payments_request in ldk-server ? Pretty much delete the PageToken type in the proto definition, and switch it to optional string next_page_token = 2.
Like this people who interact with the server programmatically also no longer can mishandle these two pieces ?
Although I agree they get a single object of type PageToken, so may be good enough there.
Another thing in the backend but not the cli