From 3b0015dda5c6a2812bc0f98e2ac26b7b947d7019 Mon Sep 17 00:00:00 2001 From: Ivan Folgueira Bande Date: Thu, 9 Jan 2025 22:48:10 +0100 Subject: [PATCH] store use Duration type instead of i32 in waku_store_query exposed fn --- waku-bindings/src/node/mod.rs | 2 +- waku-bindings/src/node/store.rs | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/waku-bindings/src/node/mod.rs b/waku-bindings/src/node/mod.rs index 27d0fbf..e24ada9 100644 --- a/waku-bindings/src/node/mod.rs +++ b/waku-bindings/src/node/mod.rs @@ -179,7 +179,7 @@ impl WakuNodeHandle { include_data: bool, // is true, resp contains payload, etc. Only msg_hashes otherwise time_start: Option, // unix time nanoseconds time_end: Option, // unix time nanoseconds - timeout_millis: Option, + timeout_millis: Option, ) -> Result> { let mut cursor: Option = None; diff --git a/waku-bindings/src/node/store.rs b/waku-bindings/src/node/store.rs index 2225e86..8fe36cb 100644 --- a/waku-bindings/src/node/store.rs +++ b/waku-bindings/src/node/store.rs @@ -3,6 +3,8 @@ // std use std::ffi::CString; use uuid::Uuid; +// crates +use tokio::time::Duration; // internal use crate::general::libwaku_response::{handle_response, LibwakuResponse}; use crate::general::time::get_now_in_nanosecs; @@ -145,7 +147,7 @@ pub async fn waku_store_query( ctx: &WakuNodeContext, query: StoreQueryRequest, peer_addr: &str, - timeout_millis: Option, + timeout_millis: Option, ) -> Result { let json_query = CString::new( serde_json::to_string(&query).expect("StoreQuery should always be able to be serialized"), @@ -157,12 +159,14 @@ pub async fn waku_store_query( .expect("correct multiaddress in store query"); let peer_addr = CString::new(peer_addr).expect("peer_addr CString should be created"); + let timeout_millis = timeout_millis.unwrap_or(Duration::from_secs(10)); + handle_ffi_call!( waku_sys::waku_store_query, handle_response, ctx.get_ptr(), json_query.as_ptr(), peer_addr.as_ptr(), - timeout_millis.unwrap_or(10000i32) + timeout_millis.as_millis() as i32 ) }