little fixes

This commit is contained in:
vms 2020-09-30 22:15:30 +03:00
parent 4100c986c7
commit 86c691bd4a
6 changed files with 12 additions and 7 deletions

View File

@ -9,3 +9,6 @@ modules_dir = "./target/wasm32-wasi/release/"
name = "aquamarine" name = "aquamarine"
mem_pages_count = 100 mem_pages_count = 100
logger_enabled = true logger_enabled = true
[module.wasi]
envs = ["CURRENT_PEER_ID=asd"]

View File

@ -50,11 +50,12 @@ pub enum FunctionPart {
} }
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq)] #[derive(Serialize, Deserialize, Debug, PartialEq, Eq)]
#[serde(rename_all = "kebab-case")]
pub(crate) struct Call(PeerPart, FunctionPart, Vec<String>, String); pub(crate) struct Call(PeerPart, FunctionPart, Vec<String>, String);
impl super::ExecutableInstruction for Call { impl super::ExecutableInstruction for Call {
fn execute(self, data: &mut AquaData, next_peer_pks: &mut Vec<String>) -> Result<()> { fn execute(self, data: &mut AquaData, next_peer_pks: &mut Vec<String>) -> Result<()> {
log::info!("call called with data: {:?} and next_peer_pks: {:?}", data, next_peer_pks);
let (peer_pk, service_id, func_name) = parse_peer_fn_parts(self.0, self.1)?; let (peer_pk, service_id, func_name) = parse_peer_fn_parts(self.0, self.1)?;
let function_args = parse_args(self.2, data)?; let function_args = parse_args(self.2, data)?;
let function_args = serde_json::to_string(&function_args)?; let function_args = serde_json::to_string(&function_args)?;

View File

@ -28,7 +28,7 @@ use serde_derive::Deserialize;
use serde_derive::Serialize; use serde_derive::Serialize;
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq)] #[derive(Serialize, Deserialize, Debug, PartialEq, Eq)]
#[serde(untagged)] #[serde(rename_all = "kebab-case")]
pub(crate) enum Instruction { pub(crate) enum Instruction {
Null(Null), Null(Null),
Call(Call), Call(Call),

View File

@ -21,11 +21,12 @@ use serde_derive::Deserialize;
use serde_derive::Serialize; use serde_derive::Serialize;
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq)] #[derive(Serialize, Deserialize, Debug, PartialEq, Eq)]
#[serde(rename_all = "kebab-case")]
pub(crate) struct Null {} pub(crate) struct Null {}
impl super::ExecutableInstruction for Null { impl super::ExecutableInstruction for Null {
fn execute(self, _data: &mut AquaData, _next_peer_pks: &mut Vec<String>) -> Result<()> { fn execute(self, data: &mut AquaData, next_peer_pks: &mut Vec<String>) -> Result<()> {
log::info!("null called with data: {:?} and next_peer_pks: {:?}", data, next_peer_pks);
Ok(()) Ok(())
} }
} }

View File

@ -40,12 +40,12 @@ fn execute_aqua_impl(init_user_id: String, aqua: String, data: String) -> Result
parsed_data parsed_data
); );
super::stepper::execute(parsed_aqua, &mut parsed_data)?; let next_peer_pks = super::stepper::execute(parsed_aqua, &mut parsed_data)?;
let data = serde_json::to_string(&parsed_data)?; let data = serde_json::to_string(&parsed_data)?;
Ok(StepperOutcome { Ok(StepperOutcome {
ret_code: 0, ret_code: 0,
data, data,
next_peer_pks: vec![init_user_id], next_peer_pks,
}) })
} }

View File

@ -17,6 +17,6 @@ pub fn call_service(service_id: String, fn_name: String, args: String) -> CallSe
CallServiceResult { CallServiceResult {
ret_code: 0, ret_code: 0,
result: args, result: String::from("[\"args\"]"),
} }
} }