diff --git a/Cargo.lock b/Cargo.lock index 35ed824..235ff3e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1685,7 +1685,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "waku-bindings" -version = "0.5.0" +version = "0.6.0" dependencies = [ "aes-gcm", "base64 0.21.0", @@ -1710,7 +1710,7 @@ dependencies = [ [[package]] name = "waku-sys" -version = "0.5.0" +version = "0.6.0" dependencies = [ "bindgen", ] diff --git a/waku-bindings/Cargo.toml b/waku-bindings/Cargo.toml index ab66e20..19039dc 100644 --- a/waku-bindings/Cargo.toml +++ b/waku-bindings/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "waku-bindings" -version = "0.5.0" +version = "0.6.0" edition = "2021" authors = [ "Daniel Sanchez Quiros " @@ -26,7 +26,7 @@ serde_json = "1.0" sscanf = "0.4" smart-default = "0.6" url = "2.3" -waku-sys = { version = "0.5.0", path = "../waku-sys" } +waku-sys = { version = "0.6.0", path = "../waku-sys" } libc = "0.2" serde-aux = "4.3.1" diff --git a/waku-bindings/src/general/mod.rs b/waku-bindings/src/general/mod.rs index 1a665b7..df7e3e8 100644 --- a/waku-bindings/src/general/mod.rs +++ b/waku-bindings/src/general/mod.rs @@ -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, - /// Optional pubsub topic - pubsub_topic: Option, -} - -impl LegacyFilterSubscription { - pub fn new(content_filters: Vec, pubsub_topic: Option) -> 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. #[derive(Clone, Serialize, Deserialize, Debug)] #[serde(rename_all = "camelCase")] diff --git a/waku-bindings/src/lib.rs b/waku-bindings/src/lib.rs index bd1291b..ffb26c6 100644 --- a/waku-bindings/src/lib.rs +++ b/waku-bindings/src/lib.rs @@ -17,9 +17,8 @@ pub use node::{ pub use general::{ ContentFilter, DecodedPayload, Encoding, FilterSubscriptionDetail, FilterSubscriptionResult, - LegacyContentFilter, LegacyFilterSubscription, MessageId, MessageIndex, PagingOptions, PeerId, - ProtocolId, Result, StoreQuery, StoreResponse, WakuContentTopic, WakuMessage, - WakuMessageVersion, WakuPubSubTopic, + MessageId, MessageIndex, PagingOptions, PeerId, ProtocolId, Result, StoreQuery, StoreResponse, + WakuContentTopic, WakuMessage, WakuMessageVersion, WakuPubSubTopic, }; pub use events::{waku_set_event_callback, Event, Signal, WakuMessageEvent}; diff --git a/waku-bindings/src/node/config.rs b/waku-bindings/src/node/config.rs index d596aff..a99f326 100644 --- a/waku-bindings/src/node/config.rs +++ b/waku-bindings/src/node/config.rs @@ -50,10 +50,6 @@ pub struct WakuNodeConfig { /// The minimum number of peers required on a topic to allow broadcasting a message. Default `0` #[default(Some(0))] pub min_peers_to_publish: Option, - /// Enable filter protocol. Default `false` - #[default(Some(false))] - #[serde(rename = "legacyFilter")] - pub filter: Option, /// Set the log level. Default `INFO`. Allowed values "DEBUG", "INFO", "WARN", "ERROR", "DPANIC", "PANIC", "FATAL" #[default(Some(WakuLogLevel::Info))] pub log_level: Option, diff --git a/waku-bindings/src/node/legacyfilter.rs b/waku-bindings/src/node/legacyfilter.rs deleted file mode 100644 index 35ef177..0000000 --- a/waku-bindings/src/node/legacyfilter.rs +++ /dev/null @@ -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) -} diff --git a/waku-bindings/src/node/mod.rs b/waku-bindings/src/node/mod.rs index 54c005e..927a9f8 100644 --- a/waku-bindings/src/node/mod.rs +++ b/waku-bindings/src/node/mod.rs @@ -3,7 +3,6 @@ mod config; mod discovery; mod filter; -mod legacyfilter; mod lightpush; mod management; mod peers; @@ -21,8 +20,8 @@ use std::time::Duration; // internal use crate::general::{ - ContentFilter, FilterSubscriptionResult, LegacyFilterSubscription, MessageId, PeerId, - ProtocolId, Result, StoreQuery, StoreResponse, WakuMessage, WakuPubSubTopic, + ContentFilter, FilterSubscriptionResult, MessageId, PeerId, ProtocolId, Result, StoreQuery, + StoreResponse, WakuMessage, WakuPubSubTopic, }; pub use config::{GossipSubParams, WakuLogLevel, WakuNodeConfig, WebsocketParams}; @@ -214,29 +213,6 @@ impl WakuNodeHandle { 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. /// Returns the PeerId on which the filter subscription was created pub fn filter_subscribe( diff --git a/waku-sys/Cargo.toml b/waku-sys/Cargo.toml index c5c6ae1..b321592 100644 --- a/waku-sys/Cargo.toml +++ b/waku-sys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "waku-sys" -version = "0.5.0" +version = "0.6.0" edition = "2021" authors = [ "Daniel Sanchez Quiros " diff --git a/waku-sys/vendor b/waku-sys/vendor index e340337..46c4698 160000 --- a/waku-sys/vendor +++ b/waku-sys/vendor @@ -1 +1 @@ -Subproject commit e340337d64622d22cb94a969255efe4e36637df0 +Subproject commit 46c46989deb8e0263dc9a08cf7f63b35703231fd