diff --git a/cli/src/cli.rs b/cli/src/cli.rs index b2b9386865..2933438dee 100644 --- a/cli/src/cli.rs +++ b/cli/src/cli.rs @@ -177,6 +177,7 @@ pub enum CliCommand { program_id: Pubkey, }, Fees, + FirstAvailableBlock, GetBlockTime { slot: Option, }, @@ -619,6 +620,10 @@ pub fn parse_command( command: CliCommand::Fees, signers: vec![], }), + ("first-available-block", Some(_matches)) => Ok(CliCommandInfo { + command: CliCommand::FirstAvailableBlock, + signers: vec![], + }), ("block-time", Some(matches)) => parse_get_block_time(matches), ("epoch-info", Some(matches)) => parse_get_epoch_info(matches), ("genesis-hash", Some(_matches)) => Ok(CliCommandInfo { @@ -1487,6 +1492,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult { program_id, } => process_create_address_with_seed(config, from_pubkey.as_ref(), &seed, &program_id), CliCommand::Fees => process_fees(&rpc_client, config), + CliCommand::FirstAvailableBlock => process_first_available_block(&rpc_client), CliCommand::GetBlockTime { slot } => process_get_block_time(&rpc_client, config, *slot), CliCommand::GetEpoch => process_get_epoch(&rpc_client, config), CliCommand::GetEpochInfo => process_get_epoch_info(&rpc_client, config), diff --git a/cli/src/cluster_query.rs b/cli/src/cluster_query.rs index 6ed6afd363..d04f492134 100644 --- a/cli/src/cluster_query.rs +++ b/cli/src/cluster_query.rs @@ -91,6 +91,10 @@ impl ClusterQuerySubCommands for App<'_, '_> { .about("Get the version of the cluster entrypoint"), ) .subcommand(SubCommand::with_name("fees").about("Display current cluster fees")) + .subcommand( + SubCommand::with_name("first-available-block") + .about("Get the first available block in the storage"), + ) .subcommand(SubCommand::with_name("block-time") .about("Get estimated production time of a block") .alias("get-block-time") @@ -614,6 +618,11 @@ pub fn process_fees(rpc_client: &RpcClient, config: &CliConfig) -> ProcessResult Ok(config.output_format.formatted_string(&fees)) } +pub fn process_first_available_block(rpc_client: &RpcClient) -> ProcessResult { + let first_available_block = rpc_client.get_first_available_block()?; + Ok(format!("{}", first_available_block)) +} + pub fn process_leader_schedule(rpc_client: &RpcClient) -> ProcessResult { let epoch_info = rpc_client.get_epoch_info()?; let first_slot_in_epoch = epoch_info.absolute_slot - epoch_info.slot_index; diff --git a/client/src/rpc_client.rs b/client/src/rpc_client.rs index 155ed107a6..e4603612bc 100644 --- a/client/src/rpc_client.rs +++ b/client/src/rpc_client.rs @@ -709,6 +709,10 @@ impl RpcClient { .into()) } + pub fn get_first_available_block(&self) -> ClientResult { + self.send(RpcRequest::GetFirstAvailableBlock, Value::Null) + } + pub fn get_genesis_hash(&self) -> ClientResult { let hash_str: String = self.send(RpcRequest::GetGenesisHash, Value::Null)?; let hash = hash_str.parse().map_err(|_| { diff --git a/client/src/rpc_request.rs b/client/src/rpc_request.rs index 97019577ef..7bf60294e5 100644 --- a/client/src/rpc_request.rs +++ b/client/src/rpc_request.rs @@ -21,6 +21,7 @@ pub enum RpcRequest { GetFeeCalculatorForBlockhash, GetFeeRateGovernor, GetFees, + GetFirstAvailableBlock, GetGenesisHash, GetIdentity, GetInflationGovernor, @@ -74,6 +75,7 @@ impl fmt::Display for RpcRequest { RpcRequest::GetFeeCalculatorForBlockhash => "getFeeCalculatorForBlockhash", RpcRequest::GetFeeRateGovernor => "getFeeRateGovernor", RpcRequest::GetFees => "getFees", + RpcRequest::GetFirstAvailableBlock => "getFirstAvailableBlock", RpcRequest::GetGenesisHash => "getGenesisHash", RpcRequest::GetIdentity => "getIdentity", RpcRequest::GetInflationGovernor => "getInflationGovernor",