feat: update discv5 bootnodes (#62)

This commit is contained in:
RichΛrd 2023-06-12 09:46:13 -04:00 committed by GitHub
parent 803fc37e04
commit a4bfddece7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 39 additions and 10 deletions

4
Cargo.lock generated
View File

@ -1674,7 +1674,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]] [[package]]
name = "waku-bindings" name = "waku-bindings"
version = "0.1.0" version = "0.1.1"
dependencies = [ dependencies = [
"aes-gcm", "aes-gcm",
"base64 0.21.0", "base64 0.21.0",
@ -1697,7 +1697,7 @@ dependencies = [
[[package]] [[package]]
name = "waku-sys" name = "waku-sys"
version = "0.1.0-rc.3" version = "0.1.0"
dependencies = [ dependencies = [
"bindgen", "bindgen",
] ]

4
examples/Cargo.lock generated
View File

@ -1497,7 +1497,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]] [[package]]
name = "waku-bindings" name = "waku-bindings"
version = "0.1.0" version = "0.1.1"
dependencies = [ dependencies = [
"aes-gcm", "aes-gcm",
"base64 0.21.0", "base64 0.21.0",
@ -1517,7 +1517,7 @@ dependencies = [
[[package]] [[package]]
name = "waku-sys" name = "waku-sys"
version = "0.1.0-rc.3" version = "0.1.0"
dependencies = [ dependencies = [
"bindgen", "bindgen",
] ]

View File

@ -1,6 +1,6 @@
[package] [package]
name = "waku-bindings" name = "waku-bindings"
version = "0.1.0" version = "0.1.1"
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.1.0-rc.3", path = "../waku-sys" } waku-sys = { version = "0.1.0", path = "../waku-sys" }
[dev-dependencies] [dev-dependencies]
futures = "0.3.25" futures = "0.3.25"

View File

@ -9,7 +9,7 @@ mod utils;
pub use node::{ pub use node::{
waku_create_content_topic, waku_create_pubsub_topic, waku_dafault_pubsub_topic, waku_create_content_topic, waku_create_pubsub_topic, waku_dafault_pubsub_topic,
waku_dns_discovery, waku_new, Aes256Gcm, DnsInfo, GossipSubParams, Initialized, Key, Multiaddr, waku_dns_discovery, waku_discv5_update_bootnodes, waku_new, Aes256Gcm, DnsInfo, GossipSubParams, Initialized, Key, Multiaddr,
Protocol, PublicKey, Running, SecretKey, WakuLogLevel, WakuNodeConfig, WakuNodeHandle, Protocol, PublicKey, Running, SecretKey, WakuLogLevel, WakuNodeConfig, WakuNodeHandle,
WakuPeerData, WakuPeers, WakuPeerData, WakuPeers,
}; };

View File

@ -59,6 +59,26 @@ pub fn waku_dns_discovery(
decode_and_free_response(result_ptr) decode_and_free_response(result_ptr)
} }
/// Update the bootnodes used by DiscoveryV5 by passing a list of ENRs
pub fn waku_discv5_update_bootnodes(
bootnodes: Vec<String>
) -> Result<()> {
let bootnodes_ptr = CString::new(
serde_json::to_string(&bootnodes)
.expect("Serialization from properly built bootnode array should never fail"),
)
.expect("CString should build properly from the string vector")
.into_raw();
let result_ptr = unsafe {
let res = waku_sys::waku_discv5_update_bootnodes(bootnodes_ptr);
drop(CString::from_raw(bootnodes_ptr));
res
};
decode_and_free_response::<bool>(result_ptr).map(|_| ())
}
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use url::Url; use url::Url;

View File

@ -25,7 +25,7 @@ use crate::general::{
}; };
pub use config::{GossipSubParams, WakuLogLevel, WakuNodeConfig}; pub use config::{GossipSubParams, WakuLogLevel, WakuNodeConfig};
pub use discovery::{waku_dns_discovery, DnsInfo}; pub use discovery::{waku_dns_discovery, waku_discv5_update_bootnodes, DnsInfo};
pub use peers::{Protocol, WakuPeerData, WakuPeers}; pub use peers::{Protocol, WakuPeerData, WakuPeers};
pub use relay::{waku_create_content_topic, waku_create_pubsub_topic, waku_dafault_pubsub_topic}; pub use relay::{waku_create_content_topic, waku_create_pubsub_topic, waku_dafault_pubsub_topic};
pub use store::{waku_local_store_query, waku_store_query}; pub use store::{waku_local_store_query, waku_store_query};
@ -312,6 +312,15 @@ impl WakuNodeHandle<Running> {
) -> Result<()> { ) -> Result<()> {
filter::waku_filter_unsubscribe(filter_subscription, timeout) filter::waku_filter_unsubscribe(filter_subscription, timeout)
} }
/// Update the bootnodes used by DiscoveryV5 by passing a list of ENRs
pub fn discv5_update_bootnodes(
bootnodes: Vec<String>
) -> Result<()> {
discovery::waku_discv5_update_bootnodes(bootnodes)
}
} }
/// Spawn a new Waku node with the given configuration (default configuration if `None` provided) /// Spawn a new Waku node with the given configuration (default configuration if `None` provided)

View File

@ -1,6 +1,6 @@
[package] [package]
name = "waku-sys" name = "waku-sys"
version = "0.1.0-rc.3" version = "0.1.0"
edition = "2021" edition = "2021"
authors = [ authors = [
"Daniel Sanchez Quiros <danielsq@status.im>" "Daniel Sanchez Quiros <danielsq@status.im>"

@ -1 +1 @@
Subproject commit d9a12bf079a8bbb59ab1df591062b9bb91d3804d Subproject commit f6fe353e2ee31bd5514811327cb1ca2478e2e4a9