Add SnapshotArchiveInfo and refactor functions in snapshot_utils (#18232)
This commit is contained in:
@ -49,7 +49,7 @@ use {
|
||||
inline_spl_token_v2_0::{SPL_TOKEN_ACCOUNT_MINT_OFFSET, SPL_TOKEN_ACCOUNT_OWNER_OFFSET},
|
||||
non_circulating_supply::calculate_non_circulating_supply,
|
||||
snapshot_config::SnapshotConfig,
|
||||
snapshot_utils::get_highest_snapshot_archive_path,
|
||||
snapshot_utils,
|
||||
},
|
||||
solana_sdk::{
|
||||
account::{AccountSharedData, ReadableAccount},
|
||||
@ -2255,8 +2255,9 @@ pub mod rpc_minimal {
|
||||
|
||||
meta.snapshot_config
|
||||
.and_then(|snapshot_config| {
|
||||
get_highest_snapshot_archive_path(&snapshot_config.snapshot_package_output_path)
|
||||
.map(|(_, (slot, _, _))| slot)
|
||||
snapshot_utils::get_highest_snapshot_archive_slot(
|
||||
&snapshot_config.snapshot_package_output_path,
|
||||
)
|
||||
})
|
||||
.ok_or_else(|| RpcCustomError::NoSnapshot.into())
|
||||
}
|
||||
|
@ -198,13 +198,14 @@ impl RequestMiddleware for RpcRequestMiddleware {
|
||||
if let Some(ref snapshot_config) = self.snapshot_config {
|
||||
if request.uri().path() == "/snapshot.tar.bz2" {
|
||||
// Convenience redirect to the latest snapshot
|
||||
return if let Some((snapshot_archive, _)) =
|
||||
snapshot_utils::get_highest_snapshot_archive_path(
|
||||
return if let Some(snapshot_archive_info) =
|
||||
snapshot_utils::get_highest_snapshot_archive_info(
|
||||
&snapshot_config.snapshot_package_output_path,
|
||||
) {
|
||||
RpcRequestMiddleware::redirect(&format!(
|
||||
"/{}",
|
||||
snapshot_archive
|
||||
snapshot_archive_info
|
||||
.path
|
||||
.file_name()
|
||||
.unwrap_or_else(|| std::ffi::OsStr::new(""))
|
||||
.to_str()
|
||||
|
Reference in New Issue
Block a user