pub async fn command_upload_bundles_with_sol(
    arweave: &Arweave,
    glob_str: &str,
    log_dir: Option<String>,
    tags: Option<Vec<Tag<String>>>,
    bundle_size: u64,
    reward_mult: f32,
    output_format: Option<&str>,
    buffer: usize,
    sol_keypair_path: &str,
) -> CommandResult {
    let paths_iter = glob(glob_str)?.filter_map(Result::ok);
    let log_dir = log_dir.map(|s| PathBuf::from(s)).unwrap();
    let output_format = get_output_format(output_format.unwrap_or(""));
    let tags = tags.unwrap_or(Vec::new());
    let price_terms = arweave.get_price_terms(reward_mult).await?;
    let path_chunks = arweave.chunk_file_paths(paths_iter, bundle_size)?;
    let solana_url = "https://api.mainnet-beta.solana.com/".parse::<Url>()?;
    let sol_ar_url = SOL_AR_BASE_URL.parse::<Url>()?.join("sol")?;
    let from_keypair = keypair::read_keypair_file(sol_keypair_path)?;

    if path_chunks.len() == 0 {
        println!("The pattern \"{}\" didn't match any files.", glob_str);
        return Ok(());
    } else {
        let mut stream = upload_bundles_stream_with_sol(
            arweave,
            path_chunks,
            tags,
            price_terms,
            buffer,
            solana_url,
            sol_ar_url,
            &from_keypair,
        );

        let mut counter = 0;
        let mut number_of_files = 0;
        let mut data_size = 0;
        while let Some(result) = stream.next().await {
            match result {
                Ok(status) => {
                    number_of_files += status.number_of_files;
                    data_size += status.data_size;
                    if counter == 0 {
                        println!("{}", status.header_string(&output_format));
                    }
                    print!("{}", output_format.formatted_string(&status));
                    fs::write(
                        log_dir.join(status.id.to_string()).with_extension("json"),
                        serde_json::to_string(&status)?,
                    )
                    .await?;
                    counter += 1;
                }
                Err(e) => println!("{:#?}", e),
            }
        }

        println!(
            "\nUploaded {} KB in {} files in {} bundle transaction(s). Run `arloader update-status --log-dir \"{}\"` to update statuses.",
            data_size / 1000,
            number_of_files,
            counter,
            log_dir.display().to_string()
        );
    }
    Ok(())
}
/// Uploads bundles created from provided glob to Arweave, paying with SOL.
Uploads bundles created from provided glob to Arweave, paying with SOL.
Uploads bundles created from provided glob to Arweave paying with SOL .
pub async fn command_upload_bundles_with_sol(
    arweave: &Arweave,
    glob_str: &str,
    log_dir: Option<String>,
    tags: Option<Vec<Tag<String>>>,
    bundle_size: u64,
    reward_mult: f32,
    output_format: Option<&str>,
    buffer: usize,
    sol_keypair_path: &str,
) -> CommandResult {
    let paths_iter = glob(glob_str)?.filter_map(Result::ok);
    let log_dir = log_dir.map(|s| PathBuf::from(s)).unwrap();
    let output_format = get_output_format(output_format.unwrap_or(""));
    let tags = tags.unwrap_or(Vec::new());
    let price_terms = arweave.get_price_terms(reward_mult).await?;
    let path_chunks = arweave.chunk_file_paths(paths_iter, bundle_size)?;
    let solana_url = "https://api.mainnet-beta.solana.com/".parse::<Url>()?;
    let sol_ar_url = SOL_AR_BASE_URL.parse::<Url>()?.join("sol")?;
    let from_keypair = keypair::read_keypair_file(sol_keypair_path)?;
    if path_chunks.len() == 0 {
        println!("The pattern \"{}\" didn't match any files.", glob_str);
        return Ok(());
    } else {
        let mut stream = upload_bundles_stream_with_sol(
            arweave,
            path_chunks,
            tags,
            price_terms,
            buffer,
            solana_url,
            sol_ar_url,
            &from_keypair,
        );
        let mut counter = 0;
        let mut number_of_files = 0;
        let mut data_size = 0;
        while let Some(result) = stream.next().await {
            match result {
                Ok(status) => {
                    number_of_files += status.number_of_files;
                    data_size += status.data_size;
                    if counter == 0 {
                        println!("{}", status.header_string(&output_format));
                    }
                    print!("{}", output_format.formatted_string(&status));
                    fs::write(
                        log_dir.join(status.id.to_string()).with_extension("json"),
                        serde_json::to_string(&status)?,
                    )
                    .await?;
                    counter += 1;
                }
                Err(e) => println!("{:#?}", e),
            }
        }
        println!(
            "\nUploaded {} KB in {} files in {} bundle transaction(s). Run `arloader update-status --log-dir \"{}\"` to update statuses.",
            data_size / 1000,
            number_of_files,
            counter,
            log_dir.display().to_string()
        );
    }
    Ok(())
}
pub async fn command_upload_bundles_with_sol ( arweave : & Arweave , glob_str : & str , log_dir : Option < String > , tags : Option < Vec < Tag < String > > > , bundle_size : u64 , reward_mult : f32 , output_format : Option < & str > , buffer : usize , sol_keypair_path : & str , ) -> CommandResult { let paths_iter = glob ( glob_str ) ? . filter_map ( Result :: ok ) ; let log_dir = log_dir . map ( | s | PathBuf :: from ( s ) ) . unwrap ( ) ; let output_format = get_output_format ( output_format . unwrap_or ( " " ) ) ; let tags = tags . unwrap_or ( Vec :: new ( ) ) ; let price_terms = arweave . get_price_terms ( reward_mult ) . await ? ; let path_chunks = arweave . chunk_file_paths ( paths_iter , bundle_size ) ? ; let solana_url = " " . parse :: < Url > ( ) ? ; let sol_ar_url = SOL_AR_BASE_URL . parse :: < Url > ( ) ? . join ( " " ) ? ; let from_keypair = keypair :: read_keypair_file ( sol_keypair_path ) ? ; if path_chunks . len ( ) == 0 { println ! ( " \" \" " glob_str ) ; return Ok ( ( ) ) ; } else { let mut stream = upload_bundles_stream_with_sol ( arweave , path_chunks , tags , price_terms , buffer , solana_url , sol_ar_url , & from_keypair , ) ; let mut counter = 0 ; let mut number_of_files = 0 ; let mut data_size = 0 ; while let Some ( result ) = stream . next ( ) . await { match result { Ok ( status ) => { number_of_files += status . number_of_files ; data_size += status . data_size ; if counter == 0 { println ! ( " " status header_string ( output_format ) ) ; } print ! ( " " output_format formatted_string ( status ) ) ; fs :: write ( log_dir . join ( status . id . to_string ( ) ) . with_extension ( " " ) , serde_json :: to_string ( & status ) ? , ) . await ? ; counter += 1 ; } Err ( e ) => println ! ( " " e ) , } } println ! ( " \n \" \" " data_size 1000 number_of_files counter log_dir display ( ) to_string ( ) ) ; } Ok ( ( ) ) }
Uploads bundles created from provided glob to Arweave, paying with SOL.
Uploads bundles created from provided glob to Arweave paying with SOL .
arweave
&Arweave
glob_str
&str
log_dir
Option<String>
tags
Option<Vec<Tag<String>>>
bundle_size
u64
reward_mult
f32
output_format
Option<&str>
buffer
usize
sol_keypair_path
&str
arweave
&Arweave
glob_str
&str
log_dir
Option<String>
tags
Option<Vec<Tag<String>>>
bundle_size
u64
reward_mult
f32
output_format
Option<&str>
buffer
usize
sol_keypair_path
&str