Skip to content

Commit

Permalink
implement Send + Sync for Error
Browse files Browse the repository at this point in the history
  • Loading branch information
CalebEverett committed Feb 15, 2022
2 parents 99af64c + 53acc35 commit d238c70
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "arloader"
authors = ["calebeverett <caleb@calebeverett.io>"]
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"
Expand Down Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<LOG_DIR>` 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 <LOG_DIR>
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
23 changes: 23 additions & 0 deletions examples/error_send.rs
Original file line number Diff line number Diff line change
@@ -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(())
}
3 changes: 3 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -879,10 +879,10 @@ where
fn is_valid_reward_multiplier(reward_mult: String) -> Result<(), String> {
match reward_mult.parse::<f32>() {
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.")),
Expand Down

0 comments on commit d238c70

Please sign in to comment.