Improve UX querying rpc for blocks at or before the snapshot from boot (backport #23403) (#23405)

* Improve UX querying rpc for blocks at or before the snapshot from boot (#23403)

* Bump first-available block to first complete block

* Remove obsolete purges in tests (PrimaryIndex toggling no longer in use

* Check first-available block in Rpc check_slot_cleaned_up

(cherry picked from commit 3b5b71ce44)

# Conflicts:
#	ledger/src/blockstore.rs

* Fix conflicts

Co-authored-by: Tyera Eulberg <tyera@solana.com>
This commit is contained in:
mergify[bot]
2022-03-01 17:13:54 +00:00
committed by GitHub
parent 46a02b7b4a
commit db9826c93f
2 changed files with 22 additions and 18 deletions

View File

@ -937,15 +937,20 @@ impl JsonRpcRequestProcessor {
result: &std::result::Result<T, BlockstoreError>,
slot: Slot,
) -> Result<()> {
let first_available_block = self
.blockstore
.get_first_available_block()
.unwrap_or_default();
let err: Error = RpcCustomError::BlockCleanedUp {
slot,
first_available_block,
}
.into();
if let Err(BlockstoreError::SlotCleanedUp) = result {
return Err(RpcCustomError::BlockCleanedUp {
slot,
first_available_block: self
.blockstore
.get_first_available_block()
.unwrap_or_default(),
}
.into());
return Err(err);
}
if slot < first_available_block {
return Err(err);
}
Ok(())
}