0.1.0 |
|
---|
#12 in #arweave
1MB
2.5K SLoC
arload
用于将文件上传到Arweave的命令行应用程序和库。
使用方法
-
获取Arweave钱包json文件并购买AR代币。
-
安装
git clone [email protected]:CalebEverett/arload.git
cd arload
cargo build
- 估算存储文件的成本
cargo run estimate "tests/fixtures/*.png"
The price to upload 10 files with 18265 total bytes is 9071040 winstons ($0.00045219137).
- 检查您的钱包余额
cargo run wallet-balance
Wallet balance is 1549658342531 winstons ($49.82). At the current price of 444274406 winstons ($0.0221) per MB, you can upload 3488 MB of data.
- 上传您的文件,指定一个
log_dir
来写入状态,以便您稍后检查。请确保将路径用引号括起来,以避免您的shell将其展开为文件列表。
cargo run upload "tests/fixtures/[1-5]*.png" --log-dir target/tmp/
path id status confirms
-------------------------------------------------------------------------------------------------
tests/fixtures/1.png s0BdmZ6KDfvjWojSr-BW7RnEcJaC44yNboQsL4V4o2c Submitted 0
tests/fixtures/2.png jLBrbCm5gGpxomIFh0GBCxxYkelF-CPaxbxy8hUW2kE Submitted 0
tests/fixtures/3.png rgudrIf_hVF_VRz3-el9-kVaki8U4OEfxTEYEoZ6eME Submitted 0
tests/fixtures/4.png GK6FieopUSDQ7MLPJ1GvoO9227BhdcY8c0AewPF_ZhY Submitted 0
tests/fixtures/5.png Frj44HRVdfvz98x7zR63sTkVLa7I159HI6IsphLHhQc Submitted 0
Uploaded 5 files. Run `update-status "tests/fixtures/[1-5]*.png" --log-dir target/tmp/` to confirm transaction(s).
上传是异步的,并使用流,尽管默认的缓冲区大小为1。要增加缓冲区大小,请传递带有大小的标志--buffer
。
- 根据网络流量和矿工将它们添加到区块链所需的时间,您的交易可能不会立即写入。要检查您的交易状态,请运行
cargo run update-status "tests/fixtures/[1-5]*.png" --log-dir target/tmp/
path id status confirms
-------------------------------------------------------------------------------------------------
tests/fixtures/1.png s0BdmZ6KDfvjWojSr-BW7RnEcJaC44yNboQsL4V4o2c Confirmed 3
tests/fixtures/2.png jLBrbCm5gGpxomIFh0GBCxxYkelF-CPaxbxy8hUW2kE Confirmed 2
tests/fixtures/3.png rgudrIf_hVF_VRz3-el9-kVaki8U4OEfxTEYEoZ6eME Confirmed 1
tests/fixtures/4.png GK6FieopUSDQ7MLPJ1GvoO9227BhdcY8c0AewPF_ZhY Confirmed 1
tests/fixtures/5.png Frj44HRVdfvz98x7zR63sTkVLa7I159HI6IsphLHhQc Confirmed 1
- 要获取上传状态的摘要报告,请运行
cargo run status-report "tests/fixtures/[1-5]*.png" --log-dir target/tmp/
status count
-----------------------------
Submitted 0
Pending 0
NotFound 0
Confirmed 5
-----------------------------
Total 5
- 如果您想确定任何上传交易是否失败 - 您可以通过状态和确认次数过滤您文件的文件状态。
cargo run list-status "tests/fixtures/[1-5]*.png" --log-dir target/tmp/ --min-confirms 7
path id status confirms
-------------------------------------------------------------------------------------------------
tests/fixtures/3.png rgudrIf_hVF_VRz3-el9-kVaki8U4OEfxTEYEoZ6eME Confirmed 6
tests/fixtures/4.png GK6FieopUSDQ7MLPJ1GvoO9227BhdcY8c0AewPF_ZhY Confirmed 6
tests/fixtures/5.png Frj44HRVdfvz98x7zR63sTkVLa7I159HI6IsphLHhQc Confirmed 6
Found 3 files matching filter criteria.
- 如果您想重新上传一些文件,您可以运行
cargo run upload-filter "tests/fixtures/[1-5]*.png" --log-dir target/tmp/ --min-confirms 7 --buffer 3
使用与上面相同的过滤标准。
path id status confirms
-------------------------------------------------------------------------------------------------
tests/fixtures/4.png NaB-1fZzzu1ntIe7APxhXZQlmEWz6PDi3oKkfIqYsLg Submitted 0
tests/fixtures/3.png MUaEgj2qzrRfIEgRXyJJFw-ilKk7YvTVqBMnT6K7kaM Submitted 0
tests/fixtures/5.png NLkmVtUAsphbmjNYMWTMMbZ7Kd6l40Fsj4MagKDkgRA Submitted 0
Uploaded 3 files. Run `update-statuses` to confirm acceptance.
and then if you run
cargo run update-status "tests/fixtures/[1-5]*.png" --log-dir target/tmp/
you can see that your files have been re-uploaded.
path id status confirms
-------------------------------------------------------------------------------------------------
tests/fixtures/1.png s0BdmZ6KDfvjWojSr-BW7RnEcJaC44yNboQsL4V4o2c Confirmed 14
tests/fixtures/2.png jLBrbCm5gGpxomIFh0GBCxxYkelF-CPaxbxy8hUW2kE Confirmed 14
tests/fixtures/3.png cA2ZrJSzEH4dJWQgTIrk7uVd9WSXPJTDBsONWk779No Pending 0
tests/fixtures/4.png OTSp9uxU02ZlTDnSuZT70CzFl1VCN5bveW2-W7hrUZ0 Pending 0
tests/fixtures/5.png nWChdcmmIBLYHAjD90IuRVEsd3D3-WzUaknskK9f790 Pending 0
Updated 5 statuses.
- 如果您想获取所有上传的交易ID,状态对象将写入到
log_dir
中的json文件,或者您可以通过传递json
到output flag
来获取json输出。
cargo run list-status "tests/fixtures/[1-5]*.png" --log-dir target/tmp/ --output json
{
"id": "s0BdmZ6KDfvjWojSr-BW7RnEcJaC44yNboQsL4V4o2c",
"status": "Confirmed",
"file_path": "tests/fixtures/1.png",
"created_at": "2021-10-31T08:22:48.026149300Z",
"last_modified": "2021-10-31T09:00:56.406929800Z",
"reward": 2150860,
"block_height": 801254,
"block_indep_hash": "QixYntgtTrp83jB97bxyJEKsihZnIACZ7mowGmTxRPbqUXuCHMhM9YywwX5Y6rpO",
"number_of_confirmations": 14
},
{
"id": "jLBrbCm5gGpxomIFh0GBCxxYkelF-CPaxbxy8hUW2kE",
"status": "Confirmed",
"file_path": "tests/fixtures/2.png",
"created_at": "2021-10-31T08:22:50.477367700Z",
"last_modified": "2021-10-31T09:00:57.849300500Z",
"reward": 2150860,
"block_height": 801255,
"block_indep_hash": "4qPA3zuROGZ6HKkjf7YtUJxyEBJaUMnZQojCSknuGg8g5bgs6aZGJUSXEp-maSyT",
"number_of_confirmations": 14
},
{
"id": "cA2ZrJSzEH4dJWQgTIrk7uVd9WSXPJTDBsONWk779No",
"status": "Pending",
"file_path": "tests/fixtures/3.png",
"created_at": "2021-10-31T09:00:43.362172200Z",
"last_modified": "2021-10-31T09:00:59.089684200Z",
"reward": 2150860
},
请注意,list-status
命令只是从磁盘读取状态。您需要运行update-status
来从网络获取它们。
依赖项
~16–32MB
~578K SLoC