Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions cli/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use anyhow::Result;
use clap::{Parser, Subcommand};
use solana_client::nonblocking::rpc_client::RpcClient;
use solana_sdk::commitment_config::CommitmentConfig;
use solana_sdk::commitment_config::{CommitmentConfig, CommitmentLevel};
use solana_sdk::signature::Keypair;
use tape_network::store::TapeStore;
use std::env;
Expand All @@ -26,18 +26,34 @@ pub struct Cli {
pub keypair_path: Option<PathBuf>,

#[arg(
short = 'u',
long = "cluster",
default_value = "l",
short = 'u',
long = "cluster",
default_value = "l",
global = true,
help = "Cluster to use: l (localnet), m (mainnet), d (devnet), t (testnet),\n or a custom RPC URL"
)]
pub cluster: Cluster,

#[arg(short = 'v', long = "verbose", help = "Print verbose output", global = true)]
pub verbose: bool,

#[arg(
long = "commitment",
default_value = "finalized",
global = true,
)]
pub commitment: CommitmentLevel
}
impl Cli {
pub fn commitment_time(&self)-> u64 {
match self.commitment {
CommitmentLevel::Confirmed => 32,
CommitmentLevel::Finalized => 16,
CommitmentLevel::Processed => 8,
}
}

}
#[derive(Subcommand)]
pub enum Commands {

Expand Down Expand Up @@ -249,11 +265,11 @@ impl Context{
let rpc_url = cli.cluster.rpc_url();
let rpc = Arc::new(
RpcClient::new_with_commitment(rpc_url.clone(),
CommitmentConfig::finalized())
CommitmentConfig { commitment: cli.commitment.clone() })
);
let keypair_path = get_keypair_path(cli.keypair_path.clone());
let payer = get_payer(keypair_path.clone())?;

Ok(Self {
rpc,
keypair_path,
Expand Down
3 changes: 1 addition & 2 deletions cli/src/commands/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ pub async fn handle_write_command(cli: Cli, context: Context) -> Result<()> {
write_chunks(&rpc, &payer, tape_address, writer_address, chunks, &pb).await?;

pb.set_message("finalizing tape...");
tokio::time::sleep(Duration::from_secs(32)).await;
tokio::time::sleep(Duration::from_secs(cli.commitment_time())).await;

set_header(&rpc, &payer, tape_address, header).await?;
subsidize_tape(&rpc, &payer, tape_address, payer_ata, required_rent).await?;
Expand Down Expand Up @@ -291,4 +291,3 @@ fn read_from_stdin() -> std::io::Result<Vec<u8>> {
std::io::stdin().read_to_end(&mut buffer)?;
Ok(buffer)
}