Update blake2b wrapper, block_on async client builders
-#[cfg(not(feature = "async"))]
+//#[cfg(not(feature = "async"))]
use smol::block_on;
#[cfg(feature = "async")]
@@ -28,7 +28,7 @@ use crate::{
use futures::future::join_all;
-use crypto::blake2b;
+use crypto::hashes::{Digest, blake2b};
use iota_streams_core::prelude::String;
@@ -57,8 +57,7 @@ fn handle_client_result<T>(result: iota_client::Result<T>) -> Result<T> {
fn get_hash(tx_address: &[u8], tx_tag: &[u8]) -> Result<String> {
let total = [tx_address, tx_tag].concat();
- let mut hash = [0u8; HASHED_INDEX_LENGTH];
- blake2b::hash(&total, &mut hash);
+ let hash = blake2b::Blake2b256::digest(&total);
Ok(hex::encode(&hash))
}
@@ -116,7 +115,7 @@ pub async fn async_send_message_with_options<F>(client: &iota_client::Client, ms
//TODO: Get rid of copy caused by to_owned
client
- .send()
+ .message()
.with_index(&hash.to_string())
.with_data(bytes)
.finish()
@@ -156,7 +155,7 @@ impl Default for Client {
fn default() -> Self {
Self {
send_opt: SendOptions::default(),
- client: iota_client::ClientBuilder::new().with_node("http://localhost:14265").unwrap().finish().unwrap()
+ client: block_on(iota_client::ClientBuilder::new().with_node("http://localhost:14265").unwrap().finish()).unwrap()
}
}
}
@@ -174,7 +173,7 @@ impl Client {
pub fn new_from_url(url: &str) -> Self {
Self {
send_opt: SendOptions::default(),
- client: iota_client::ClientBuilder::new().with_node(url).unwrap().finish().unwrap()
+ client: block_on(iota_client::ClientBuilder::new().with_node(url).unwrap().with_local_pow(false).finish()).unwrap()
}
}
}
