Expose local archive query method (#44)
* Update vendor * Expose local archive query Update to beta4 * Update bindings package to beta4 * Update bindings package to beta4 * Make store response fields public * Added store configuration * Use decode response function
This commit is contained in:
parent
d1a467edcc
commit
3593ff18e6
|
@ -87,9 +87,9 @@ checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd"
|
|||
|
||||
[[package]]
|
||||
name = "bindgen"
|
||||
version = "0.63.0"
|
||||
version = "0.64.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "36d860121800b2a9a94f9b5604b332d5cffb234ce17609ea479d723dbc9d3885"
|
||||
checksum = "c4243e6031260db77ede97ad86c27e501d646a27ab57b59a574f725d98ab1fb4"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cexpr",
|
||||
|
@ -1246,9 +1246,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
|
|||
|
||||
[[package]]
|
||||
name = "tokio"
|
||||
version = "1.24.2"
|
||||
version = "1.25.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "597a12a59981d9e3c38d216785b0c37399f6e415e8d0712047620f189371b0bb"
|
||||
checksum = "c8e00990ebabbe4c14c08aca901caed183ecd5c09562a12c824bb53d3c3fd3af"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"pin-project-lite",
|
||||
|
@ -1381,7 +1381,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
|
|||
|
||||
[[package]]
|
||||
name = "waku-bindings"
|
||||
version = "0.1.0-beta3"
|
||||
version = "0.1.0-beta4"
|
||||
dependencies = [
|
||||
"aes-gcm",
|
||||
"base64",
|
||||
|
@ -1403,7 +1403,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "waku-sys"
|
||||
version = "0.1.0-beta3"
|
||||
version = "0.1.0-beta4"
|
||||
dependencies = [
|
||||
"bindgen",
|
||||
]
|
||||
|
|
|
@ -1203,7 +1203,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
|
|||
|
||||
[[package]]
|
||||
name = "waku-bindings"
|
||||
version = "0.1.0-beta1"
|
||||
version = "0.1.0-beta3"
|
||||
dependencies = [
|
||||
"aes-gcm",
|
||||
"base64",
|
||||
|
@ -1222,7 +1222,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "waku-sys"
|
||||
version = "0.1.0-beta1"
|
||||
version = "0.1.0-beta4"
|
||||
dependencies = [
|
||||
"bindgen",
|
||||
]
|
||||
|
|
|
@ -102,6 +102,7 @@ fn retrieve_history(
|
|||
})
|
||||
.collect())
|
||||
}
|
||||
|
||||
fn setup_node_handle() -> std::result::Result<WakuNodeHandle<Running>, Box<dyn Error>> {
|
||||
let node_handle = waku_new(None)?;
|
||||
let node_handle = node_handle.start()?;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "waku-bindings"
|
||||
version = "0.1.0-beta3"
|
||||
version = "0.1.0-beta4"
|
||||
edition = "2021"
|
||||
authors = [
|
||||
"Daniel Sanchez Quiros <danielsq@status.im>"
|
||||
|
@ -25,7 +25,7 @@ serde_json = "1.0"
|
|||
sscanf = "0.3"
|
||||
smart-default = "0.6"
|
||||
url = "2.3"
|
||||
waku-sys = { version = "0.1.0-beta3", path = "../waku-sys" }
|
||||
waku-sys = { version = "0.1.0-beta4", path = "../waku-sys" }
|
||||
|
||||
[dev-dependencies]
|
||||
futures = "0.3.25"
|
||||
|
|
|
@ -249,9 +249,9 @@ pub struct StoreQuery {
|
|||
pub struct StoreResponse {
|
||||
/// Array of retrieved historical messages in [`WakuMessage`] format
|
||||
#[serde(default)]
|
||||
messages: Vec<WakuMessage>,
|
||||
pub messages: Vec<WakuMessage>,
|
||||
/// Paging information in [`PagingOptions`] format from which to resume further historical queries
|
||||
paging_options: Option<PagingOptions>,
|
||||
pub paging_options: Option<PagingOptions>,
|
||||
}
|
||||
|
||||
impl StoreResponse {
|
||||
|
|
|
@ -34,7 +34,18 @@ pub struct WakuNodeConfig {
|
|||
/// Enable relay protocol. Default `true`
|
||||
#[default(Some(true))]
|
||||
pub relay: Option<bool>,
|
||||
#[serde(default)]
|
||||
/// Enable store protocol to persist message history
|
||||
#[default(Some(false))]
|
||||
pub store: Option<bool>,
|
||||
/// Url connection string. Accepts SQLite and PostgreSQL connection strings
|
||||
#[default(Some("sqlite3://store.db".to_string()))]
|
||||
pub database_url: Option<String>,
|
||||
/// Max number of messages to store in the databas
|
||||
#[default(Some(1000))]
|
||||
pub store_retention_max_messages: Option<usize>,
|
||||
/// Max number of seconds that a message will be persisted in the database, default 1 day
|
||||
#[default(Some(86400))]
|
||||
pub store_retention_max_seconds: Option<usize>,
|
||||
pub relay_topics: Vec<WakuPubSubTopic>,
|
||||
/// The minimum number of peers required on a topic to allow broadcasting a message. Default `0`
|
||||
#[default(Some(0))]
|
||||
|
|
|
@ -225,6 +225,14 @@ impl WakuNodeHandle<Running> {
|
|||
store::waku_store_query(query, peer_id, timeout)
|
||||
}
|
||||
|
||||
/// Retrieves locally stored historical messages on specific content topics. This method may be called with [`PagingOptions`](`crate::general::PagingOptions`),
|
||||
/// to retrieve historical messages on a per-page basis. If the request included [`PagingOptions`](`crate::general::PagingOptions`),
|
||||
/// the node must return messages on a per-page basis and include [`PagingOptions`](`crate::general::PagingOptions`) in the response.
|
||||
/// These [`PagingOptions`](`crate::general::PagingOptions`) must contain a cursor pointing to the Index from which a new page can be requested
|
||||
pub fn local_store_query(&self, query: &StoreQuery) -> Result<StoreResponse> {
|
||||
store::waku_local_store_query(query)
|
||||
}
|
||||
|
||||
/// Publish a message using Waku Lightpush
|
||||
/// As per the [specification](https://rfc.vac.dev/spec/36/#extern-char-waku_lightpush_publishchar-messagejson-char-topic-char-peerid-int-timeoutms)
|
||||
pub fn lightpush_publish(
|
||||
|
|
|
@ -46,3 +46,21 @@ pub fn waku_store_query(
|
|||
|
||||
decode_and_free_response(result_ptr)
|
||||
}
|
||||
|
||||
/// Retrieves locally stored historical messages on specific content topics from the local archive system. This method may be called with [`PagingOptions`](`crate::general::PagingOptions`),
|
||||
/// to retrieve historical messages on a per-page basis. If the request included [`PagingOptions`](`crate::general::PagingOptions`),
|
||||
/// the node must return messages on a per-page basis and include [`PagingOptions`](`crate::general::PagingOptions`) in the response.
|
||||
/// These [`PagingOptions`](`crate::general::PagingOptions`) must contain a cursor pointing to the Index from which a new page can be requested
|
||||
pub fn waku_local_store_query(query: &StoreQuery) -> Result<StoreResponse> {
|
||||
let query_ptr = CString::new(
|
||||
serde_json::to_string(query).expect("StoreQuery should always be able to be serialized"),
|
||||
)
|
||||
.expect("CString should build properly from the serialized filter subscription")
|
||||
.into_raw();
|
||||
let result_ptr = unsafe {
|
||||
let res = waku_sys::waku_store_local_query(query_ptr);
|
||||
drop(CString::from_raw(query_ptr));
|
||||
res
|
||||
};
|
||||
decode_and_free_response(result_ptr)
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "waku-sys"
|
||||
version = "0.1.0-beta3"
|
||||
version = "0.1.0-beta4"
|
||||
edition = "2021"
|
||||
authors = [
|
||||
"Daniel Sanchez Quiros <danielsq@status.im>"
|
||||
|
@ -19,4 +19,4 @@ crate-type = ["rlib"]
|
|||
[dependencies]
|
||||
|
||||
[build-dependencies]
|
||||
bindgen = "0.63"
|
||||
bindgen = "0.64"
|
|
@ -1 +1 @@
|
|||
Subproject commit 6c989fb1780159aacd8ec210ac4d7a33f40005df
|
||||
Subproject commit 11161b8919d2d2ad28b9f51dc38ca28ce2c94b72
|
Loading…
Reference in New Issue