Skip to content

Commit

Permalink
store use Duration type instead of i32 in waku_store_query exposed fn
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivansete-status committed Jan 9, 2025
1 parent f1e4e02 commit 3b0015d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion waku-bindings/src/node/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ impl WakuNodeHandle<Running> {
include_data: bool, // is true, resp contains payload, etc. Only msg_hashes otherwise
time_start: Option<u64>, // unix time nanoseconds
time_end: Option<u64>, // unix time nanoseconds
timeout_millis: Option<i32>,
timeout_millis: Option<Duration>,
) -> Result<Vec<StoreWakuMessageResponse>> {
let mut cursor: Option<MessageHash> = None;

Expand Down
8 changes: 6 additions & 2 deletions waku-bindings/src/node/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -145,7 +147,7 @@ pub async fn waku_store_query(
ctx: &WakuNodeContext,
query: StoreQueryRequest,
peer_addr: &str,
timeout_millis: Option<i32>,
timeout_millis: Option<Duration>,
) -> Result<StoreResponse> {
let json_query = CString::new(
serde_json::to_string(&query).expect("StoreQuery should always be able to be serialized"),
Expand All @@ -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
)
}

0 comments on commit 3b0015d

Please sign in to comment.