From 53acc358fa6da34df92f4463b274a4fb349434f2 Mon Sep 17 00:00:00 2001 From: Caleb Date: Tue, 15 Feb 2022 12:41:19 -0800 Subject: [PATCH] implement Send and Sync for Error --- CHANGELOG.md | 4 ++++ Cargo.toml | 4 ++-- README.md | 6 +++--- examples/error_send.rs | 23 +++++++++++++++++++++++ src/error.rs | 3 +++ src/main.rs | 4 ++-- 6 files changed, 37 insertions(+), 7 deletions(-) create mode 100644 examples/error_send.rs diff --git a/CHANGELOG.md b/CHANGELOG.md index 486e6c8..e43cd25 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes starting with v0.1.34 to this project will be documented in The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +# v0.1.57 (2022-02-07) +- **changed:** reduced max `--reward-multiplier` from 10.0 to 3.0 since Arweave transactions seemed to fail for overspend greater than that. +- **added:** implemented `Send` and `Sync` for `Error` and [error_send](examples/error_send.rs) example. + # v0.1.56 (2022-02-07) - **changed:** increase default bundle size to 100 MB to reduce number of tx and use `chunk/` endpoint instead of `tx/` endpoint used for bundles 10 MB or less. - **changed:** post transactions in chunks when uploading files greater than 10 MB to allow individual files of unlimited size to be uploaded. diff --git a/Cargo.toml b/Cargo.toml index 11a3a23..fb92e1e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "arloader" authors = ["calebeverett "] description = "Command line application and library for uploading files to Arweave." -version = "0.1.56" +version = "0.1.57" edition = "2021" license = "Apache-2.0" repository = "https://github.com/CalebEverett/arloader" @@ -31,7 +31,7 @@ dirs-next = "2.0.0" env_logger = "0.9.0" futures = "0.3.17" glob = "0.3.0" -infer = { version = "0.6.0", default-features = false } +infer = { version = "0.7.0", default-features = false } jsonwebkey = { version = "0.3.4", features = [ "pkcs-convert" ] } log = "0.4.14" matches = "0.1.9" diff --git a/README.md b/README.md index a45c1ea..7b4f745 100644 --- a/README.md +++ b/README.md @@ -137,7 +137,7 @@ If you are creating your NFTs with the [Metaplex Candy Machine](https://docs.met Before you create your tokens, make sure that all of your transactions have been confirmed at least 25 times. Run the command below where `` refers to the automatically created directory in your assets folder that begins with `arloader_`. -The primary reason for transactions having a status of `NotFound` is that they were rejected by miners for not having a big enough reward. See [Reward Multiplier](#reward-multiplier) for instructions on increasing the reward by passing the optional `--reward-multiplier` argument. +The primary reason for transactions having a status of `NotFound` is that they were rejected by miners for not having a big enough reward or for having to big of a reward. See [Reward Multiplier](#reward-multiplier) for instructions on increasing the reward by passing the optional `--reward-multiplier` argument. ``` arloader update-nft-status @@ -178,7 +178,7 @@ Updating metadata manifest status... If you're uploading more than one file, you should pretty much always be using bundles. Bundles take multiple files and packages them together in a single transaction. This is better than uploading multiple individual files because you only have to wait for one transaction to be confirmed. Once the bundle transaction is confirmed, all of your files will be available. Larger transactions with larger rewards are more attractive to miners, which means a larger bundled transaction is more likely to get written quickly than a bunch of smaller individual ones. -Arloader will create as many bundles as necessary to upload all of your files. Your files are read asynchronously, bundled in parallel across multiple threads and then posted to [arweave.net](https://arweave.net). Arloader supports bundle sizes up to 200 MB, with a default of 10 MB, which makes it possible to post full bundle size payloads to the `/tx` endpoint instead of in 256 KB chunks to the `/chunk` endpoint. This should work fine for individual files up to 100 MB. If your files sizes are bigger than 100 MB (but smaller than 200 MB), you can specify a larger bundle size with the `--bundles-size` argument - `--bundle-size 200` to specify a size of 200 MB, for example. If you file sizes are bigger than 200 MB, you can upload them as individual files by passing the `--no-bundle` flag. +Arloader will create as many bundles as necessary to upload all of your files. Your files are read asynchronously, bundled in parallel across multiple threads and then posted to [arweave.net](https://arweave.net). Arloader supports bundle sizes up to 200 MB, with a default of 100 MB. This should work fine for individual files up to 100 MB. If your files sizes are bigger than 100 MB (but smaller than 200 MB), you can specify a larger bundle size with the `--bundles-size` argument - `--bundle-size 200` to specify a size of 200 MB, for example. If your file sizes are bigger than 200 MB, you can upload them as individual files by passing the `--no-bundle` flag. ### Estimate Cost To get an estimate of the cost of uploading your files run @@ -359,7 +359,7 @@ and that will print the number of pending transactions every second for one minu 128 | ▥▥▥ ``` -Given that Arloader bundles by default, your transaction is hopefully relatively attractive and you don't need to increase the reward to get it written in a timely fashion. However, if you see that there are a lot of transactions pending and you want to be sure your transaction goes through quickly, you can adjust the reward with `--reward-multiplier` followed by something tha can be parsed as a float between `0.0` and `10.0`. The reward included in your transaction will then be multiplied by this factor when it gets submitted. Similar to the `--with-sol` flag, you can add `--reward-multiplier` to both `estimate` and `upload` commands. +Given that Arloader bundles by default, your transaction is hopefully relatively attractive and you don't need to increase the reward to get it written in a timely fashion. However, if you see that there are a lot of transactions pending and you want to be sure your transaction goes through quickly, you can adjust the reward with `--reward-multiplier` followed by something tha can be parsed as a float between `0.0` and `3.0`. The reward included in your transaction will then be multiplied by this factor when it gets submitted. Similar to the `--with-sol` flag, you can add `--reward-multiplier` to both `estimate` and `upload` commands. ## Usage without Bundles diff --git a/examples/error_send.rs b/examples/error_send.rs new file mode 100644 index 0000000..0972dc6 --- /dev/null +++ b/examples/error_send.rs @@ -0,0 +1,23 @@ +use arloader::{commands::CommandResult, Arweave}; +use std::sync::Arc; + +#[tokio::main] +async fn main() -> CommandResult { + let arweave = Arc::new(Arweave::default()); + + let mut price_futures = Vec::new(); + for m in 2..6 { + let arweave = arweave.clone(); + + price_futures.push(tokio::task::spawn(async move { + arweave.get_price_terms(m as f32).await + })); + } + + let results = futures::future::join_all(price_futures).await; + for result in results { + println!("{:?}", result.unwrap()) + } + + Ok(()) +} diff --git a/src/error.rs b/src/error.rs index b6487d9..7eaf914 100644 --- a/src/error.rs +++ b/src/error.rs @@ -74,3 +74,6 @@ pub enum Error { #[error("url parse error: {0}")] UrlParse(#[from] ParseError), } + +unsafe impl Send for Error {} +unsafe impl Sync for Error {} diff --git a/src/main.rs b/src/main.rs index a7c43e0..46b4234 100644 --- a/src/main.rs +++ b/src/main.rs @@ -879,10 +879,10 @@ where fn is_valid_reward_multiplier(reward_mult: String) -> Result<(), String> { match reward_mult.parse::() { Ok(n) => { - if n > 0. && n <= 10. { + if n > 0. && n <= 3. { Ok(()) } else { - Err(format!("Multiplier must be a float between 0 and 10.")) + Err(format!("Multiplier must be a float between 0 and 3.")) } } Err(_) => Err(format!("Not a valid multiplier.")),