fix: Ensure pagination cursor updates for all cases in get_cells and get_transactions#234
fix: Ensure pagination cursor updates for all cases in get_cells and get_transactions#234tea2x wants to merge 1 commit intonervosnetwork:developfrom tea2x:develop
get_cells and get_transactions#234Conversation
get_cells and get_transactionsget_cells and get_transactions
|
So if I'm not mistaken at this, full node rpc Just correct me if i'm wrong. |
let cells = iter
.take_while(|(key, _value)| key.starts_with(&prefix))
.filter_map(|(key, value)| {
...
})
.take(limit)
.collect::<Vec<_>>();The Considering that we have only
So I think the problem is that we should exit the loop because there are no more results, but we didn't. If you can share your client-side code / test cases to reproduce the problem, we may be able to identify potential problems better.
Because, as far as I can tell, I didn't see a logical problem with existing code. The However, this might lead to a performance improvement if we skip a lot of invalid cells after the last valid ones, and the client-side code only checks empty Also, this might be regarded as a code style improvement. In the future, if we add more valid returns before the last one, early assignment can prevent us from forgetting to update the cursor. |
|
I’d like to clarify our design decision regarding pagination. In the current implementation, the In other words, the cursor does not advance when no items are returned because there is no “last object” to anchor the pagination. This approach makes the behavior consistent and predictable for clients:
If an application requires different semantics (e.g., skipping over filtered-out items even when a page is empty), this would fall into the category of client-side handling or an additional feature proposal rather than a bug in the core design. I also added an unit test to ensure this behavior is explicitly verified: #235 |
|
hi @Hanssen0 , @quake it's good to see you here.
So it seems I am the only one who thinks this is an issue here - even if it is a rare one. Here's my argument. Check the following scenario: I do see this is an issue in case all cells on the first page are filtered out. When
The problem here is that
Please check ckb-devrel/ccc#283 (comment) |
Let me reiterate my point about this hypothesis:
I don't think there is a situation where the first page is completely filtered out and empty, but the second page has data. |
I see. It's clear I'm mistaken about #234 (comment) The issue is in WASM module only. |
|
Update: |
As the title goes, I notice pagination cursor in some corner cases does not get updated and results in infinite loops. The root cause is pagination cursor update is skipped when certain edge conditions are met simultaneously for example:
Please check this out!
BR,