diff --git a/iroh/src/node.rs b/iroh/src/node.rs index 10ce6196d9..8ccb312e8d 100644 --- a/iroh/src/node.rs +++ b/iroh/src/node.rs @@ -37,7 +37,10 @@ pub use self::builder::{Builder, DiscoveryConfig, DocsStorage, GcPolicy, Storage pub use self::rpc_status::RpcStatus; pub use protocol::ProtocolHandler; -type IrohServerEndpoint = quic_rpc::transport::boxed::ServerEndpoint< +/// The quic-rpc server endpoint for the iroh node. +/// +/// We use a boxed endpoint here to allow having a concrete type for the server endpoint. +pub type IrohServerEndpoint = quic_rpc::transport::boxed::ServerEndpoint< crate::rpc_protocol::Request, crate::rpc_protocol::Response, >; diff --git a/iroh/src/node/builder.rs b/iroh/src/node/builder.rs index d5d22474fc..cde4c7dbee 100644 --- a/iroh/src/node/builder.rs +++ b/iroh/src/node/builder.rs @@ -301,30 +301,17 @@ where }) } - /// Configure rpc endpoint, changing the type of the builder to the new endpoint type. - pub fn rpc_endpoint(self, value: IrohServerEndpoint, port: Option) -> Builder { - // we can't use ..self here because the return type is different - Builder { - storage: self.storage, - bind_port: self.bind_port, - secret_key: self.secret_key, - blobs_store: self.blobs_store, - keylog: self.keylog, + /// Configure rpc endpoint. + pub fn rpc_endpoint(self, value: IrohServerEndpoint, port: Option) -> Self { + Self { rpc_endpoint: value, rpc_port: port, - relay_mode: self.relay_mode, - dns_resolver: self.dns_resolver, - gc_policy: self.gc_policy, - docs_storage: self.docs_storage, - node_discovery: self.node_discovery, - #[cfg(any(test, feature = "test-utils"))] - insecure_skip_relay_cert_verify: self.insecure_skip_relay_cert_verify, - gc_done_callback: self.gc_done_callback, + ..self } } /// Configure the default iroh rpc endpoint. - pub async fn enable_rpc(self) -> Result> { + pub async fn enable_rpc(self) -> Result { let (ep, actual_rpc_port) = make_rpc_endpoint(&self.secret_key, DEFAULT_RPC_PORT)?; let ep = quic_rpc::transport::boxed::ServerEndpoint::new(ep); if let StorageConfig::Persistent(ref root) = self.storage { @@ -332,22 +319,10 @@ where RpcStatus::store(root, actual_rpc_port).await?; } - Ok(Builder { - storage: self.storage, - bind_port: self.bind_port, - secret_key: self.secret_key, - blobs_store: self.blobs_store, - keylog: self.keylog, + Ok(Self { rpc_endpoint: ep, rpc_port: Some(actual_rpc_port), - relay_mode: self.relay_mode, - dns_resolver: self.dns_resolver, - gc_policy: self.gc_policy, - docs_storage: self.docs_storage, - node_discovery: self.node_discovery, - #[cfg(any(test, feature = "test-utils"))] - insecure_skip_relay_cert_verify: self.insecure_skip_relay_cert_verify, - gc_done_callback: self.gc_done_callback, + ..self }) }