store use Duration type instead of i32 in waku_store_query exposed fn

This commit is contained in:
Ivan Folgueira Bande 2025-01-09 22:48:10 +01:00
parent f1e4e024d5
commit 3b0015dda5
No known key found for this signature in database
GPG Key ID: 3C117481F89E24A7
2 changed files with 7 additions and 3 deletions

View File

@ -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;

View File

@ -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<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"),
@ -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
)
}