-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(autonomi): add docs; expose types; local
Use `local` if feature is enabled
- Loading branch information
Showing
9 changed files
with
100 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use autonomi::{Bytes, Client, Metadata, PrivateArchive}; | ||
use test_utils::evm::get_funded_wallet; | ||
use tracing_subscriber::{fmt, layer::SubscriberExt, util::SubscriberInitExt, EnvFilter}; | ||
|
||
#[tokio::main] | ||
async fn main() -> eyre::Result<()> { | ||
tracing_subscriber::registry() | ||
.with(fmt::layer()) | ||
.with(EnvFilter::from_env("RUST_LOG")) | ||
.init(); | ||
|
||
let client = Client::init().await?; | ||
let wallet = get_funded_wallet(); | ||
|
||
// Upload 10MiB of random data and verify it by fetching it back. | ||
let data = Bytes::from("Hello, World!"); | ||
let data_map = client.data_put(data.clone(), (&wallet).into()).await?; | ||
let data_fetched = client.data_get(data_map.clone()).await?; | ||
assert_eq!(data, data_fetched); | ||
|
||
// Upload the data as part of an archive, giving it the name `test.txt`. | ||
let mut archive = PrivateArchive::new(); | ||
archive.add_file( | ||
"test.txt".into(), | ||
data_map, | ||
Metadata::new_with_size(data.len() as u64), | ||
); | ||
|
||
// Upload the archive to the network. | ||
let archive_data_map = client.archive_put(&archive, (&wallet).into()).await?; | ||
let archive_fetched = client.archive_get(archive_data_map).await?; | ||
assert_eq!(archive, archive_fetched); | ||
|
||
println!("Archive uploaded successfully"); | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters