mirror of
https://github.com/fluencelabs/examples
synced 2025-04-26 19:22:19 +00:00
update to marine, marine-test, bump versions
This commit is contained in:
parent
70a32bc46f
commit
1fc1cfffd7
@ -3,13 +3,15 @@ set -o errexit -o nounset -o pipefail
|
|||||||
|
|
||||||
# This script builds all subprojects and puts all created Wasm modules in one dir
|
# This script builds all subprojects and puts all created Wasm modules in one dir
|
||||||
cd effector
|
cd effector
|
||||||
cargo update
|
cargo update --aggressive
|
||||||
fce build --release
|
marine build --release
|
||||||
|
|
||||||
cd ../pure
|
cd ../pure
|
||||||
cargo update
|
cargo update --aggressive
|
||||||
fce build --release
|
marine build --release
|
||||||
|
|
||||||
cd ..
|
cd ..
|
||||||
rm artifacts/*
|
mkdir -p artifacts
|
||||||
cp ../../target/wasm32-wasi/release/ipfs_effector.wasm artifacts/
|
rm -f artifacts/*.wasm
|
||||||
cp ../../target/wasm32-wasi/release/ipfs_pure.wasm artifacts/
|
cp effector/target/wasm32-wasi/release/ipfs_effector.wasm artifacts/
|
||||||
|
cp pure/target/wasm32-wasi/release/ipfs_pure.wasm artifacts/
|
||||||
|
@ -10,5 +10,5 @@ name = "ipfs_effector"
|
|||||||
path = "src/main.rs"
|
path = "src/main.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
fluence = { version = "=0.5.0", features = ["logger"] }
|
fluence = { version = "0.6.9", features = ["logger"] }
|
||||||
log = "0.4.14"
|
log = "0.4.14"
|
@ -20,10 +20,10 @@ mod path;
|
|||||||
|
|
||||||
use crate::path::to_full_path;
|
use crate::path::to_full_path;
|
||||||
|
|
||||||
use fluence::fce;
|
use fluence::marine;
|
||||||
use fluence::module_manifest;
|
use fluence::module_manifest;
|
||||||
use fluence::WasmLoggerBuilder;
|
|
||||||
use fluence::MountedBinaryResult;
|
use fluence::MountedBinaryResult;
|
||||||
|
use fluence::WasmLoggerBuilder;
|
||||||
|
|
||||||
const RESULT_FILE_PATH: &str = "/tmp/ipfs_rpc_file";
|
const RESULT_FILE_PATH: &str = "/tmp/ipfs_rpc_file";
|
||||||
const IPFS_ADDR_ENV_NAME: &str = "IPFS_ADDR";
|
const IPFS_ADDR_ENV_NAME: &str = "IPFS_ADDR";
|
||||||
@ -39,7 +39,7 @@ pub fn main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Put file from specified path to IPFS and return its hash.
|
/// Put file from specified path to IPFS and return its hash.
|
||||||
#[fce]
|
#[marine]
|
||||||
pub fn put(file_path: String) -> String {
|
pub fn put(file_path: String) -> String {
|
||||||
log::info!("put called with file path {}", file_path);
|
log::info!("put called with file path {}", file_path);
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ pub fn put(file_path: String) -> String {
|
|||||||
file_path,
|
file_path,
|
||||||
];
|
];
|
||||||
|
|
||||||
let ipfs_result = unsafe { ipfs(cmd) };
|
let ipfs_result = ipfs(cmd);
|
||||||
ipfs_result
|
ipfs_result
|
||||||
.into_std()
|
.into_std()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
@ -62,7 +62,7 @@ pub fn put(file_path: String) -> String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Get file by provided hash from IPFS, saves it to a temporary file and returns a path to it.
|
/// Get file by provided hash from IPFS, saves it to a temporary file and returns a path to it.
|
||||||
#[fce]
|
#[marine]
|
||||||
pub fn get(hash: String) -> String {
|
pub fn get(hash: String) -> String {
|
||||||
log::info!("get called with hash {}", hash);
|
log::info!("get called with hash {}", hash);
|
||||||
|
|
||||||
@ -78,11 +78,11 @@ pub fn get(hash: String) -> String {
|
|||||||
hash,
|
hash,
|
||||||
];
|
];
|
||||||
|
|
||||||
unsafe { ipfs(cmd) };
|
ipfs(cmd);
|
||||||
RESULT_FILE_PATH.to_string()
|
RESULT_FILE_PATH.to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[fce]
|
#[marine]
|
||||||
pub fn get_address() -> String {
|
pub fn get_address() -> String {
|
||||||
match std::env::var(IPFS_ADDR_ENV_NAME) {
|
match std::env::var(IPFS_ADDR_ENV_NAME) {
|
||||||
Ok(addr) => addr,
|
Ok(addr) => addr,
|
||||||
@ -93,7 +93,7 @@ pub fn get_address() -> String {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[fce]
|
#[marine]
|
||||||
#[link(wasm_import_module = "host")]
|
#[link(wasm_import_module = "host")]
|
||||||
extern "C" {
|
extern "C" {
|
||||||
/// Execute provided cmd as a parameters of ipfs cli, return result.
|
/// Execute provided cmd as a parameters of ipfs cli, return result.
|
||||||
|
@ -18,8 +18,8 @@ pub(super) fn to_full_path<S>(cmd: S) -> String
|
|||||||
where
|
where
|
||||||
S: Into<String>,
|
S: Into<String>,
|
||||||
{
|
{
|
||||||
use std::path::Path;
|
|
||||||
use std::path::Component;
|
use std::path::Component;
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
let cmd = cmd.into();
|
let cmd = cmd.into();
|
||||||
let path = Path::new(&cmd);
|
let path = Path::new(&cmd);
|
||||||
|
@ -10,5 +10,5 @@ name = "ipfs_pure"
|
|||||||
path = "src/main.rs"
|
path = "src/main.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
fluence = { version = "=0.5.0", features = ["logger"] }
|
fluence = { version = "0.6.9", features = ["logger"] }
|
||||||
log = "0.4.14"
|
log = "0.4.14"
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
#![allow(improper_ctypes)]
|
#![allow(improper_ctypes)]
|
||||||
|
|
||||||
use fluence::fce;
|
use fluence::marine;
|
||||||
use fluence::module_manifest;
|
use fluence::module_manifest;
|
||||||
use fluence::WasmLoggerBuilder;
|
use fluence::WasmLoggerBuilder;
|
||||||
|
|
||||||
@ -34,12 +34,12 @@ pub fn main() {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[fce]
|
#[marine]
|
||||||
pub fn invoke() -> String {
|
pub fn invoke() -> String {
|
||||||
"IPFS_RPC wasm example, it allows to:\ninvoke\nput\nget".to_string()
|
"IPFS_RPC wasm example, it allows to:\ninvoke\nput\nget".to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[fce]
|
#[marine]
|
||||||
pub fn put(file_content: Vec<u8>) -> String {
|
pub fn put(file_content: Vec<u8>) -> String {
|
||||||
log::info!("put called with {:?}", file_content);
|
log::info!("put called with {:?}", file_content);
|
||||||
|
|
||||||
@ -50,18 +50,18 @@ pub fn put(file_content: Vec<u8>) -> String {
|
|||||||
return format!("file can't be written: {}", e);
|
return format!("file can't be written: {}", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe { ipfs_put(rpc_tmp_filepath) }
|
ipfs_put(rpc_tmp_filepath)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[fce]
|
#[marine]
|
||||||
pub fn get(hash: String) -> Vec<u8> {
|
pub fn get(hash: String) -> Vec<u8> {
|
||||||
log::info!("get called with hash: {}", hash);
|
log::info!("get called with hash: {}", hash);
|
||||||
|
|
||||||
let file_path = unsafe { ipfs_get(hash) };
|
let file_path = ipfs_get(hash);
|
||||||
fs::read(file_path).unwrap_or_else(|_| b"error while reading file".to_vec())
|
fs::read(file_path).unwrap_or_else(|_| b"error while reading file".to_vec())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[fce]
|
#[marine]
|
||||||
#[link(wasm_import_module = "ipfs_effector")]
|
#[link(wasm_import_module = "ipfs_effector")]
|
||||||
extern "C" {
|
extern "C" {
|
||||||
/// Put provided file to ipfs, return ipfs hash of the file.
|
/// Put provided file to ipfs, return ipfs hash of the file.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user