embed discv5 functions to node initialized
This commit is contained in:
parent
b8172167f4
commit
7983add1ca
|
@ -45,14 +45,14 @@ pub struct WakuNodeConfig {
|
|||
/// Enable DiscoveryV5. Default `false`
|
||||
#[default(Some(false))]
|
||||
#[serde(rename = "discV5")]
|
||||
pub disc_v5: Option<bool>,
|
||||
pub discv5: Option<bool>,
|
||||
/// Array of bootstrap nodes ENR.
|
||||
#[serde(rename = "discV5BootstrapNodes")]
|
||||
pub disc_v5_bootstrap_nodes: Vec<String>,
|
||||
pub discv5_bootstrap_nodes: Vec<String>,
|
||||
/// UDP port for DiscoveryV5. Default `9000`.
|
||||
#[default(Some(9000))]
|
||||
#[serde(rename = "discV5UDPPort")]
|
||||
pub disc_v5_udp_port: Option<u16>,
|
||||
pub discv5_udp_port: Option<u16>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Default, Serialize, Deserialize, Debug)]
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//! Waku node implementation
|
||||
|
||||
mod config;
|
||||
mod disc_v5;
|
||||
mod discv5;
|
||||
mod discovery;
|
||||
mod filter;
|
||||
mod lightpush;
|
||||
|
@ -27,7 +27,6 @@ use crate::general::{
|
|||
};
|
||||
|
||||
pub use config::{WakuLogLevel, WakuNodeConfig};
|
||||
pub use disc_v5::{waku_discv5_start, waku_discv5_stop};
|
||||
pub use peers::{Protocol, WakuPeerData, WakuPeers};
|
||||
pub use relay::{waku_create_content_topic, waku_create_pubsub_topic, waku_dafault_pubsub_topic};
|
||||
pub use store::waku_store_query;
|
||||
|
@ -90,6 +89,16 @@ fn stop_node() -> Result<()> {
|
|||
}
|
||||
|
||||
impl WakuNodeHandle<Initialized> {
|
||||
/// Starts the DiscoveryV5 service to discover and connect to new peers
|
||||
pub fn discv5_start(&self) -> Result<bool> {
|
||||
discv5::waku_discv5_start()
|
||||
}
|
||||
|
||||
/// Stops the DiscoveryV5 service
|
||||
pub fn discv5_stop(&self) -> Result<bool> {
|
||||
discv5::waku_discv5_stop()
|
||||
}
|
||||
|
||||
/// 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<WakuNodeHandle<Running>> {
|
||||
|
|
|
@ -29,9 +29,9 @@ pub fn main() -> Result<(), String> {
|
|||
min_peers_to_publish: None,
|
||||
filter: None,
|
||||
log_level: Some(WakuLogLevel::Error),
|
||||
disc_v5: Some(false),
|
||||
disc_v5_udp_port: Some(9000),
|
||||
disc_v5_bootstrap_nodes: Vec::new(),
|
||||
discv5: Some(false),
|
||||
discv5_udp_port: Some(9000),
|
||||
discv5_bootstrap_nodes: Vec::new(),
|
||||
};
|
||||
let node = waku_new(Some(config))?;
|
||||
let node = node.start()?;
|
||||
|
|
Loading…
Reference in New Issue