diff --git a/examples/ipfs_node/Config.toml b/examples/ipfs_node/Config.toml index 360b739c..8d6aa637 100644 --- a/examples/ipfs_node/Config.toml +++ b/examples/ipfs_node/Config.toml @@ -10,7 +10,7 @@ core_modules_dir = "wasm/artifacts/wasm_modules" ipfs = "/usr/local/bin/ipfs" [core_module.wasi] - envs = ["IPFS_ADDR=/dns4/relay02.fluence.dev/tcp/15001"] + envs = ["IPFS_ADDR=/dns4/relay02.fluence.dev/tcp/15001", "timeout=1s"] preopened_files = ["./wasm/artifacts"] mapped_dirs = { "tmp" = "./wasm/artifacts" } diff --git a/examples/ipfs_node/wasm/artifacts/wasm_modules/ipfs_node.wasm b/examples/ipfs_node/wasm/artifacts/wasm_modules/ipfs_node.wasm index 6028f984..91747eea 100644 Binary files a/examples/ipfs_node/wasm/artifacts/wasm_modules/ipfs_node.wasm and b/examples/ipfs_node/wasm/artifacts/wasm_modules/ipfs_node.wasm differ diff --git a/examples/ipfs_node/wasm/ipfs_node/src/main.rs b/examples/ipfs_node/wasm/ipfs_node/src/main.rs index bc421c1d..53672827 100644 --- a/examples/ipfs_node/wasm/ipfs_node/src/main.rs +++ b/examples/ipfs_node/wasm/ipfs_node/src/main.rs @@ -25,6 +25,7 @@ use crate::path::to_full_path; const RESULT_FILE_PATH: &str = "/tmp/ipfs_rpc_file"; const IPFS_ADDR_ENV_NAME: &str = "IPFS_ADDR"; +const TIMEOUT_ENV_NAME: &str = "timeout"; pub fn main() { let msg = "ipfs_node.main: WASI initialization finished"; @@ -42,7 +43,8 @@ pub unsafe fn put(file_path_ptr: *mut u8, file_path_size: usize) { let file_path = to_full_path(file_path); - let cmd = format!("add -Q {}", file_path); + let timeout = std::env::var(TIMEOUT_ENV_NAME).unwrap_or_else(|_| "1s".to_string()); + let cmd = format!("add --timeout {} -Q {}", timeout, file_path); let result = ipfs(cmd.as_ptr() as _, cmd.len() as _); let hash = if result == 0 { @@ -72,7 +74,11 @@ pub unsafe fn get(hash_ptr: *mut u8, hash_size: usize) { let result_file_path = to_full_path(RESULT_FILE_PATH); - let cmd = format!("get -o {} {}", result_file_path, hash); + let timeout = std::env::var(TIMEOUT_ENV_NAME).unwrap_or_else(|_| "1s".to_string()); + let cmd = format!( + "get --timeout {} -o {} {}", + timeout, result_file_path, hash + ); let _result = ipfs(cmd.as_ptr() as _, cmd.len() as _); let _output = String::from_raw_parts( diff --git a/examples/ipfs_node/wasm/ipfs_node/src/path.rs b/examples/ipfs_node/wasm/ipfs_node/src/path.rs index fcecf042..60453c25 100644 --- a/examples/ipfs_node/wasm/ipfs_node/src/path.rs +++ b/examples/ipfs_node/wasm/ipfs_node/src/path.rs @@ -41,6 +41,7 @@ where let mut full_path = std::path::PathBuf::from(to_dir); // TODO: optimize this + #[warn(clippy::while_let_on_iterator)] while let Some(component) = components.next() { full_path.push(component); }