From 9705c0ef59c0d5442c2c3a67dcb4b1cedcf4d998 Mon Sep 17 00:00:00 2001 From: danielsanchezq Date: Mon, 31 Oct 2022 09:51:13 +0100 Subject: [PATCH] Remove private items docs --- waku/src/node/mod.rs | 85 ++++++++++++++++-------------------------- waku/src/node/relay.rs | 2 +- 2 files changed, 33 insertions(+), 54 deletions(-) diff --git a/waku/src/node/mod.rs b/waku/src/node/mod.rs index 11e9771..147cb66 100644 --- a/waku/src/node/mod.rs +++ b/waku/src/node/mod.rs @@ -61,22 +61,19 @@ unsafe impl Sync for WakuNodeHandle {} impl WakuNodeHandle { /// If the execution is successful, the result is the peer ID as a string (base58 encoded) - /// - /// wrapper around [`management::waku_peer_id`] + /// as per the [specification](https://rfc.vac.dev/spec/36/#extern-char-waku_stop) pub fn peer_id(&self) -> Result { management::waku_peer_id() } /// Get the multiaddresses the Waku node is listening to - /// - /// wrapper around [`management::waku_listen_addresses`] + /// as per [specification](https://rfc.vac.dev/spec/36/#extern-char-waku_listen_addresses) pub fn listen_addresses(&self) -> Result> { management::waku_listen_addresses() } - /// Add a node multiaddress and protocol to the waku node’s peerstore - /// - /// wrapper around [`peers::waku_add_peers`] + /// Add a node multiaddress and protocol to the waku node’s peerstore. + /// As per the [specification](https://rfc.vac.dev/spec/36/#extern-char-waku_add_peerchar-address-char-protocolid) pub fn add_peer(&self, address: &Multiaddr, protocol_id: ProtocolId) -> Result { peers::waku_add_peers(address, protocol_id) } @@ -91,16 +88,14 @@ fn stop_node() -> Result<()> { } impl WakuNodeHandle { - /// Start a Waku node mounting all the protocols that were enabled during the Waku node instantiation - /// - /// wrapper around [`management::waku_start`] + /// Start a Waku node mounting all the protocols that were enabled during the Waku node instantiation. + /// as per the [specification](https://rfc.vac.dev/spec/36/#extern-char-waku_start) pub fn start(self) -> Result> { management::waku_start().map(|_| WakuNodeHandle(Default::default())) } /// Stops a Waku node - /// - /// internally uses [`management::waku_stop`] + /// as per the [specification](https://rfc.vac.dev/spec/36/#extern-char-waku_stop) pub fn stop(self) -> Result<()> { stop_node() } @@ -108,8 +103,7 @@ impl WakuNodeHandle { impl WakuNodeHandle { /// Stops a Waku node - /// - /// internally uses [`management::waku_stop`] + /// as per the [specification](https://rfc.vac.dev/spec/36/#extern-char-waku_stop) pub fn stop(self) -> Result<()> { stop_node() } @@ -118,8 +112,7 @@ impl WakuNodeHandle { /// If `timeout` as milliseconds doesn't fit into a `i32` it is clamped to [`i32::MAX`] /// If the function execution takes longer than `timeout` value, the execution will be canceled and an error returned. /// Use 0 for no timeout - /// - /// wrapper around [`peers::waku_connect_peer_with_address`] + /// As per the [specification](https://rfc.vac.dev/spec/36/#extern-char-waku_connect_peerchar-address-int-timeoutms) pub fn connect_peer_with_address( &self, address: &Multiaddr, @@ -128,37 +121,35 @@ impl WakuNodeHandle { peers::waku_connect_peer_with_address(address, timeout) } - /// Dial peer using its peer ID - /// - /// wrapper around [`peers::waku_connect_peer_with_id`] + /// Dial peer using a peer id + /// If `timeout` as milliseconds doesn't fit into a `i32` it is clamped to [`i32::MAX`] + /// The peer must be already known. + /// It must have been added before with [`WakuNodeHandle::add_peer`] or previously dialed with [`WakuNodeHandle::connect_peer_with_address`] + /// As per the [specification](https://rfc.vac.dev/spec/36/#extern-char-waku_connect_peeridchar-peerid-int-timeoutms) pub fn connect_peer_with_id(&self, peer_id: PeerId, timeout: Option) -> Result<()> { peers::waku_connect_peer_with_id(peer_id, timeout) } - /// Disconnect a peer using its peerID - /// - /// wrapper around [`peers::waku_disconnect_peer_with_id`] + /// Disconnect a peer using its peer id + /// As per the [specification](https://rfc.vac.dev/spec/36/#extern-char-waku_disconnect_peerchar-peerid) pub fn disconnect_peer_with_id(&self, peer_id: &PeerId) -> Result<()> { peers::waku_disconnect_peer_with_id(peer_id) } /// Get number of connected peers - /// - /// wrapper around [`peers::waku_peer_count`] + /// As per the [specification](https://rfc.vac.dev/spec/36/#extern-char-waku_peer_count) pub fn peer_count(&self) -> Result { peers::waku_peer_count() } /// Retrieve the list of peers known by the Waku node - /// - /// wrapper around [`peers::waku_peers`] + /// As per the [specification](https://rfc.vac.dev/spec/36/#extern-char-waku_peers) pub fn peers(&self) -> Result { peers::waku_peers() } /// Publish a message using Waku Relay - /// - /// wrapper around [`relay::waku_relay_publish_message`] + /// As per the [specification](https://rfc.vac.dev/spec/36/#extern-char-waku_relay_publishchar-messagejson-char-pubsubtopic-int-timeoutms) pub fn relay_publish_message( &self, message: &WakuMessage, @@ -169,8 +160,7 @@ impl WakuNodeHandle { } /// Optionally sign, encrypt using asymmetric encryption and publish a message using Waku Relay - /// - /// wrapper around [`relay::waku_relay_publish_encrypt_asymmetric`] + /// As per the [specification](https://rfc.vac.dev/spec/36/#extern-char-waku_relay_publish_enc_asymmetricchar-messagejson-char-pubsubtopic-char-publickey-char-optionalsigningkey-int-timeoutms) pub fn relay_publish_encrypt_asymmetric( &self, message: &WakuMessage, @@ -189,8 +179,7 @@ impl WakuNodeHandle { } /// Optionally sign, encrypt using symmetric encryption and publish a message using Waku Relay - /// - /// wrapper around [`relay::waku_relay_publish_encrypt_symmetric`] + /// As per the [specification](https://rfc.vac.dev/spec/36/#extern-char-waku_relay_publish_enc_symmetricchar-messagejson-char-pubsubtopic-char-symmetrickey-char-optionalsigningkey-int-timeoutms) pub fn relay_publish_encrypt_symmetric( &self, message: &WakuMessage, @@ -209,29 +198,24 @@ impl WakuNodeHandle { } /// Determine if there are enough peers to publish a message on a given pubsub topic - /// - /// wrapper around [`relay::waku_enough_peers`] pub fn relay_enough_peers(&self, pubsub_topic: Option) -> Result { relay::waku_enough_peers(pubsub_topic) } /// Subscribe to a Waku Relay pubsub topic to receive messages - /// - /// wrapper around [`relay::waku_relay_subscribe`] pub fn relay_subscribe(&self, pubsub_topic: Option) -> Result<()> { relay::waku_relay_subscribe(pubsub_topic) } /// Closes the pubsub subscription to a pubsub topic. No more messages will be received from this pubsub topic - /// - /// wrapper around [`relay::waku_relay_unsubscribe`] pub fn relay_unsubscribe(&self, pubsub_topic: Option) -> Result<()> { relay::waku_relay_unsubscribe(pubsub_topic) } - /// Retrieves historical messages on specific content topics - /// - /// wrapper around [`store::waku_store_query`] + /// Retrieves 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 store_query( &self, query: &StoreQuery, @@ -242,8 +226,7 @@ impl WakuNodeHandle { } /// Publish a message using Waku Lightpush - /// - /// wrapper around [`lightpush::waku_lightpush_publish`] + /// 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( &self, message: &WakuMessage, @@ -255,8 +238,7 @@ impl WakuNodeHandle { } /// Optionally sign, encrypt using asymmetric encryption and publish a message using Waku Lightpush - /// - /// wrapper around [`lightpush::waku_lightpush_publish_encrypt_asymmetric`] + /// As per the [specification](https://rfc.vac.dev/spec/36/#extern-char-waku_lightpush_publish_enc_asymmetricchar-messagejson-char-pubsubtopic-char-peerid-char-publickey-char-optionalsigningkey-int-timeoutms) pub fn lightpush_publish_encrypt_asymmetric( &self, message: &WakuMessage, @@ -277,8 +259,7 @@ impl WakuNodeHandle { } /// Optionally sign, encrypt using symmetric encryption and publish a message using Waku Lightpush - /// - /// wrapper around [`lightpush::waku_lightpush_publish_encrypt_symmetric`] + /// As per the [specification](https://rfc.vac.dev/spec/36/#extern-char-waku_lightpush_publish_enc_symmetricchar-messagejson-char-pubsubtopic-char-peerid-char-symmetrickey-char-optionalsigningkey-int-timeoutms) pub fn lightpush_publish_encrypt_symmetric( &self, message: &WakuMessage, @@ -299,8 +280,7 @@ impl WakuNodeHandle { } /// Creates a subscription in a lightnode for messages that matches a content filter and optionally a [`WakuPubSubTopic`](`crate::general::WakuPubSubTopic`) - /// - /// wrapper around [`filter::waku_filter_subscribe`] + /// As per the [specification](https://rfc.vac.dev/spec/36/#extern-char-waku_filter_subscribechar-filterjson-char-peerid-int-timeoutms) pub fn filter_subscribe( &self, filter_subscription: &FilterSubscription, @@ -311,8 +291,7 @@ impl WakuNodeHandle { } /// Removes subscriptions in a light node matching a content filter and, optionally, a [`WakuPubSubTopic`](`crate::general::WakuPubSubTopic`) - /// - /// wrapper around [`filter::waku_filter_unsubscribe`] + /// As per the [specification](https://rfc.vac.dev/spec/36/#extern-char-waku_filter_unsubscribechar-filterjson-int-timeoutms) pub fn filter_unsubscribe( &self, filter_subscription: &FilterSubscription, @@ -331,8 +310,8 @@ impl WakuNodeHandle { } } -/// Spawn a new Waku node with the givent configuration (default configuration if `None` provided) -/// Internally uses [`management::waku_new`] +/// Spawn a new Waku node with the given configuration (default configuration if `None` provided) +/// as per the [specification](https://rfc.vac.dev/spec/36/#extern-char-waku_newchar-jsonconfig) pub fn waku_new(config: Option) -> Result> { let mut node_initialized = WAKU_NODE_INITIALIZED .lock() diff --git a/waku/src/node/relay.rs b/waku/src/node/relay.rs index d6888ae..fc18092 100644 --- a/waku/src/node/relay.rs +++ b/waku/src/node/relay.rs @@ -28,7 +28,7 @@ pub fn waku_create_content_topic( .try_into() .expect("Version should fit within an u32"), CString::new(content_topic_name) - .expect("Conmtent topic should always transform to CString") + .expect("Content topic should always transform to CString") .into_raw(), CString::new(encoding.to_string()) .expect("Encoding should always transform to CString")