We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
canister has a query concat method, and an update concat_update method
use ic_cdk_macros::{init, post_upgrade, pre_upgrade, query, update}; use ic_cdk::api::call::{msg_cycles_accept, msg_cycles_available}; use sha2::{Digest, Sha256}; const SINGLE_SHA256_COST_CYCLES :u64 = 200_000_000; const CONCAT_STRING_COST_CYCLES :u64 = 0; #[query] pub fn greet()->String{ format!("Hello, World!") } #[update] pub fn sha256(msg :String, n :u32) -> String { let available_cycles = msg_cycles_available(); let needed_cycles:u64 = SINGLE_SHA256_COST_CYCLES*(n as u64); ic_cdk::println!("needed_cycles: {}", needed_cycles); if available_cycles < needed_cycles{ ic_cdk::eprintln!("Not enough cycles provided for sha256 operation."); return String::from("Not enough cycles provided for sha256 operation."); } let _ = msg_cycles_accept(needed_cycles); let mut input = msg.clone().into_bytes(); ic_cdk::println!("input: {}", msg); for _ in 0..n { let mut hasher = Sha256::new(); hasher.update(input); input = hasher.finalize().to_vec(); } ic_cdk::println!("result: {}", hex::encode(input.clone())); hex::encode(input) } #[query] pub fn concat(s1:String, s2:String) -> String { format!("{} {}", s1, s2) } #[update] pub fn concat_update(s1:String, s2:String) -> String { let available_cycles = msg_cycles_available(); let needed_cycles:u64 = CONCAT_STRING_COST_CYCLES; if available_cycles < needed_cycles{ ic_cdk::eprintln!("Not enough cycles provided for concat operation."); return String::from("Not enough cycles provided for concat operation."); } let _ = msg_cycles_accept(needed_cycles); format!("{} {}", s1, s2) }
call concat method by agent-rs, it works as expected
call concat_update by dfx, it works as expected
call concat method by agent-rs, it reports Certificate verification failed. the identity file is exported by “dfx identity export identity1”
The text was updated successfully, but these errors were encountered:
No branches or pull requests
canister has a query concat method, and an update concat_update method
call concat method by agent-rs, it works as expected
call concat_update by dfx, it works as expected
call concat method by agent-rs, it reports Certificate verification failed. the identity file is exported by “dfx identity export identity1”
The text was updated successfully, but these errors were encountered: