Expand description
Shared Watermark construction for the v2alpha list APIs.
Both ledger-history backends — the fullnode (sui-rpc-api) and bigtable
(sui-kv-rpc) — and all three list handlers (list_transactions,
list_events, list_checkpoints) emit the same wire Watermark: a resume
cursor plus a direction-matching completion boundary (checkpoint_hi
ascending / checkpoint_lo descending). The cursor encoding and the
boundary bookkeeping are identical; what differs per API is how a scan
position resolves into a completion-boundary candidate:
list_transactions/list_eventsscan within a checkpoint, so an item at cpCdoes NOT proveCcomplete (more matches may sit at higher/lower tx_seqs / event_seqs). Their boundary candidate isC ∓ 1— seeadvance_boundary_excluding_cp.list_checkpointsdedupes cp_seq, so “cpCemitted” ≡ “cpCcomplete.” It feedsCstraight intoadvance_checkpoint_boundaryfor items, and translates its scan frontier into a cp-space candidate itself before doing the same.
This module owns the shared pieces; each handler keeps only its API-specific frontier-to-candidate adapter.
Functions§
- advance_
boundary_ excluding_ cp - Fold a cp whose own checkpoint is NOT proven complete into the
accumulated boundary (
list_transactions/list_events: cpCmay still hold further matches at other tx_seqs / event_seqs; and any scan frontier, which lands partway through the checkpoint it resolves to). The boundary excludesCitself:C - 1ascending /C + 1descending. - advance_
checkpoint_ boundary - Fold an already-resolved completion-boundary
candidateinto the accumulated boundary, keeping the most-advanced value in scan direction: the max ascending, the min descending. - boundary_
cursor_ cp - Resolve the boundary-cursor checkpoint coordinate for a
list_transactions/list_eventsscan frontier. The cursor encoding is asymmetric: ascendingBoundarycursors advance the cp-range start, so the frontier cp is used directly; descendingBoundarycursors treat the cp coordinate as an EXCLUSIVE upper bound, socp + 1is needed to keepcpitself included on resume. - boundary_
watermark - Build a standalone scan-frontier
Watermark.cursor_cp/positionare the boundary cursor coordinates the caller has already resolved for its scan domain (seeboundary_cursor_cpfor the per-checkpoint scanners’ direction adjustment);boundaryis the accumulated completion boundary. - item_
watermark - Build the embedded
Watermarkfor an item: the cursor encodes this item’s position (so the next request’safter/beforeresumes past it) plus the current direction-matching checkpoint boundary.cp/positionare the item’s cursor coordinates (list_checkpointspasses its cp_seq for both). - reached_
range_ end - Whether the scan reached the natural end of the requested range (the
ledger tip or a requested
end_checkpoint) rather than being truncated by an item or scan limit, or bounded by a client cursor. Only natural completion proves the range’s final checkpoint complete. - terminal_
boundary_ watermark - Boundary watermark emitted once a scan has drained its entire resolved
range under natural completion. Unlike per-item watermarks it can claim
the range’s final checkpoint complete —
end_checkpoint - 1ascending (the exclusive cp upper) orend_checkpointdescending (the inclusive cp lower) — because no further items exist in it within the requested range. The(end_checkpoint, end_position)cursor resumes exactly past the scanned range.