Skip to content

Commit dc58dfb

Browse files
authored
[archival service] fix get latest checkpoint request (#24435)
## Description fix get latest checkpoint request --- ## Release notes Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required. For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates. - [ ] Protocol: - [ ] Nodes (Validators and Full nodes): - [ ] gRPC: - [ ] JSON-RPC: - [ ] GraphQL: - [ ] CLI: - [ ] Rust SDK: - [ ] Indexing Framework:
1 parent c0e3edd commit dc58dfb

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

crates/sui-kv-rpc/src/v2/get_checkpoint.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,11 @@ pub async fn get_checkpoint(
4747
.await?
4848
.pop()
4949
.ok_or(CheckpointNotFoundError::sequence_number(sequence_number))?,
50-
None => {
51-
let sequence_number = client.get_latest_checkpoint().await?;
52-
client
53-
.get_checkpoints(&[sequence_number])
54-
.await?
55-
.pop()
56-
.ok_or(CheckpointNotFoundError::sequence_number(sequence_number))?
57-
}
5850
_ => {
5951
let sequence_number = client.get_latest_checkpoint().await?;
52+
let not_found_response = CheckpointNotFoundError::sequence_number(sequence_number);
6053
client
61-
.get_checkpoints(&[sequence_number])
54+
.get_checkpoints(&[sequence_number.checked_sub(1).ok_or(not_found_response)?])
6255
.await?
6356
.pop()
6457
.ok_or(CheckpointNotFoundError::sequence_number(sequence_number))?

0 commit comments

Comments
 (0)