mirror of
https://github.com/logos-messaging/logos-messaging-rust-bindings.git
synced 2026-01-05 23:43:11 +00:00
chore: bump go-waku and drop legacy filter support
This commit is contained in:
parent
1ea96f80b2
commit
aaeabd54de
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -1685,7 +1685,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "waku-bindings"
|
name = "waku-bindings"
|
||||||
version = "0.5.0"
|
version = "0.6.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aes-gcm",
|
"aes-gcm",
|
||||||
"base64 0.21.0",
|
"base64 0.21.0",
|
||||||
@ -1710,7 +1710,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "waku-sys"
|
name = "waku-sys"
|
||||||
version = "0.5.0"
|
version = "0.6.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bindgen",
|
"bindgen",
|
||||||
]
|
]
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "waku-bindings"
|
name = "waku-bindings"
|
||||||
version = "0.5.0"
|
version = "0.6.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = [
|
authors = [
|
||||||
"Daniel Sanchez Quiros <danielsq@status.im>"
|
"Daniel Sanchez Quiros <danielsq@status.im>"
|
||||||
@ -26,7 +26,7 @@ serde_json = "1.0"
|
|||||||
sscanf = "0.4"
|
sscanf = "0.4"
|
||||||
smart-default = "0.6"
|
smart-default = "0.6"
|
||||||
url = "2.3"
|
url = "2.3"
|
||||||
waku-sys = { version = "0.5.0", path = "../waku-sys" }
|
waku-sys = { version = "0.6.0", path = "../waku-sys" }
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
serde-aux = "4.3.1"
|
serde-aux = "4.3.1"
|
||||||
|
|
||||||
|
|||||||
@ -199,53 +199,6 @@ impl DecodedPayload {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The content topic of a Waku message
|
|
||||||
/// as per the [specification](https://rfc.vac.dev/spec/36/#contentfilter-type)
|
|
||||||
#[derive(Clone, Serialize, Deserialize, Debug)]
|
|
||||||
#[serde(rename_all = "camelCase")]
|
|
||||||
pub struct LegacyContentFilter {
|
|
||||||
/// The content topic of a Waku message
|
|
||||||
content_topic: WakuContentTopic,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl LegacyContentFilter {
|
|
||||||
pub fn new(content_topic: WakuContentTopic) -> Self {
|
|
||||||
Self { content_topic }
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn content_topic(&self) -> &WakuContentTopic {
|
|
||||||
&self.content_topic
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The criteria to create subscription to a light node in JSON Format
|
|
||||||
/// as per the [specification](https://rfc.vac.dev/spec/36/#filtersubscription-type)
|
|
||||||
#[derive(Clone, Serialize, Deserialize, Debug)]
|
|
||||||
#[serde(rename_all = "camelCase")]
|
|
||||||
pub struct LegacyFilterSubscription {
|
|
||||||
/// Array of [`ContentFilter`] being subscribed to / unsubscribed from
|
|
||||||
content_filters: Vec<ContentFilter>,
|
|
||||||
/// Optional pubsub topic
|
|
||||||
pubsub_topic: Option<WakuPubSubTopic>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl LegacyFilterSubscription {
|
|
||||||
pub fn new(content_filters: Vec<ContentFilter>, pubsub_topic: Option<WakuPubSubTopic>) -> Self {
|
|
||||||
Self {
|
|
||||||
content_filters,
|
|
||||||
pubsub_topic,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn content_filters(&self) -> &[ContentFilter] {
|
|
||||||
&self.content_filters
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn pubsub_topic(&self) -> Option<&WakuPubSubTopic> {
|
|
||||||
self.pubsub_topic.as_ref()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The criteria to create subscription to a filter full node matching a content filter.
|
/// The criteria to create subscription to a filter full node matching a content filter.
|
||||||
#[derive(Clone, Serialize, Deserialize, Debug)]
|
#[derive(Clone, Serialize, Deserialize, Debug)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
|
|||||||
@ -17,9 +17,8 @@ pub use node::{
|
|||||||
|
|
||||||
pub use general::{
|
pub use general::{
|
||||||
ContentFilter, DecodedPayload, Encoding, FilterSubscriptionDetail, FilterSubscriptionResult,
|
ContentFilter, DecodedPayload, Encoding, FilterSubscriptionDetail, FilterSubscriptionResult,
|
||||||
LegacyContentFilter, LegacyFilterSubscription, MessageId, MessageIndex, PagingOptions, PeerId,
|
MessageId, MessageIndex, PagingOptions, PeerId, ProtocolId, Result, StoreQuery, StoreResponse,
|
||||||
ProtocolId, Result, StoreQuery, StoreResponse, WakuContentTopic, WakuMessage,
|
WakuContentTopic, WakuMessage, WakuMessageVersion, WakuPubSubTopic,
|
||||||
WakuMessageVersion, WakuPubSubTopic,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub use events::{waku_set_event_callback, Event, Signal, WakuMessageEvent};
|
pub use events::{waku_set_event_callback, Event, Signal, WakuMessageEvent};
|
||||||
|
|||||||
@ -50,10 +50,6 @@ pub struct WakuNodeConfig {
|
|||||||
/// The minimum number of peers required on a topic to allow broadcasting a message. Default `0`
|
/// The minimum number of peers required on a topic to allow broadcasting a message. Default `0`
|
||||||
#[default(Some(0))]
|
#[default(Some(0))]
|
||||||
pub min_peers_to_publish: Option<usize>,
|
pub min_peers_to_publish: Option<usize>,
|
||||||
/// Enable filter protocol. Default `false`
|
|
||||||
#[default(Some(false))]
|
|
||||||
#[serde(rename = "legacyFilter")]
|
|
||||||
pub filter: Option<bool>,
|
|
||||||
/// Set the log level. Default `INFO`. Allowed values "DEBUG", "INFO", "WARN", "ERROR", "DPANIC", "PANIC", "FATAL"
|
/// Set the log level. Default `INFO`. Allowed values "DEBUG", "INFO", "WARN", "ERROR", "DPANIC", "PANIC", "FATAL"
|
||||||
#[default(Some(WakuLogLevel::Info))]
|
#[default(Some(WakuLogLevel::Info))]
|
||||||
pub log_level: Option<WakuLogLevel>,
|
pub log_level: Option<WakuLogLevel>,
|
||||||
|
|||||||
@ -1,89 +0,0 @@
|
|||||||
//! Waku [filter](https://rfc.vac.dev/spec/36/#waku-filter) protocol related methods
|
|
||||||
|
|
||||||
// std
|
|
||||||
use std::ffi::CString;
|
|
||||||
use std::time::Duration;
|
|
||||||
// crates
|
|
||||||
use libc::*;
|
|
||||||
// internal
|
|
||||||
use crate::general::Result;
|
|
||||||
use crate::general::{LegacyFilterSubscription, PeerId};
|
|
||||||
use crate::utils::{get_trampoline, handle_no_response};
|
|
||||||
|
|
||||||
/// Creates a subscription in a lightnode for messages that matches a content filter and optionally a [`WakuPubSubTopic`](`crate::general::WakuPubSubTopic`)
|
|
||||||
/// As per the [specification](https://rfc.vac.dev/spec/36/#extern-char-waku_legacy_filter_subscribechar-filterjson-char-peerid-int-timeoutms)
|
|
||||||
pub fn waku_legacy_filter_subscribe(
|
|
||||||
filter_subscription: &LegacyFilterSubscription,
|
|
||||||
peer_id: PeerId,
|
|
||||||
timeout: Duration,
|
|
||||||
) -> Result<()> {
|
|
||||||
let filter_subscription_ptr = CString::new(
|
|
||||||
serde_json::to_string(filter_subscription)
|
|
||||||
.expect("FilterSubscription should always succeed to serialize"),
|
|
||||||
)
|
|
||||||
.expect("FilterSubscription should always be able to be serialized")
|
|
||||||
.into_raw();
|
|
||||||
let peer_id_ptr = CString::new(peer_id)
|
|
||||||
.expect("PeerId should always be able to be serialized")
|
|
||||||
.into_raw();
|
|
||||||
|
|
||||||
let mut error: String = Default::default();
|
|
||||||
let error_cb = |v: &str| error = v.to_string();
|
|
||||||
let code = unsafe {
|
|
||||||
let mut closure = error_cb;
|
|
||||||
let cb = get_trampoline(&closure);
|
|
||||||
let out = waku_sys::waku_legacy_filter_subscribe(
|
|
||||||
filter_subscription_ptr,
|
|
||||||
peer_id_ptr,
|
|
||||||
timeout
|
|
||||||
.as_millis()
|
|
||||||
.try_into()
|
|
||||||
.expect("Duration as milliseconds should fit in a i32"),
|
|
||||||
cb,
|
|
||||||
&mut closure as *mut _ as *mut c_void,
|
|
||||||
);
|
|
||||||
|
|
||||||
drop(CString::from_raw(filter_subscription_ptr));
|
|
||||||
drop(CString::from_raw(peer_id_ptr));
|
|
||||||
|
|
||||||
out
|
|
||||||
};
|
|
||||||
|
|
||||||
handle_no_response(code, &error)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Removes subscriptions in a light node matching a content filter and, optionally, a [`WakuPubSubTopic`](`crate::general::WakuPubSubTopic`)
|
|
||||||
/// As per the [specification](https://rfc.vac.dev/spec/36/#extern-char-waku_filter_unsubscribechar-filterjson-int-timeoutms)
|
|
||||||
pub fn waku_legacy_filter_unsubscribe(
|
|
||||||
filter_subscription: &LegacyFilterSubscription,
|
|
||||||
timeout: Duration,
|
|
||||||
) -> Result<()> {
|
|
||||||
let filter_subscription_ptr = CString::new(
|
|
||||||
serde_json::to_string(filter_subscription)
|
|
||||||
.expect("FilterSubscription should always succeed to serialize"),
|
|
||||||
)
|
|
||||||
.expect("CString should build properly from the serialized filter subscription")
|
|
||||||
.into_raw();
|
|
||||||
|
|
||||||
let mut error: String = Default::default();
|
|
||||||
let error_cb = |v: &str| error = v.to_string();
|
|
||||||
let code = unsafe {
|
|
||||||
let mut closure = error_cb;
|
|
||||||
let cb = get_trampoline(&closure);
|
|
||||||
let out = waku_sys::waku_legacy_filter_unsubscribe(
|
|
||||||
filter_subscription_ptr,
|
|
||||||
timeout
|
|
||||||
.as_millis()
|
|
||||||
.try_into()
|
|
||||||
.expect("Duration as milliseconds should fit in a i32"),
|
|
||||||
cb,
|
|
||||||
&mut closure as *mut _ as *mut c_void,
|
|
||||||
);
|
|
||||||
|
|
||||||
drop(CString::from_raw(filter_subscription_ptr));
|
|
||||||
|
|
||||||
out
|
|
||||||
};
|
|
||||||
|
|
||||||
handle_no_response(code, &error)
|
|
||||||
}
|
|
||||||
@ -3,7 +3,6 @@
|
|||||||
mod config;
|
mod config;
|
||||||
mod discovery;
|
mod discovery;
|
||||||
mod filter;
|
mod filter;
|
||||||
mod legacyfilter;
|
|
||||||
mod lightpush;
|
mod lightpush;
|
||||||
mod management;
|
mod management;
|
||||||
mod peers;
|
mod peers;
|
||||||
@ -21,8 +20,8 @@ use std::time::Duration;
|
|||||||
// internal
|
// internal
|
||||||
|
|
||||||
use crate::general::{
|
use crate::general::{
|
||||||
ContentFilter, FilterSubscriptionResult, LegacyFilterSubscription, MessageId, PeerId,
|
ContentFilter, FilterSubscriptionResult, MessageId, PeerId, ProtocolId, Result, StoreQuery,
|
||||||
ProtocolId, Result, StoreQuery, StoreResponse, WakuMessage, WakuPubSubTopic,
|
StoreResponse, WakuMessage, WakuPubSubTopic,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub use config::{GossipSubParams, WakuLogLevel, WakuNodeConfig, WebsocketParams};
|
pub use config::{GossipSubParams, WakuLogLevel, WakuNodeConfig, WebsocketParams};
|
||||||
@ -214,29 +213,6 @@ impl WakuNodeHandle<Running> {
|
|||||||
lightpush::waku_lightpush_publish(message, pubsub_topic, peer_id, timeout)
|
lightpush::waku_lightpush_publish(message, pubsub_topic, peer_id, timeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a subscription in a lightnode for messages that matches a content filter and optionally a [`WakuPubSubTopic`](`crate::general::WakuPubSubTopic`)
|
|
||||||
/// As per the [specification](https://rfc.vac.dev/spec/36/#extern-char-waku_filter_subscribechar-filterjson-char-peerid-int-timeoutms)
|
|
||||||
#[deprecated]
|
|
||||||
pub fn legacy_filter_subscribe(
|
|
||||||
&self,
|
|
||||||
filter_subscription: &LegacyFilterSubscription,
|
|
||||||
peer_id: PeerId,
|
|
||||||
timeout: Duration,
|
|
||||||
) -> Result<()> {
|
|
||||||
legacyfilter::waku_legacy_filter_subscribe(filter_subscription, peer_id, timeout)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Removes subscriptions in a light node matching a content filter and, optionally, a [`WakuPubSubTopic`](`crate::general::WakuPubSubTopic`)
|
|
||||||
/// As per the [specification](https://rfc.vac.dev/spec/36/#extern-char-waku_filter_unsubscribechar-filterjson-int-timeoutms)
|
|
||||||
#[deprecated]
|
|
||||||
pub fn legacy_filter_unsubscribe(
|
|
||||||
&self,
|
|
||||||
filter_subscription: &LegacyFilterSubscription,
|
|
||||||
timeout: Duration,
|
|
||||||
) -> Result<()> {
|
|
||||||
legacyfilter::waku_legacy_filter_unsubscribe(filter_subscription, timeout)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Creates a subscription to a filter full node matching a content filter.
|
/// Creates a subscription to a filter full node matching a content filter.
|
||||||
/// Returns the PeerId on which the filter subscription was created
|
/// Returns the PeerId on which the filter subscription was created
|
||||||
pub fn filter_subscribe(
|
pub fn filter_subscribe(
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "waku-sys"
|
name = "waku-sys"
|
||||||
version = "0.5.0"
|
version = "0.6.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = [
|
authors = [
|
||||||
"Daniel Sanchez Quiros <danielsq@status.im>"
|
"Daniel Sanchez Quiros <danielsq@status.im>"
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
Subproject commit e340337d64622d22cb94a969255efe4e36637df0
|
Subproject commit 46c46989deb8e0263dc9a08cf7f63b35703231fd
|
||||||
Loading…
x
Reference in New Issue
Block a user