marine/examples/ipfs_node/src/main.rs

53 lines
1.5 KiB
Rust
Raw Normal View History

2020-06-06 18:34:13 +00:00
/*
* Copyright 2020 Fluence Labs Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
2020-06-11 21:05:04 +00:00
#![feature(pattern)]
2020-06-06 18:34:13 +00:00
mod node;
mod errors;
mod config;
mod imports;
2020-06-10 13:55:18 +00:00
mod node_public_interface;
2020-06-06 18:34:13 +00:00
2020-06-10 15:00:07 +00:00
use fce::IValue;
2020-06-06 18:34:13 +00:00
use node::IpfsNode;
use std::path::PathBuf;
const IPFS_MODULES_DIR: &str = "/Users/mike/dev/work/fluence/wasm/fce/bin/wasm_modules";
const IPFS_MODULES_CONFIG_PATH: &str =
"/Users/mike/dev/work/fluence/wasm/fce/examples/ipfs_node/Config.toml";
2020-06-11 00:10:37 +00:00
const IPFS_RPC: &str = "/Users/mike/dev/work/fluence/wasm/fce/bin/wasm_ipfs_rpc_wit.wasi.wasm";
2020-06-06 18:34:13 +00:00
fn main() {
let ipfs_rpc = std::fs::read(IPFS_RPC).unwrap();
2020-06-10 15:00:07 +00:00
let mut ipfs_node = IpfsNode::new(
2020-06-06 18:34:13 +00:00
PathBuf::from(IPFS_MODULES_DIR),
PathBuf::from(IPFS_MODULES_CONFIG_PATH),
)
.unwrap();
2020-06-10 15:00:07 +00:00
println!("ipfs node interface is\n{}", ipfs_node.get_interface());
2020-06-10 13:55:18 +00:00
2020-06-10 15:00:07 +00:00
let result = ipfs_node
2020-06-11 21:05:04 +00:00
.rpc_call(&ipfs_rpc, "put", &[IValue::String("QmdHsYnAvbrvXg3iwr6bLaqooVT31E8CMpZRWc9wX2Fbt8".to_string())])
2020-06-10 15:00:07 +00:00
.unwrap();
2020-06-06 18:34:13 +00:00
println!("execution result {:?}", result);
}